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("#results", "client-results-height"); | ||||||
|             Helper.addClass(".pagination-results", "client-pagination-height"); |             Helper.addClass(".pagination-results", "client-pagination-height"); | ||||||
|             Helper.addClass(".control-list", "client-control-list"); |             Helper.addClass(".control-list", "client-control-list"); | ||||||
|  |         } else { | ||||||
|  |             Player.soundcloud_player = document.querySelector("#soundcloud_player"); | ||||||
|         } |         } | ||||||
|         if(!Admin.logged_in) Admin.display_logged_out(); |         if(!Admin.logged_in) Admin.display_logged_out(); | ||||||
|         number_suggested = 0; |         number_suggested = 0; | ||||||
| @@ -29,6 +31,7 @@ var Channel = { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         window.onpopstate = function(e){ |         window.onpopstate = function(e){ | ||||||
|  |             console.log(e) | ||||||
|             Channel.onepage_load(); |             Channel.onepage_load(); | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -187,6 +187,57 @@ window.addEventListener("DOMContentLoaded", function() { | |||||||
|     else if(!fromChannel && window.location.pathname == "/"){ |     else if(!fromChannel && window.location.pathname == "/"){ | ||||||
|         Frontpage.init(); |         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()) { |     if(Helper.mobilecheck()) { | ||||||
|         socket.on("guid", function(msg) { |         socket.on("guid", function(msg) { | ||||||
| @@ -1232,6 +1283,7 @@ addListener("click", "#closeSettings", function(event) | |||||||
|     Admin.hide_settings(); |     Admin.hide_settings(); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  |  | ||||||
| window.addEventListener("focus", function(event) { | window.addEventListener("focus", function(event) { | ||||||
|     document.getElementById("favicon").setAttribute("href", "/assets/images/favicon.png"); |     document.getElementById("favicon").setAttribute("href", "/assets/images/favicon.png"); | ||||||
|     unseen = false; |     unseen = false; | ||||||
|   | |||||||
| @@ -251,7 +251,7 @@ var Player = { | |||||||
|             empty_clear = false; |             empty_clear = false; | ||||||
|         } |         } | ||||||
|         try { |         try { | ||||||
|             //document.getElementById("play").focus(); |             document.getElementById("play").focus(); | ||||||
|             console.log("focused"); |             console.log("focused"); | ||||||
|             if(videoSource == "soundcloud") { |             if(videoSource == "soundcloud") { | ||||||
|                 Player.player.stopVideo(); |                 Player.player.stopVideo(); | ||||||
| @@ -847,7 +847,9 @@ var Player = { | |||||||
|     notifyUser: function(id, title) { |     notifyUser: function(id, title) { | ||||||
|         title = title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&"); |         title = title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&"); | ||||||
|         if (Notification.permission === "granted" && document.hidden && !embed) { |         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(); }; |             notification.onclick = function(x) { window.focus(); this.cancel(); }; | ||||||
|             setTimeout(function(){ |             setTimeout(function(){ | ||||||
|                 notification.close(); |                 notification.close(); | ||||||
| @@ -994,45 +996,49 @@ var Player = { | |||||||
|             tag.src        = "https://www.youtube.com/iframe_api"; |             tag.src        = "https://www.youtube.com/iframe_api"; | ||||||
|             firstScriptTag = document.getElementsByTagName('script')[0]; |             firstScriptTag = document.getElementsByTagName('script')[0]; | ||||||
|             firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); |             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() { |             tag.onload = function() { | ||||||
|                 if(firstLoad == "") { |                 console.log("loaded script") | ||||||
|                     firstLoad = "widget"; |                 if(document.querySelectorAll("script[src='https://w.soundcloud.com/player/api.js']").length == 1) { | ||||||
|                     _SC1 = SC; |                     SC.Widget(Player.soundcloud_player); | ||||||
|                 } |                     SC.Widget(Player.soundcloud_player).bind(SC.Widget.Events.READY, Player.soundcloudReady); | ||||||
|                 SC.Widget(Player.soundcloud_player); |                 } else { | ||||||
|                 SC.Widget(Player.soundcloud_player).bind(SC.Widget.Events.READY, Player.soundcloudReady); |                     tagS            = document.createElement('script'); | ||||||
|                 tagSearch            = document.createElement('script'); |                     tagS.src        = "https://w.soundcloud.com/player/api.js"; | ||||||
|                 tagSearch.setAttribute("async", true); |                     firstScriptTag = document.getElementsByTagName('script')[0]; | ||||||
|                 tagSearch.src        = "https://connect.soundcloud.com/sdk/sdk-3.3.0.js"; |                     firstScriptTag.parentNode.insertBefore(tagS, firstScriptTag); | ||||||
|                 firstScriptTag = document.getElementsByTagName('script')[0]; |                     tagS.setAttribute("async", true); | ||||||
|                 firstScriptTag.parentNode.insertBefore(tagSearch, firstScriptTag); |  | ||||||
|  |  | ||||||
|                 tagSearch.onload = function() { |  | ||||||
|                     if(firstLoad == "") { |                     tagS.onload = function() { | ||||||
|                         firstLoad = "search"; |                         if(firstLoad == "") { | ||||||
|                         _SC2 = SC; |                             firstLoad = "widget"; | ||||||
|                     } else { |                             _SC1 = SC; | ||||||
|                         _SC2 = SC; |                         } | ||||||
|                         SC = _SC1; |                         SC.Widget(Player.soundcloud_player); | ||||||
|                         _SC1 = _SC2; |                         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