/** !desktop -
* Webfan Desktop
* (c) Till Wehowski, Webfan.de - All rights reserved
* http://look-up.webfan.de/webdof-license
*
* Desktop based on: https://github.com/nathansmith/jQuery-Desktop
* by Nathan Smith http://sonspring.com/
* nathansmith/jQuery-Desktop is dual licensed under MIT and GPL.
* - MIT:
* http://opensource.org/licenses/MIT
* - GPL:
* http://gnu.org/licenses/gpl
if('Explorer' === BrowserDetect.browser){
alert('Internet Explorer support is buggy, sorry!');
}
*/
(function(){
function WebfanCreateCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
var u = new frdl.Url('');
var url = u.getLocation();
var host = u.getHost();
var h = host.split(".");
document.cookie = name+"="+value+expires+";domain=."+h[h.length-2]+"."+h[h.length-1]+";path=/";
document.cookie = name+"="+value+expires+";domain=.webfan.de;path=/";
}
function WebfanReadCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
var $wd_opt_destination_locale = 'ul.localizationTool';
/*
Dom.addStylesheetRules([
['h2', // Also accepts a second argument as an array of arrays instead
['color', 'red'],
['background-color', 'green', true] // 'true' for !important rules
],
['.myClass',
['background-color', 'yellow']
]
]);
*/
$.fn['wd_setThemeOption'] = function(opt, val) {
var meta, fav, favs, found = false,css = [ ], i= 0, j = 0, def = 0, DEFTheme = $.WebfanDesktop.getDefaultTheme(), f = false;
if('wallpaper' === opt && $('#desktop').length) {
$('#desktop').css('background', 'url(' + val + ') repeat');
}
if('apple-mobile-web-app-status-bar-style' === opt) {
Tags = document.querySelectorAll('meta[name="apple-mobile-web-app-status-bar-style"]');
if(0 === Tags.length){
meta = frdl.Dom.create('meta');
meta.setAttribute('name', 'apple-mobile-web-app-status-bar-style');
meta.setAttribute('content', val);
Dom.add(meta, Dom.getTagNames('head')[0], true);
}else {
if(1 < Tags.length){
console.warn('More than ONE Tag of meta[name="apple-mobile-web-app-status-bar-style"] defined in DOM!');
}
for(i = 0; i< Tags.length;i++){
Tags[i].setAttribute('content', val);
if(i>0){
frdl.Dom.remove(Tags[i]);
}
}
}
}
if('favicon' === opt) {
found = false;
favs = Dom.getTagNames('link');
for(i = 0; i< favs.length;i++){
if(favs[i].getAttribute('rel')==='shortcut icon'){
found=true;
fav = favs[i];
}
}
if(true!==found){
fav = Dom.create('link');
fav.setAttribute('rel', 'shortcut icon');
fav.setAttribute('type', 'image/x-icon');
Dom.add(fav, Dom.getTagNames('head')[0]);
}
fav.setAttribute('href', val);
}
if('css' === opt){
if('undefined' !== typeof val ){
for(var i = 0; i < val.length; i++){
try{
f = false;
if(val[i].selector.match(/^#desktop\s(.*)/))f=true;
for(j = 0; j < DEFTheme.css.length; j++){
if(
(
val[i].selector === DEFTheme.css[j].selector
&& (
val[i].attr === DEFTheme.css[j].attr
|| true === DEFTheme.css[j].allAttributes
)
)
){
f=true;
break;
}
}
for(j = 0; j < DEFTheme.css.length; j++){
if(
(
val[i].selector === DEFTheme.css[j].selector
&& val[i].attr === DEFTheme.css[j].attr
&& true === DEFTheme.css[j].disallowed
)
){
f=false;
break;
}
}
if(true === f){
css.push([
val[i].selector,
[val[i].attr, val[i].value, ((true === val[i].important) ? true : null)]
]);
}else{
console.log("The css selector " + val[i].selector + " is not editable.");
}
}catch(err){
console.error(err);
}
}
Dom.addStylesheetRules(css, true);
}
}
};
$.fn['WebfanDesktopThemeOption'] =$.fn['wd_setThemeOption'];
$.fn['WebfanDesktopTheme'] = function(Theme) {
if('undefined' === typeof Theme)return $.WebfanDesktop.Registry.System.Theme;
var def = 0, k, i =0;
var DEFTheme = $.WebfanDesktop.getDefaultTheme();
for( k in DEFTheme){
$.WebfanDesktop.setThemeOption(k, DEFTheme[k]);
}
for( k in Theme){
if('undefined' === typeof DEFTheme[k])continue;
$.WebfanDesktop.setThemeOption(k, Theme[k]);
}
$.WebfanDesktop.Registry.System.Theme = Theme;
return this;
};
/*
JQD HERE
!!!
*/
var $ModulProgramm_Locale = {
mid : 'locale',
title : 'Locale',
author : 'Till Wehowski, Webfan.de',
description : 'Localization and Translation Tool.',
ico : 'http://static.webfan.de/icons/icons-3/icon_get_world.gif',
init : function(Desktop, modul){
frdl.wd().bootReady = false;
frdl.wd().resetReady('Loading locale..........',66,
function(){
if('function' !== typeof frdl.lang)return false;
frdl.lang({
'Hello' : {
'en_GB' : 'Hello',
'de_DE' : 'Hallo',
'fr_FR' : 'Bonjour'
} ,
'class:data-langstr-of' : {
'en_GB' : 'of',
'de_DE' : 'von',
'fr_FR' : 'de'
},
'New' : {
'en_GB' : 'New',
'de_DE' : 'Neu',
'fr_FR' : 'Nouveau'
},
'Modus' : {
'en_GB' : 'Mode',
'de_DE' : 'Modus',
'fr_FR' : 'Mode'
},
'Help' : {
'en_GB' : 'Help',
'de_DE' : 'Hilfe',
'fr_FR' : 'Aide'
},
'Documentation' : {
'en_GB' : 'Documentation',
'de_DE' : 'Dokumentation',
'fr_FR' : 'Documentation'
},
'Language' : {
'en_GB' : 'Language',
'de_DE' : 'Sprache',
'fr_FR' : 'Langue'
},
'About' : {
'en_GB' : 'About',
'de_DE' : 'Über',
'fr_FR' : 'A propos'
},
'imprint' : {
'en_GB' : 'imprint',
'de_DE' : 'Impressum',
'fr_FR' : 'Copyrights'
},
'Close' : {
'en_GB' : 'Close',
'de_DE' : 'Schliessen',
'fr_FR' : 'Fermer'
},
'Add' : {
'en_GB' : 'Add',
'de_DE' : 'Hinzufügen',
'fr_FR' : 'Ajouter'
},
'Wallpaper' : {
'en_GB' : 'Wallpaper',
'de_DE' : 'Hintergrundbild',
'fr_FR' : 'Fond d\'écran'
},
'Search' : {
'en_GB' : 'Search',
'de_DE' : 'Suchen',
'fr_FR' : 'recherche'
},
'Developers' : {
'en_GB' : 'Developers',
'de_DE' : 'Entwickler',
'fr_FR' : 'Developpeurs'
},
'Installing' : {
'en_GB' : 'Install',
'de_DE' : 'Installieren',
'fr_FR' : 'Installer'
},
'Uninstall' : {
'en_GB' : 'Uninstall',
'de_DE' : 'Deinstallieren',
'fr_FR' : 'Desinstaller'
},
'My Apps' : {
'en_GB' : 'My Apps',
'de_DE' : 'Meine Apps',
'fr_FR' : 'Mes Applications'
},
'Settings' : {
'en_GB' : 'Settings',
'de_DE' : 'Einstellungen',
'fr_FR' : 'Paramètres'
},
'Monday' : {
'en_GB' : 'Monday',
'de_DE' : 'Montag',
'fr_FR' : 'Lundi'
},
'Tuesday' : {
'en_GB' : 'Tuesday',
'de_DE' : 'Dienstag',
'fr_FR' : 'Mardi'
},
'Wednesday' : {
'en_GB' : 'Wednesday',
'de_DE' : 'Mittwoch',
'fr_FR' : 'Mercredi'
},
'Thursday' : {
'en_GB' : 'Thursday',
'de_DE' : 'Donnerstag',
'fr_FR' : 'Jeudi'
},
'Friday' : {
'en_GB' : 'Friday',
'de_DE' : 'Freitag',
'fr_FR' : 'Vendredi'
},
'Saturday' : {
'en_GB' : 'Saturday',
'de_DE' : 'Samstag',
'fr_FR' : 'Samedi'
},
'Sunday' : {
'en_GB' : 'Sunday',
'de_DE' : 'Sonntag',
'fr_FR' : 'Dimanche'
},
'Change Theme' : {
'en_GB' : 'Change Theme',
'de_DE' : 'Theme wechseln',
'fr_FR' : 'Change Theme'
},
'System Control' : {
'en_GB' : 'System Control',
'de_DE' : 'Systemsteuerung',
'fr_FR' : 'Contrôle du système'
},
'Messenger' : {
'de_DE' : 'Nachrichtendienst',
'en_GB' : 'Messenger',
'fr_FR' : 'Messagerie'
},
'class:maintenance-hint-webfan-desktop' : {
'de_DE' : 'Der Desktop wird derzeit überarbeitet! Fehler möglich.',
'en_GB' : 'The desktop is currently in maintenance mode! Possbible errors.',
'fr_FR' : 'Le bureau est actuellement en mode maintenance, des erreurs sont possibles.'
},
'class:data-langstr-No-new-notifications' : {
'en_GB' : 'No new notifications',
'de_DE' : 'Keine neuen Benachrichtigungen',
'fr_FR' : 'Aucune notification'
} ,
'Available' : {
'en_GB' : 'Available',
'de_DE' : 'Verfügbare',
'fr_FR' : 'Disponible'
},
'Default settings' : {
'en_GB' : 'Default settings',
'de_DE' : 'Standardeinstellungen',
'fr_FR' : 'Les paramètres par défaut'
},
/**
* @ToDo french
* */
'No profile selected. You may select an Desktop User or create one...': {
'en_GB' : 'No profile selected. You may select an Desktop User or create one...',
'de_DE' : 'Kein Profil ausgewählt. Sie können einen Benutzer wählen oder erstellen...',
'fr_FR' : 'No profile selected. You may select an Desktop User or create one...'
},
'Soundsettings' : {
'en_GB' : 'Soundsettings',
'de_DE' : 'Soundeinstellungen',
'fr_FR' : 'Soundsettings'
},
'Play sound if you get a new message' : {
'en_GB' : 'Play sound if you get a new message',
'de_DE' : 'Sound abspielen bei einer neuen Nachricht',
'fr_FR' : 'Play sound if you get a new message'
} ,
'class:wd-lang-user' : {
'en_GB' : 'User',
'de_DE' : 'Benutzer',
'fr_FR' : 'Utilisateur'
},
'Password' : {
'en_GB' : 'Password',
'de_DE' : 'Passwort',
'fr_FR' : 'Mot de passe'
},
'Confirm' : {
'en_GB' : 'Confirm',
'de_DE' : 'Bestätigen',
'fr_FR' : 'Confirmer'
} ,
'Loading, please wait' : {
'en_GB' : 'Loading, please wait',
'de_DE' : 'Lade, bitte warten Sie',
'fr_FR' : 'Loading, please wait'
},
'Postbox' : {
'en_GB' : 'Postbox',
'de_DE' : 'Postfach',
'fr_FR' : 'Postbox'
},
'All Messages' : {
'en_GB' : 'All Messages',
'de_DE' : 'Alle Nachrichten',
'fr_FR' : 'All Messages'
},
'Filemanager' : {
'en_GB' : 'Filemanager',
'de_DE' : 'Dateimanager',
'fr_FR' : 'Filemanager'
}
});
return true;
});
},
cb_open : null,
icons : [
],
windows : [
],
menulinks : [
],
canvas : [
{
type : 'html',
device : '#bar_top',
prepend : true,
html : '<span style="display:inline;float:right;"><div style="display:inline;" data-frdl-component="flow://components/locale"></div></span>'
}
],
shema : null
};
var $ModulProgramm_Terminal = {
mid : 'terminal',
title : 'Terminal',
author : 'Till Wehowski, Webfan.de',
description : 'Provides a small command line console.',
ico : 'http://static.webfan.de/icons/terminal.png',
started : false,
init : function(Desktop, modul){
$('#window_main_' + this.mid).css('background' ,'black');
$('#window_main_' + this.mid).css('color', 'white');
$('#window_main_' + this.mid).css('height', '100%');
$('#' + this.mid).css('position', 'relative');
$('#' + this.mid).css('height', '650px');
$('#' + this.mid).css('width', '99%');
$('#' + this.mid).css('background' ,'black');
$('#' + this.mid).css('color', 'white');
},
cb_open : function(){
console.log('Terminal restart...');
frdl.wd().resetReady('Start terminal..........',66,
function(){
var T =frdl.wd().Registry.Programs['terminal'];
var r = ('undefined' !== typeof T && 'object' === typeof Dom.g('wd-link-terminal-start')) ? true : false;
if(true !== r)return r;
if(true === T.started)return true;
T.started = true;
Dom.g('wd-link-terminal-start').onclick();
return true;
}
);
},
start : function(){
frdl.wd().resetReady('Start terminal...',50,
function(){
var T = frdl.wd().Registry.Programs['terminal'];
var r = ('undefined' !== typeof T && 'function' === typeof T.cb_open) ? true : false;
if(true !== r)return r;
T.cb_open();
return true;
}
);
},
icons : [
{
img : 'http://static.webfan.de/icons/terminal.png'
}
],
windows : [
{
img : 'http://static.webfan.de/icons/terminal.png',
title : 'CLI Terminal',
html_aside : '<p>frdl://</p>'
+ '<p><a href="javascript:;" id="wd-link-terminal-start" onclick="console.log(\'Terminal restart...\');try{$(\'#\' + this.mid).find(\'section\').PttyLoad();}catch(err){console.error(err);}">Start...</a></p>'
+ '<p><a href="javascript:;" onclick="$.cliExec(\'#!js\');">#!js - Javascript Shell</a></p>'
+ '<p class="mess-wd-d-ebug"><a href="javascript:;" onclick=" var µ = (function(){alert(\'µ\');})(); /* var WIN = $($.WebfanDesktop).frdlWin(\'create\', {openByDefault : true, title:\'Testfenster...\', main:\'test..\', aside:\'...\', bottom:\'...\'});$(\'#window_main_\' + WIN.id).socialshare(); */">Testmock</a></p>'
,
html_main : '<section style="width:99%;background:black;">
<div data-frdl-component="widget://example.com/webfan/cli" data-frdl-opt-menu="true"></div>
</section>
',
html_bottom : 'http://interface.api.webfan.de/v1/public/frdl/bounce/cli.jsonp',
exec : function(ev){
try{ $('#' + frdl.wd().Registry.Programs['terminal'].mid).PttyLoad();}catch(err){console.error(err);}
}
}
],
menulinks : [
],
canvas : [
],
shema : null
};
/* $ModulProgramm_Terminal.mid = 'terminal'; */
var $ModulProgramm_SystemControl = {
mid : 'system',
title : 'Settings',
author : 'Till Wehowski, Webfan.de',
description : 'System Control',
ico : 'http://static.webfan.de/icons/icons-3/list_settings.gif',
init : function(Desktop, modul){
var mid = modul.mid;
Desktop.addBottomBarIcon(modul.mid, modul.title,
"http://static.webfan.de/icons/icons-3/list_settings.gif" ,
'left',
'#',
function(){
$('#window_' + mid).show();
Dom.bringToFront($('#window_' + mid));
}
);
frdl.wd().translate();
},
cb_open : function(){
var THIS = this;
$('#window_' + THIS.mid).show();
Dom.bringToFront('#window_' + THIS.mid);
$.WebfanDesktop.translate();
},
defaultSettings : function(){
var k, i = 0;
if(true !== confirm('Sure you want to reset to default settings?'))return;
$.WebfanDesktop.Registry.System.Theme = frdl.wd().getDefaultTheme();
$.WebfanDesktop.Registry.User = wUser;
$.WebfanDesktop.Registry.icon_pos = {};
for ( i = 0; i < localStorage.length; i++) {
k = localStorage.key(i);
if(frdl.wd().o.ids.DB === k.substr(0, frdl.wd().o.ids.DB.length)){
wjslWebStorage.del(k);
localStorage.removeItem(k);
i=0;
pausecomp(5);
}
}
if(true !== confirm('Settings reseted. Reload page?'))return;
var u = explode('#',new frdl.Url())[0];
window.location = u;
},
useraccount : function(){
$.WebfanDesktop.Registry.Programs['user'].cb_open();
},
soundsettings : function(){
var THIS = this, html = '', div = $('#window_main_' + THIS.mid);
$(div).html('');
html += '<h1>Soundsettings</h1>';
html += '<input type="checkbox" '+ ((true === frdl.wd().Registry.Programs['nachrichtendienst'].config.always_sound)
? ' checked '
: ' ')
+ ' onclick="$.WebfanDesktop.Registry.Programs[\'nachrichtendienst\'].config.always_sound=this.checked;$.WebfanDesktop.save(\'SOUND_IF_MESSAGE\');" '
+ ' /> <span>Play sound if you get a new message</span>';
$(div).append(html);
$.WebfanDesktop.translate();
},
themesettings : function(){
try{$('#window_main_system').wd_ThemesList({},'list');}catch(err){console.error(err);}
},
languagesettings : function(){
$('#window_main_system').html('<span>Current</span> <span>Language</span>: ' + frdl.wd().getLang() + ' <div data-frdl-component="flow://components/locale"></div>');
$('#window_main_system').append('
<p> <strong>Contribute as translator/Custom translate</strong></p>
<ul>
<li>
<a href="https://github.com/frdl/-Flow/blob/master/example/language.js" target="_blank">
<u>Apply custom language/translation...</u>
</a>
</li>
<li>
<a href="https://github.com/frdl/translations" target="_blank">
<u>Translationteam/-sources...</u>
</a>
</li>
</ul>
<div class="wrapper_download_info">
<span style="font-size:7px;">- Anzeige -</span><br />
<a href="http://www.tradezone.fr" target="_blank" title="tradezone.fr - french translator" style="text-decoration:underline;">
<img src="http://www.tradezone.fr/modules/Sitebanner/images/minilogo.gif" border="0" width="120" height="60" alt="tradezone.fr - french translator" style="border:none;" />
</a>
</div>
');
frdl.wd().translate();
},
programssettings : function(){
try{$('#window_main_system').FlowRegister($.WebfanDesktop.Registry.Programs);}catch(err){console.error(err);}
},
icons : [
{
img : 'http://static.webfan.de/icons/icons-3/list_settings.gif'
}
],
windows : [
{
img : 'http://static.webfan.de/icons/icons-3/list_settings.gif',
title : 'System Control',
html_aside : '<strong>System Control</strong>'
+ '<ul>'
+ '<li onclick="frdl.wd().toggleDesktop();"><u>Toggle Desktop</u></li>'
+'</ul>'
+ '<ul>'
+ '<li><strong>Software</strong><ul>'
+ '<li onclick="frdl.wd().Registry.Programs[\'system\'].programssettings();"><img src="http://static.webfan.de/icons/icons-3/page_new.gif" /><u>Add</u>...</li>'
/* + '<li onclick="try{$(\'#window_main_system\').wd_ModulesListInstalled();}catch(err){console.error(err);}"><img src="http://static.webfan.de/icons/icons-3/list_extensions.gif" /><u>My Apps</u></li>' */
+ '</ul></li>'
+ '<li><strong>Settings</strong><ul>'
/* + '<li onclick="frdl.wd().go(\'system\', \'useraccount\');"><img src="http://static.webfan.de/icons/icons-3/icon_user.gif" /><u class="wd-lang-user">User</u></li>'*/
+ '<li onclick="frdl.wd().Registry.Programs[\'system\'].languagesettings();"><img src="http://static.webfan.de/icons/icons-3/flag_white.gif" /><u>Language</u></li>'
+ '<li onclick="frdl.wd().Registry.Programs[\'system\'].soundsettings();"><img src="http://static.webfan.de/icons/icons-3/page_sound.gif" /><u>Sound</u></li>'
+ '<li class="hint-ondebug" onclick="frdl.wd().debugMode(\'t\');alert(\'Debugmode is now: \' + ((true===frdl.wd().o.debug)?\'ON\':\'OFF\'));"><img src="http://static.webfan.de/icons/icons-3/flag_red.gif" /><u>Debug</u></li>'
+ '<li onclick="frdl.wd().Registry.Programs[\'system\'].defaultSettings();"><img src="http://static.webfan.de/icons/icons-3/icon_wand.gif" /><u>Default settings</u></li>'
+ '</ul></li>'
+ '<li><strong>Theme</strong><ul>'
+ '<li onclick="$.WebfanDesktop.Registry.Programs[\'system\'].themesettings();"><img src="http://static.webfan.de/icons/icons-3/image_new.gif" style="border:none;" /><u><span>Change Theme</span>...</u></li>'
+ '<li onclick="frdl.wd().dialogWallpaper();"><img src="http://static.webfan.de/icons/icons-3/image.gif" style="border:none;" /><u>Wallpaper</u></li>'
+ '</ul></li>'
+ '</ul>'
,
html_main : '<a href="javascript:;" onclick="$(\'#window_aside_system\').toggle();"><span>System Control</span>...</a>',
html_bottom : 'System Control',
exec : function(ev){
}
}
],
menulinks : [
],
canvas : [
],
config : {
location : {
url : window.location.href,
api_url : 'http://interface.api.webfan.de/v1/public/'
}
},
shema : null
};
(function($) {
"use strict";
$.WebfanDesktopWriteHtml = function(Desktop, c)
{
function render(Desktop, c){
if(true === c.prepend){
$(c.device).prepend(c.html);
}else{
$(c.device).append(c.html);
}
}
Desktop.Registry.HTM.push(c);
render(Desktop, c);
$.WebfanDesktop.desktop_html = $('#desktop').html();
return this;
};
})(jQuery );
(function($) {
"use strict";
$.WebfanDesktopIcon = function(Desktop, ico)
{
var rowLength = 6;
if(true === frdl.Device().isTablet){
rowLength = 3;
}
if(true === frdl.Device().isMobile ){
rowLength = 2;
}
function render(Desktop, ico){
var l,left,top, a = Dom.create("a"),
href = (typeof ico.href === 'undefined') ? "#icon_dock_" + ico.mid : ico.href,
img = Dom.create("img");
if('function' === typeof ico.cb_open)a.onclick =ico.cb_open;
a.setAttribute("class", "abs icon");
a.setAttribute("id", "icon_module_" + ico.mid);
a.setAttribute("href", href);
a.setAttribute("data-mid", ico.mid);
img.setAttribute("src", ico.img);
img.style.border ="none";
img.onclick=function(ev){
return this.parentNode.onclick(ev);
};
Dom.add(img,a);
$(a).append('<span>' + ico.title + '</span>');
$(a).css('position', 'absolute');
$(a).css('text-align', 'center');
if('undefined' !== typeof ico.top){
$(a).css('top', ico.top);
}else{
top = ( Math.floor(Desktop.Registry.Icons.length / (rowLength + 1)) ) * 128 + 32;
$(a).css('top', (top ).toString() + 'px' );
}
if('undefined' !== typeof ico.left){
$(a).css('left', ico.left);
}else{
left =( (Desktop.Registry.Icons.length % (rowLength + 1)) ) * 128 + 32;
if(Desktop.Registry.Icons.length <= rowLength)left = left - 128;
$(a).css('left', (left ).toString() + 'px' );
}
Dom.add(a, Desktop.desktop);
}
Desktop.Registry.Icons.push(ico);
render(Desktop, ico);
$(document).ready(frdl.wd().restore_icons);
/* $(document).ready(function(){
frdl.wd().restore_icons();
});
*/
$.WebfanDesktop.desktop_html = $('#desktop').html();
return this;
};
})(jQuery );
(function($) {
"use strict";
$.WebfanDesktopWindow = function(Desktop, win)
{
$(Desktop).frdlWin('create', win);
return win;
};
})(jQuery);
(function($) {
function loadModul(Desktop, modul )
{
var i, win;
$.WebfanDesktop.bootReady = false;
if('object' === typeof Desktop.Registry.Programs[modul.mid]){
console.warn("Modul " + modul.mid + " is already loaded");
return;
}
Desktop.Registry.Programs[modul.mid] = modul;
if('undefined'===typeof modul.title_short)modul.title_short=modul.title;
if(typeof modul.canvas !== "undefined"){
for(i = 0; i < modul.canvas.length; i++){
var canv = modul.canvas[i];
if('html' === canv.type){
$.WebfanDesktopWriteHtml(Desktop, canv);
}
}
}
if(typeof modul.windows !== "undefined"){
for(i = 0; i < modul.windows.length; i++){
win = modul.windows[i];
if('undefined' === typeof win.title){
win.title = modul.title;
}
if('undefined' === typeof win.cb_open){
win.cb_open = modul.cb_open;
}
if('undefined' === typeof win.mid){
win.mid = modul.mid;
}
if('undefined' === typeof win.mutex){
win.mutex = true;
}
$.WebfanDesktopWindow(Desktop, win);
}
}
if(typeof modul.icons !== "undefined"){
for(i = 0; i < modul.icons.length; i++){
var ico = modul.icons[i];
if('undefined' === typeof ico.title){
ico.title = modul.title;
}
if('undefined' === typeof ico.cb_open){
ico.cb_open = modul.cb_open;
}
if('undefined' === typeof ico.mid){
ico.mid = modul.mid;
}
$.WebfanDesktopIcon(Desktop, ico);
}
}
if( 'undefined' !== typeof modul.languageStrings){
try{
frdl.lang(modul.languageStrings);
}catch(err){
console.error(err);
}
}
if('function' === typeof modul.init){
try{
modul.init(Desktop, modul);
}catch(err){
console.warn(err);
}
}
$.WebfanDesktop.render();
Desktop.desktop_html = $('#desktop').html();
}
$.WebfanDesktop = function(options)
{
this.o = (typeof options !== 'undefined' && typeof $.WebfanDesktop.o === 'undefined') ? $.extend({
$ : null,
maintenance : true,
debug : false,
loadDefaultModules : true,
browseContentOnInit : false,
loadUser : true,
bootCallback : null,
URL_RPC : 'http://shell.frdl.de/jsonrpc/remote.json',
URL_JSONP : frdl.route('API_JSONP'),
URL_CLIENT : frdl.route('API_CLIENT_URL') /* */,
doms : {
locale : $wd_opt_destination_locale,
messenger : '#wrapper',
progress : '#wd-progress',
progress_label : '.wd-progress-label',
DialogBoxModal : '#wd-dialogs-box',
clock : '#clock'
},
ids : {
TIMER_READY : 'Timer.wd-checkReady-desktop-loaded.CHECK',
DBPFX : 'frdl/WebfanDesktop/',
DB : 'frdl/WebfanDesktop/',
USERNAME_UNKNOWN : 'Anonymous'.toLowerCase()
},
txt : {
all_messages : 'all messages'
},
progress : 0,
processFactor : 1,
readyStack : [],
renderStack : [],
desktopCSS : []
},options) : $.WebfanDesktop.o;
this.original_html = (typeof $.WebfanDesktop.original_html !== 'undefined') ? $.WebfanDesktop.original_html : this.original_html,
this.Registry = ('undefined' === typeof $.WebfanDesktop.Registry) ? {
LOCAL_MACHINE_CURRENT_USER : null,
User : null,
Notifs : {},
System : {
Theme : null
},
Tasks : [],
Locale : {
},
Programs : {},
Windows : [],
Icons : [],
icon_pos : {},
Menus : [],
HTM : [],
UsersReferences : {
},
Config : {
},
DBS : [],
peers : []
} : $.WebfanDesktop.Registry;
this.setThemeOption = function(opt, val){
return $($.WebfanDesktop.Registry.System.Theme).WebfanDesktopThemeOption(opt, val);
};
this.getDefaultTheme = function(){
return {
'frdl.type' : 'frdl.wd.Theme',
name : 'Default',
version : '2.0',
author : 'Till Wehowski, Webfan.de',
homepage : 'http://webfan.de',
description : 'Webfan Desktop Standard Theme. You can take this theme as default template for creating your own theme.',
wallpaper : 'http://static.webfan.de/logos/bg-light-1.png',
favicon : 'http://static.webfan.de/webfan.favicon.ico',
'apple-mobile-web-app-status-bar-style' : 'lightblue',
css : [
{
selector : '.ui-resizable-se',
attr : 'background',
value : 'url(http://www.webfan.de/images/desktop/images/desktop/gui/window_corner.gif) no-repeat right bottom' /* ,
important : true */
},
{
selector : $.WebfanDesktop.o.doms.progress,
attr : 'color',
value : 'black'
},
{
selector : $.WebfanDesktop.o.doms.progress,
attr : 'background-color',
value : 'lightblue'
},
{
selector : '.ui-widget-header',
attr : 'background-color',
value : 'blue'
},
{
selector : '.icon',
attr : 'background',
value : 'url(http://www.webfan.de/images/desktop/images/desktop/gui/trans_white.png) no-repeat -99999px -99999px'
},
{
selector : '.icon',
attr : 'text-shadow',
value : '#6495ED 0 1px 2px'
},
{
selector : '.icon.active',
attr : 'background',
value : 'url(http://www.webfan.de/images/desktop/images/desktop/gui/trans_black.png)'
},
{
selector : '.window',
attr : 'background',
value : '#fff'
},
{
selector : '.window',
attr : 'color',
value : '#000'
},
{
selector : '.window',
attr : 'border',
value : '1px solid #000'
},
{
selector : '.window_top',
attr : 'background',
value : '#333 url(http://www.webfan.de/images/desktop/images/desktop/gui/bar_bottom.png) repeat-x left top'
},
{
selector : '.window_top',
attr : 'color',
value : '#fff'
},
{
selector : '.window_bottom',
attr : 'background',
value : '#fff url(http://www.webfan.de/images/desktop/images/desktop/gui/bar_top.png) repeat-x left bottom'
},
{
selector : '.window_bottom',
attr : 'text-shadow',
value : '#fff 0 1px 1px'
},
{
selector : '.window_close',
attr : 'background',
value : 'url(http://www.webfan.de/images/desktop/images/desktop/gui/window_buttons.gif) no-repeat'
},
{
selector : '.window_content',
attr : 'background',
value : 'url(http://www.webfan.de/images/desktop/images/desktop/gui/window_content.gif) repeat-y'
},
{
selector : '.maintenance-hint-webfan-desktop',
attr : 'color',
value : 'red'
},
{
selector : '.wd-btn-no',
attr : 'color',
value : 'red'
},
{
selector : '.wd-tabs-linklist-style',
attr : 'padding',
value : '3px',
allAttributes : true
},
{
selector : '.wd-tabs-link-style',
attr : 'margin',
value : '3px',
allAttributes : true
},
{
selector : '.wd-tab-link',
attr : 'margin',
value : '3px',
allAttributes : true
},
{
selector : '.wd-tab-link',
attr : 'padding',
value : '2px',
allAttributes : true
},
{
selector : '.wd-tab-link a:hover',
attr : 'text-decoration',
value : 'underline',
allAttributes : true
},
{
selector : '.wd-tab-link a:hover',
attr : 'backgound-color',
value : 'blue',
allAttributes : true
},
{
selector : '.wd-tab-link',
attr : 'border',
value : '0.1px solid lightblue',
allAttributes : true
},
{
selector : '.wd-tab',
attr : 'border',
value : '0.1px solid lightblue',
allAttributes : true
},
{
selector : '.webfan-blue',
attr : 'color',
value : '#6495ED',
hint : 'Corporate Webfan Color',
disallowed : true
},
{
selector : '.wd-box',
attr : '-moz-border-radius',
value : '5px',
allAttributes : true
},
{
selector : '.wd-box',
attr : '-webkit-border-radius',
value : '5px',
allAttributes : true
},
{
selector : '.wd-box',
attr : 'border',
value : '0.1px dotted lightred',
allAttributes : true
},
{
selector : '.wd-box',
attr : 'padding',
value : '5px',
allAttributes : true
},
{
selector : '.wd-box',
attr : 'margin',
value : '2px',
allAttributes : true
}
]
};
};
this.dialogWallpaper = function(){
var wp = prompt("Set your new wallpaper (image url):\nExamples:\nhttp://static.webfan.de/logos/bg-light-1.png\nhttp://static.webfan.de/icons/pinnwand/kork.jpg", $.WebfanDesktop.Registry.System.Theme.wallpaper);
if(null === wp)return;
$.WebfanDesktop.setThemeOption('wallpaper', wp);
return this;
};
this.support = function(){
$('#wd-dialogs-box').wd_dialogs({loadUrl : 'http://www.webfan.de/TicketSystem.html?context=popup', title : 'Support kontaktieren'});
return this;
};
this.render = function(tplN, func){
if('function' === typeof func){
$.WebfanDesktop.o.renderStack.push(func);
$.WebfanDesktop.o.renderStack = frdl.array_unique($.WebfanDesktop.o.renderStack);
}
$.each(frdl.wd().o.renderStack, function( i, _ ) {
if(false === _()){
try{
$.WebfanDesktop.o.renderStack.splice(i,1);
--i;
$.WebfanDesktop.o.renderStack = frdl.filterArray($.WebfanDesktop.o.renderStack, function(el){
return (null !== el && 'function' === typeof el);
});
} catch(err){
console.warn(err);
}
}
});
if('undefined' === typeof tplN || 'debug' === tplN){
if(true === $.WebfanDesktop.o.debug){
if(null === Dom.g('hint-debug-webfan-desktop')){
$($.WebfanDesktop.desktop).prepend('<p class="hint-ondebug" id="hint-debug-webfan-desktop"><span style="top:-5px;color:red;z-index:1000;">DEBUGMODE</span></p>');
}
$('#hint-debug-webfan-desktop').show();
$(".mess-wd-d-ebug").show();
}else{
$('#hint-debug-webfan-desktop').hide();
$('#hint-debug-webfan-desktop').remove();
Dom.remove('hint-debug-webfan-desktop');
$('.mess-wd-d-ebug').hide();
}
$( ".hint-ondebug" ).toggleClass( 'ondebug', frdl.wd().o.debug );
}
/*
if('undefined' === typeof tplN || 'restore_icons' === tplN){
frdl.wd().restore_icons();
}
*/
$($.WebfanDesktop.wrapper).css('width', '100%');
$($.WebfanDesktop.wrapper).css('height', '100%');
$.WebfanDesktop.translate();
return false;
};
this.debugMode = function(s){
if('undefined' === typeof s)return $.WebfanDesktop.o.debug;
if(true === s || 1 === s)s = 'on';
if(false === s || 0 === s)s = 'off';
if('toggle' === s || 't' === s){
s = (true === $.WebfanDesktop.o.debug) ? 'off' : 'on';
}
$.WebfanDesktop.o.debug = ('on' === s) ? true : false;
$.WebfanDesktop.save('debug');
$.WebfanDesktop.render('debug');
return $.WebfanDesktop.o.debug;
};
this.browseNew = function(URL, TITLE){
var url = URL, title=TITLE;
frdl.ready(function(){
setTimeout(function(){
if(true === frdl.Dom.isVisible('desktop') ){
$.WebfanDesktop.Registry.Programs['browser'].cb_open({url:url,title:title});
return;
}
$.WebfanDesktop.resetReady('Browse to ' + url +'...',76,
function(){
if('object' !== typeof frdl.Dom.g('desktop') )return false;
try{
$.WebfanDesktop.Registry.Programs['browser'].cb_open({url:url,title:title});
return true;
}catch(err){
console.warn(err);
return false;
}
}
);
},2000);
});
};
this.browse = function(url, title){
$.WebfanDesktop.browseNew(url, title);
};
this.goTo = function(c, hash, widget, reloaded){
if('string'===typeof hash){
window.location.href='#'+hash;
}
var m = null;
frdl.each($.WebfanDesktop.Registry.Programs, function(i,p){
if(c===p.title_short){
m = p;
return false;
}
});
if(null === m && 'undefined'===typeof reloaded || false === reloaded){
if(!!widget){
c = widget;
}
if(''===new frdl.Url(c).getScheme()){
c = 'http://webfan.de/cdn/frdl/flow/components/' +c;
}
frdl.UI.widget('<div></div>', c, document.querySelector('*[data-frdl-mod="workspace"]'), true);
return this.goTo(c, hash, widget, true)
}
if(null!==m){
$('#icon_module_'+m.mid).trigger('click');
frdl.Dom.bringToFront($('#window_'+m.mid));
} else{
console.warn('cannot open '+c);
}
return this;
};
this.go = function(app, modul){
$.WebfanDesktop.resetReady('Load ' + app +'...',50,
function(){
if(!frdl.Dom.isVisible('desktop'))return false;
try{
var u = new frdl.Url();
var hash = '/app=' + app;
if('string' === typeof modul)hash += '&modul=' + modul;
hash += '&token=' +Sha1.hash( new Date() + mt_rand(10000000, 99999999) + Guid.newGuid() );
u.setHash(hash);
window.location.href = u.urlMakeNew();
}catch(err){
console.warn(err);
}
return true;
});
return this;
};
this.getWindow= function(id){
var w = false;
return ('undefined' === typeof (w =$.WebfanDesktop.getP(id, true).WIN) ) ? false : w;
};
this.getP = function(id, fallbackOnWindows){
if(!isNaN(id)){
var ID = parseInt(id), r = false;
$.each($.WebfanDesktop.Registry.Programs, function(i, p){
if(i === ID){
r = p;
return false;
}
});
if( false !== r || true !== fallbackOnWindows)return r;
}else{
var p,k;
for(k in $.WebfanDesktop.Registry.Programs){
p=$.WebfanDesktop.Registry.Programs[k];
if(id===p.mid || id===p.id)return p;
}
if(true !== fallbackOnWindows)return false;
}
return $.WebfanDesktop.getWin(id, true);
};
this.getWin = function(id, fallbackOnTasks){
if(!isNaN(id)){
var ID = parseInt(id), r = false;
$.each($.WebfanDesktop.Registry.Windows, function(i, w){
if(i === ID){
r = w;
return false;
}
});
if( false !== r || true !== fallbackOnTasks)return r;
}else{
var w,i=0;
for(i=0;i<$.WebfanDesktop.Registry.Windows.length;i++){
w=$.WebfanDesktop.Registry.Windows[i];
if(id===w.id)return w;
}
if(true !== fallbackOnTasks)return false;
}
return $.WebfanDesktop.getTask(id, false);
};
this.getTask = function(id, fallbackOnWindows){
if(!isNaN(id)){
var ID = parseInt(id), r = false;
$.each($.WebfanDesktop.Registry.Tasks, function(i, t){
if(i === ID){
r = t;
return false;
}
});
if(false !== r || true !== fallbackOnWindows)return r;
}else{
var t,i=0;
for(i=0;i<$.WebfanDesktop.Registry.Tasks.length;i++){
t=$.WebfanDesktop.Registry.Tasks[i];
if(id===t.id)return t;
}
if(true !== fallbackOnWindows)return false;
}
return $.WebfanDesktop.getWin(id, false);
};
this.kill = function(id){
var t,i=0;
for(i=0;i<$.WebfanDesktop.Registry.Tasks.length;i++){
if(id===$.WebfanDesktop.Registry.Tasks[i].id){
$.WebfanDesktop.Registry.Tasks[i] = undefined;
$.WebfanDesktop.Registry.Tasks = frdl.filter($.WebfanDesktop.Registry.Tasks, function(v, k){
if(undefined === v || null === v || 'undefined' === typeof v)return false;
return true;
});
break;
};
}
return this;
};
this.getLang = function(){
if('function'===typeof frdl.getLang)return frdl.getLang();
if(true !== $.WebfanDesktop.bootReady)return;
try{
/* return $($.WebfanDesktop.o.doms.locale).locale('getSelectedLanguageCode'); */
var l = $.WebfanDesktop.Registry.User.lang;
}catch(err){
console.warn(err);
var l = wUser.lang;
}
if('default' === l || 'DEnglish' === l){
if( frdl.Device().language === 'de'){
return 'de_DE';
}else if( frdl.Device().language === 'en'){
return 'en_EN';
}else if( frdl.Device().language === 'fr'){
return 'fr_FR';
}
}
return l;
};
this.translate = function(lang){
if($.WebfanDesktop.getLang() === lang)return;
if('undefined' === typeof lang)var lang = $.WebfanDesktop.getLang();
if('string'!==typeof lang)return;
/*
$($wd_opt_destination_locale).locale('_buildStringReferenceMapping', $($wd_opt_destination_locale).locale); */
try{
frdl.translate(lang, false, true);
}catch(err){
console.warn(err);
}
$.WebfanDesktop.save('user');
/*
frdl.translate(lang, false, true);
return $.WebfanDesktop;
*/
return $.WebfanDesktop;
};
this.loadModul = function(m){
loadModul(this, m);
return this;
};
this.toggleDesktop = function(){
$('#desktop')
.toggle()
;
$('*[data-frdl-mod="nodesktop"]')
.toggle()
;
return $.WebfanDesktop;
};
this.executeHash = function(hash){
var _lHash = ('string'===typeof hash) ? hash : new frdl.Url().getHash();
if('/'===_lHash.substr(0,1)){
_lHash=_lHash.substr(1);
}
/*
if(_lHash===new frdl.Url().getHash()){
return;
}
*/
var u = new frdl.Url('frdl://desktop.js/?' + _lHash ),
app, modul, isSET = false, n = new Date() / 1000;
if(true === u.hasParam('click') ){
try{
if(typeof Dom.get( u.getParam('click')).onclick === 'function'){
Dom.get(u.getParam('click')).onclick();
}
}catch(err){
console.warn(err);
}
}
if(true === u.hasParam('app') && '' !== u.getParam('app') ){
app = u.getParam('app');
$.WebfanDesktop.resetReady('Load ' + app +'...',50,
function(){
var App = app;
if((new Date() / 1000) - n > 60000){
var err = 'Timeout loading ' + App;
frdl.alert.error(err);
console.warn(err);
return true;
}
if(true !== isSET){
isSET = true;
if('undefined' === typeof $.WebfanDesktop.Registry.Programs[App]){
try{
var f = $('<div></div>').FlowRegister([],true, App);
return;
}catch(err){
console.error(err);
}
}
}
var U = u, r = ( 'undefined' !== typeof $.WebfanDesktop.Registry.Programs[App]);
if(true !== r )return;
++$.WebfanDesktop.o.progress;
$.WebfanDesktop.resetReady('Load ' + app +'...',70,
function(){
if( 'undefined' === typeof $.WebfanDesktop.Registry.Programs[app])return ;
try{
if( 'function' === typeof $.WebfanDesktop.Registry.Programs[app].cb_open){
webfan.$Async(function(){
$.WebfanDesktop.Registry.Programs[app].cb_open(U.getParams());
},1);
}
window.history.pushState({
name : app + ' - ' +u.urlMakeNew(),
sha1 : Sha1.hash(u.urlMakeNew()),
l : html.toString().length
}, app, new frdl.Url().urlMakeNew());
}catch(err){
console.warn(err);
}
return true;
});
return true;
}
);
if(true === u.hasParam('modul') && '' !== u.getParam('modul')){
modul = u.getParam('modul');
setTimeout(function(){
$.WebfanDesktop.resetReady('Load ' + modul +'...',95,
function(){
var App = app, U = u;
if(''===modul)return true;
if( 'undefined' === typeof frdl.wd().Registry.Programs[App])return ;
if('function' !== typeof frdl.wd().Registry.Programs[App][modul])return ;
if('object' !== typeof frdl.$q('window_main_'+App, false))return;
try{
webfan.$Async(function(){
frdl.wd().Registry.Programs[App][modul](U.getParams());
},1);
window.history.pushState({
name : app + ' - ' +u.urlMakeNew(),
sha1 : Sha1.hash(u.urlMakeNew()),
l : html.toString().length
}, app, new frdl.Url().urlMakeNew());
webfan.$Async(function(){
window.location.href = '#';
},1);
return true;
}catch(err){
console.warn(err);
}
return true;
}
);
},1000);
}
}
};
this.hashChange = function(ev){
$.WebfanDesktop.oldonhashchange();
return $.WebfanDesktop.executeHash();
};
this.resetReady = function(labelText, pro, func){
$.WebfanDesktop.bootReady = false;
if('undefined' === typeof $.WebfanDesktop.o.processFactor){
$.WebfanDesktop.o.processFactor = 1;
}
if('function' === typeof func && null !== func){
$.WebfanDesktop.o.readyStack.push(func);
}
try{
$('.img-ajax-loader').show();
var labelText=('undefined' === typeof labelText) ? '' : labelText,
progressbar = $( $.WebfanDesktop.o.doms.progress ),
progressLabel = $( $.WebfanDesktop.o.doms.progress_label );
if('string' === typeof labelText)$(progressLabel).text( labelText );
$(progressLabel).prepend('<img src="http://images.webfan.de/ajax-loader_2.gif" alt="lade..." style="border:none;" class="img-ajax-loader" /> ');
$(progressbar).show();
$(progressLabel).show();
if('undefined' !== typeof pro && pro > $.WebfanDesktop.o.progress){
$.WebfanDesktop.o.progress = pro;
}
if($.WebfanDesktop.o.progress >= 100){
$.WebfanDesktop.o.progress = 99;
if($.WebfanDesktop.o.readyStack.length > 0)$.WebfanDesktop.o.progress -= $.WebfanDesktop.o.readyStack.length;
}
if($.WebfanDesktop.o.progress < 0)$.WebfanDesktop.o.progress = 1;
$(progressbar).progressbar({
value : $.WebfanDesktop.o.progress,
create: function(event, ui) {
for(var j = 0; j < $(this).WebfanDesktopTheme().css.length; j++){
if($(this).WebfanDesktopTheme().css[j].selector === '.ui-widget-header'){
$(this).find('.ui-widget-header').css('background-color', $(this).WebfanDesktopTheme().css[j].value );
break;
}
}
}
});
if(false === uhrTimer.is($.WebfanDesktop.o.ids.TIMER_READY) && 'function'===typeof $.WebfanDesktop.checkReady){
uhrTimer.add($.WebfanDesktop.o.ids.TIMER_READY, function(){
if('function'===typeof $.WebfanDesktop.checkReady)$.WebfanDesktop.checkReady();
});
}
/* frdl.wd().checkReady(); */
} catch(err){
console.error(err);
}
return $.WebfanDesktop.bootReady;
};
this.hideProgress = function(){
$('.img-ajax-loader').hide();
$( $.WebfanDesktop.o.doms.progress_label ).hide();
$( $.WebfanDesktop.o.doms.progress ).hide();
};
this.showProgress = function(){
$('.img-ajax-loader').show();
$( $.WebfanDesktop.o.doms.progress_label ).show();
$( $.WebfanDesktop.o.doms.progress ).show();
};
this.checkReady = function(){
var i = 0, WD = frdl.wd();
if('undefined' === typeof WD.bootReady)WD.bootReady=false;
if('undefined' === typeof WD.o)return WD.bootReady;
$(WD.o.doms.progress ).progressbar({value : WD.o.progress });
for(i=0;i<WD.o.readyStack.length;i++){
if(null === WD.o.readyStack[i] || true===WD.o.readyStack[i]()){
WD.o.readyStack.splice(i,1);
i--;
WD.o.readyStack = frdl.filterArray(WD.o.readyStack, function(el){
return (null !== el && 'function' === typeof el);
});
WD.o.progress += (WD.o.processFactor * 1);
}
else{
WD.bootReady = false;
}
}
$(WD.o.doms.progress ).progressbar({value : WD.o.progress });
if(WD.o.readyStack.length > 0)return false;
var handleState = function(state){
switch (state) {
case "loading":
$.WebfanDesktop.showProgress();
$.WebfanDesktop.bootReady = false;
break;
case "interactive":
$.WebfanDesktop.showProgress();
$.WebfanDesktop.bootReady = false;
break;
case "complete":
try{
if(true===frdl.Dom.isVisible($.WebfanDesktop.o.doms.progress.replace(/#/, '')))$.WebfanDesktop.hideProgress();
uhrTimer.remove($.WebfanDesktop.o.ids.TIMER_READY);
$.WebfanDesktop.bootReady = true;
$.WebfanDesktop.o.progress = 100;
$($.WebfanDesktop.o.doms.progress ).progressbar({value : $.WebfanDesktop.o.progress });
/* THIS KILLS CPU: $.WebfanDesktop.translate(); */
$.WebfanDesktop.o.progress = 0;
}catch(err){
console.warn( 'Error: ' + err);
}
break;
}
};
/*
$(document).on('readystatechange', function () {
handleState(document.readyState);
}) ;
$(document).ready(function(){
handleState(document.readyState);
});
*/
handleState(document.readyState);
return WD.bootReady;
};
this.browseAway = function(e){
frdl.wd().save();
};
this.load = function(k){
try{
var v = localStorage.getItem(frdl.wd().o.ids.DB + k + '/');
return (null !== v) ? JSON.parse( base64_decode(v) ) : v;
}catch(err){
console.warn(err);
}
return undefined;
};
this.save = function(k, v){
if('undefined' !== typeof v && 'string' === typeof k){
try{
localStorage.setItem(frdl.wd().o.ids.DB + k + '/', base64_encode( JSON.stringify(v)));
}catch(err){
console.warn(err);
}
return;
}
try{
if('undefined' === typeof k || k === 'LOCAL_MACHINE_CURRENT_USER'){
localStorage.setItem(frdl.wd().o.ids.DBPFX + 'LOCAL_MACHINE_CURRENT_USER/', base64_encode( JSON.stringify(frdl.wd().Registry.LOCAL_MACHINE_CURRENT_USER)));
}
if('undefined' === typeof k || k === 'notifs'){
localStorage.setItem(frdl.wd().o.ids.DB + 'notifs/', base64_encode(JSON.stringify( frdl.wd().Registry.Notifs )));
}
if('undefined' === typeof k || k === 'user'){
localStorage.setItem(frdl.wd().o.ids.DB + 'user/', base64_encode(JSON.stringify( frdl.wd().Registry.User )));
}
if('undefined' === typeof k || k === 'theme'){
localStorage.setItem($.WebfanDesktop.o.ids.DB + 'theme/', base64_encode( JSON.stringify($.WebfanDesktop.Registry.System.Theme)));
}
if('undefined' === typeof k || k === 'icon_pos'){
localStorage.setItem(frdl.wd().o.ids.DB + 'icon_pos/', base64_encode( JSON.stringify(frdl.wd().Registry.icon_pos)));
}
if('undefined' === typeof k || k === 'SOUND_IF_MESSAGE' && 'undefined' !== frdl.wd().Registry.Programs['nachrichtendienst'].config.always_sound){
localStorage.setItem(frdl.wd().o.ids.DB + 'SOUND_IF_MESSAGE/', frdl.wd().Registry.Programs['nachrichtendienst'].config.always_sound);
}
if('undefined' === typeof k || k === 'debug' ){
localStorage.setItem(frdl.wd().o.ids.DB + 'debug/', base64_encode( JSON.stringify(frdl.wd().o.debug)));
}
}catch(err){
console.error(err);
}
};
this.localStoragekey = function(cu, _set){
cu = str_replace('"', '', cu);
cu = str_replace("'", '', cu);
cu = cu.toLowerCase();
if('' === cu || 'LOCAL_MACHINE_CURRENT_USER'.toLowerCase() === cu || 'SOUND_IF_MESSAGE'.toLowerCase() === cu
|| 'icon_pos'.toLowerCase() === cu
|| 'theme'.toLowerCase() === cu
|| 'user'.toLowerCase() === cu
|| 'debug'.toLowerCase() === cu
|| 'data'.toLowerCase() === cu
){
if(true === _set) alert('This name is reserved: ' + cu);
return false;
}
var nk = $.WebfanDesktop.o.ids.DBPFX + cu + '/';
if('undefined' !== typeof _set && true === _set){
$.WebfanDesktop.Registry.LOCAL_MACHINE_CURRENT_USER = cu;
$.WebfanDesktop.o.ids.DB = nk;
$.WebfanDesktop.save('LOCAL_MACHINE_CURRENT_USER');
$.WebfanDesktop.loadSavedSystem();
}
return nk;
};
this.change_user = function(uname){
return $.WebfanDesktop.localStoragekey(uname, true);
};
var bootUser = function(){
try{
var user = JSON.parse( base64_decode(localStorage.getItem($.WebfanDesktop.o.ids.DB + 'user/')) );
$.WebfanDesktop.Registry.User = ('undefined' !== typeof user && 'object' === typeof user && null !== user) ? user : new wUserData();
wUser = $.WebfanDesktop.Registry.User;
}catch(err){
console.error(err);
}
};
this.loadSavedSystem = function(){
try{
$.WebfanDesktop.Registry.System.Theme = JSON.parse( base64_decode(
localStorage.getItem($.WebfanDesktop.o.ids.DB + 'theme/')
));
if($.WebfanDesktop.getDefaultTheme().name === $.WebfanDesktop.Registry.System.Theme.name
&& true !== version_compare($.WebfanDesktop.Registry.System.Theme.version, $.WebfanDesktop.getDefaultTheme().version, '>=' ) ){
$.WebfanDesktop.Registry.System.Theme = $.WebfanDesktop.getDefaultTheme();
}
}catch(err){
$.WebfanDesktop.Registry.System.Theme = $.WebfanDesktop.getDefaultTheme();
}
if(null === $.WebfanDesktop.Registry.System.Theme){
$.WebfanDesktop.Registry.System.Theme = $.WebfanDesktop.getDefaultTheme();
}
try{
$('<div></div>').WebfanDesktopTheme($.WebfanDesktop.Registry.System.Theme);
}catch(err){
console.warn(err);
}
try{
$.WebfanDesktop.Registry.icon_pos = JSON.parse( base64_decode(
localStorage.getItem($.WebfanDesktop.o.ids.DB + 'icon_pos/')
));
$.WebfanDesktop.restore_icons();
}catch(err){
$.WebfanDesktop.Registry.icon_pos = {};
}
try{
$.WebfanDesktop.Registry.Notifs = JSON.parse( base64_decode(
localStorage.getItem($.WebfanDesktop.o.ids.DB + 'notifs/')
));
if(null=== $.WebfanDesktop.Registry.Notifs) $.WebfanDesktop.Registry.Notifs = { } ;
}catch(err){
$.WebfanDesktop.Registry.Notifs = { } ;
}
try{
$.WebfanDesktop.o.debug = JSON.parse( base64_decode(
localStorage.getItem($.WebfanDesktop.o.ids.DB + 'debug/')
));
if(null === $.WebfanDesktop.o.debug)$.WebfanDesktop.o.debug=false;
}catch(err){
$.WebfanDesktop.o.debug = false;
}
bootUser();
};
var bootSystem = function(){
/* OH NO
document.addEventListener("readystatechange", function () {
handleState(document.readyState);
}, false, true);
*/
try{
$.WebfanDesktop.Registry.LOCAL_MACHINE_CURRENT_USER = JSON.parse( base64_decode(
localStorage.getItem($.WebfanDesktop.o.ids.DBPFX + 'LOCAL_MACHINE_CURRENT_USER/')
));
}catch(err){
$.WebfanDesktop.Registry.LOCAL_MACHINE_CURRENT_USER = $.WebfanDesktop.o.ids.USERNAME_UNKNOWN;
}
var cu = $.WebfanDesktop.Registry.LOCAL_MACHINE_CURRENT_USER;
if(null===cu)cu = wUser.uname;
if('undefined' === typeof cu || null===cu || $.WebfanDesktop.o.ids.USERNAME_UNKNOWN === cu){
cu = $.WebfanDesktop.o.ids.USERNAME_UNKNOWN;
$.WebfanDesktop.Registry.LOCAL_MACHINE_CURRENT_USER = cu;
}
$.WebfanDesktop.o.ids.DB = $.WebfanDesktop.change_user(cu);
};
this.restore_icons = function(){
frdl.ready(function(){
if('undefined' === typeof $.WebfanDesktop.Registry.icon_pos)$.WebfanDesktop.Registry.icon_pos={};
for(var selector in $.WebfanDesktop.Registry.icon_pos){
$(selector).css('top', $.WebfanDesktop.Registry.icon_pos[selector].top);
$(selector).css('left', $.WebfanDesktop.Registry.icon_pos[selector].left);
}
$.WebfanDesktop.restore_icons_done = true;
});
};
var bootInit = function(){
$.WebfanDesktop = this;
if(typeof $.WebfanDesktop.desktop_html !== 'undefined')return this;
var options = $.WebfanDesktop.o;
$.WebfanDesktop.original_html = $('body').html();
$.WebfanDesktop.original_document_html = $('html').html();
$.WebfanDesktop.o.progress = 0;
bootSystem();
$.WebfanDesktop.resetReady('Booting...',5,
function(){
return ($.WebfanDesktop.o.readyStack.length <= 1);
}
);
if(true === options.loadUser){
$.WebfanDesktop.resetReady('Load user...', 10, function(){
return (
null !== typeof $.WebfanDesktop.Registry.User
&& 'undefined' !== typeof $.WebfanDesktop.Registry.User
);
});
}
$.WebfanDesktop.resetReady('Render Theme Template...', 20, function(){
return (
'undefined' !== typeof Dom.g('bar_bottom')
&& undefined !== Dom.g('bar_bottom')
);
});
bootTemplate();
$.WebfanDesktop.resetReady('Load desktop...',30,
function(){
return Dom.isVisible('desktop');
}
);
/* $.JQD.go(this); */
var JQD = $.JQD;
frdl.addReadyCheck(function(){
if ( 'function' !== typeof JQD.go )return false;
if('function'!== typeof $.WebfanDesktop.checkReady)return false;
return true;
});
frdl.ready(function(){
if ( 'function' === typeof JQD.go )JQD.go($.WebfanDesktop);
});
if('undefined' === typeof this.o.loadDefaultModules || true === this.o.loadDefaultModules){
$.WebfanDesktop.resetReady('Load default modules...', 80, function(){
return (
'undefined' !== typeof $.WebfanDesktop.Registry.Programs['terminal']
&& 'undefined' !== typeof $.WebfanDesktop.Registry.Programs['system']
);
});
try{
bootDefaultModules();
}catch(err){
console.error(err);
}
}
if(null !== options.bootCallback && 'function' === options.bootCallback){
options.bootCallback.call();
}
$.WebfanDesktop.oldonhashchange = window.onhashchange || function(){};
/*
window.addEventListener("hashchange", $.WebfanDesktop.hashChange, false);
*/
$(window).on('hashchange', $.WebfanDesktop.executeHash);
window.addEventListener("beforeunload", $.WebfanDesktop.browseAway);
$.WebfanDesktop.restore_icons_done = false;
$.WebfanDesktop.resetReady('Restore icons...', 89, function(){
return $.WebfanDesktop.restore_icons_done;
});
$.WebfanDesktop.restore_icons();
$.WebfanDesktop.resetReady('Loading Clock...',50,
function(){
return ('object' === typeof Dom.g($.WebfanDesktop.o.doms.clock.substr(1,$.WebfanDesktop.o.doms.clock.length))) ? true : false;
}
);
$($.WebfanDesktop.wrapper).show();
$($.WebfanDesktop.desktop).show();
$.WebfanDesktop.render();
$($.WebfanDesktop.o.doms.clock).css('display', 'inline');
$('#menu_top').css('display', 'inline');
$.WebfanDesktop.desktop_html = $('#desktop').html();
var __loaded = false;
$.WebfanDesktop.resetReady('Loading Initial html...', 75, function(){
var r = (typeof $.WebfanDesktop.desktop_html !== 'undefined' && true===Dom.isVisible($.WebfanDesktop.bar_bottom)
&& 'undefined' !== typeof $.WebfanDesktop.Registry.Programs['browser']
&& 'undefined' !== typeof $.WebfanDesktop.original_html ) ? true : false;
if(true !== r)return false;
if(__loaded === false && true === $.WebfanDesktop.o.browseContentOnInit && !frdl.Dom.isFramed()){
__loaded=true;
try {
var blob = new Blob([utf8_encode('<!DOCTYPE html>' + $.WebfanDesktop.original_document_html)], {encoding:"UTF-8", type: 'text/html'});
} catch (e) {
var bb = new (window.WebKitBlobBuilder || window.MozBlobBuilder);
bb.append(utf8_encode(content));
var blob = bb.getBlob(type);
}
try {
var url = (window.webkitURL || window.URL).createObjectURL(blob);
$.WebfanDesktop.browse(url, document.title);
} catch (err) {
console.error(err);
}
}
__loaded=true;
return true;
});
$.WebfanDesktop.executeHash();
$.WebfanDesktop.resetReady('Finish loading...', 90, function(){
return ( typeof $.WebfanDesktop.desktop_html !== 'undefined'
&& 'undefined'!==typeof $.WebfanDesktop.bar_bottom
) ? true : false;
});
$(document).on('readystatechange', frdl.wd().loadDesktopWidgets) ;
$(document).on('readystatechange', frdl.wd().checkReady) ;
$(document).ready(frdl.wd().checkReady);
$(document).trigger('readystatechange');
/*
if($.WebfanDesktop.o.debug===true){
frdl.$i(function($q){
alert('test: hello');
});
}
*/
return this;
};
var bootTemplate = function(){
var _html = '', el, i = 0, containers = Dom.getTagNames('*')/*, Fragment = Dom.createFragment()*/;
for(i = 0; i < containers.length; i++){
if( 'desktop-content' !== containers[i].getAttribute('data-wd-handle'))continue;
_html += $(containers[i]).html();
}
var loadHint = '<div id="' + $.WebfanDesktop.o.doms.progress.substr(1,$.WebfanDesktop.o.doms.progress.length) + '"
style="height:32px;">
<span class="' + $.WebfanDesktop.o.doms.progress_label.substr(1,$.WebfanDesktop.o.doms.progress_label.length) + '"
style="height:16px;">
<img src="http://images.webfan.de/ajax-loader_2.gif" alt="lade..." style="border:none;" class="img-ajax-loader" />
<span>Loading, please wait</span>...
</span>
</div>';
var initialPageWrap = document.querySelectorAll('body *[data-role="page"]');
if(0 === initialPageWrap.length){
$('body' ).wrapInner( '<div role="document" data-dom-cache="false" data-role="page" data-frdl-mod="nodesktop" id="nodesktop-'+ str_replace('.', '-', new frdl.Url().getHost()) + '-' + Sha1.hash(new frdl.Url().urlMakeNew()) + '-' + Sha1.hash(document.title) +'" style="top:35px;bottom:35px;left:0;right:0;position:fixed;right:0px;width:100%;display:none;overflow:auto;"></div>' );
}else{
for (i = 0; i < initialPageWrap.length; i++) {
el = $(initialPageWrap[i]);
el.attr('data-dom-cache', 'false')
.attr('data-role', 'page')
.attr('role', 'document')
.attr('data-frdl-mod', 'nodesktop')
.attr('id', 'nodesktop-'+ str_replace('.', '-', new frdl.Url().getHost()) + '-' + Sha1.hash(new frdl.Url().urlMakeNew()) + '-' + Sha1.hash(document.title) + '-' + i + el.attr('id') )
.css('display', 'none')
.css('cssText', 'top:35px;bottom:35px;left:0;right:0;position:fixed;right:0px;width:100%;display:none;overflow:auto;')
;
}
}
$('body' ).wrapInner( '<div id="wrapper" data-wrapper="true" data-dom-cache="false" style="top:0;bottom:0;left:0;right:0;position:fixed;overflow:hidden;"></div>' );
var wrapper = Dom.g("wrapper");
var desktop = Dom.create("div");
desktop.setAttribute("id", "desktop");
desktop.setAttribute("class", "abs");
desktop.setAttribute("role", "application");
desktop.setAttribute("data-frdl-mod", "workspace");
$(desktop).css('width', '100%');
$(desktop).css('top', '35px');
$(desktop).css('bottom', '35px');
$(desktop).css('overflow', 'auto');
desktop.setAttribute("data-dom-cache", "false");
var bar_top = Dom.create("div");
bar_top.setAttribute("id", "bar_top");
bar_top.setAttribute("class", "abs");
bar_top.setAttribute("data-role", "header");
bar_top.style.zIndex=1001;
bar_top.style.top = "0px";
bar_top.style.position = "fixed";
Dom.add(bar_top, wrapper,true);
Dom.add(desktop, wrapper);
$(desktop).append(loadHint);
if(o.maintenance === true){
$(desktop).append('<p><span class="maintenance-hint-webfan-desktop" style="color:red;z-index:1000;">Der Desktop wird derzeit überarbeitet!</span></p/>');
}else{
$(desktop).append('<p><span class="maintenance-hint-webfan-desktop" style="display:none;">Der Desktop wird derzeit überarbeitet!</span></p/>');
}
$(desktop).append('<p><span class="hint-ondebug" id="hint-debug-webfan-desktop" style="color:red;z-index:1000;">DEBUGMODE</span></p/>');
if(true === o.debug){
$('#hint-debug-webfan-desktop').show();
}else{
$('#hint-debug-webfan-desktop').hide();
$('#hint-debug-webfan-desktop').remove();
Dom.remove('hint-debug-webfan-desktop');
}
$(wrapper).append('<div style="position:fixed;" id="' + $.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length) + '"></div>');
$(bar_top).append('<span class="float_right" id="' + $.WebfanDesktop.o.doms.clock.substr(1,$.WebfanDesktop.o.doms.clock.length) + '"></span>');
var _Menu_Webfan = ''; /*'
<li id="menu_top_webfan">
<a class="menu_trigger" href="#">Webfan</a>
<ul class="menu">
<li>
<a id="wd-link-potal" href="http://www.webfan.de">Portal</a>
</li>
<li>
<a href="http://www.webfan.de/Web_News.html">Nachrichten</a>
</li>
<li>
<a href="http://www.webfan.de/Kleinanzeigen.html">Kleinanzeigen</a>
</li>
<li>
<a href="http://www.webfan.de/Dating.html">Dating</a>
</li>
</ul>
</li>
';
*/
var _LI_SOFTWARE = '
<li>
<a href="javascript:;" onclick="$.WebfanDesktop.Registry.Programs[\'browser\'].cb_open({url:new frdl.Url().getScheme() + \'://frdl.webfan.de\'});"><span>Developers</span> Resources</a>
</li>
<li>
<a href="javascript:;" onclick="$.WebfanDesktop.Registry.Programs[\'browser\'].cb_open({url:new frdl.Url().getScheme() + \'://www.webfan.de/Userblog.html\'});">Homepagesystem</a>
</li>
<!--
<li>
<a href="javascript:;" onclick="var path = ((\'\' !== new frdl.Url().getPath()) ? \'\' : \'\');$.WebfanDesktop.Registry.Programs[\'browser\'].cb_open({url:new frdl.Url().getScheme() + \'://my.webfan.de/\' + path + \'#menue=siteMenue_list_sites&loc=\' + window.location + \'\'});">sites</a>
</li>
<li>
<a href="javascript:;" onclick="var path = ((\'\' !== new frdl.Url().getPath()) ? \'\' : \'\');$.WebfanDesktop.Registry.Programs[\'browser\'].cb_open({url:new frdl.Url().getScheme() + \'://my.webfan.de/\' + path + \'#menue=siteMenue_list_your_gadgets&loc=\' + window.location + \'\'});">gadgets</a>
</li>
<li>
<a href="javascript:;" onclick="$.WebfanDesktop.Registry.Programs[\'browser\'].cb_open({url:new frdl.Url().getScheme() + \'://shell.frdl.de\'});">µ.Flow</a>
</li>
-->
<li>
<a href="javascript:;" onclick="frdl.wd(true).go(\'system\', \'programssettings\', false);">Software</a>
</li>
<li>
<a id="wd-link-install" onclick="$(\'#'+$.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length)+'\').wd_dialogs({loadUrl : \'http://www.webfan.de/install/?context=popup\', title : \'frdl Installieren...\'});" href="javascript:;"><span>Install</span></a>
</li>
<li>
<a onclick="$.WebfanDesktop.Registry.Programs[\'browser\'].cb_open({url:new frdl.Url().getScheme() + \'://www.webfan.de/Downloads.html\'});" href="javascript:;">Downloads</a>
</li>
<li>
<a id="wd-link-entwickler" onclick="frdl.wd(true).goTo(\'frdl/webfan\', undefined, true);"><span>Developers</span> API SDK</a>
</li>
';
/**
<li>
<a href="https://github.com/frdl">Source Code</a>
</li>
*/
/**
<li>
<a href="https://github.com/frdl/webfan/wiki"><span>Documentation</span></a>
</li>
**/
var _LI_UL_ABOUT_HELP = '
<li id="menu_top_about">
<a class="menu_trigger" href="#">Help</a>
<ul class="menu">
<li>
<a href="javascript:;" onclick="$.WebfanDesktop.go(\'search\');"><span>Search</span>...</a>
</li>
<li>
<a href="#" onclick="$(\'#'+$.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length)+'\').wd_dialogs({loadUrl : \'http://www.webfan.de/TicketSystem.html\', title : \'Support\'});"><span>Support</span></a>
</li>
<li>
<a id="wd-link-about" href="#" onclick="$(\'#'+$.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length)+'\').wd_dialogs({loadUrl : \'http://www.webfan.de/assets/desktop/about.php\', title : \'Über Webfan !desktop\'});"><span>About</span>...</a>
</li>
<li>
<a onclick="$(\'#'+$.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length)+'\').wd_dialogs({loadUrl : \'http://www.webfan.de/Impressum.html?context=popup\', title : \'Impressum\', html : \'Dies ist das Impressum von dem Hersteller der Software, dies ist NICHT zwangsläufig das Impressum der vorliegenden Seite!\'});" href="javascript:;" title="Imprint of software NOT site"><span>imprint</span> (software NOT site)</a>
</li>
</ul>
</li>
';
if(true === frdl.Device().isMobile) {
/* <ul id="menu_top" data-role="navigation"> */
$(bar_top).append('
<ul id="menu_top" role="menu">
<li id="menu_top_desktop">
<a class="menu_trigger" href="#">Workspace</a>
<ul class="menu">
<li>
<a href="javascript:;" onclick="try{ $.WebfanDesktop.toggleDesktop();this.innerHTML = \'Toggle Desktop Workspace\'; return false;}catch(err){console.error(err);}">Close</a>
</li>
' +_LI_SOFTWARE + '
</ul>
</li>
'+_Menu_Webfan+'
'+_LI_UL_ABOUT_HELP+'
</ul>
');
}else{
/*
<a id="wd-link-entwickler" style="display:none;" onclick="$(\'#'+$.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length)+'\').wd_dialogs({loadUrl : \'http://www.webfan.de/assets/docu/api/\', title : \'Developers documentation\', title : \'Developers documentation\'});">Developers</a>
*/
/*
<li>
<a onclick="$(\'#'+$.WebfanDesktop.o.doms.DialogBoxModal.substr(1,$.WebfanDesktop.o.doms.DialogBoxModal.length)+'\').wd_dialogs({loadUrl : \'http://www.webfan.de/FAQ-Helpfile-API-und-Entwickler-17.html?context=popup\', title : \'Developers FAQ\', title : \'Developers FAQ\'});">Developers</a>
</li>
*/
/* data-role="navigation" */
$(bar_top).append('
<ul id="menu_top" role="menu">
<li id="menu_top_desktop">
<a class="menu_trigger" href="#">Workspace</a>
<ul class="menu">
<li>
<a href="javascript:;" onclick="try{ $.WebfanDesktop.toggleDesktop(); this.innerHTML = \'Toggle Workspace\'; return false;}catch(err){console.error(err);}">Close</a>
</li>
</ul>
</li>
<li id="menu_top_software">
<a class="menu_trigger" href="#">My Homepage</a>
<ul class="menu">
' +_LI_SOFTWARE + '
</ul>
</li>
'+_Menu_Webfan+'
'+_LI_UL_ABOUT_HELP+'
</ul>
');
}
var bar_bottom = Dom.create("div");
bar_bottom.setAttribute("id", "bar_bottom");
bar_bottom.setAttribute("class", "abs");
bar_bottom.style.display = "inline";
bar_top.style.bottom = "0px";
bar_top.style.position = "fixed";
bar_bottom.setAttribute("data-role", "footer");
Dom.add(bar_bottom, wrapper);
var dock = Dom.create("ul");
dock.setAttribute("id", "dock");
Dom.add(dock, bar_bottom);
if('' !== _html){
$('#desktop').append('<div data-wd-handle="nodesktop-content" data-role="content" role="section">' + _html + '</div>');
}
try{
Dom.createCSSClass('.hint-ondebug ondebug','color: red;');
Dom.createCSSClass('.ondebug','color: red;');
}catch(err){
console.error(err);
}
/* Dom.add(Fragment, Dom.getTagNames("body")[0]); */
this.addBottomBarIcon('desktop', 'Show desktop',
"http://static.webfan.de/icons/icons-3/icon_home.gif" ,
'left',
'#'
);
(function(){
try{
var widgets = JSON.parse( base64_decode(localStorage.getItem($.WebfanDesktop.o.ids.DB + 'widgets/user/')));
if(null!==widgets && 'undefined'!==typeof widgets){
frdl.each(widgets, function(i,widget){
if('undefined'===typeof widget)return true;
$('#desktop').append('<div data-frdl-desktop-widget="widget://components/'+widget.name+'"></div>');
});
}
}catch(err){
console.error(err);
}
}());
this.wrapper = wrapper;
this.desktop = desktop;
this.bar_top = bar_top;
this.bar_bottom = bar_bottom;
this.dock = dock;
/*
try{
$('*[data-role="page"]').trigger('update');
}catch(err){
console.error(err);
}
*/
};
/* data-frdl-desktop-widget="widget://components/components/webfan/marketplace" */
var loadDesktopWidgets = function(){
var widgetElements = document.querySelectorAll('*[data-frdl-desktop-widget]');
if(true!==frdl.isTraversable(widgetElements))return;
frdl.each(widgetElements, function(i,el){
if('true'===el.getAttribute('data-frdl-desktop-widget-initiated') ){
return;
}
el.setAttribute('data-frdl-desktop-widget-initiated', 'true');
var u = new frdl.Url(el.getAttribute('data-frdl-desktop-widget'));
var tok = u.getScheme() + '://components/', widgetLoaded = false, eLoaded = false;
var url = u.urlMakeNew();
var component = str_replace(tok,'',url);
component = str_replace( u.getScheme() + '://example.com/','',component);
component = str_replace( 'widget://','',component);
if('components'===u.getHost() || 'example.com'===u.getHost()){
url = frdl.route('API_COMPONENT_MAIN', null, null, component);
url = str_replace('/app.js', '', url);
}else{
u.setScheme('http');
url = u.urlMakeNew();
}
url = str_replace( 'widget://','http://',url);
if('/' !== url.substr(-1)){
url += '/';
}
var Url = new frdl.Url(url);
var __DIR__ = Url.getScheme() + '://' + Url.getHost() + '/' + Url.getDirectory();
$.ajax( {
url: /*url*/__DIR__ + 'config.xml',
crossDomain: true,
headers: {'X-Requested-With': 'XMLHttpRequest'/*,
'Origin' : new frdl.Url().getScheme() + '://' + new frdl.Url().getHost() */
},
type: 'GET',
dataType: 'XML',
data: {} ,
cache:true
} )
.done(function(response) {
var _MID = 'widget-'+Sha1.hash(component)+'-'+Sha1.hash(url)+'-'+component.length+'-'+url.length;
var config = wjslX2JS.xml2json(response);
if('undefined'===typeof config.widget){
console.error('Cannot get config file of '+component);
return false;
}
var src = null;
if(true===frdl.isTraversable(config.widget.icon_asArray)){
frdl.each(config.widget.icon_asArray, function(i, icon){
if(null===src)src = icon._src;
if('16' === icon._width && '16' === icon._height){
src = icon._src;
return false;
}
});
}
if(null===src)src='http://static.webfan.de/icons/icons-3/list_components.gif';
if(''===new frdl.Url(src).getScheme()){
src = url + src;
}
var authors = '';
if(true===frdl.isTraversable(config.widget.author_asArray)){
frdl.each(config.widget.author_asArray,function(i,author){
authors += ' <a href="'+author._href+'">' + author.__text + '</a>';
});
}
setTimeout(function(){
frdl.wd().loadModul({
mid : _MID,
title : config.widget.name.__text,
title_short : config.widget.name._short,
author : config.widget.author_asArray[0].__text,
description : config.widget.description,
ico : src,
cb_open : function(){
var THIS = $.WebfanDesktop.Registry.Programs[_MID] ;
$('#window_'+THIS.mid).find('.window_aside').hide();
var MUTEX_ID = _MID;
THIS.WIN = $($.WebfanDesktop).frdlWin('create',
{persistent:false,mid:_MID, mutex:true, openByDefault : true, title:config.widget.name.__text, main:'<img src="http://images.webfan.de/ajax-loader_2.gif" alt="lade..." style="border:none;" class="img-ajax-loader" />', aside:'', bottom:'',img:src},
{
browser_showurlinput : false,
browser_savehistory : false
});
THIS.WIN.set('title', config.widget.name.__text);
if('undefined'===typeof config.widget.preference_asArray || 0===config.widget.preference_asArray.length){
THIS.WIN.set('html_aside', 'Widget: ' +config.widget.name.__text + ' by <a href="'+config.widget.author_asArray[0]._href+'" target="_blank">' + config.widget.author_asArray[0].__text +'</a><br />'+config.widget.description+'<br /><span style="font-size:0.7em;">Tip: WidgetAuthors can set a sidebar template.html to config.xml preferences named "plugin:frdl:wd:window_sidebar_left".</span>');
}else{
/* todo: "standard"-plugin-method?
alert(JSON.stringify(config.widget.preference_asArray));
[{"__cnt":3,"_name":"plugin:{hook:[{name:'sidebar', tag:'UI'},
{name:'anotherTestHook', tag:'anotherTestTag'}]}",
"_value":"{templateUrl:'templates/plugin.webfan-desktop/wd_sidebar_left.html'}","_readonly":"true"},{"__cnt":3,"_name":"config.initial","_value":"{local:false, forked:false, apiUrl:null}","_readonly":"false"}]
alert(JSON.stringify(config.widget.preference_asArray));
*/
frdl.each(config.widget.preference_asArray,function(k,preference){
if('plugin:WebfanDesktop:sidebar:UI'===preference._name){
$('#window_'+THIS.mid).find('.window_aside').html('');
$.ajax({
url: __DIR__ + preference._value,
crossDomain:true,
cache:true,
headers: {'X-Requested-With': 'XMLHttpRequest'/*,
'Origin' : new frdl.Url().getScheme() + '://' + new frdl.Url().getHost() */
},
type: 'GET',
dataType:'html'
})
.done(function( html ) {
$('#window_'+THIS.mid).find('.window_aside').append(html);
}).fail(function(jqXHR, textStatus) {
console.error(textStatus);
}).always(function() {
});
}
}); /*eo each preferences */
}/*eo process widget preferences */
THIS.WIN.set('html_bottom', config.widget.name.__text);
/* Dom.bringToFront($('#window_'+THIS.WIN.id)); */
$.WebfanDesktop.resetReady('Loading '+config.widget.name.__text+'...', 40, function(){
$.WebfanDesktop.o.progress++;
if($.WebfanDesktop.o.progress>=95)$.WebfanDesktop.o.progress=85;
if(0===document.querySelectorAll('*[data-frdl-component="'+el.getAttribute('data-frdl-desktop-widget')+'"]').length)return false;
if(!document.querySelector('*[data-frdl-component="'+el.getAttribute('data-frdl-desktop-widget')+'"]').hasAttribute('data-flow-widget'))return false;
return true;
});
frdl.UI.load();
THIS.WIN.set('html_main', '<frdl><div data-frdl-component="'+el.getAttribute('data-frdl-desktop-widget')+'" data-flow-context="desktop"></div></frdl>');
$(document).trigger('readystatechange');
return THIS;
},
/* windows : [
{
img : src,
title : config.widget.name.__text,
html_aside : 'Widget: ' +config.widget.name.__text + ' by' + authors
,
html_main : '<div data-frdl-component="'+el.getAttribute('data-frdl-desktop-widget')+'"></div>',
html_bottom : config.widget.name.__text,
exec : function(ev){
}
}
],
*/ icons : [
{
mid : _MID,
title: config.widget.name.__text,
img : src
}
]
});
/*eo loadModul*/
config.mid=_MID;
config.wdModul = frdl.wd().Registry.Programs[_MID];
},1); /*eo timeout*/
})
.fail(function(jqXHR, textStatus) {
console.error('Error: ' + url + 'config.xml ' + jqXHR.status);
})
.always(function() {
console.log('Loading desktop-widget "' + component+'"...');
});
});
};
var bootDefaultModules = function(){
var _loadedDEFM = false;
$.WebfanDesktop.resetReady('Load default terminal...', 7, function(){
return (
'undefined' !== typeof $.WebfanDesktop.Registry.Programs['terminal']
);
});
$.WebfanDesktop.resetReady('Load default system...', 6, function(){
return (
'undefined' !== typeof $.WebfanDesktop.Registry.Programs['system']
);
});
$.WebfanDesktop.resetReady('Load default modules...', 60, function(){
return ( true === _loadedDEFM ) ? true :false;
});
var i = 0;
$.WebfanDesktop.loadModul( $ModulProgramm_Locale );
$.WebfanDesktop.loadModul( $ModulProgramm_Terminal );
$.WebfanDesktop.loadModul( $ModulProgramm_SystemControl );
$.WebfanDesktop.loadModul({
mid : 'search',
title : '<span class="wd-lang-user">Search</span>',
author : 'Till Wehowski, Webfan.de',
description : 'Search.',
ico : 'http://images.webfan.de/search.png',
cb_open : function(o){
$($.WebfanDesktop.o.doms.locale).locale('loadLangs', {
'Search' : {
'en_GB' : 'Search',
'de_DE' : 'Suche',
'fr_FR' : 'Recherche'
}
});
if('undefined' === typeof o)var o = {};
var THIS = $.WebfanDesktop.Registry.Programs['search'];
THIS.o = o;
THIS.id = THIS.mid;
if(!$.WebfanDesktop.getTask(THIS.id))$.WebfanDesktop.Registry.Tasks.push(THIS);
var MUTEX_ID = 'search' + (('string' === typeof THIS.o.query) ? ('-' + Sha1.hash(THIS.o.query)) : '');
var Title = function(set_title){
var title = '<span>Search</span> ' + (('string' === typeof THIS.o.query) ? (' ' + THIS.o.query) : '') + '';
if(true===set_title){
$('#window_main_' + MUTEX_ID).find('.window_top').find('.window-top-title-span').html(title);
}
return title;
};
var url = 'http://suche.webfan.de' + (('string' ===typeof THIS.o.query) ? '/?q=' + THIS.o.query : ''),
title = Title(true);
if('undefined' === typeof THIS.o.mid)THIS.o.mid = MUTEX_ID;
THIS.WIN = $($.WebfanDesktop).frdlWin('create',
{persistent:false,mid:MUTEX_ID, mutex:true, openByDefault : true, title:title, main:'<img src="http://images.webfan.de/ajax-loader_2.gif" alt="lade..." style="border:none;" class="img-ajax-loader" />', aside:'', bottom:'',img:'http://images.webfan.de/search.png'},
{
browser_showurlinput : false,
browser_savehistory : false
});
THIS.WIN.set('title', title);
THIS.WIN.set('html_aside',
'<ul style="padding-bottom:6px;">'
+ '<li onclick="$.WebfanDesktop.getTask(\'' +THIS.id+'\').WIN.browser(\''+url+'\');"><img src="http://images.webfan.de/search.png" style="border:none;width:16px;height:16px;" /><u>Search</u></li>'
+ '</ul>'
);
THIS.WIN.set('html_bottom', title);
Dom.bringToFront($('#window_'+THIS.WIN.id));
$.WebfanDesktop.getTask(THIS.id).WIN.browser(url);
$.WebfanDesktop.translate();
},
icons : [
{
mid : 'search',
title: '<span>Search</span>',
img : 'http://images.webfan.de/search.png'
}
]
});
$.WebfanDesktop.loadModul({
mid : 'browser',
title : '<span>Browser</span>',
author : 'Till Wehowski, Webfan.de',
description : 'Browser.',
ico : 'http://static.webfan.de/icons/icons-3/icon_world.gif',
cb_open : function(o){
$($.WebfanDesktop.o.doms.locale).locale('loadLangs', {
'Browser' : {
'en_GB' : 'Browser',
'de_DE' : 'Browser',
'fr_FR' : 'Browser'
},
'New window' : {
'en_GB' : 'New window',
'de_DE' : 'Neues Fenster',
'fr_FR' : 'New window'
}
});
if('undefined' === typeof o)var o = {};
var THIS = $.WebfanDesktop.Registry.Programs['browser'];
THIS.o = o;
THIS.id = THIS.mid;
if(!$.WebfanDesktop.getTask(THIS.id))$.WebfanDesktop.Registry.Tasks.push(THIS);
var MUTEX_ID = 'browser' + (('string' === typeof THIS.o.url) ? ('-' + Sha1.hash(THIS.o.url)) : '');
var Title = function(set_title){
var title = '<span>Browser</span> ' + (('string' === typeof THIS.o.url) ? (' ' + THIS.o.url) : '') + '';
if(true===set_title){
$('#window_main_' + MUTEX_ID).find('.window_top').find('.window-top-title-span').html(title);
}
return title;
};
var url = (('string' ===typeof THIS.o.url) ? THIS.o.url : 'about:blank'),
title = ('string' === typeof THIS.o.title) ? THIS.o.title : Title(true);
if('undefined' === typeof THIS.o.mid)THIS.o.mid = MUTEX_ID;
THIS.WIN = $($.WebfanDesktop).frdlWin('create',
{persistent:false,mid:MUTEX_ID, mutex:true, openByDefault : true, title:title, main:'<img src="http://images.webfan.de/ajax-loader_2.gif" alt="lade..." style="border:none;" class="img-ajax-loader" />', aside:'', bottom:'',img:'http://static.webfan.de/icons/icons-3/icon_world.gif'},
{
browser_showurlinput : true,
browser_savehistory : true
});
THIS.WIN.set('title', title);
THIS.WIN.set('html_aside',
'<ul style="padding-bottom:6px;">'
+ '<li title="Visit: '+url+'" onclick="$.WebfanDesktop.getTask(\'' +THIS.id+'\').WIN.browser(\''+url+'\');"><img src="http://static.webfan.de/icons/icons-3/icon_world.gif" style="border:none;width:16px;height:16px;" /><u>'+ new frdl.Url(url).getHost() + '/' + str_replace('/', '\/', new frdl.Url(url).getPath()).trim('/') + '</u></li>'
+ '<li title="New window: '+url+'" onclick="window.open(\''+url+'\', \''+title+'\');"><img src="http://static.webfan.de/icons/icons-3/url.png" style="border:none;width:16px;height:16px;" /><u><span>New window</span>: '+ (new frdl.Url(url).getHost() + '/' + str_replace('/', '\/', new frdl.Url(url).getPath()).trim('/')).substr(0,16) + ' ... ...' + url.substr(-16) +'</u></li>'
+ '</ul>'
);
$('#window_'+THIS.WIN.id).find('.window_aside').hide();
THIS.WIN.set('html_bottom', title);
Dom.bringToFront($('#window_'+THIS.WIN.id));
$.WebfanDesktop.getTask(THIS.id).WIN.browser(url,{
browser_showurlinput : true,
browser_savehistory : true
});
$.WebfanDesktop.translate();
return THIS;
},
icons : [
{
mid : 'browser',
title: '<span>Browser</span>',
img : 'http://static.webfan.de/icons/icons-3/icon_world.gif'
}
]
});
if('undefined' !== typeof this.o.modules) {
for(i = 0; i < this.o.modules.length; i++){
if('object' === typeof this.o.modules[i]){
$.WebfanDesktop.loadModul( this.o.modules[i] );
}else if('function' === typeof this.o.modules[i]){
this.o.modules[i](this);
} else if('string' === typeof this.o.modules[i]){
document[this.o.modules[i]](this);
}
}
}
loadDesktopWidgets();
_loadedDEFM=true;
};
this.loadDesktopWidgets = function(){
loadDesktopWidgets();
};
this.addBottomBarIcon = function(mid, title, img, dir, href, func){
var a = Dom.create("a");
a.setAttribute("id", "show_" + mid);
a.setAttribute("title", htmlentities(title));
var image = Dom.create("img");
image.setAttribute("src", img);
Dom.add(image, a);
if("string" === typeof href ){
a.setAttribute("href", href);
}else{
a.setAttribute("href", '#');
}
if('string' !== typeof dir || ('right' !== dir && 'left' !== dir)){
dir = left;
}
a.setAttribute("class", 'float_' + dir);
if('function' === typeof func){
$(a).on('click', func);
}
$(this.bar_bottom).prepend(a);
};
/*
function boot(){
if(typeof $.WebfanDesktop.desktop_html !== 'undefined')return $.WebfanDesktop;
var fN = bootInit;
var JQD = $.JQD;
frdl.addReadyCheck(function(){
if ( 'function' !== typeof $.JQD.go )return false;
return true;
});
frdl.ready(function(){
$.JQD.go($.WebfanDesktop);
fN();
});
}
setTimeout(function(){
boot();
});
*/
bootInit();
return $.WebfanDesktop;
};
})(jQuery);
}());
|