File: application/webfan/node_modules/webfan/boot.js

Recommend this page to a friend!
  Classes of Till Wehowski   µ.Flow   application/webfan/node_modules/webfan/boot.js   Download  
File: application/webfan/node_modules/webfan/boot.js
Role: Class source
Content type: text/plain
Description: Class source
Class: µ.Flow
General purpose library of objects
Author: By
Last change: Update boot.js
Date: 7 years ago
Size: 7,210 bytes
 

Contents

Class file image Download
/* webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ var Boot = function(scope, require, webfan, global, jQuery){ var Scope = scope || global.frdl; var main = Scope.main = this; global.frdl = window.frdl = Scope; global.webfan = window.webfan = webfan; main.state = new Scope.EventEmitter(); /** e.g. main.dependency.add('module $frdl.inX loaded'); */ main.dependency = main.state.required([ // 'loading', 'ready', 'complete', 'load flow', 'module $1:libraries/angular/angular loaded' , 'module $frdl.UI loaded' ], function (dataArray) { try{ frdl.UI.emitter.emit('dependency.resolved', dataArray, main); }catch(err){ console.error(err); } }, main); require.state.on('resolved', function(){ main.state.emit('module $'+arguments[0].identifier+' loaded', arguments[0]); }); frdl.require.state.emit('resolved', { identifier : 'frdl.main', module : frdl.main }); frdl.require.state.emit('resolved frdl.main', { identifier : 'frdl.main', module : frdl.main }); require('common/json2', function(JSON) { JSON = JSON; if('undefined' === typeof global.JSON || 'undefined' === typeof global.JSON.parse || 'undefined' === typeof global.JSON.stringify)global.JSON=window.JSON=JSON; }); frdl.require('url', function(url) { Scope.url = global.frdl.url = url; }); require('1:libraries/angular/angular', function(angular) { try { Object.defineProperty(Scope, 'a', { 'get':function() { return window.angular; } }); }catch (e){ Scope.a = window.angular; } }); require('webfan/navigator/WebkitWebfanStorage', function(mod){ Scope.$S = mod; Scope.$DB = new Scope.$S({ prefix : 'frdl://$S/schema.info/', user :null, crypt : false, pwd : null }, false); require.state.emit('resolved', { identifier : 'frdl.$DB', module :frdl.$DB }); require.state.emit('resolved frdl.$DB', { identifier : 'frdl.$DB', module : frdl.$DB }); try{ var debugmode = parseInt( frdl.$DB.load('settings/debugmode').toString() ); if(!debugmode || isNaN(debugmode))debugmode=0; } catch(err){ var debugmode = 0; } frdl.debug.mode(debugmode); frdl.ready(function(){ webfan.$Async(function(){ if(0<frdl.debug.mode()){ if('undefined'!==frdl.alert)frdl.alert.log('DEBUG ENABLED ('+frdl.debug.mode()+')'); } },3000); }); }); require('webfan/navigator/dom-observer', function(DOMObserver){ Scope.watchFor = new DOMObserver().watchFor; frdl.require('1:ui/frdlui', function(){ webfan.$Async(function(){ frdl.UI.emitter.once('dependency.resolved', function(){ if(1<frdl.debug.mode())console.log('dependency.resolved => frdl.main.state.emit'); }); },1); main.state.emit('load flow', arguments[0]); }); }); try { Object.defineProperty(Scope, 'sql', { 'get':function() { return Scope.require('webfan/ql'); } }); }catch (e){ Scope.require('webfan/ql', function(sql){ Scope.sql =sql; }); } try { Object.defineProperty(Scope, 'cipher', { 'get':function() { return Scope.require('sjcl/sjcl'); } }); }catch (e){ Scope.require('sjcl/sjcl', function(cipher){ Scope.cipher =cipher; }); } try { Object.defineProperty(Scope, 'util', { 'get':function() { return Scope.require('util'); } }); }catch (e){ Scope.require('util', function(util){ Scope.util =util; }); } require('webfan/navigator/simpledialog', function(alertify) { Scope.alert = alertify; }); require('webfan/navigator/anchor-routing', function(HashHandler) { Scope.Hash = HashHandler; require.state.emit('resolved', { identifier : 'frdl.Hash', module :frdl.Hash }); require.state.emit('resolved frdl.Hash', { identifier : 'frdl.Hash', module : frdl.Hash }); }); webfan.$Async(function(){ require('5:http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/frdl/flow/components/locale/jsin/jsin.js', function(Translator) { Scope.inX = Translator; webfan.$Async(function(){ Scope.inX.start(); },250); require.state.emit('resolved', { identifier : 'frdl.inX', module :frdl.inX }); require.state.emit('resolved frdl.inX', { identifier : 'frdl.inX', module : frdl.inX }); }); },1); frdl.formatBytes = function(bytes,decimals) { if(bytes == 0) return '0 Byte'; // var k = 1000; // or 1024 for binary var k = 1024; var dm = decimals + 1 || 3; var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; var i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; }; //deprectaed... webfan.plug('$fs --local', function(){ if(!!frdl.nw){ return require('fs'); } return frdl.fs5.polyfill.getFiler(); }); webfan.plug('$fs --local root', function(){ try{ return webfan['$fs --local']().fs.root.toURL(); }catch(err){ return document.base || window.location.href; } }); webfan.plug('file://', function(){ try{ return webfan['$fs --local']().fs.root.toURL(); }catch(err){ return document.base || window.location.href; } }); webfan.plug('app://', function(){ try{ if('temp' === arguments[0])return webfan['$fs --local']('temp').fs.root.toURL(); return webfan['$fs --local']().fs.root.toURL(); }catch(err){ return window.location.href; } }); webfan.plug('path.exec', function(){ try{ return webfan['$fs --local']().fs.root.toURL(); }catch(err){ return document.base || window.location.href; } }); webfan.plug('$win open', function(){ return window.open(arguments[0][0]); }); //buggy ..._ //require('http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/frdl/flow/components/webfan/workspace/js/win.js', function(){ // //}); return this; }; Boot.prototype.ready = function(){ if(1<frdl.debug.mode())console.log('<boot>.ready()'); this.state.emit('ready', this); }; Boot.prototype.interactive = function(){ // if(1<frdl.debug.mode())console.log('<boot>.interactive()'); }; Boot.prototype.complete = function(){ if(1<frdl.debug.mode())console.log('<boot>.complete()'); this.state.emit('complete', this); }; Boot.prototype.loading = function(){ //if(1<frdl.debug.mode())console.log('<boot>.loading()'); // this.state.emit('loading', this); }; exports = module.exports = Boot;