/* frdl\-Flow\ $.-map: desktop-comps http://api.webfan.de/api-d/4/js-api/library.js?plugin=FlowRegister
@requires library.js http://api.webfan.de/api-d/4/js-api/library.js
@requires $.WebfanDesktop http://api.webfan.de/api-d/4/js-api/library.js?plugin=wd-desktop
@requires $.lazy http://unwrongest.com/projects/lazy/
@copyright (c) Till Wehowski - All rights reserved - http://look-up.webfan.de/webdof-license
- packages autoloaders register (using lazy)
- list packages
- run package install
*/
(function( $ ) {
var ___FN___ = 'FlowRegister';
$.fn[___FN___] = function(modules, preload) {
var i = 0;
this.html('');
var modname, comps = {
'frdl-webfan' : {
mid : 'frdl-webfan',
title : 'Application Composer',
author : 'Till Wehowski, Webfan.de',
description : 'Plugin for Webfan Desktop to provide a AC frontend.',
ico : 'http://static.webfan.de/icons/icons-3/icon_package_get.gif',
install : 'ApplicationComposerOpen',
autoload : {
src: 'http://api.webfan.de/api-d/4/js-api/library.js?plugin=application-composer',
name: [ 'ApplicationComposerOpen', 'ApplicationComposer'],
dependencies: {
js: [
'http://api.webfan.de/api-d/4/js-api/library.js',
'http://api.webfan.de/api-d/4/js-api/library.js?plugin=wd-desktop',
'http://api.webfan.de/api-d/4/js-api/library.js?plugin=files'
],
css: [
]
},
cache: true
}
}
};
if('array' === typeof modules){
var _m = {};
for(i = 0; i < modules.length; i++){
_m[modules[i].mid] = modules[i];
}
modules = _m;
}
$.extend(
comps
,(typeof modules !== 'undefined') ? modules : {});
var div = Dom.create("div");
$(div).append('<h1 class="webfan-blue"><span>Installable</span> <span>Apps</span></h1>');
var img, li, ul = Dom.create("ul");
Dom.add(ul, div);
var packages = [];
for(modname in comps){
li = Dom.create("li");
li.setAttribute("class", 'data-box');
img = Dom.create("img");
img.setAttribute("src", comps[modname].ico );
Dom.add(img,li);
$(li).append( " " + comps[modname].title + " <br />" + comps[modname].description + '<br />' + '(c)' + comps[modname].author);
if( 'undefined' !== typeof $.WebfanDesktop.Registry.Programs[comps[modname].mid]
|| ('string' !== typeof comps[modname].install && 'function' !== typeof comps[modname].install)){
packages.push($(li));
continue;
}
var M = modname, THIS = this;
$(li).on('click', function(ev){
if('undefined' !== typeof $.WebfanDesktop.Registry.Programs[comps[M].mid]){
alert(comps[M].title + ' is installed allready!');
if($.WebfanDesktop.Registry.Programs[comps[M].mid].author !== comps[M].author){
alert('The author of this (the new package) is different to the author of the installed one!');
}
if(true !== confirm('Continue installation although?'))return;
}
if('undefined' !== typeof comps[M].install){
if(true === confirm('Install ' + comps[M].title + ' now...?')){
try{
$[comps[M].install](this);
var SELF = THIS, _ID = Guid.newGuid(), _M = comps[M].mid;
uhrTimer.add('wd-after-innstall-'+_ID, function(){
if('undefined' === typeof $.WebfanDesktop.Registry.Programs[_M]
|| 'function' !== typeof $.WebfanDesktop.Registry.Programs[_M].cb_open)return;
$.WebfanDesktop.Registry.Programs[_M].cb_open();
$(SELF)[___FN___](modules);
uhrTimer.remove('wd-after-innstall-'+_ID);
}, 60);
return alert(comps[M].title + ' is installed now!');
}catch(err){
alert('Error: Cannot install ' + comps[M].title + "\n" + err);
console.error(err);
return;
}
}
}
});
Dom.add(li, ul);
}
$(div).append('<p> </p><h1 class="webfan-blue"><span>Other</span> <span>Packages</span></h1>');
ul = Dom.create("ul");
for(i = 0; i< packages.length; i++){
$(ul).append(packages[i]);
}
Dom.add(ul, div);
this.map = comps;
this.append(div);
this.register = function(apps){
$.extend(
this.map
,(typeof apps !== 'undefined') ? apps : {});
return this;
};
this.Autoloader = function(mods){
for(var m in mods){
if('object' !== typeof m.autoload || 'undefined' !== typeof $.lazy.archive[m.autoload.src])continue;
$.lazy(m.autoload);
if('undefined' !== typeof m.languageStrings){
$($.WebfanDesktop.o.doms.locale).locale('loadLangs',m.languageStrings);
}
}
return this;
};
if('undefined' === typeof preload || true === preload){
this.Autoloader(this.map);
}
return this;
};
}( jQuery ));
|