Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Remove sync calls
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Feb 17, 2017
1 parent 639db35 commit f2209bd
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 162 deletions.
172 changes: 91 additions & 81 deletions core/src/plugins/editor.soundmanager/class.SMPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,97 +17,107 @@
*
* The latest code can be found at <https://pydio.com>.
*/
window.SM2_DEFER = true;
if(!$$("html")[0].hasClassName("no-canvas") && !window.soundManager){
var conn = new Connexion();
conn._libUrl = (ajxpBootstrap.parameters.get('SERVER_PREFIX_URI')?ajxpBootstrap.parameters.get('SERVER_PREFIX_URI'):'')+'plugins/editor.soundmanager/sm/';
conn.loadLibrary('360-player/script/berniecode-animator.js');
conn.loadLibrary('script/soundmanager2-nodebug-jsmin.js', function(){
window.soundManager = new SoundManager('plugins/editor.soundmanager/sm/swf/');
window.soundManager.url = (ajxpBootstrap.parameters.get('SERVER_PREFIX_URI')?ajxpBootstrap.parameters.get('SERVER_PREFIX_URI'):'')+'plugins/editor.soundmanager/sm/swf/';
if(ajaxplorer && ajaxplorer.user && ajaxplorer.user.getPreference("soundmanager.volume") !== undefined){
soundManager.defaultOptions.volume = ajaxplorer.user.getPreference("soundmanager.volume");
}
var conn2 = new Connexion();
conn2._libUrl = (ajxpBootstrap.parameters.get('SERVER_PREFIX_URI')?ajxpBootstrap.parameters.get('SERVER_PREFIX_URI'):'')+'plugins/editor.soundmanager/sm/';
conn2.loadLibrary('360-player/script/360player.js', function(){
function threeSixtyLoaded(){

if(!window.threeSixtyPlayer) return;
if(!window.threeSixtyPlayer) return;

window.threeSixtyPlayer.config.scaleFont = (navigator.userAgent.match(/msie/i)?false:true);
window.threeSixtyPlayer.config.showHMSTime = true;
window.threeSixtyPlayer.config.useWaveformData = true;
window.threeSixtyPlayer.config.useEQData = true;
// enable this in SM2 as well, as needed
if (window.threeSixtyPlayer.config.useWaveformData) {
window.soundManager.flash9Options.useWaveformData = true;
}
if (window.threeSixtyPlayer.config.useEQData) {
window.soundManager.flash9Options.useEQData = true;
window.threeSixtyPlayer.config.scaleFont = (navigator.userAgent.match(/msie/i)?false:true);
window.threeSixtyPlayer.config.showHMSTime = true;
window.threeSixtyPlayer.config.useWaveformData = true;
window.threeSixtyPlayer.config.useEQData = true;
// enable this in SM2 as well, as needed
if (window.threeSixtyPlayer.config.useWaveformData) {
window.soundManager.flash9Options.useWaveformData = true;
}
if (window.threeSixtyPlayer.config.useEQData) {
window.soundManager.flash9Options.useEQData = true;
}
if (window.threeSixtyPlayer.config.usePeakData) {
window.soundManager.flash9Options.usePeakData = true;
}
if (window.threeSixtyPlayer.config.useWaveformData || window.threeSixtyPlayer.flash9Options.useEQData || window.threeSixtyPlayer.flash9Options.usePeakData) {
// even if HTML5 supports MP3, prefer flash so the visualization features can be used.
window.soundManager.preferFlash = true;
}

window.soundManager.useFastPolling = true; // increased JS callback frequency, combined with useHighPerformance = true
window.threeSixtyPlayer.config.onfinish = function(smPlayer){
try{
var finishingPlayer = smPlayer._360data.oUI360;
if(finishingPlayer.hasClassName("ui360-vis")) {
window.setTimeout(function(){
finishingPlayer.addClassName("ui360-vis-retracted");
}, 1000);
}else{
var links = $$("div.ui360").reject(function(el){
return el.hasClassName("ui360-vis");
});
var index = links.indexOf(finishingPlayer);
if(index < links.length-1 ){
window.threeSixtyPlayer.handleClick({'target':links[index+1].down("a.sm2_link")});
}
if(finishingPlayer.up('.ajxpNodeProvider')){
finishingPlayer.up('.ajxpNodeProvider').removeClassName("SMNodePlaying");
}
}
if (window.threeSixtyPlayer.config.usePeakData) {
window.soundManager.flash9Options.usePeakData = true;
}catch(e){}
};

window.threeSixtyPlayer.config.onplay = function(smPlayer){
try{
var playerDiv = smPlayer._360data.oUI360;
if(!playerDiv.hasClassName("ui360-vis")) {
if(playerDiv.up('.ajxpNodeProvider')){
playerDiv.up('.ajxpNodeProvider').addClassName("SMNodePlaying");
}
}else{
playerDiv.removeClassName("ui360-vis-retracted");
}
if (window.threeSixtyPlayer.config.useWaveformData || window.threeSixtyPlayer.flash9Options.useEQData || window.threeSixtyPlayer.flash9Options.usePeakData) {
// even if HTML5 supports MP3, prefer flash so the visualization features can be used.
window.soundManager.preferFlash = true;
}catch(e){}
};

window.threeSixtyPlayer.config.onstop = function(smPlayer){
try{
var playerDiv = smPlayer._360data.oUI360;
if(!playerDiv.hasClassName("ui360-vis")) {
if(playerDiv.up('.ajxpNodeProvider')){
playerDiv.up('.ajxpNodeProvider').removeClassName("SMNodePlaying");
}
}else{
window.setTimeout(function(){
playerDiv.addClassName("ui360-vis-retracted");
}, 1000);
}
}catch(e){}
};

window.soundManager.useFastPolling = true; // increased JS callback frequency, combined with useHighPerformance = true
window.threeSixtyPlayer.config.onfinish = function(smPlayer){
try{
var finishingPlayer = smPlayer._360data.oUI360;
if(finishingPlayer.hasClassName("ui360-vis")) {
window.setTimeout(function(){
finishingPlayer.addClassName("ui360-vis-retracted");
}, 1000);
}else{
var links = $$("div.ui360").reject(function(el){
return el.hasClassName("ui360-vis");
});
var index = links.indexOf(finishingPlayer);
if(index < links.length-1 ){
window.threeSixtyPlayer.handleClick({'target':links[index+1].down("a.sm2_link")});
}
if(finishingPlayer.up('.ajxpNodeProvider')){
finishingPlayer.up('.ajxpNodeProvider').removeClassName("SMNodePlaying");
}
}
}catch(e){}
};
window.soundManager.beginDelayedInit();
}

window.threeSixtyPlayer.config.onplay = function(smPlayer){
try{
var playerDiv = smPlayer._360data.oUI360;
if(!playerDiv.hasClassName("ui360-vis")) {
if(playerDiv.up('.ajxpNodeProvider')){
playerDiv.up('.ajxpNodeProvider').addClassName("SMNodePlaying");
}
}else{
playerDiv.removeClassName("ui360-vis-retracted");
}
}catch(e){}
};

window.threeSixtyPlayer.config.onstop = function(smPlayer){
try{
var playerDiv = smPlayer._360data.oUI360;
if(!playerDiv.hasClassName("ui360-vis")) {
if(playerDiv.up('.ajxpNodeProvider')){
playerDiv.up('.ajxpNodeProvider').removeClassName("SMNodePlaying");
}
}else{
window.setTimeout(function(){
playerDiv.addClassName("ui360-vis-retracted");
}, 1000);
}
}catch(e){}
};
window.SM2_DEFER = true;
if(!$$("html")[0].hasClassName("no-canvas") && !window.soundManager){

window.soundManager.beginDelayedInit();
});
});
var conn = new Connexion();
conn._libUrl = (ajxpBootstrap.parameters.get('SERVER_PREFIX_URI')?ajxpBootstrap.parameters.get('SERVER_PREFIX_URI'):'')+'plugins/editor.soundmanager/sm/';
conn.loadLibrary('360-player/script/berniecode-animator.js', function(){
var conn3 = new Connexion();
conn3._libUrl = conn._libUrl;
conn3.loadLibrary('script/soundmanager2-nodebug-jsmin.js', function(){

window.soundManager = new SoundManager('plugins/editor.soundmanager/sm/swf/');
window.soundManager.url = conn._libUrl + 'swf/';
if(ajaxplorer && ajaxplorer.user && ajaxplorer.user.getPreference("soundmanager.volume") !== undefined){
soundManager.defaultOptions.volume = ajaxplorer.user.getPreference("soundmanager.volume");
}
var conn2 = new Connexion();
conn2._libUrl = conn._libUrl;
conn2.loadLibrary('360-player/script/360player.js', threeSixtyLoaded, true);

}, true);
}, true);
hookToFilesList();

}

function hookToFilesList(){
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.soundmanager/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<class_definition filename="plugins/editor.audio/AudioPreviewer.php" classname="Pydio\Editor\Audio\AudioPreviewer"/>
<client_settings>
<resources>
<js className="SMPlayer" file="plugins/editor.soundmanager/class.SMPlayer.js" autoload="true"/>
<js className="SMPlayer" file="plugins/editor.soundmanager/class.SMPlayer.js"/>
<i18n namespace="sm_editor" path="plugins/editor.soundmanager/i18n"/>
<css file="plugins/editor.soundmanager/sm/360-player/360player.css"/>
<css file="plugins/editor.soundmanager/sm/360-player/360player-visualization.css"/>
Expand Down
26 changes: 13 additions & 13 deletions core/src/plugins/gui.ajax/res/js/es6/Pydio.es6
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,23 @@ class Pydio extends Observable{
if(!this.UI && window.useReactPydioUI){
ResourcesManager.loadClassesAndApply(["React", "PydioReactUI"], function(){
this.UI = new PydioReactUI.Builder(this);
}.bind(this));
}
this.UI.initTemplates();
this.UI.modal.initForms();
this.UI.initObjects();

this.UI.initTemplates();
this.UI.modal.initForms();
this.UI.initObjects();
if(!this.user) {
PydioApi.getClient().tryToLogUserFromRememberData();
}
this.fire("registry_loaded", this.Registry.getXML());

if(!this.user) {
PydioApi.getClient().tryToLogUserFromRememberData();
}
this.fire("registry_loaded", this.Registry.getXML());
window.setTimeout(function(){
this.fire('loaded');
}.bind(this), 200);

window.setTimeout(function(){
this.fire('loaded');
}.bind(this), 200);
this.Router = new Router(this);

this.Router = new Router(this);
}.bind(this));
}

}.bind(this);

Expand Down
48 changes: 6 additions & 42 deletions core/src/plugins/gui.ajax/res/js/es6/http/PydioApi.es6
Original file line number Diff line number Diff line change
Expand Up @@ -224,50 +224,14 @@ class PydioApi{
if(window.pydio && pydio.Parameters.get('SERVER_PREFIX_URI')){
PydioApi._libUrl = pydio.Parameters.get('SERVER_PREFIX_URI');
}
//var path = (PydioApi._libUrl?PydioApi._libUrl+'/'+fileName:fileName);

/*if(window.jQuery && window.jQuery.ajax){
jQuery.ajax(path,
{
method:'get',
async: (aSync?true:false),
complete:function(transport){
if(transport.responseText)
{
try
{
var script = transport.responseText;
if (window.execScript){
window.execScript( script );
}
else{
// TO TEST, THIS SEEM TO WORK ON SAFARI
window.my_code = script;
var script_tag = document.createElement('script');
script_tag.type = 'text/javascript';
script_tag.innerHTML = 'eval(window.my_code)';
document.getElementsByTagName('head')[0].appendChild(script_tag);
}
if(onLoadedCode != null) onLoadedCode();
}
catch(e)
{
alert('error loading '+fileName+':'+ e.message);
}
}
pydio.fire("server_answer");
}
});
}else */if(window.Connexion){

var conn = new Connexion();
conn._libUrl = false;
if(pydio.Parameters.get('SERVER_PREFIX_URI')){
conn._libUrl = pydio.Parameters.get('SERVER_PREFIX_URI');
}
conn.loadLibrary(fileName, onLoadedCode, aSync);

var conn = new Connexion();
conn._libUrl = false;
if(pydio.Parameters.get('SERVER_PREFIX_URI')){
conn._libUrl = pydio.Parameters.get('SERVER_PREFIX_URI');
}
conn.loadLibrary(fileName, onLoadedCode, aSync);


}

Expand Down
57 changes: 41 additions & 16 deletions core/src/plugins/gui.ajax/res/js/es6/http/ResourcesManager.es6
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,47 @@ class ResourcesManager{
}
/**
* Load resources
* @param resourcesRegistry $H Ajaxplorer ressources registry
* @param resourcesRegistry Pydio resources registry
*/
load(resourcesRegistry, jsAutoloadOnly=false){
if(this.loaded) return;
if(this.hasDependencies()){
load(resourcesRegistry, jsAutoloadOnly=false, callback = FuncUtils.Empty){
if(this.loaded) {
callback();
return;
}
if(this.hasDependencies() && !this.dependenciesLoaded){
this.resources.dependencies.forEach(function(el){
if(resourcesRegistry[el]){
resourcesRegistry[el].load(resourcesRegistry);
// Load dependencies and try again
resourcesRegistry[el].load(resourcesRegistry, false, function(){
this.dependenciesLoaded = true;
this.load(resourcesRegistry, false, callback);
}.bind(this));
}
}.bind(this) );
}
}
if(this.resources.forms){
this.resources.forms.forEach(function(value,key){
this.loadGuiForm(key, value);
}.bind(this) );
}
if(this.resources.js){
this.resources.js.forEach(function(value){
if(jsAutoloadOnly && !value.autoload) return;
this.loadJSResource(value.fileName, value.className);
}.bind(this));
}
if(this.resources.js){
let it = this.resources.js.values();
let cb = function(){
let object = it.next();
if(object.value){
if(jsAutoloadOnly && !object.value.autoload) {
cb();
return;
}
this.loadJSResource(object.value.fileName, object.value.className, cb, true);
}else{
callback();
}
}.bind(this);
cb();
}else{
callback();
}
if(this.resources.css){
this.resources.css.forEach(function(value){
this.loadCSSResource(value);
Expand Down Expand Up @@ -381,10 +400,16 @@ class ResourcesManager{
}else{
// Load sync and apply the callback manually
var loader = new ResourcesManager();
modules.forEach(function(element){
loader.loadJSResource(element.fileName, element.className, null, false);
});
callbackFunc();
let it = modules.values();
let cb = function(){
let object = it.next();
if(object.value){
loader.loadJSResource(object.value.fileName, object.value.className, cb, true);
}else{
callbackFunc();
}
};
cb();
}
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/plugins/gui.ajax/res/js/es6/model/Registry.es6
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ class Registry{
/**
* Trigger the load method of the resourcesManager.
* @param resourcesManager ResourcesManager
* @param callback triggered after JS loaded
*/
loadEditorResources (resourcesManager){
resourcesManager.load(this._resourcesRegistry);
loadEditorResources (resourcesManager, callback){
resourcesManager.load(this._resourcesRegistry, false, callback);
}

/**
Expand Down
Loading

0 comments on commit f2209bd

Please sign in to comment.