Press Ctrl/Cmd + D to add Color Hunt to your bookmarks bar!') } document.addEventListener('keydown', function(event) { if ((event.ctrlKey || event.metaKey) && event.key === 'd') { gtag('event', 'added_to_bookmark', { 'event_category': 'user_engagement' }); } }); $(document).ready(function() { page = "palettes"; sort = ""; tags = "rainbow"; tagString = "rainbow"; single = ""; step = 0; oktoload = "yes"; filterRedirect = true; carbonRendered = false; bannerInFeed = false if ( page == "" ) { page = 'palettes'; } if ( page == "palettes" && sort == "" && tags == "" ) { sort = "new"; } if ( sort != "" && single == "" ) { $('.tab[tab='+sort+']').attr('status','on'); } if ( sort == 'popular' ) { $('.timeframe').css('display','flex'); } if ( page == 'palettes' ){ if ( single != '' ) { getSingle(); } else { getFeed(); } getLikes(); } else { if ( page != 'collection' ) { $('.main .left').hide(); $('.main .right').hide(); } if ( page == 'collection' ) { $('.main .right .meta').hide(); carbonAd() } } if ( tagString != "" ) { tagString = tagString.split('-'); tagString.forEach(function(tag) { applyTag(tag); }) $('.tab[tab='+tags+']').attr('status','on'); } $('.tab[tab='+page+']').attr('status','on'); window.addEventListener('scroll', function scrolling() { if ( page == "palettes" && oktoload == "yes" && $(document).scrollTop() + $(window).height() >= $("body").height()-300 ) { step++; getFeed(); oktoload = "no"; setTimeout(function(){ oktoload = "yes" }, 500); } }); $(window).click(function(event) { if (!$(event.target).closest(".filterContainer").length) { $('.filterWindow').addClass('hidden'); } if (!$(event.target).closest(".kebab").length) { $('.littleMenu').addClass('hidden'); $('.kebab').attr('status','off'); } }); $('.tab').click(function() { $('.tab').attr('status','off') $(this).attr('status','on') $('.timeframe').hide(); if ( $(this).attr('tab') == 'popular' ) { $('.timeframe').css('display','flex'); } }); $('a').click(function() { $('.loader').show(); setTimeout(function() { $('.loader').hide(); }, 2000) }); $('.filterContainer input').keydown(function(e) { if (e.keyCode == 13 && query != "") { gtag('event', query, { 'event_category': 'search_query' }); if ($('.filterWindow .button.tag').length > 0) { $('.filterWindow .button.tag').eq(0).click() } else { tagString = $('.filterContainer input').val().replace(' and ','-').replace(' ','-') tagArray = tagString.split('-') for (word in tagArray) { if ( $('.button.tag[tag='+tagArray[word]+']').length == 0 ) { delete tagArray[word] } } tagString = tagArray.filter(value => JSON.stringify(value) !== '{}').join('-') window.location = '/palettes/'+tagString } } if (e.keyCode == 8 && query == "") { $('.inputContainer .tag').last().click(); } }); $('.filterContainer input').focus(function(e) { showTags(); $('.filterWindow').removeClass('hidden'); }); $('.kebab').click(function(e) { if ( $('.littleMenu.hidden').length == 1 ) { $('.kebab').attr('status','on'); $('.littleMenu').removeClass('hidden'); } else { $('.kebab').attr('status','off'); $('.littleMenu').addClass('hidden'); } }); if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/service-worker.js', { scope: '.' // <--- THIS BIT IS REQUIRED }).then(function(registration) { // Registration was successful }, function(err) { // registration failed :( }); } });