$(".fbrowser .fbswitcher [data-mode=" + FileBrowser.type + "]").addClass("active");\r
// We need to add the AjaxUpload to the button\r
FileBrowser.uploadButtons();\r
- \r
},\r
\r
// Load new content (e.g. change photo album)\r
var jsbrowser = function() {
FileBrowser.init(nickname, type, hash);
};
+ loadScript("view/js/ajaxupload.js");
loadScript("view/theme/frio/js/filebrowser.js", jsbrowser);
};
$('#photo-album-contents').justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; });
}
+// Load a js script to the html head.
function loadScript(url, callback) {
- // Adding the script tag to the head as suggested before
+ // Check if the script is already in the html head.
+ var oscript = $('head script[src="' + url + '"]');
+
+ // Delete the old script from head.
+ if (oscript.length > 0) {
+ oscript.remove();
+ }
+ // Adding the script tag to the head as suggested before.
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.onreadystatechange = callback;
script.onload = callback;
- // Fire the loading
+ // Fire the loading.
head.appendChild(script);
}