mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Upped performance of load somewhat for channel-load
This commit is contained in:
		| @@ -15,6 +15,8 @@ var Channel = { | ||||
|             Helper.addClass("#results", "client-results-height"); | ||||
|             Helper.addClass(".pagination-results", "client-pagination-height"); | ||||
|             Helper.addClass(".control-list", "client-control-list"); | ||||
|         } else { | ||||
|             Player.soundcloud_player = document.querySelector("#soundcloud_player"); | ||||
|         } | ||||
|         if(!Admin.logged_in) Admin.display_logged_out(); | ||||
|         number_suggested = 0; | ||||
| @@ -29,6 +31,7 @@ var Channel = { | ||||
|         } | ||||
|  | ||||
|         window.onpopstate = function(e){ | ||||
|             console.log(e) | ||||
|             Channel.onepage_load(); | ||||
|         }; | ||||
|  | ||||
|   | ||||
| @@ -187,6 +187,57 @@ window.addEventListener("DOMContentLoaded", function() { | ||||
|     else if(!fromChannel && window.location.pathname == "/"){ | ||||
|         Frontpage.init(); | ||||
|     } | ||||
|     console.log(window.location.pathname); | ||||
|     if(window.location.pathname == "/" && !client) { | ||||
|         console.log("time to load"); | ||||
|         tag            = document.createElement('script'); | ||||
|         tag.src        = "https://www.youtube.com/iframe_api"; | ||||
|         firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|         firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | ||||
|  | ||||
|         tag.onload = function() { | ||||
|             console.log("loaded script") | ||||
|             if(document.querySelectorAll("script[src='https://w.soundcloud.com/player/api.js']").length == 1) { | ||||
|                 SC.Widget(Player.soundcloud_player); | ||||
|             } else { | ||||
|                 tagS            = document.createElement('script'); | ||||
|                 tagS.src        = "https://w.soundcloud.com/player/api.js"; | ||||
|                 firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|                 firstScriptTag.parentNode.insertBefore(tagS, firstScriptTag); | ||||
|                 tagS.setAttribute("async", true); | ||||
|  | ||||
|  | ||||
|                 tagS.onload = function() { | ||||
|                     if(firstLoad == "") { | ||||
|                         firstLoad = "widget"; | ||||
|                         _SC1 = SC; | ||||
|                     } | ||||
|  | ||||
|                     tagSearch            = document.createElement('script'); | ||||
|                     tagSearch.setAttribute("async", true); | ||||
|                     tagSearch.src        = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js"; | ||||
|                     firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|                     firstScriptTag.parentNode.insertBefore(tagSearch, firstScriptTag); | ||||
|  | ||||
|                     tagSearch.onload = function() { | ||||
|                         if(firstLoad == "") { | ||||
|                             firstLoad = "search"; | ||||
|                             _SC2 = SC; | ||||
|                         } else { | ||||
|                             _SC2 = SC; | ||||
|                             SC = _SC1; | ||||
|                             _SC1 = _SC2; | ||||
|                         } | ||||
|                         console.log("loaded1") | ||||
|                         window._SC1 = _SC1; | ||||
|                         _SC1.initialize({ | ||||
|                           client_id: 'ed53fc01f248f15becddf8eb52cc91ef' | ||||
|                         }); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if(Helper.mobilecheck()) { | ||||
|         socket.on("guid", function(msg) { | ||||
| @@ -1232,6 +1283,7 @@ addListener("click", "#closeSettings", function(event) | ||||
|     Admin.hide_settings(); | ||||
| }); | ||||
|  | ||||
|  | ||||
| window.addEventListener("focus", function(event) { | ||||
|     document.getElementById("favicon").setAttribute("href", "/assets/images/favicon.png"); | ||||
|     unseen = false; | ||||
|   | ||||
| @@ -251,7 +251,7 @@ var Player = { | ||||
|             empty_clear = false; | ||||
|         } | ||||
|         try { | ||||
|             //document.getElementById("play").focus(); | ||||
|             document.getElementById("play").focus(); | ||||
|             console.log("focused"); | ||||
|             if(videoSource == "soundcloud") { | ||||
|                 Player.player.stopVideo(); | ||||
| @@ -847,7 +847,9 @@ var Player = { | ||||
|     notifyUser: function(id, title) { | ||||
|         title = title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&"); | ||||
|         if (Notification.permission === "granted" && document.hidden && !embed) { | ||||
|             var notification = new Notification("Now Playing", {body: title, icon: "https://img.youtube.com/vi/"+id+"/mqdefault.jpg", iconUrl: "http://img.youtube.com/vi/"+id+"/mqdefault.jpg"}); | ||||
|             var icon = "https://img.youtube.com/vi/"+id+"/mqdefault.jpg"; | ||||
|             if(videoSource) icon = full_playlist[full_playlist.length - 1].thumbnail; | ||||
|             var notification = new Notification("Now Playing", {body: title, icon: icon, iconUrl: icon}); | ||||
|             notification.onclick = function(x) { window.focus(); this.cancel(); }; | ||||
|             setTimeout(function(){ | ||||
|                 notification.close(); | ||||
| @@ -994,45 +996,49 @@ var Player = { | ||||
|             tag.src        = "https://www.youtube.com/iframe_api"; | ||||
|             firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|             firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | ||||
|         } | ||||
|  | ||||
|         if(document.querySelectorAll("script[src='https://w.soundcloud.com/player/api.js']").length == 1) { | ||||
|             SC.Widget(Player.soundcloud_player); | ||||
|         } else { | ||||
|             tag            = document.createElement('script'); | ||||
|             tag.src        = "https://w.soundcloud.com/player/api.js"; | ||||
|             firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|             firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | ||||
|  | ||||
|  | ||||
|  | ||||
|             tag.onload = function() { | ||||
|                 if(firstLoad == "") { | ||||
|                     firstLoad = "widget"; | ||||
|                     _SC1 = SC; | ||||
|                 } | ||||
|                 SC.Widget(Player.soundcloud_player); | ||||
|                 SC.Widget(Player.soundcloud_player).bind(SC.Widget.Events.READY, Player.soundcloudReady); | ||||
|                 tagSearch            = document.createElement('script'); | ||||
|                 tagSearch.setAttribute("async", true); | ||||
|                 tagSearch.src        = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js"; | ||||
|                 firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|                 firstScriptTag.parentNode.insertBefore(tagSearch, firstScriptTag); | ||||
|                 console.log("loaded script") | ||||
|                 if(document.querySelectorAll("script[src='https://w.soundcloud.com/player/api.js']").length == 1) { | ||||
|                     SC.Widget(Player.soundcloud_player); | ||||
|                     SC.Widget(Player.soundcloud_player).bind(SC.Widget.Events.READY, Player.soundcloudReady); | ||||
|                 } else { | ||||
|                     tagS            = document.createElement('script'); | ||||
|                     tagS.src        = "https://w.soundcloud.com/player/api.js"; | ||||
|                     firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|                     firstScriptTag.parentNode.insertBefore(tagS, firstScriptTag); | ||||
|                     tagS.setAttribute("async", true); | ||||
|  | ||||
|                 tagSearch.onload = function() { | ||||
|                     if(firstLoad == "") { | ||||
|                         firstLoad = "search"; | ||||
|                         _SC2 = SC; | ||||
|                     } else { | ||||
|                         _SC2 = SC; | ||||
|                         SC = _SC1; | ||||
|                         _SC1 = _SC2; | ||||
|  | ||||
|                     tagS.onload = function() { | ||||
|                         if(firstLoad == "") { | ||||
|                             firstLoad = "widget"; | ||||
|                             _SC1 = SC; | ||||
|                         } | ||||
|                         SC.Widget(Player.soundcloud_player); | ||||
|                         SC.Widget(Player.soundcloud_player).bind(SC.Widget.Events.READY, Player.soundcloudReady); | ||||
|                         tagSearch            = document.createElement('script'); | ||||
|                         tagSearch.setAttribute("async", true); | ||||
|                         tagSearch.src        = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js"; | ||||
|                         firstScriptTag = document.getElementsByTagName('script')[0]; | ||||
|                         firstScriptTag.parentNode.insertBefore(tagSearch, firstScriptTag); | ||||
|  | ||||
|                         tagSearch.onload = function() { | ||||
|                             if(firstLoad == "") { | ||||
|                                 firstLoad = "search"; | ||||
|                                 _SC2 = SC; | ||||
|                             } else { | ||||
|                                 _SC2 = SC; | ||||
|                                 SC = _SC1; | ||||
|                                 _SC1 = _SC2; | ||||
|                             } | ||||
|                             console.log("loaded1") | ||||
|                             window._SC1 = _SC1; | ||||
|                             _SC1.initialize({ | ||||
|                               client_id: 'ed53fc01f248f15becddf8eb52cc91ef' | ||||
|                             }); | ||||
|                         } | ||||
|                     } | ||||
|                     console.log("loaded1") | ||||
|                     window._SC1 = _SC1; | ||||
|                     _SC1.initialize({ | ||||
|                       client_id: 'ed53fc01f248f15becddf8eb52cc91ef' | ||||
|                     }); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user