File: api-d/4/js-api/library.js/core/frdl.js

Recommend this page to a friend!
  Classes of Till Wehowski   µ.Flow   api-d/4/js-api/library.js/core/frdl.js   Download  
File: api-d/4/js-api/library.js/core/frdl.js
Role: Class source
Content type: text/plain
Description: Class source
Class: µ.Flow
General purpose library of objects
Author: By
Last change: Update frdl.js
Date: 8 years ago
Size: 128,868 bytes
 

Contents

Class file image Download
/* @copyright (c) Till Wehowski - All rights reserved @license (Basic/EULA) http://look-up.webfan.de/webdof-license @license (Source Code Re-Usage) http://look-up.webfan.de/bsd-license Copyright (c) 2015, Till Wehowski All rights reserved. @library.part frdl.Core-1 @link https://github.com/frdl/-Flow FRDLweb */ 'use strict'; function wait(timeout, condition, _do, observed){ var d = new Date(); while (('undefined'===typeof condition || ( true !== condition(observed)))) { if('undefined'!==typeof timeout && null!==timeout && new Date() - d >= timeout)break; if('function'===typeof _do)_do(observed); } if('function'===typeof _do)return _do(observed); return (new Date() - d); }; /** Event shims ... */ /* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Compatibility */ (function() { if (!Event.prototype.preventDefault) { Event.prototype.preventDefault=function() { this.returnValue=false; }; } if (!Event.prototype.stopPropagation) { Event.prototype.stopPropagation=function() { this.cancelBubble=true; }; } if (!Element.prototype.addEventListener) { var eventListeners=[]; var addEventListener=function(type,listener /*, useCapture (will be ignored) */) { var self=this; var wrapper=function(e) { e.target=e.srcElement; e.currentTarget=self; if (listener.handleEvent) { listener.handleEvent(e); } else { listener.call(self,e); } }; if (type=="DOMContentLoaded") { var wrapper2=function(e) { if (document.readyState=="complete") { wrapper(e); } }; document.attachEvent("onreadystatechange",wrapper2); eventListeners.push({object:this,type:type,listener:listener,wrapper:wrapper2}); if (document.readyState=="complete") { var e=new Event(); e.srcElement=window; wrapper2(e); } } else { this.attachEvent("on"+type,wrapper); eventListeners.push({object:this,type:type,listener:listener,wrapper:wrapper}); } }; var removeEventListener=function(type,listener /*, useCapture (will be ignored) */) { var counter=0; while (counter<eventListeners.length) { var eventListener=eventListeners[counter]; if (eventListener.object==this && eventListener.type==type && eventListener.listener==listener) { if (type=="DOMContentLoaded") { this.detachEvent("onreadystatechange",eventListener.wrapper); } else { this.detachEvent("on"+type,eventListener.wrapper); } eventListeners.splice(counter, 1); break; } ++counter; } }; Element.prototype.addEventListener=addEventListener; Element.prototype.removeEventListener=removeEventListener; if (HTMLDocument) { HTMLDocument.prototype.addEventListener=addEventListener; HTMLDocument.prototype.removeEventListener=removeEventListener; } if (Window) { Window.prototype.addEventListener=addEventListener; Window.prototype.removeEventListener=removeEventListener; } } if(!EventTarget || !EventTarget.prototype.addEventListener || !EventTarget.prototype.listeners || !EventTarget.prototype.dispatchEvent){ var EventTarget = function() { this.listeners = {}; this.events = {}; }; EventTarget.prototype.listeners = null; EventTarget.prototype.addEventListener = function(type, callback){ if(!(type in this.listeners)) { this.listeners[type] = []; } this.listeners[type].push(callback); }; EventTarget.prototype.removeEventListener = function(type, callback){ if(!(type in this.listeners)) { return; } var stack = this.listeners[type]; for(var i = 0, l = stack.length; i < l; i++){ if(stack[i] === callback){ stack.splice(i, 1); return this.removeEventListener(type, callback); } } }; EventTarget.prototype.dispatchEvent = function(event){ if(!(event.type in this.listeners)) { return; } var stack = this.listeners[event.type]; event.target = this; for(var i = 0, l = stack.length; i < l; i++) { stack[i].call(this, event); } }; } /** * https://gist.github.com/mudge/5830382 */ /* if(!EventEmitter || !EventEmitter.emit){ Polyfill indexOf. */ var indexOf; if (typeof Array.prototype.indexOf === 'function') { indexOf = function (haystack, needle) { return haystack.indexOf(needle); }; } else { indexOf = function (haystack, needle) { var i = 0, length = haystack.length, idx = -1, found = false; while (i < length && !found) { if (haystack[i] === needle) { idx = i; found = true; } i++; } return idx; }; }; /* Polyfill EventEmitter. var EventEmitter = function () { this.events = {}; }; */ var EventEmitter = /* new EventTarget(); */ EventTarget; /** * https://tonicdev.com/npm/event-state */ EventEmitter.prototype.on = function (event, listener) { if (typeof this.events[event] !== 'object') { this.events[event] = []; } this.events[event].push(listener); }; EventEmitter.prototype.addListener = function (event, listener) { this.on(event, listener); }; EventEmitter.prototype.removeListener = function (event, listener) { var idx; if (typeof this.events[event] === 'object') { idx = indexOf(this.events[event], listener); if (idx > -1) { this.events[event].splice(idx, 1); } } }; EventEmitter.prototype.emit = function (event) { var i, listeners, length, args = [].slice.call(arguments, 1); if (typeof this.events[event] === 'object') { listeners = this.events[event].slice(); length = listeners.length; for (i = 0; i < length; i++) { listeners[i].apply(this, args); } } }; EventEmitter.prototype.once = function (event, listener) { this.on(event, function g () { this.removeListener(event, g); listener.apply(this, arguments); }); }; /** * (c) by * Cory Brown <oh.wise.man@gmail.com> * Daniel Sellers <daniel@designfrontier.net> * * edited by webfan.de */ EventEmitter.prototype.required=function(eventsArrayIn, callback, scopeIn, multiple) { var that = this , scope = scopeIn || {} , eventArray = eventsArrayIn , eventData = [] , updateData = [] , called = false , listen = function(events, multiple) { if (multiple) { return events.on || events.addListener; } else { return events.once || events.one || events.on || events.addListener; } }(that, multiple) , silence = that.off || that.removeListener , isOn = (listen === that.on) || (listen === that.addListener) , clear = function () { eventArray.forEach(function (event) { silence.apply(that,[event, updateData[eventArray.indexOf(event)]]); }); eventData = []; } , updateState = function (eventName) { var index = eventArray.indexOf(eventName); return function (data) { if(typeof data === 'undefined'){ data = true; } eventData[index] = data; stateCheck(); }; } , stateCheck = function () { var ready = eventArray.every(function (event) { return (typeof eventData[eventArray.indexOf(event)] !== 'undefined'); }); if(ready && !called){ callback.apply(scope, [eventData]); if(!multiple){ called = true; if(isOn){ clear(); } } } } , addState = function () { var events = function(){ var args = [].slice.call(arguments), flat = [], fltn = function (arry) { return arry.reduce(function (flat, item) { if (Array.isArray(item)) { flat.concat(fltn(item)); } else { flat.push(item); } return flat; }, flat); }; return [].concat(fltn(args)); }([].slice.call(arguments)); events.forEach(function (event) { var index = eventArray.indexOf(event); if(index === -1){ eventArray.push(event); index = eventArray.length - 1; } updateData[index] = updateState(event); listen.apply(that, [event, updateData[index]]); }); }; eventArray.forEach(function (event) { addState(event); }); return {cancel: clear, add: addState, events: eventArray, status: eventData}; }; try{ window.Event = Event; window.EventTarget = EventTarget; window.EventEmitter = EventEmitter; }catch(err){ if('undefined' !== typeof console)console.error(err); } })(); /* debugout.js by @inorganik */ /* https://github.com/inorganik/debugout.js/blob/master/debugout.js https://github.com/inorganik/debugout.js/blob/master/LICENSE The MIT License (MIT) Copyright (c) 2014-2016 Inorganik Produce, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function debugout() { /* try{ if('undefined' !== typeof Event){ var LoggerEvent = new Event('log'); }else{ var LoggerEvent = document.createEvent('Event'); LoggerEvent.initEvent('log', true, true); } }catch(err){ } */ var LoggerEvent = document.createEvent('Event'); LoggerEvent.initEvent('log', true, true); var self = this; var debugmode=true; self.ERRORLEVEL = false; self.doc = document.createDocumentFragment(); var element = document.createElement('log'); self.doc.appendChild(element); element.addEventListener('log', function (ev, e) { ev.target.innerHTML='<pre class="console-sreen">'+self.getLog()+'</pre>'; try{ if(true===debugmode && 'undefined'!==typeof frdl && 'undefined'!==typeof frdl.UI && 'undefined'!==typeof jQuery){ jQuery( frdl.UI ).trigger( 'flow:console:log', [ JSON.stringify(e) ] ); } if( true===debugmode && 'undefined'!==typeof frdl && 'undefined'!==typeof jQuery /* && 1 < frdl.debug.mode() */ ){ jQuery( window ).trigger( 'log:debug', [ JSON.stringify(e) ] ); } }catch(err){ } }, false); self.realTimeLoggingOn = true; self.useTimestamps = self.ERRORLEVEL; self.useLocalStorage = self.ERRORLEVEL; self.recordLogs = true; self.autoTrim = true; self.maxLines = 25000000; self.tailNumLines = 100; self.logFilename = 'debugout.txt'; self.depth = 0; self.parentSizes = [0]; self.currentResult = ''; self.startTime = new Date(); self.output = ''; this.html = function(el){ if(!!el){ $(el).html($(element).html()); element.addEventListener('log', function (e) { $(el).html($(element).html()); }, false); return this; } return $(element).html(); }; this.version = function() { return '0.5.0' }; this.mode = function(isOn){ if(true===isOn){ debugmode=true; }else if(false===isOn){ debugmode=false; } return debugmode; }; /* USER METHODS */ this.getLog = function() { var retrievalTime = new Date(); if (!self.recordLogs) { self.log('[debugout.js] log recording is off.'); } if (self.useLocalStorage) { var saved = window.localStorage.getItem('debugout.js'); if (saved) { saved = JSON.parse(saved); self.startTime = new Date(saved.startTime); self.output = saved.log; retrievalTime = new Date(saved.lastLog); } } return self.output + '\n---- Log retrieved: '+retrievalTime+' ----\n' + self.formatSessionDuration(self.startTime, retrievalTime); }; this.tail = function(numLines) { var numLines = numLines || self.tailLines; return self.trimLog(self.getLog(), numLines); }; this.last = function(maxLines, offset) { if(isNaN(maxLines)) maxLines=1; if(isNaN(offset)) offset=3; var lines = self.getLog().split('\n'), r = []; if(lines.length > maxLines) { for(var i = lines.length - maxLines - offset; i < lines.length - offset ; i++){ r.push(lines[i]); } } return r.join('\n'); }; this.search = function(string) { var lines = self.output.split('\n'); var rgx = new RegExp(string); var matched = []; for (var i = 0; i < lines.length; i++) { var addr = '['+i+'] '; if (lines[i].match(rgx)) { matched.push(addr + lines[i]); } } var result = matched.join('\n'); if (result.length == 0) result = 'Nothing found for "'+string+'".'; return result }; this.getSlice = function(lineNumber, numLines) { var lines = self.output.split('\n'); var segment = lines.slice(lineNumber, lineNumber + numLines); return segment.join('\n'); }; this.downloadLog = function(filename) { self.logFilename=('string'===typeof filename)?filename:self.logFilename; var file = "data:text/plain;charset=utf-8,"; var logFile = self.getLog(); var encoded = encodeURIComponent(logFile); file += encoded; var a = document.createElement('a'); a.href = file; a.target = '_blank'; a.download = self.logFilename; document.body.appendChild(a); a.click(); a.remove(); }; this.clear = function() { var clearTime = new Date(); self.output = '---- Log cleared: '+clearTime+' ----\n'; if (self.useLocalStorage) { var saveObject = { startTime: self.startTime, log: self.output, lastLog: clearTime }; saveObject = JSON.stringify(saveObject); window.localStorage.setItem('debugout.js', saveObject); } /*if (self.realTimeLoggingOn) console.log('[debugout.js] clear()');*/ }; this.log = function(obj) { /*if (self.realTimeLoggingOn) console.log(obj); */ var type = self.determineType(obj); if (type != null && self.recordLogs) { var addition = self.formatType(type, obj); if (self.useTimestamps) { var logTime = new Date(); self.output += self.formatTimestamp(logTime); } self.output += addition+'\n'; if (self.autoTrim) self.output = self.trimLog(self.output, self.maxLines); if (self.useLocalStorage) { var last = new Date(); var saveObject = { startTime: self.startTime, log: self.output, lastLog: last }; saveObject = JSON.stringify(saveObject); window.localStorage.setItem('debugout.js', saveObject); } } self.depth = 0; self.parentSizes = [0]; self.currentResult = ''; element.dispatchEvent(LoggerEvent); }; /* METHODS FOR CONSTRUCTING THE LOG */ this.determineType = function(object) { if (object != null) { var typeResult; var type = typeof object; if (type == 'object') { var len = object.length; if (len == null) { if (typeof object.getTime == 'function') { typeResult = 'Date'; } else if (typeof object.test == 'function') { typeResult = 'RegExp'; } else { typeResult = 'Object'; } } else { typeResult = 'Array'; } } else { typeResult = type; } return typeResult; } else { return null; } }; this.formatType = function(type, obj) { switch(type) { case 'Object' : self.currentResult += '{\n'; self.depth++; self.parentSizes.push(self.objectSize(obj)); var i = 0; for (var prop in obj) { self.currentResult += self.indentsForDepth(self.depth); self.currentResult += prop + ': '; var subtype = self.determineType(obj[prop]); var subresult = self.formatType(subtype, obj[prop]); if (subresult) { self.currentResult += subresult; if (i != self.parentSizes[self.depth]-1) self.currentResult += ','; self.currentResult += '\n'; } else { if (i != self.parentSizes[self.depth]-1) self.currentResult += ','; self.currentResult += '\n'; } i++; } self.depth--; self.parentSizes.pop(); self.currentResult += self.indentsForDepth(self.depth); self.currentResult += '}'; if (self.depth == 0) return self.currentResult; break; case 'Array' : self.currentResult += '['; self.depth++; self.parentSizes.push(obj.length); for (var i = 0; i < obj.length; i++) { var subtype = self.determineType(obj[i]); if (subtype == 'Object' || subtype == 'Array') self.currentResult += '\n' + self.indentsForDepth(self.depth); var subresult = self.formatType(subtype, obj[i]); if (subresult) { self.currentResult += subresult; if (i != self.parentSizes[self.depth]-1) self.currentResult += ', '; if (subtype == 'Array') self.currentResult += '\n'; } else { if (i != self.parentSizes[self.depth]-1) self.currentResult += ', '; if (subtype != 'Object') self.currentResult += '\n'; else if (i == self.parentSizes[self.depth]-1) self.currentResult += '\n'; } } self.depth--; self.parentSizes.pop(); self.currentResult += ']'; if (self.depth == 0) return self.currentResult; break; case 'function' : obj += ''; var lines = obj.split('\n'); for (var i = 0; i < lines.length; i++) { if (lines[i].match(/\}/)) self.depth--; self.currentResult += self.indentsForDepth(self.depth); if (lines[i].match(/\{/)) self.depth++; self.currentResult += lines[i] + '\n'; } return self.currentResult; break; case 'RegExp' : return '/'+obj.source+'/'; break; case 'Date' : case 'string' : if (self.depth > 0 || obj.length == 0) { return '"'+obj+'"'; } else { return obj; } case 'boolean' : if (obj) return 'true'; else return 'false'; case 'number' : return obj+''; break; } }; this.indentsForDepth = function(depth) { var str = ''; for (var i = 0; i < depth; i++) { str += '\t'; } return str; }; this.trimLog = function(log, maxLines) { var lines = log.split('\n'); if (lines.length > maxLines) { lines = lines.slice(lines.length - maxLines); } return lines.join('\n'); }; this.lines = function() { return self.output.split('\n').length; }; this.formatSessionDuration = function(startTime, endTime) { var msec = endTime - startTime; var hh = Math.floor(msec / 1000 / 60 / 60); var hrs = ('0' + hh).slice(-2); msec -= hh * 1000 * 60 * 60; var mm = Math.floor(msec / 1000 / 60); var mins = ('0' + mm).slice(-2); msec -= mm * 1000 * 60; var ss = Math.floor(msec / 1000); var secs = ('0' + ss).slice(-2); msec -= ss * 1000; return '---- Session duration: '+hrs+':'+mins+':'+secs+' ----' }; this.formatTimestamp = function(timestamp) { var year = timestamp.getFullYear(); var date = timestamp.getDate(); var month = ('0' + (timestamp.getMonth() +1)).slice(-2); var hrs = Number(timestamp.getHours()); var mins = ('0' + timestamp.getMinutes()).slice(-2); var secs = ('0' + timestamp.getSeconds()).slice(-2); return '['+ year + '-' + month + '-' + date + ' ' + hrs + ':' + mins + ':'+secs + ']: '; }; this.objectSize = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; /* START/RESUME LOG */ if (self.useLocalStorage) { var saved = window.localStorage.getItem('debugout.js'); if (saved) { saved = JSON.parse(saved); self.output = saved.log; var start = new Date(saved.startTime); var end = new Date(saved.lastLog); self.output += '\n---- Session end: '+saved.lastLog+' ----\n'; self.output += self.formatSessionDuration(start, end); self.output += '\n\n'; } } self.output += '---- Session started: '+self.startTime+' ----\n\n'; return self; } function str_replace(search, replace, subject) { try{ return subject.split(search).join(replace); }catch(err){ if(0<frdl.debug.mode())console.warn(err); return ''; } } function getScript(url, callBack, doNotRemove, prepend, args) { /* document.dispatchEvent(new Event('load'), script); */ var scripts = document.getElementsByTagName('script'); if(true === doNotRemove){ for(var i=0; i < scripts.length;i++){ if(url === scripts[i].getAttribute('src')){ if (typeof callBack === "function") {callBack(args);/*document.dispatchEvent(new Event('readystatechange'), script); */} return "undefined"; } } } var head = document.getElementsByTagName("head", document)[0]; var script = document.createElement("script"); script.setAttribute('src', url); script.setAttribute('async', 'true'); /* script.setAttribute('defer', 'true'); */ var done = false, persistent = ('undefined'===typeof doNotRemove || true === doNotRemove) ? true : false; script.setAttribute('type', 'text/javascript'); script.onload = script.onreadystatechange = function () { if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) { done = true; if(true !== persistent){ script.onload = script.onreadystatechange = null; head.removeChild(script); } if (typeof callBack === "function") {callBack(args);/* document.dispatchEvent(new Event('readystatechange'), script);*/} } }; if( true === prepend){ head.insertBefore(script, head.firstChild); }else{ head.appendChild(script); } return "undefined"; } function FrdlFatalErrorException(){ Error.apply(this, arguments); this.name = "Ausnahmefehler"; } function FrdlRangeErrorException(){ RangeError.apply(this, arguments); this.name = "Overflow"; } function FrdlSyntaxErrorException(){ SyntaxError.apply(this, arguments); this.name = "Bad Syntax"; } function FrdlTypeErrorException(){ TypeError.apply(this, arguments); this.name = "Invalid Data"; } function FrdlDependencyErrorException(){ Error.apply(this, arguments); this.name = "Missing Dependency"; } function FrdlRedundancyErrorException(){ Error.apply(this, arguments); this.name = "SoftwareRedundancyError"; } function FrdlFrameworkDauProtectionErrorException(){ SyntaxError.apply(this, arguments); this.name = "FrameworkDauProtectionError"; } FrdlFatalErrorException.prototype = Object.create(Error.prototype); FrdlRangeErrorException.prototype = Object.create(RangeError.prototype); FrdlSyntaxErrorException.prototype = Object.create(SyntaxError.prototype); FrdlTypeErrorException.prototype = Object.create(TypeError.prototype); FrdlDependencyErrorException.prototype = Object.create(Error.prototype); FrdlRedundancyErrorException.prototype = Object.create(Error.prototype); FrdlFrameworkDauProtectionErrorException.prototype = Object.create(SyntaxError.prototype); if('undefined' !== typeof frdl){ try{ throw new FrdlRedundancyErrorException('Frdl is already defined, you may have loaded the library twice.'); }catch(err){ if(!!console && !! console.warn)console.warn(err); } } var HOST_API = 'api.webfan.de'; var HOST_CDN_PUBLIC_FRDL = 'cdn.frdl.webfan.de'; var PARENT_CONTEXT = ((typeof window !== 'undefined') ? window : (typeof global !== 'undefined') ? global : this); /* [ 'http://'+HOST_API+'/api-d/4/js-api/library.js?plugin=l10n' ].forEach(function(element, ix, array) { try{ getScript(element, function(){}, true, false); }catch(err){ alert('Cannot get script: ' + err + ' '+element); } }) ; */ var originalConsole = window.console || console || { error : function(){}, log : function(){}, warn : function(){}, debug : function(){}, deprecated : function(){}, notice : function(){} }; var bugout = new debugout(); var consoleCustom = function() { this.init(); }; consoleCustom.prototype = { init : function() { this.isCustom = true; this.time("Console logging"); /* this.log("window.console.custom started"); */ return this; }, isCustom : true, debug : function(message) { if('function'===typeof this.trace) this.trace(message); bugout.log('[DEBUG] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.debug(message ); }catch(err){ alert("Error in console::error : " + err); } } }, count : function(name) { if(typeof originalConsole === "object") { try{ name = name; originalConsole.count(name ); }catch(err){ alert("Notice: " + err); } } }, notice : function(message) { /* if('function'===typeof this.trace) this.trace(message); */ bugout.log('[NOTICE] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.debug(message ); }catch(err){ alert("Notice: " + err); } } }, deprecated : function(message) { /* if('function'===typeof this.trace) this.trace(message); */ bugout.log('[DEPRECATED] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.info(message ); }catch(err){ alert("Deprecated warning: " + err); } } }, dir : function(obj) { try{ if(0< frdl.debug.mode())obj = JSON.stringify(obj); }catch(err){ } bugout.log('[DIR] '+(/*('undefined' !== typeof frdl) ? frdl.Dom.renderJSON(obj) : JSON.stringify(obj)*/obj/*.toString()*/)); if(typeof originalConsole === "object")return originalConsole.dir(obj); }, dirxml : function(node) {bugout.log('[DIRXML] '+node);if(typeof originalConsole === "object")return originalConsole.dirxml(node);}, error : function(message) { if('function'===typeof this.trace) this.trace(message); bugout.log('[ERROR] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.error(message); }catch(err){ alert("Error in console::error : " + err); } } }, /* Creates a time stamp, which can be used together with HTTP traffic timing to measure when a certain piece of code was executed. */ timeStamp : function(name) {if(typeof originalConsole === "object" && 'function'===typeof originalConsole.timeStamp)originalConsole.timeStamp(name);}, /* console.assert() logs an exception if an expression evaluates to false. */ assert : function(expression) {if(typeof originalConsole === "object")originalConsole.assert(expression);}, group : function(name) {if(typeof originalConsole === "object")originalConsole.group(name);}, groupCollapsed : function(name) {if(typeof originalConsole === "object")originalConsole.groupCollapsed(name);}, groupEnd : function() {if(typeof originalConsole === "object")originalConsole.groupEnd();}, profile : function(name) {if(typeof originalConsole === "object" && 'function'===typeof originalConsole.profile)originalConsole.profile(name);}, profileEnd : function(name) {if(typeof originalConsole === "object" && 'function'===typeof originalConsole.profileEnd)originalConsole.profileEnd(name);}, info : function(message) { /* if('function'===typeof this.trace) this.trace(message); */ bugout.log('[INFO] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.info(message ); }catch(err){ alert("Error in console::log : " + err); } } }, log : function(message) { /* if('function'===typeof this.trace) this.trace(message); */ bugout.log('[LOG] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.log(message ); }catch(err){ alert("Error in console::log : " + err); } } }, time : function(t) {this.log("Timer " + t + "::begin");if(typeof originalConsole === "object")return originalConsole.time(t);}, timeEnd : function(t) {this.log("Timer " + t + "::end");if(typeof originalConsole === "object")return originalConsole.timeEnd(t);}, trace : function(message) { /* try { var a = {}; a.debug(); } catch(ex) {console.log(ex.stack)} */ bugout.log('[TRACE] '+message); if(typeof originalConsole === "object") { try{ message = message; originalConsole.trace(message ); }catch(err){ alert("Error in console::log : " + err); } } }, warn : function(message) { if('function'===typeof this.trace) this.trace(message); bugout.log('[WARNING] '+message); try{ if(typeof originalConsole === "object")return originalConsole.warn(message); }catch(err){ alert("Error in console::error : " + err); } }, clear : function() { bugout.clear(); this.timeEnd("Console logging"); try{ if(typeof originalConsole === "object")originalConsole.clear(); }catch(err){ } } }; window.console = console = new consoleCustom(); /* window.onerror = function (message, url, lineNo) { console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo); return true; }; */ var _ObjectFlow = function() { var _Obj = { inherit : function($parent,_new) { var sup = $parent, base = _new; var descriptor = Object.getOwnPropertyDescriptor( base.prototype,"constructor" ); base.prototype = Object.create(sup); var handler = { constructor: function(target, args) { var obj = Object.create(base.prototype); this.apply(target,obj,args); return obj; }, apply: function(target, that, args) { base.apply(that,args); } }; if('function'===typeof Promise.polyfill){ var proxy = Object.create(sup, base); }else{ var proxy = new Proxy(base.prototype,handler); } descriptor.value = proxy; try{ Object.defineProperty(base.__proto__, "constructor", descriptor); }catch(err){ console.error(err); } return proxy; }, extend : function(sup,base) { var descriptor = Object.getOwnPropertyDescriptor( base.prototype,"constructor" ); base.prototype = Object.create(sup.prototype); var handler = { constructor: function(target, args) { var obj = Object.create(base.prototype); this.apply(target,obj,args); return obj; }, apply: function(target, that, args) { sup.apply(that,args); base.apply(that,args); } }; if('function'===typeof Promise.polyfill){ var proxy =Object.create(sup.__proto__, base); }else{ var proxy = new Proxy(base,handler); } descriptor.value = proxy; try{ Object.defineProperty(base.prototype, "constructor", descriptor); }catch(err){ console.error(err); } return proxy; } }; return _Obj; }; var OverloadableObject = /* _ObjectFlow().inherit(_ObjectFlow, _ObjectFlow); */ _ObjectFlow; OverloadableObject.prototype.__noSuchMethod__ = function(name, args) { if('function' === typeof this.__call)return this.__call(name, args); console.warn('Method ' + name + ' of overloaded object and magic method __call is not defined!'); }; /* var $FRDL = new OverloadableObject(); */ var $FRDL = _ObjectFlow().inherit(OverloadableObject , function(){ }); /** * var t = frdl.overload({}); t.__call=function(name,args){alert(name);alert(JSON.stringify(args));}; t.hallo('welt') */ $FRDL.I = { has: function(target, name) { return true; }, get: function(target, name, receiver) { if (name in target.__proto__) { return target.__proto__[name]; } if (name in receiver.__proto__) { return receiver.__proto__[name]; } return function() { try{ var args = Array.prototype.slice.call(arguments); if( 'function' === typeof receiver.__call )return receiver.__call(name, args); }catch(err){ console.error(err); } }; }, apply: function(target, THIS, args) { target.apply(THIS,args); this.apply(THIS,args); } }; $FRDL.IO = Object.create( $FRDL.I); if(typeof window.Proxy !== 'function'){ try{ console.deprecated('window.Proxy Object not defined, please update your browser! '+ typeof window.Proxy); }catch(err){ /* console.log('window.Proxy Object not defined, please update your browser!'); */ } $FRDL.IO.__magic_proxy = Object.create(OverloadableObject, $FRDL.I); }else{ $FRDL.IO.__magic_proxy = new Proxy(OverloadableObject, $FRDL.I); } var __FILE__= function(def, tok) { /* if('string'===typeof sourceURL)return sourceURL; */ return function(def, tok){ if('undefined'=== typeof tok){ var tok = '__FILE__'; } if('undefined'=== typeof def){ var def = ''; } /* var regex = '/' + tok + ' \(.+\/(.*):\d+:\d+\)/'; var error = new Error() , source , lastStackFrameRegex = new RegExp(/.+\/(.*?):\d+(:\d+)*$/) , currentStackFrameRegex = new RegExp(regex); */ var s = '', regex = '/' + tok + ' \(.+\/(.*):\d+:\d+\)/'; var error = new Error() , source , lastStackFrameRegex = new RegExp(/.+\/(.*?):\d+(:\d+)*$/) , currentStackFrameRegex = new RegExp(regex); try{ if(!!error.stack && (source = lastStackFrameRegex.exec(error.stack.trim())) && source[1] != "") s = source[0]; else if(!!error.stack && (source = currentStackFrameRegex.exec(error.stack.trim()))) s = source[0]; else if(error.fileName != undefined) s = error.fileName; else s = def; if(null!==s && '@' === s.substr(0,1)) s = s.substr(1,s.length); if(''!== new frdl.Url(s).getHost()) { s = explode(':', s); s = s[0] + ':' + s[1]; } }catch(err){ return ''; } ; return new frdl.Url(s).urlMakeNew(); }(def, tok); /* return eval(fN)(); */ }; var webfanURLParser = function(u){ var file="",scheme="",url="",host="",path="",query="",hash="",params, user = '', pass = '', port = ''; if(!u || u === '') { u = window.location.href; } url = u; if(u.indexOf("#") > 0){ hash = u.substr(u.indexOf("#") + 1); u = u.substr(0 , u.indexOf("#")); } if(u.indexOf("?") > 0){ path = u.substr(0 , u.indexOf("?")); query = u.substr(u.indexOf("?") + 1); params= query.split('&'); }else{ path = u; } return { getPort : function(){ var portexp = /\/\/[\w.-]*:([0-9]*)/; var match = portexp.exec(url); return (match !== null && match.length > 0) ? match[1] : ''; }, getLocation: function(){ return window.location.href; }, getUrl: function(){ return url; }, getPath: function(){ var pathexp = /\/\/[\w.-]*(?:\/([^?]*))/; var match = pathexp.exec(path); if (match != null && match.length > 1) return match[1]; return ""; }, getFile : function(){ var f = this.getPath().split("/"); var f2 = f[f.length-1].split("?"); file = f2[0]; return file; }, getFileExtension : function(){ return this.getfile().split('.').reverse()[0]; }, getDirectory : function(){ return this.getPath().substr(0, (this.getPath().length - this.getFile().length) ); }, getScheme: function(){ var schemeexp = /([\w.-]*):\/\//; var match = schemeexp.exec(url); scheme = (match !== null && typeof match[1] !== 'undefined') ? match[1] : ''; if (match !== null && match.length > 0) scheme = match[1]; return scheme; }, getHost: function(){ var hostexp = /\/\/([\w.-]*)/; var match = hostexp.exec(url); try{ host = (match !== null && typeof match[1] !== 'undefined') ? match[1] : ''; }catch(err){ host = ""; } return host; }, getHash: function(){ return hash; }, getParams: function(){ return query.split('&'); }, getQuery: function(){ return query; }, getParam: function(name){ if(params){ for (var i = 0; i < params.length; i++) { var pair = params[i].split('='); if (decodeURIComponent(pair[0]) === name) return decodeURIComponent(pair[1]); } } return null; }, hasParam: function(name){ if(params){ for (var i = 0; i < params.length; i++) { var pair = params[i].split('='); if (decodeURIComponent(pair[0]) == name) return true; } } return false; }, removeParam: function(name){ query = ""; if(params){ var newparams = new Array(); for (var i = 0;i < params.length;i++) { var pair = params[i].split('='); if (decodeURIComponent(pair[0]) != name) newparams .push(params[i]); } params = newparams ; for (var i = 0; i < params.length; i++) { if(query.length > 0) query += "&"; query += params[i]; } } if(query.length > 0) query = "?" + query; /* if(hash.length > 0) query = query + "#" + hash; */ return this.unparse(); }, setHash: function(value){ hash = value; var p = path, q = query; if(q.length > 0) q = "?" + q; if(value.length > 0) q = q + "#" + value; return this.unparse(); }, setParam: function(name, value){ if(!params){ params= new Array(); } params.push(name + '=' + value); query = ""; for (var i = 0; i < params.length; i++) { if(query.length > 0) query += "&"; query += params[i]; } if(query.length > 0) query = "?" + query; return this.unparse(); }, setScheme : function(s){ scheme = s; return this.unparse(); }, setHost : function(s){ host = s; return this.unparse(); }, setPort : function(s){ port = s; return this.unparse(); }, setPath : function(){ path = path; return this.unparse(); }, setFile : function(file){ path = this.getPath().substr(0,path.length - this.getFile().length) + file; }, setQuery : function(str){ query = str; params = query.split('&'); return this.unparse(); }, urlMakeNew: function(){ url = this.unparse(); return url; }, unparse : function(obj){ if('undefined' !== typeof obj && 'undefined' !== typeof obj.file){ this.setFile(obj.file); } var o = { scheme : this.getScheme(), host : this.getHost(), user : user , pass : pass, port : this.getPort(), path : this.getPath(), query : this.getQuery(), hash : this.getHash(), params : this.getParams() }; var n = Object.create(o, ('undefined' !== typeof obj) ? obj : {}); var _url = ""; if(n.scheme !== "")_url += n.scheme + "://"; _url += n.host + (('' !== n.port && parseInt(n.port.toString()) === parseInt(n.port) ) ? ':' + n.port : '') + (('' !== n.path || '' !== n.query) ? '/' : '') + n.path /* + (('' !== n.query) ? '?' : '') + n.query */ + (('' !== n.query && '?' !== n.query.substr(0,1)) ? '?' : '') + n.query + (('' !== n.hash) ? '#' + n.hash : ''); return _url; }, resolve : function(base, to){ if('undefined' === typeof to)var to = this.urlMakeNew(); var Url = new (frdl.Url || this)(to); var HUrl = new (frdl.Url || this)(base); if('/'===to.substr(0,1) ){ Url.setScheme( HUrl.getScheme() ) .setHost( HUrl.getHost() ) ; }else if(''===Url.getScheme() ){ Url.setScheme( HUrl.getScheme() ) .setHost( HUrl.getHost() ) .setPath( '/' + HUrl.getDirectory() + to ) ; } return Url.urlMakeNew(); } }; }; document.INF = Infinity; var frdl = function(_, ns){ /*what the fuck*/ _.strictmode = false; _.frdlID = new Date() + '.' + (function (min, max) { return Math.random() * (max - min) + min; })(1000, 9999); var _ROOT = ns; _.__FILE__= __FILE__; var debugmode = 0; _.debug = { mode : function(m){ if(!isNaN(m) && null !== m && undefined !==m)debugmode=parseInt(m); return debugmode; }, Logger : function(){ return bugout; }, last : function(maxLines, offset){ return bugout.last(maxLines, offset); }, getScripts : function(){ var scripts = []; frdl.each(document.querySelectorAll('script'), function(i,el){ var s = { inline : (el.innerHTML==='') ? false : el.innerHTML, src : (el.hasAttribute('src')) ? el.getAttribute('src') : false }; scripts.push(s); }); return scripts; }, getLog : function(){ return bugout.getLog(); }, tail : function(numLines){ return bugout.tail();/* returns the last X lines of the log, where X is the number you pass. Defaults to 100. */ }, search : function(str){ return bugout.search(str); }, getSlice : function(){ return bugout.getSlice(start, numLines);/* get a 'slice' of the log. Pass the starting line and how many lines after it you want */ }, downloadLog : function(filename){ return bugout.downloadLog(filename); }, TypeOf : function(v){ return bugout.determineType(v); }, stackStr : function(offset){ if('undefined'===typeof offset)var offset=0; var stack; try { throw new Error(''); }catch (error) { stack = error.stack || ''; } stack = stack.split('\n').map(function (line) { return line.trim(); }); return stack.splice(stack[0] === 'Error' ? 2+offset : 1+offset); }, stack : function(){ console.log(this.stackStr(1)); } }; var urlAliasMap = { API_JSONP : function(alias, params, path, options){ if(1===2 && 'undefined'!==typeof $.WebfanDesktop && 'undefined'!==typeof $.WebfanDesktop.o && 'undefined'!==typeof $.WebfanDesktop.o.URL_JSONP && 'string'===typeof $.WebfanDesktop.o.URL_JSONP){ if('string'===typeof params){ $.WebfanDesktop.o.URL_JSONP = params; } return $.WebfanDesktop.o.URL_JSONP; }else{ if('string'===typeof params){ frdl.Route('API_URL', params); } return frdl.route('API_URL'); } }, API_CLIENT_URL : function(alias, params, path, options){ if('string'===typeof params){ document.querySelector('meta[name="flow.component.frdl.webfan.api.url"]').setAttribute('content', params); } var metaApi=null, meta = document.querySelector('meta[name="flow.component.frdl.webfan.api.url"]'); if(null!==meta){ if(meta.hasAttribute('content')){ metaApi=meta.getAttribute('content'); } } if(1===2 && 'undefined'!==typeof $.WebfanDesktop && 'undefined'!==typeof $.WebfanDesktop.o && 'undefined'!==typeof $.WebfanDesktop.o.URL_CLIENT && 'string'===typeof $.WebfanDesktop.o.URL_CLIENT){ return (null!==metaApi)?metaApi:$.WebfanDesktop.o.URL_CLIENT; }else{ return (null!==metaApi)?metaApi:/* window.location.href*/ frdl.route('DEMO_API_CLIENT_URL'); /* return 'http://test.freizeittreffen.de/admin/api.php'; */ } }, API_TRANSLATION_MAIN : function(alias, params, path, options){ /* var url = 'https://'+frdl.route('HOST_CDN_PUBLIC_TEST')+'/frdl/translations/master/api-d/4/js-api/library.js/'; var u = new frdl.Url(url); todo negotiate path !!! , own cdn... if('string'===typeof path && '' !== path){ u.setPath(path); } */ var url = frdl.route('JS_LIB') + '?plugin=locale-'; if('string'===typeof options){ url+=options; }else if('undefined'!==typeof options && 'string'===typeof options.path){ url+=options.path; } /* if('string'===typeof options){ url+='plugin.locale_' + options+'.js'; }else if('undefined'!==typeof options && 'string'===typeof options.path){ url+='plugin.locale_' + options.path+'.js'; } */ return url; /* if(params){ for(var p in params){ u.setParam(p, params[p]); } } return u.urlMakeNew(); */ }, API_COMPONENT_MAIN : function(alias, params, path, options){ /* var url = preferences.URL__COMPONENTS_SHOP_MAIN__+'/frdl/-Flow/master/components/'+component+'/app.js'; */ /* var url = 'https://'+frdl.route('HOST_CDN_PUBLIC_TEST')+'/frdl/-Flow/master/components/'; */ var url = 'http://'+frdl.route('HOST_CDN_PUBLIC_FRDL')+'/cdn/frdl/flow/components/'; if('string'===typeof options){ url+= options+'/app.js'; }else if('undefined'!==typeof options && 'string'===typeof options.path){ url+= options.path+'/app.js'; } var u = new frdl.Url(url); if('string'===typeof path && '' !== path){ u.setPath(path); } if(params){ for(var p in params){ u.setParam(p, params[p]); } } return u.urlMakeNew(); }, HOST_CDN_PUBLIC_PRODUCTIONAL : 'cdn.rawgit.com',/* 'cdn.rawgit.com',todo */ HOST_CDN_PUBLIC_TEST : 'rawgit.com',/* todo */ HOST_CDN_PUBLIC_DEVELOPMENT : 'rawgit.com', /* todo */ HOST_CDN_PUBLIC_FRDL : HOST_CDN_PUBLIC_FRDL, /* todo */ HOST_API : HOST_API, JS_LIB : function (){ return 'http://'+HOST_API+'/api-d/4/js-api/library.js'; }, DEMO_API_CLIENT_URL : 'http://test.freizeittreffen.de/admin/api.php', DEMO_API_CLIENT_URL_ALT : 'http://test.freizeittreffen.de/pmx/api.php', API_URL : 'http://interface.'+HOST_API+'/v1/public/frdl/bounce/cli.jsonp', 'FRDL.URL.SERACHENGINE.PLUGIN' : 'http://suche.webfan.de/searchplugin.xml', 'FRDL.URL.MANIFEST.WEBAPP.WEBFAN.MY' : 'http://my.webfan.de/cdn/application/webfan/manifest.webapp', 'jQueryMobile.autoInitializePage' : false, 'jQueryMobile.ajaxEnabled' : false, 'jQueryMobile.linkBindingEnabled' : false, 'jQueryMobile.hashListeningEnabled' : false, 'jQueryMobile.pushStateEnabled' : false }; _.isTraversable = function(thing){ return (('object' === typeof thing || 'array' === typeof thing) && null !== thing ) ? true : false; }; /* Smoothie _.require = require; /* _.requireHandler = requireHandler; */ _.map = function(){ /*todo*/ }; _.route = function(alias, params, path, options){ return ('function'===typeof urlAliasMap[alias]) ? urlAliasMap[alias](alias, params, path, options) : urlAliasMap[alias]; /* var u = new frdl.Url(id); if(params){ for(var p in params){ u.setParam(p, params[p]); } } if(path) u.setPath(path); return id; */ }; _.Route = function(r,v){ if('undefined'===typeof v && 'object'===typeof r){ frdl.each(r, function(i,R){ urlAliasMap[i]=R; }); }else if('undefined'===typeof urlAliasMap[r] && ('function'===typeof v || 'string' === typeof v) ){ urlAliasMap[r]=v; }else if('undefined'!==typeof urlAliasMap[r] && (null===v || typeof v === typeof urlAliasMap[r])){ urlAliasMap[r]=v; }else if('undefined'===typeof v && 'undefined'===typeof r){ return urlAliasMap; }else{ frdl.Throw('framework', 'Invalid arguments: frdl.Route('+JSON.stringify(r)+', '+JSON.stringify(v)+');'); } return _; }; _.Throw = function(type, message, options){ switch (type.toLowerCase()){ case 'silent' : try{ throw new Error(message); }catch(err){ /* console.error(message); */ _.Throw('hidden', message, options); } break; case 'hidden' : /* http://stackoverflow.com/questions/9298839/is-it-possible-to-stop-javascript-execution , ?wtf? */ window.onerror = function(/*message, url, lineNumber*/) { setTimeout(function() { (function(){ window.onerror = function() { return false; }; }()); }, ('integer'===typeof options.duration)?options.duration:1); return true; }; throw new Error(message); break; case 'redundancy' : throw new FrdlDependencyErrorException(message); break; case 'dependency' : throw new FrdlDependencyErrorException(message); break; case 'range' : throw new FrdlRangeErrorException(message); break; case 'type' : throw new FrdlTypeErrorException(message); break; case 'syntax' : throw new FrdlSyntaxErrorException(message); break; case 'framework' : throw new FrdlFrameworkDauProtectionErrorException(message); break; default : case 'fatal' : throw new FrdlFatalErrorException(message); break; }; }; _.checkExclusivVarNames = function(v, reservedNames){ var n = ('array' === typeof reservedNames) ? reservedNames : ['Dom','DomObject','Event','wUser','wUserData', 'lokTimer', 'uhrTimer']; for(var i = 0; i < n.length; i++){ if('undefined' !== typeof _ROOT[n[i]]){ var msg = 'The library.js framework requires the variable identifier -' + n[i] +'- exclusivly, sorry!'; if(true === v){ throw msg; }else{ console.log(msg); } } } return _; }; _.Url = webfanURLParser; _.__call = function(name, args){ try{ var str = 'calling __noSuchMethod__ on ' + name + '(' + JSON.stringify(args) +'): Just assign any function to yourObj.__call to make this work! '; }catch(err){ var str = 'calling __noSuchMethod__ on ' + name + ': Just assign any function to yourObj.__call to make this work! '; } console.warn(str); }; _.__get = function(name){ try{ var str = 'calling __get on ' + name + ': Just assign any function to yourObj.__get to make this work! '; }catch(err){ var str = 'calling __get on ' + name + ': Just assign any function to yourObj.__get to make this work! '; } console.warn(str); }; _.inherit = function(a,b){ return $FRDL.IO.__magic_proxy.inherit(a,b); }; _.extend=function(a,b){ return $FRDL.IO.__magic_proxy.extend(a,b); }; _.overload=function(obj, fn){ var o = Object.create($FRDL.IO.__magic_proxy, obj); if('function'===typeof fn){ o.__call=fn; } return o; }; _.time = function(){ return explode('.', (new Date() / 1000))[0]; }; _.microtime = function(){ return (new Date() / 1000); }; _.getCSS=function(src, p, once){ if('undefined' === typeof once ||true === once || true === p){ if(null!==frdl.$q('link[href="'+str_replace('/', '\/', src)+'"]', false)){ return _; } } if('undefined'===typeof p || null ===p || true === p)var p=frdl.Dom.getTagNames('head')[0]; var style = frdl.Dom.create('link'); style.setAttribute('type', 'text/css'); style.setAttribute('rel', 'stylesheet'); /* style.setAttribute('async', 'true'); style.setAttribute('defer', 'true'); */ style.setAttribute('href', src); frdl.Dom.add(style, p); return _; }; _.array_unique = function(array) { return ("udefined" === typeof jQuery) ? array.filter(function(el, i, array) { return i === arr.indexOf(el); }) : $.grep(array, function(el, i) { return i === $.inArray(el, array); }); }; _.filterArray = function(arr, filter /* func */) { var o = []; for(var index = 0; index < arr.length; index++) { if(filter(arr[index], index) === true) { o.push(arr[index]); } } return o; }; _.filterObject = function(arr, filter /* func */) { var o = {}; for(var k in arr) { if(filter(arr[k], k) === true) { o[k] = arr[k]; } } return o; }; _.filter = function(arr, filter /* func */, recursive) { if(true === recursive && true=== _.isTraversable(arr)){ arr = _.each(arr, function(i,v){ arr[i] = _.filter(v, filter, recursive); }); return arr; } if('array' === typeof arr){ return _.filterArray(arr, filter); }else if('object' === typeof arr){ return _.filterObject(arr, filter); }else{ return (true === filter(arr)) ? arr : undefined; } }; /* jQuery MIT License */ _.each = function( object, callback, args ) { var name, i = 0, length = object.length, traversable = false; if(true !== _.isTraversable(object) ){ traversable = false; } else{ traversable = true; } if ( args ) { if(false === traversable){ callback.apply( object, args ); return object; } if ( length === undefined ) { for ( name in object ) if ( callback.apply( object[ name ], args ) === false ) break; } else for ( ; i < length ; ) if ( callback.apply( object[ i++ ], args ) === false ) break; /* A special, fast, case for the most common use of each */ } else { if(false === traversable){ callback.call( object, 0, object ); return object; } if ( length === undefined ) { for ( name in object ) if ( callback.call( object[ name ], name, object[ name ] ) === false ) break; } else for ( var value = object[0]; i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} } return object; }; _.wd = function(_m){ function load(m){ if('function' === typeof $.WebfanDesktop.toggleDesktop && true===m && !frdl.Dom.isVisible(frdl.$q('*[data-frdl-mod="workspace"]', false))){ $.WebfanDesktop.toggleDesktop(); }else if('function' !== typeof $.WebfanDesktop.toggleDesktop && ( 'undefined'!== typeof m && false !== m)){ $.WebfanDesktop = $.WebfanDesktop(m); } else if('function' !== typeof $.WebfanDesktop.toggleDesktop && ( 'undefined'=== typeof m || false === m)){ $.WebfanDesktop = $.WebfanDesktop(m); } webfan.$Async(function(){ if(false === m && frdl.Dom.isVisible(frdl.$q('*[data-frdl-mod="workspace"]', false))){ frdl.wd().hide(); }else if(true === m && !frdl.Dom.isVisible(frdl.$q('*[data-frdl-mod="workspace"]', false))){ frdl.wd().show(); } },1000); return $.WebfanDesktop; } try{ $.WebfanDesktop = ('function' === typeof $.WebfanDesktop.toggleDesktop) ? load(_m) : frdl.when( function(WebfanDesktop){ return ('function' === typeof $.WebfanDesktop.toggleDesktop) ? true : false; }, function(WebfanDesktop){ /* $.WebfanDesktop = WebfanDesktop; */ $.WebfanDesktop = load(_m); }, $.WebfanDesktop, function(){ console.error('Cannot get $.WebfanDesktop (frdl.when Promise)'); }, 0, function(){ if(null === frdl.$q('*[data-frdl-mod="workspace"]', false)){ $.WebfanDesktop = $.WebfanDesktop(); } } ); return $.WebfanDesktop; }catch(err){ console.warn(err); return $.WebfanDesktop; } }; _.cookie = { write : function(name,value, days, seconds, _path, _host) { var d = 0, path = '/'; if (!isNaN(days)) { d += (days*24*60*60*1000); } if(!isNaN(seconds)) { d += seconds; } if(isNaN(seconds) && isNaN(days)) { var expires = ''; }else{ var date = new Date(); date.setTime(date.getTime()+d); var expires = ';expires='+date.toGMTString(); } if ('string' === typeof _path) { path = _path; } var host = ('string' === typeof _host) ? _host : new frdl.Url().getHost(); var h = host.split("."); if(1 < h.length){ host = '.' + h[h.length-2] + '.' + h[h.length-1]; } document.cookie = name+'='+value+expires+';domain='+host+';path='+path; }, read : function(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; }, del : function(name, path, host){ _.cookie.write(name,'', 0, -1, path, host); } }; _.tabs = function(o){ return this.init(o); }; _.tabs.prototype = { o : { outerDiv : 'window_main_' + new Date(), containerLinks : 'anHtmlContainerID', idUL : 'wd-ac-main-tabs-ul' + new Date(), keyDataTab : 'data-tab', /* div tab class e.g. */ classTab : 'wd-tab', classLink : 'wd-role-tabs-link', classUL : 'wd-tabs-linklist-style', classLI : 'wd-tabs-link-style', displayLI : 'inline', displayUL : 'inline' }, tabsUL : [], delTabs : function(){ var T = this; T.tabsUL = []; }, addTab : function(href, title, tab, collapsed){ var T = this; if('undefined' === typeof collapsed)var collapsed = true; T.tabsUL.push( { href : href, title : title, tab : tab, rendered : false, collapsed : collapsed } ); }, init : function(o){ console.deprecated('frdl tabs is very deprecated!'); /* this.o = Object.create(('object'===typeof this.o) ? this.o : {},('object'===typeof o) ? o : {}); */ this.o = ('object'===typeof o) ? o : {}; if(true === this.o.reset)this.delTabs(); return this; }, openTab : function(tab){ $('.' + this.o.classTab).hide(); $('#' + tab).show(); }, render : function(){ var _THIS = this; var idUL = _THIS.o.idUL; var ul=Dom.g(idUL), created=false, i = 0; if(null === ul || 'undefined' === typeof ul ){ ul = Dom.create('ul'); ul.setAttribute('id', idUL); ul.setAttribute('class', _THIS.o.classUL); ul.style.display= _THIS.o.displayUL; created = true; }else{ ul = Dom.g(idUL); created = false; } for(i = 0; i< _THIS.tabsUL.length; i++){ if(true === _THIS.tabsUL[i].rendered)continue; var li = Dom.create('li'); var a = Dom.create('a'); a.setAttribute('href', _THIS.tabsUL[i].href); a.setAttribute('class', _THIS.o.classLink); a.setAttribute(_THIS.o.keyDataTab, _THIS.tabsUL[i].tab); a.onclick = function(){ var T = _THIS; $('.' + T.o.classTab).hide(); $('#' + this.getAttribute(_THIS.o.keyDataTab)).show(); }; a.innerHTML = _THIS.tabsUL[i].title; Dom.add(a, li); li.setAttribute('class', _THIS.o.classLI); li.style.display= _THIS.o.displayLI; Dom.add(li,ul); if(true === _THIS.tabsUL[i].collapsed){ $('#' + _THIS.tabsUL[i].tab).hide(); } _THIS.tabsUL[i].rendered = true; } if(true === created) { if(null === Dom.g(_THIS.o.containerLinks) || 'undefined' === typeof Dom.g(_THIS.o.containerLinks) ){ Dom.add(ul,Dom.g(_THIS.o.outerDiv), true); }else{ Dom.add(ul, Dom.g(_THIS.o.containerLinks), true); } } } }; _.download = function(content, filename, type, preparingMessageHtml, failMessageHtml, parent, hidden ){ if(null === type || 'undefined' === typeof type)type = 'application/octet-stream'; if(null === filename || 'undefined' === typeof filename)filename = 'file.dat'; if('boolean' !== typeof hidden)hidden = true; if(null === parent || 'undefined' === typeof parent)parent = Dom.getTagNames('body')[0]; if(null === preparingMessageHtml || 'undefined' === typeof preparingMessageHtml)preparingMessageHtml = 'Downloading...'; if(null === failMessageHtml || 'undefined' === typeof failMessageHtml)failMessageHtml = 'Download failed.'; try { var blob = new Blob([content], {type: type}); } catch (e) { var bb = new (window.WebKitBlobBuilder || window.MozBlobBuilder); bb.append(content); var blob = bb.getBlob(type); } var url = (window.webkitURL || window.URL).createObjectURL(blob); var a = Dom.create('a'); a.style.display = 'none'; a.setAttribute('download', filename); a.setAttribute('title', filename); a.setAttribute('target', '_blank'); a.setAttribute('class', 'fileDownload' + Guid.newGuid()); /* a.innerHTML = filename; */ Dom.addText(filename,a); $( a ).click(function( event ) { $.fileDownload(url, { title : filename, popupWindowTitle : filename, preparingMessageHtml: preparingMessageHtml, failMessageHtml: failMessageHtml }); return false; }).trigger( $.Event( "click" ) ); }; _.frame = function(html, title, onLoad, onUnload, style){ return Object.create({ doc : null, clear : function(){ $("body", this.doc).html(''); return this; }, write : function(html){ $("body", this.doc).append(html); return this; }, go : function(url){ this.iframe.setAttribute('src', url); return this; }, home : function(){ this.iframe.setAttribute('src', 'about:blank'); return this; }, title : function(title){ this.doc.title = title; return this; }, init : function(html, title, onLoad, onUnload, style){ this.iframe = Dom.create('iframe'); this.iframe.setAttribute('src', 'about:blank'); this.iframe.style.border='none'; this.iframe.cssText = style; if('function' === typeof onLoad){ this.iframe.onload=onLoad; }else{ this.iframe.onload=function(){ $('.img-ajax-loader').hide(); }; } if('function' === typeof onUnload){ this.iframe.onunload=onUnload; }else{ this.iframe.onunload=function(){ $('.img-ajax-loader').show(); }; } this.doc = (this.iframe.contentWindow || this.iframe.contentDocument).document; this.doc.open(); this.doc.close(); this.doc.title = title; $("body", this.doc).append(html); return this; } }).init(html, title, onLoad, onUnload, style); }; _.top = function(){ return ('undefined' !== typeof window.QueryInterface) ? window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow) : window.top ; /* mainWindow.document.addEventListener("MyExtensionEvent", function(e) { myExtension.myListener(e); }, false, true); document.addEventListener("message", function(e) { yourFunction(e); }, */ }; _.requireWorkspace = function($state, autoLoad, gotoStateCancel, gotoParamsCancel, str, opened){ if(!!opened)opened=true; if('string'!==typeof str)var str='This modul requires workspace mode enabled!'; if(null===document.querySelector('*[data-frdl-mod="workspace"]')){ if(false ===autoLoad && true!==confirm(str+'\n' +'Open Worspace now?')){ if('undefined' !== typeof $state && 'function' === typeof $state.go){ $state.go(gotoStateCancel, gotoParamsCancel, {}); }else if('function' === typeof $state){ $state(gotoStateCancel, gotoParamsCancel); } return false; }else{ frdl.wd(opened); var TimerID = 'openWorkspaceTimer'+mt_rand(100000,9999999999999); frdl.cron.add(TimerID, function(){ if('function'!==typeof frdl.wd().toggleDesktop)return; frdl.cron.remove(TimerID); frdl.wd().toggleDesktop(); return false; }); } } }; _.focus = function(selector, speed){ $('body').animate({ scrollTop: $(selector).offset().top }, (speed || 'fast')); return this; }; _.cmd = function(CMD,CB, onError){ var ready=false, delay = 1, opened=false; opened=true; var cb = '__JSONPCALLBACK__'+str_replace('.', '_', (new Date() / 1000 ).toString() + mt_rand(10000, 2147483647)).toString(); if('function' === typeof CB && true !== new RegExp(/callback/g).test(CMD)){ frdl.cbs[cb] = function(data){ try{ CB(data); }catch(err){ console.error(err); } frdl.cbs[cb]=undefined; } ; CMD += ' --callback=frdl.cbs.'+cb+' '; } if('function'!==typeof frdlBounce_Default || null ===frdl.$q('*[data-frdl-component$="webfan\/cli"]', false)){ $('body').append('<div data-flow-id="console.'+cb+'" data-frdl-opt-menu="true" style="display:none;" data-frdl-component="flow://components/webfan/cli"></div>'); $(document).trigger('readystatechange'); setTimeout(function(){ setTimeout(function(){ $('*[data-flow-id="console.'+cb+'"]').hide(); },3000); ready=true; },1200); }else{ ready=true; } var TimerID2 = 'openWorkspaceTimer'+mt_rand(10000, 2147483647); frdl.cron.add(TimerID2, function(){ if(true !== opened || true !== ready || true !== function(){return 'function'===typeof frdlBounce_Default;}())return; frdl.cron.remove(TimerID2); $('*[data-flow-id="console.'+cb+'"]').hide(); setTimeout(function(){ $.cliExec(CMD); },delay); return false; }); return this; }; /* frdl.watchFor (DOM / CSS insertion-query ) * require http://api.webfan.de/api-d/4/js-api/library.js?plugin=insertion-observer */ /** * see frdl.when() method, * frdl.whenEver() has NO rejection and maybe executed infinite */ _.whenEver=function(condition, callback, args, delay){ if(('function'===typeof condition && true === condition(args)) || (true === (condition)) ){ callback(args); return _.whenEver; }else{ setTimeout(function(){ _.whenEver(condition, callback, args); },(delay || 1)); return _.whenEver; } }; /** * if delayed is a function, delayed is the initial Function * if delayed AND initFn are functions, delayed is the initial function and initFn is called each iteration of check(condition) function * if initFn is a function and delayed is NOT a function, initFn is the initial Function * otherwise there is no initial function or additional check(condition) function * * promise resolves if condition is true * promise rejects if condition is undefined || null * * condition should be either a function or boolean expression */ _.when=function(condition, _then, withMe, _or, delayed /* !isNaN || typeof function */, initFn /* typeof function || undefined */){ if('function'===typeof delayed && 'function'!==typeof initFn){ var init = delayed; delayed=(isNaN(initFn)) ? 1 : initFn; } else if ('function'===typeof delayed && 'function'===typeof initFn){ var fN = initFn; var init = new delayed; delayed = 1; } else if( 'function'===typeof initFn){ var init = initFn; } var check = function(condition, me){ if('function'===typeof fN)fN(me); return ( ( 'function'===typeof condition && true === condition(me) ) || (true === (condition)) ) ? true : condition; }; if('function'===typeof init){ init(withMe); } delayed=(isNaN(delayed)) ? 1 : delayed; if(true===check(condition, withMe))return _then(withMe); var p = new Promise(function(resolve, reject){ function h() { var c = check(condition, withMe); if (true===c) { resolve(withMe); /* } else if (false!==c && true!==c) { */ } else if (undefined===c || null ===c) { reject(withMe); }else{ setTimeout(function(){ h(); },(delayed || 1)); } } h(); }); p.then(function(withMe) { return _then(withMe); }, function(withMe) { return _or(withMe); }); var rProxy = _.overload(p, function(name, args){ if('function'===typeof withMe[name]){ return withMe[name](Array.prototype.slice.call(args)); }else{ setTimeout(function(){ rProxy.__call(name, args); },1000); } }); return rProxy; }; _.wait=function(timeout, condition, _do, observed){ return wait(timeout, condition, _do, observed); }; _.doc = function(w) { return (w===window) ? window.document : w.contentDocument || w.contentWindow.document; }; return _; }(frdl = frdl || /* Object.create($FRDL.IO.__magic_proxy, Object.create({})) */ Object.create($FRDL.IO,$FRDL.IO.__magic_proxy), document)/* .checkExclusivVarNames(true) */; var DomObject = function(selector) { return this.init(selector); }; DomObject.prototype = { element : null, init : function(selector) { this.element = $(selector); return this; }, attrAdd : function(k,v, el){ var El = ('undefined'!==typeof el) ? $(el) : this.$element; $(El).attr(k, $(El).attr(k) + v); return this; }, getTagNames : function(tag, scope) { if(null === scope || 'object' !== typeof scope) scope = document; return scope.getElementsByTagName(tag); }, getNames : function(name) { return document.getElementsByName(name); }, getFormData : function(form){ if(typeof FormData !== "object")return this.getFormDataFallback(form); var f = new FormData(form); return f; }, getFormDataFallback : function(form){ var formElements=this.g(form).elements; var postData={}; for (var i=0; i<formElements.length; i++) { postData[formElements[i].name]=formElements[i].value; } return postData; }, get: function(el) { if (typeof el === 'string' && 'object' === typeof document.getElementById(el)) { return document.getElementById(el); } else if (typeof el === 'string'){ return $(el); }else if ('object' === typeof el){ return el; } else { return el; } }, g : function(el){ return this.get(el); }, getByClass : function(className, parent) { parent || (parent=document); var descendants=parent.getElementsByTagName('*'), i=-1, e, result=[]; while (e==descendants[++i]) { ((' ' + (e['class']||e.className) + ' ').indexOf(' ' + className + ' ') > -1) && result.push(e); } return result; }, getStyle : function(CLASSname, raw) { if("undefined" === typeof raw)var raw = true; var styleSheets = document.styleSheets, cl = []; var styleSheetsLength = styleSheets.length; for(var i = 0; i < styleSheetsLength; i++){ if (styleSheets[i].rules ) { var classes = styleSheets[i].rules; } else { try { if(!styleSheets[i].cssRules) {continue;} } catch(e) { if(e.name === "SecurityError") { console.log("SecurityError. Cant read: "+ styleSheets[i].href); continue; }} var classes = styleSheets[i].cssRules ; } if('undefined' === typeof CLASSname || null === CLASSname){ cl.push(classes); continue; } for (var x = 0; x < classes.length; x++) { if (classes[x].selectorText === CLASSname) { var ret = (classes[x].cssText) ? classes[x].cssText : classes[x].style.cssText ; if(ret.indexOf(classes[x].selectorText) === -1 && false === raw){ret = classes[x].selectorText + "{" + ret + "}";} return ret; } } } if('undefined' === typeof CLASSname || null === CLASSname){ return cl; } }, isVisible : function(sel) { var el = ('object'===typeof this.g(sel)) ? this.g(sel) : sel; if (el !== null && typeof el !== 'undefined' && $(el).css('visibility') !== 'hidden' && $(el).css('display') !== 'none') { return true; } else { return false; } }, isFramed : function () { try { return window.self !== window.top; } catch (e) { return true; } }, addText: function(txt, dest) { var t=document.createTextNode(txt); dest = this.g(dest); dest.appendChild(t); }, add: function(el, dest, prepend) { el = this.g(el); dest = this.g(dest); if('undefined' !== typeof prepend && true === prepend ){ dest.insertBefore(el, dest.firstChild); }else{ dest.appendChild(el); } }, remove: function(el) { el = this.g(el); if(null === el)return; el.parentNode.removeChild(el); }, create: function(tag) { return document.createElement(tag); }, createFragment: function() { return document.createDocumentFragment(); }, copy: function(element,cloneChildsBool) { if(cloneChildsBool != true && cloneChildsBool != false) { cloneChildsBool = true; } return element.cloneNode(cloneChildsBool); }, insertAtCursor : function(myField, myValue, mod, afterValue) { var field = this.g(myField); if(typeof mod === "undefined")mod="deleteSelected"; if (document.selection) { field.focus(); sel = document.selection.createRange(); sel.text = myValue; }else if(field.selectionStart || field.selectionStart == '0') { var startPos = field.selectionStart; var endPos = field.selectionEnd; if(mod === "deleteSelected") { field.value = field.value.substring(0, startPos) + myValue + field.value.substring(endPos, field.value.length); }else if(mod === "render"){ field.value = field.value.substring(0, startPos) + myValue + field.value.substring(startPos, endPos) + afterValue + field.value.substring(endPos, field.value.length); }else if(mod === "insert"){ field.value = field.value.substring(0, startPos) + myValue + field.value.substring(startPos, endPos) + field.value.substring(endPos, field.value.length); }else{ field.value = field.value.substring(0, startPos) + myValue + field.value.substring(endPos, field.value.length); } } else { field.value += myValue; } }, createCSSClass : function(selector, style) { if (!document.styleSheets) { return; } if (document.getElementsByTagName("head").length === 0) { return; } var styleSheet, i; var mediaType; if (document.styleSheets.length > 0) { for (i = 0; i < document.styleSheets.length; i++) { if ("undefined" === typeof document.styleSheets[i] || document.styleSheets[i].disabled) { continue; } var media = document.styleSheets[i].media; mediaType = typeof media; if (mediaType === "string") { if (media === "" || (media.indexOf("screen") !== -1)) { styleSheet = document.styleSheets[i]; } } else if (mediaType === "object") { if (media.mediaText === "" || (media.mediaText.indexOf("screen") !== -1)) { styleSheet = document.styleSheets[i]; } } if (typeof styleSheet !== "undefined") { break; } } } if (typeof styleSheet === "undefined") { var styleSheetElement = document.createElement("style"); styleSheetElement.type = "text/css"; document.getElementsByTagName("head")[0].appendChild(styleSheetElement); for (i = 0; i < document.styleSheets.length; i++) { if ("undefined" === typeof document.styleSheets[i] || document.styleSheets[i].disabled) { continue; } styleSheet = document.styleSheets[i]; } var media = styleSheet.media; mediaType = typeof media; } if (mediaType === "string") { for (i = 0; i < styleSheet.rules.length; i++) { if (styleSheet.rules[i].selectorText.toLowerCase() === selector.toLowerCase()) { styleSheet.rules[i].style.cssText = style; return; } } styleSheet.addRule(selector, style); } else if (mediaType === "object") { try { for (i = 0; i < styleSheet.cssRules.length; i++) { if (styleSheet.cssRules[i].selectorText.toLowerCase() === selector.toLowerCase()) { styleSheet.cssRules[i].style.cssText = style; return; } } } catch(e) { return; } styleSheet.insertRule(selector + "{" + style + "}", 0); } }, addStylesheetRules : function (rules, merge) { var styleEl = document.createElement('style'), styleSheet; document.head.appendChild(styleEl); styleSheet = styleEl.sheet; for (var i = 0, rl = rules.length; i < rl; i++) { var j = 1, rule = rules[i], selector = rules[i][0], propStr = '', k; if (Object.prototype.toString.call(rule[1][0]) === '[object Array]') { rule = rule[1]; j = 0; } for (var pl = rule.length; j < pl; j++) { var prop = rule[j]; propStr += prop[0] + ':' + prop[1] + (prop[2] ? ' !important' : '') + ';\n'; $(selector).css(prop[0], prop[1] + (prop[2] ? ' !important' : '')); } styleSheet.insertRule(selector + '{' + propStr + '}', styleSheet.cssRules.length); } }, draggable : function(id, id2, save, load){ try{ var wDrag = new DragObject( this.g(id), this.g(id2) ); wDrag.ondrop = function() { if(save === true)wDrag.saveToStore(); return true; }; if(load===true)wDrag.loadFromStore(); }catch(err){ console.log(err); return; } }, tableSwitchScope : function(table){ var els = Dom.getTagNames('*', table), i =0, e; for(i=0;i<els.length;i++){ e = els[i]; if('row' === e.getAttribute('scope')){ e.setAttribute('scope', 'col'); }else if('col' === e.getAttribute('scope')){ e.setAttribute('scope', 'row'); } } }, tableFromArray : function(array, header, footer, scope, _null, flipLink) { if( 'string' === typeof array || 'undefined' === typeof array || 'boolean' === typeof array || null === array || !isNaN(array) ) { if('undefined' === typeof array || null === array)array=_null; return document.createTextNode(array.toString()); } var SCOPE = scope; var norm = function(v){ if('undefined' === typeof v || null === v ) v = _null; return v.toString(); }; var table = Dom.create('table'), _flip = flipLink; if(true === header || true === footer){ var row_head = Dom.create('tr'), row_foot = Dom.create('tr'); var count_head = 0; /* var TopArray = ('array' === typeof array && array.length > 0) ? array[0] : array; var TopArray = array; */ var TopArray = array; $.each(TopArray, function(i,r) { var cell_foot = Dom.create('td'), cell_head = Dom.create('th'), flip = _flip; var txt = (null !== i) ? norm(i) : norm(r); cell_foot.textContent = txt; cell_head.textContent = txt; if(true === flip)cell_head.setAttribute('scope', scope); if(0 === count_head && true === flip){ $(cell_head).prepend('<a href="javascript:;" onclick="try{Dom.tableSwitchScope(this.parentNode);}catch(err){console.error(err);}return false;"><sup>[<u>F</u>]</sup></a>'); } row_head.appendChild(cell_head); row_foot.appendChild(cell_foot); count_head++; }); if(true===header){ var thead = Dom.create('thead'); thead.appendChild(row_head); table.appendChild(thead); } } var tbody = Dom.create('tbody'); $.each(array, function(i,r) { var row = Dom.create('tr'); if('undefined' !== typeof r && null !== r && ('object' === typeof r || 'array' === typeof r)){ $.each(r, function(k,v){ if('undefined' !== typeof v && null !== v && ('object' === typeof v || 'array' === typeof v)){ if(true === _flip && 'string' === typeof k){ var cell_head = Dom.create('th'); cell_head.setAttribute('scope', ('col' === SCOPE) ? 'row' : 'col'); cell_head.textContent = k.toString(); row.appendChild(cell_head); } $.each(v, function(ix,value){ var zelle = Dom.create('td'); var subTable = Dom.tableFromArray(value, header, footer, SCOPE, _null, _flip); zelle.appendChild(subTable); row.appendChild(zelle); }); }else{ var cell = Dom.create('td'); cell.textContent = norm(v); row.appendChild(cell); } }); }else{ var cell = Dom.create('td'); cell.textContent = norm(r); } tbody.appendChild(row); }); table.appendChild(tbody); if(true===footer){ var tfoot = Dom.create('tfoot'); tfoot.appendChild(row_foot); table.appendChild(tfoot); } return table; }, dataToHtmlTable : function(array, header, footer, scope, _null, flipLink){ return Dom.tableFromArray(array, header, footer, scope, _null, flipLink); }, config : { regex : { jsonParse : /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)|("[\w\-^\/]\/[\w\-^\/]")|("[A-Za-z\-.0-9\/^"<>=]+[^"<>=]")|("1.3.6.1.4.1[0-9\.^\/A-Za-z<>=]{0,}")|("[\w\.\-]+@[\w\.\-]+\.[\w\.\-]+")/g, url : /("([A-Za-z]+)(:\/\/)([0-9.\-A-Za-z]+)?([0-9\-A-Za-z]+)([.]{1})([A-Za-z]+)(\/)?([^\\"]+)?")/g }, renderJSON : { defaultRules : function(_){ var kFound = false, THIS = _, regex_package = { name : 'Package', regex : /((")?[\w\-^\/]+\/[\w\-^\/]+(")?)/, type : 'string', style : function(match){ var html = '', m = match; m = str_replace('"', '', m); m = str_replace(':', '', m); var p; if((p = explode('/', m)).length === 2){ html = '<a style="text-decoration:underline;color:blue;cursor:pointer;" title="Package: ' + htmlentities(p[0] + '/' + p[1]) + '" onclick="$(frdl.wd()).package(\'c\', \'' + p[0] + '\', \'' + p[1] + '\');">' +p[0] + '/' + p[1] + '</a>'; }else{ html = m; } return html; } }, regex_any = { name : 'any', regex : /("[A-Za-z\-.0-9^"<>=]+[^"<>=]")/g, type : 'any non html', style : function(match){ var m = str_replace(':', '', str_replace('"', '', match.trim())); var p, html; if((p = explode('/', m)).length === 2){ var title = _T.pTitle(p[0], p[1]); html = '<a style="text-decoration:underline;color:blue;cursor:pointer;" title="Package: ' + htmlentities(title) + '" onclick="$(frdl.wd()).package(\'c\', \'' + p[0] + '\', \'' + p[1] + '\');">' + title + '</a>'; }else{ html = match; } return html; } }; return { def : function(match){ return match; }, defKey : function(match){ return '<span class="webfan-red" style="font-size:1.1em;">' + str_replace('"', '', match.substr(-1 * match.length-2)).ucfirst() + '</span>'; }, types : [ { name : 'True', regex : /true/, type : 'boolean', style : 'color:lightgreen;' }, { name : 'False', regex : /false/, type : 'boolean', style : 'color:lightred;' }, { name : 'Null', regex : /null/, type : 'nil', style : 'color:magenta;' }, { name : 'Number', regex : /-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/, type : 'number', style : 'color:darkorange;' }, { name : 'Unicode', regex : /"(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?/, type : 'string', style : 'color:green;' }, { name : 'OID', regex : /1.3.6.1.4.1[0-9\.^\/A-Za-z<>=]{0,}/, type : 'string', style : function(match){ var OID=str_replace('"', '', match); return '<a href="http://look-up.webfan.de/' + OID + '">' + OID +'</a>'; } }, { name : 'Email', regex : /[\w\.\-]+@[\w\.\-]+\.[\w\.\-]+/, type : 'string', style : function(match){ var mail=str_replace('"', '', match); return '<a href="mailto:' + mail + '">' + mail +'</a>'; } }, regex_package ], keys : [ { name : 'NumKey', regex : /((")?[0-9]{1,}(")?)/, type : 'key', style : function(match){ if(true===kFound)return str_replace('"', '', match); kFound = true; return '' } } ], any : regex_any, punctuation : { name : 'Punctuation', regex : /(([\s])?([\.\[\{]{1})[^"])|([\]]{1}[^"])|([\}]{1}[^"]|[^"][\}]{1})|([\,]{1}[^"]|[^"][\,]{1}|[\,]{1}[\r\n]|[^"][\,]{1}[^"]|"[\,]{1}"|[\,]{1}[\[\{]|[\]\}][\,]{1}|[\r\n][\]]{1})/g, type : 'punctuation', style : function(match){ var comma = '</li><li>', m = str_replace('"', '', match.trim()); var result = null; if(',' === m)result=comma; if('[' === m)result= '<ol style="list-style:list;"><li>' ; if(']' === m)result='</li></ol>'; if('{' === m)result= '<ul style="list-style:list;"><li>' ; if('}' === m)result = '</li></ul>'; if('],' === m)result='</li></ol>' + comma; if('string' === typeof result)return result; return match; } }, spaces : { name : 'Spaces', regex : /([\r\n]{2,})/g, type : 'lnbr', style : function(match){ return "\r\n"; } }, url : { name : 'Url', regex : Dom.config.regex.url, type : 'string', style : function(match){ var om = match, u; om = str_replace('"', '', om); var url = (u = new frdl.Url(om)).urlMakeNew(), maxLength = 16, maxSub = 6; if('' === u.getHost() && '' === u.getPath())return match; var linktext = u.getHost() + (('' !== u.getPath()) ? ('/' + u.getPath()) : ''); linktext = ( linktext.length > maxLength) ? (linktext.substr(0, maxLength) + '...' + linktext.substr((maxSub*-1)) ) : linktext; return '<a href="' + url + '">' + linktext + '</a>'; } } }; } } }, renderJSON : function(json, rr, code, pre, REGEX){ if (typeof json !== 'string') { json = JSON.stringify(json, undefined, '\t'); } var rules = this.config.renderJSON.defaultRules(); if('undefined' !== typeof jQuery){ rules = Object.create(rules, ('object' === typeof rr) ? rr : {}); }else{ for(var k in rr ){ rules[k] = rr[k]; } } var str = json.replace((('undefined' !== typeof REGEX && null !== REGEX) ? REGEX : Dom.config.regex.jsonParse), function (match) { var i = 0, p; if (rules.punctuation.regex.test(match)) { if('string' === typeof rules.punctuation.style){ return '<span style="'+ rules.punctuation.style + '">' + match + '</span>'; }else if('function' === typeof rules.punctuation.style){ return rules.punctuation.style(match); } else{ return match; } } if (/^"/.test(match)) { if (/:$/.test(match)) { for(i=0;i<rules.keys.length;i++){ p = rules.keys[i]; if (p.regex.test(match)) { if('string' === typeof p.style){ return '<span style="'+ p.style + '">' + match + '</span>'; }else if('function' === typeof p.style){ return p.style(match); } else{ return match; } } } return ('function'===typeof rules.defKey) ? rules.defKey(match) : '<span style="'+ rules.defKey + '">' + match + '</span>'; } else { /* return ('function'===typeof rules.def) ? rules.def(match) : '<span style="'+ rules.def + '">' + match + '</span>'; */ return match; } } else { for(i=0;i<rules.types.length;i++){ p = rules.types[i]; if (p.regex.test(match)) { if('string' === typeof p.style){ return '<span style="'+ p.style + '">' + match + '</span>'; }else if('function' === typeof p.style){ return p.style(match); } else{ return match; } } } } }); str = str.replace(rules.punctuation.regex, function (match) { if('function' === typeof rules.punctuation.style){ return rules.punctuation.style(match); }else if('string' === typeof rules.punctuation.style){ return '<span style="'+ rules.punctuation.style + '">' + match + '</span>'; }else{ return match; } }); str = str.replace(rules.url.regex, function (match) { if('function' === typeof rules.url.style){ return rules.url.style(match); }else if('string' === typeof rules.url.style){ return '<span style="'+ rules.url.style + '">' + match + '</span>'; }else{ return match; } }); str = str.replace(rules.any.regex, function (match) { if('function' === typeof rules.any.style){ return rules.any.style(match); }else if('string' === typeof rules.any.style){ return '<span style="'+ rules.any.style + '">' + match + '</span>'; }else{ return match; } }); str = str.replace(rules.spaces.regex, function (match) { if('function' === typeof rules.spaces.style){ return rules.spaces.style(match); }else if('string' === typeof rules.spaces.style){ return '<span style="'+ rules.spaces.style + '">' + match + '</span>'; }else{ return match; } }); if(true === pre)str = '<pre>' + str + '</pre>'; if(true === code)str = '<code>' + str + '</code>'; return str; }, bringToFront : function(selector, dSiblings){ var zmax = 1, d = Dom.getTagNames('*'), i = 0, m = 1, _Siblings = (true === dSiblings) ? true : false; for(i=0;i<d.length;i++){ var e = d[i]; var cur = parseInt(e.style.zIndex); if(isNaN(cur))continue; if(cur > 2 && cur >= zmax - 1)cur--; zmax = cur > zmax ? cur : zmax; e.style.zIndex = cur; } try{ if( 'string' === typeof selector && ('#' === selector.substr(0,1) || '.' === selector.substr(0,1) ) ){ }else if('string' === typeof selector.selector){ selector = selector.selector; }else if( 'string' === typeof selector){ selector = '#' + selector; } $( selector ).css( 'zIndex', ++zmax ); if(true===_Siblings)$(selector).siblings().css( 'zIndex', ++zmax ); }catch(err){ console.warn(err + ' : ' + JSON.stringify(selector)); } } }; var Dom = new DomObject(window.document || window); function wjslGetElementsByClass(className, parent) { console.deprecated('Use of deprecated function wjslGetElementsByClass - use Dom.getByClass instead!'); return Dom.getByClass(className, parent); } /* Moved to prototype var Event = { add: function() { if (window.addEventListener) { return function(el, type, fn) { Dom.get(el).addEventListener(type, fn, false); }; } else if (window.attachEvent) { return function(el, type, fn) { var f = function() { fn.call(Dom.get(el), window.event); }; Dom.get(el).attachEvent('on' + type, f); }; } }() }; */ var wUserData = function() { }; wUserData.prototype = { version : "2.0.0", id : 0, uid : 0, uname : null, name : null, anrede : null, sharedSecret : null, isServer : false, isClient : false, data : { }, enc : { type: 'AES', version : '1', "iv": null,"s":null}, host_sha1_enc : null, data_enc : { }, data_DecryptedCache : null, lang : 'default', theme : 'default', token : null, token_expires : null, tokenc : null, tokenc_expires : null }; var wUser = new wUserData(); var wjslTimer = function() { this.Interval = 1000; this.Enable = new Boolean(false); this.Tick = function() { }; var timerId = 0; var thisObject; this.Start = function() { this.Enable = new Boolean(true); thisObject = this; if (thisObject.Enable) { thisObject.timerId = setInterval( function() { thisObject.Tick(); }, thisObject.Interval); } }; this.Stop = function() { thisObject.Enable = new Boolean(false); clearInterval(thisObject.timerId); }; }; var lokTimer = function(interval) { this.init(interval); }; lokTimer.prototype = { init : function(interval) { var THIS = this; this.t = new wjslTimer(); this.t.Interval = interval; this.t.Tick = function() { THIS.loop(); }; this.f = [ ]; this.iModulo = 0; this.zeit(); }, t : null, f : [], iModulo : 0, tag : null, monat : null, jahr : null, jetzt : null, stunde : null, minute : null, sekunde : null, wochentag : null, datum : null, uhrzeit : null, datum_zeit : null, running : false, setInterval : function(interval) { this.t.Interval = interval; }, add : function( id, func, expires ) { var item = { }; item.id = id; item.func = func; item.expires =("undefined" !== typeof expires) ? expires : undefined; item.started = new Date() / 1000; this.f.push(item); if(true !== this.t.Enable)this.t.Start(); this.f = this.f.filter(function(val){return (val != undefined) ? true : false;}); return this; }, remove : function(id) { var i=0, l = this.f.length; if(0 === l)return this; for(var i = 0; i < (l = this.length()); i++) { if("undefined" !== typeof this.f[i] && this.f[i].id === id) { this.f.splice(i,1); i--; this.f = this.f.filter(function(val){return (val !== undefined && val !== null) ? true : false;}); l = this.f.length; i = 0; } } if(this.f.length < 1)this.t.Stop(); return this; }, is : function(id){ this.f = this.f.filter(function(val){return (val != undefined) ? true : false;}); var i=0, l = this.f.length; if(0 === l)return false; for(i = 0; i < l; i++) { if("undefined" !== typeof this.f[i] && this.f[i].id === id) { return true; } } return false; }, length : function(){ return this.f.length; }, zeit : function(){ var Wochentagname = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"); this.jetzt = new Date(); this.tag = this.jetzt.getDate(); this.monat = this.jetzt.getMonth() + 1; this.jahr = this.jetzt.getYear(); if (this.jahr < 999)this.jahr += 1900; this.stunde = this.jetzt.getHours(); this.minute = this.jetzt.getMinutes(); this.sekunde = this.jetzt.getSeconds(); this.wochentag = this.jetzt.getDay(); var Vortag = (this.tag < 10) ? "0" : ""; var Vormon = (this.monat < 10) ? ".0" : "."; var Vorstd = (this.stunde < 10) ? "0" : ""; var Vormin = (this.minute < 10) ? ":0" : ":"; var Vorsek = (this.sekunde < 10) ? ":0" : ":"; this.datum = Vortag + this.tag + Vormon + this.monat + "." + this.jahr; this.uhrzeit = Vorstd + this.stunde + Vormin + this.minute + Vorsek + this.sekunde; this.datum_zeit = Wochentagname[this.wochentag] + " " + this.datum + " " + this.uhrzeit; return this; }, loop : function() { if(true===this.running)return; this.running=true; var l = this.length(); this.iModulo++; if(this.iModulo > 32767)this.iModulo = 0; if(0=== this.iModulo % 100)this.zeit(); for(var i = 0; i < (l = this.length()); i++) { if("undefined" !== typeof this.f[i] && typeof this.f[i].func === "function") { if("undefined" !== typeof this.f[i] && (("undefined" !== typeof this.f[i].expires && (new Date() / 1000) - this.f[i].started > this.f[i].expires) || true === this.f[i].func(this)) ){ if("undefined" !== typeof this.f[i])this.remove(this.f[i].id); /* continue; */ } } /* l = this.length(); */ } this.running=false; } }; var uhrTimer = new lokTimer(90); var _auth = function(silentAdminPermission){ return false; }; /*! modernizr 3.3.1 (Custom Build) | MIT * * https://modernizr.com/download/?-pointerevents-touchevents-setclasses !*/ !function(e,n,t){function o(e,n){return typeof e===n}function s(){var e,n,t,s,i,a,r;for(var f in d)if(d.hasOwnProperty(f)){if(e=[],n=d[f],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;t<n.options.aliases.length;t++)e.push(n.options.aliases[t].toLowerCase());for(s=o(n.fn,"function")?n.fn():n.fn,i=0;i<e.length;i++)a=e[i],r=a.split("."),1===r.length?Modernizr[r[0]]=s:(!Modernizr[r[0]]||Modernizr[r[0]]instanceof Boolean||(Modernizr[r[0]]=new Boolean(Modernizr[r[0]])),Modernizr[r[0]][r[1]]=s),l.push((s?"":"no-")+r.join("-"))}}function i(e){var n=c.className,t=Modernizr._config.classPrefix||"";if(p&&(n=n.baseVal),Modernizr._config.enableJSClass){var o=new RegExp("(^|\\s)"+t+"no-js(\\s|$)");n=n.replace(o,"$1"+t+"js$2")}Modernizr._config.enableClasses&&(n+=" "+t+e.join(" "+t),p?c.className.baseVal=n:c.className=n)}function a(){return"function"!=typeof n.createElement?n.createElement(arguments[0]):p?n.createElementNS.call(n,"http://www.w3.org/2000/svg",arguments[0]):n.createElement.apply(n,arguments)}function r(){var e=n.body;return e||(e=a(p?"svg":"body"),e.fake=!0),e}function f(e,t,o,s){var i,f,l,d,u="modernizr",p=a("div"),v=r();if(parseInt(o,10))for(;o--;)l=a("div"),l.id=s?s[o]:u+(o+1),p.appendChild(l);return i=a("style"),i.type="text/css",i.id="s"+u,(v.fake?v:p).appendChild(i),v.appendChild(p),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(n.createTextNode(e)),p.id=u,v.fake&&(v.style.background="",v.style.overflow="hidden",d=c.style.overflow,c.style.overflow="hidden",c.appendChild(v)),f=t(p,e),v.fake?(v.parentNode.removeChild(v),c.style.overflow=d,c.offsetHeight):p.parentNode.removeChild(p),!!f}var l=[],d=[],u={_version:"3.3.1",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){d.push({name:e,fn:n,options:t})},addAsyncTest:function(e){d.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=u,Modernizr=new Modernizr;var c=n.documentElement,p="svg"===c.nodeName.toLowerCase(),v=u._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];u._prefixes=v;var h="Moz O ms Webkit",m=u._config.usePrefixes?h.toLowerCase().split(" "):[];u._domPrefixes=m;var g=function(){function e(e,n){var s;return e?(n&&"string"!=typeof n||(n=a(n||"div")),e="on"+e,s=e in n,!s&&o&&(n.setAttribute||(n=a("div")),n.setAttribute(e,""),s="function"==typeof n[e],n[e]!==t&&(n[e]=t),n.removeAttribute(e)),s):!1}var o=!("onblur"in n.documentElement);return e}();u.hasEvent=g,Modernizr.addTest("pointerevents",function(){var e=!1,n=m.length;for(e=Modernizr.hasEvent("pointerdown");n--&&!e;)g(m[n]+"pointerdown")&&(e=!0);return e});var w=u.testStyles=f;Modernizr.addTest("touchevents",function(){var t;if("ontouchstart"in e||e.DocumentTouch&&n instanceof DocumentTouch)t=!0;else{var o=["@media (",v.join("touch-enabled),("),"heartz",")","{#modernizr{top:9px;position:absolute}}"].join("");w(o,function(e){t=9===e.offsetTop})}return t}),s(),i(l),delete u.addTest,delete u.addAsyncTest;for(var y=0;y<Modernizr._q.length;y++)Modernizr._q[y]();e.Modernizr=Modernizr}(window,document); var _BrowserDetect = { init: function () { /* var navigator = navigator || window.navigator; */ this.change = this.change; this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS); this.OS_S = this.OS; console.deprecated('Frdl.Device() is broken and has to be rewritten!'); this.isMobile = navigator.isMobile; this.isTablet = navigator.isTablet; this.isTouchable = (true === Modernizr.pointerevents || true === Modernizr.touchevents) ? true : false; this.isDesktop = (false !== this.isDesktop && false === this.isTouchable && false === this.isMobile && false === this.isTablet) ? true : false; if(true === Modernizr.pointerevents || true === Modernizr.touchevents)this.isDesktop=false; this.isApp = navigator.isApp; this.isWebfanApp = (!!navigator['-webkit-webfan']) ? true : false; frdl.cookie.write('frdl.flow.device-info',JSON.stringify({ isMobile : this.isMobile, isTablet : this.isTablet, isDesktop : this.isDesktop, isTouchable : this.isTouchable }), 91, 0, '/', null); try{ this.mimeTypes = navigator.mimeTypes; this.plugins = navigator.plugins; this.doNotTrack = navigator.doNotTrack; this.oscpu = navigator.oscpu; this.vendor = navigator.vendor; this.vendorSub = navigator.vendorSub; this.productSub = navigator.productSub; this.cookieEnabled = navigator.cookieEnabled; this.buildID = navigator.buildID; this.mediaDevices = navigator.mediaDevices; this.battery = navigator.battery; this.geolocation = navigator.geolocation; this.appCodeName = navigator.appCodeName; this.appName = navigator.appName; this.appVersion = navigator.appVersion; this.platform = navigator.platform; this.userAgent = navigator.userAgent; this.product = navigator.product; this.language = navigator.language; this.languages = navigator.languages; this.onLine = navigator.onLine; }catch(err){ console.warn(err); } var n = "", i, props = this.get(); for(i = 0; i < props.length; i++){ n += props[i].toString(); } return this; }, get : function (){ var p = [], prop; for( prop in this ){ if(typeof prop === "function" || typeof prop === "object")continue; if(prop.substr(0, 4) === "data" )continue; p.push(prop); } return p; }, searchString: function (data) { for (var i=0;i<data.length;i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [ { string: navigator.userAgent, subString: "Webfan", identity: "Webfan" }, { string: navigator.userAgent, subString: "Chrome", identity: "Chrome" }, { string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" }, { string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version" }, { prop: window.opera, identity: "Opera", versionSearch: "Version" }, { string: navigator.vendor, subString: "iCab", identity: "iCab" }, { string: navigator.vendor, subString: "KDE", identity: "Konqueror" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.vendor, subString: "Camino", identity: "Camino" }, { string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla" } ], dataOS : [ { string: navigator.platform, subString: "Win", identity: "Windows" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.userAgent, subString: "iPhone", identity: "iPhone/iPod" }, { string: navigator.userAgent, subString: "android", identity: "Android" }, { string: navigator.platform, subString: "Linux", identity: "Linux" } ] , change : function(prop,val, silentAdminPermission){ if("undefined" === typeof frdl)throw "frdl is not defined"; var _VAL = val, T = this; function change(){ var VAL = _VAL, THIS = T; var fakeGetter = function () { return VAL; }; if (Object.defineProperty) { Object.defineProperty(navigator, prop, { get: fakeGetter }); } else if (Object.prototype.__defineGetter__) { navigator.__defineGetter__(prop, fakeGetter ); } return THIS.init(); } if(true === _auth(silentAdminPermission)){ change(); }else{ frdl.alert.confirm("User permission required:<br />Do you allow the current javascript to change<br />UserAgent."+prop+"<br />to the value<br />"+val, function (e) { if (e) { change(); } else { frdl.alert.error("Canceled"); } }); } } }; frdl.Device = function(client, v){ if (!arguments || 0 === arguments.length){ return _BrowserDetect; }else if('object'===typeof client){ for(var k in client){ _BrowserDetect[k]=client[k]; } }else if ( 'string' === typeof client && 'undefined' === typeof v){ return _BrowserDetect[client]; }else if ( 'string' === typeof client && 'undefined' !== typeof v){ _BrowserDetect[client] = v; } return function(){ return _BrowserDetect; }(); }; window.BrowserDetect = frdl.Device().init(); frdl.Dom = Object.create( Dom,$FRDL.prototype); frdl.Event = Object.create( Event, $FRDL.prototype); frdl.cron = uhrTimer; frdl.getScript = getScript; /* Copied + modified from http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the Thanks! */ (function(InitBaseObj, InitFuncName, InitAddReadyCheckfuncName){ "use strict"; var ThenEvent = function(baseObj, funcName, addReadyCheckfuncName) { "use strict"; /*/ The public function name defaults to window.docReady // but you can pass in your own object and own function name and those will be used // if you want to put them in a different namespace*/ funcName = funcName || "ready"; baseObj = baseObj || window; var readyList = []; var readyFired = false; var readyEventHandlersInstalled = false; var defered = false; var readyQueue = []; /*/ call this when the document is ready // this function protects itself against being called more than once*/ function ready() { var df = false; frdl.each(readyQueue, function(i,v){ if(true !== v()){ defered=true; df=true; return false; }else{ readyQueue[i]=null; readyQueue=frdl.filter(readyQueue, function(v,i){ if(null === v || 'function' !== typeof v)return false; return true; }, false); i--; } }); defered=df; if (false === readyFired && false === defered && document.readyState === "complete") { /*/ this must be set to true before we start calling callbacks */ readyFired = true; /* for (var i = 0; i < readyList.length; i++) { */ while(0 < readyList.length && false === defered && document.readyState === "complete"){ /*/ if a callback here happens to add new ready handlers, // the docReady() function will see that it already fired // and will schedule the callback to run right after // this event loop finishes so all handlers will still execute // in order and no new ones will be added to the readyList // while we are processing the list*/ var Cb = readyList.shift(); var r = Cb.fn.call(window, Cb.ctx); if('boolean'===typeof r){ if(true===r){ readyList.push(Cb); defered=true; /* baseObj[funcName](Cb.fn, Cb.ctx); */ } } } /*/ allow any closures held by these functions to free*/ /* readyList = []; */ }else{ setTimeout(ready, 1); } } /*/ This is the one public interface // docReady(fn, context); // the context argument is optional - if present, it will be passed // as an argument to the callback*/ baseObj[funcName] = function(callback, context) { /*/ if ready has already fired, then just schedule the callback // to fire asynchronously, but right away*/ /* repeatable readyFired=false; */ if (readyFired) { setTimeout(function() {callback(context);}, 1); return; } else { /*/ add the function and context to the list*/ readyList.push({fn: callback, ctx: context}); } /*/ if document already ready to go, schedule the ready function to run*/ if (document.readyState === "complete") { setTimeout(ready, 1); } else if (!readyEventHandlersInstalled) { /*/ otherwise if we don't have event handlers installed, install them*/ /* addEventListener available in IE too because see hack before ! */ document.addEventListener("DOMContentLoaded", ready, false); window.addEventListener("load", ready, false); document.addEventListener("readystatechange", function () { if (document.readyState !== "complete") { if(true===readyFired){ readyFired=false; if(0 < readyList.length || 0 < readyQueue.length){ } } } }, false, true/*allow injection*/); readyEventHandlersInstalled = true; } return baseObj; }; baseObj[addReadyCheckfuncName] = function(fn){ if('function' === typeof fn && 'function'===typeof readyQueue.push){ readyQueue.push(fn); } readyFired=false; return baseObj; }; baseObj.If = function(fn){ return baseObj[addReadyCheckfuncName](fn); }; return baseObj; }; InitBaseObj.addReadyEventListener = function(baseObj, funcName, addReadyCheckfuncName){ return ThenEvent(baseObj, funcName, addReadyCheckfuncName); }; InitBaseObj.addReadyEventListener(InitBaseObj, InitFuncName, InitAddReadyCheckfuncName); }(frdl, "ready", 'addReadyCheck')); /* Enum Type mit Object.freeze(obj) */ /* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols Collections and traversables, iterator and iterable todo */ var Webfan = function() { this.boot(); }; Webfan.prototype = { boot : function() { } }; var webfan = new Webfan(); /* var webfan = frdl.overload(frdl.$(new Webfan())); */ webfan = frdl.overload(webfan); /* var module = exports || window; module.frdl = frdl; module.Dom = Dom; module.webfanURLParser = webfanURLParser; module.wUser = wUser; module.wUserData =wUserData; module.$FRDL = $FRDL; module.lokTimer = lokTimer; module.uhrTimer = uhrTimer; module.getScript = getScript; module.wjslTimer = wjslTimer; module.Webfan = Webfan; module.webfan = webfan; Promise polyfill 2 module.adapter = { resolved: function(a) { return Promise.resolve(a); }, rejected: function(a) { return Promise.reject(a); }, deferred: defer, Promise: Promise }; */ (function() { "use strict"; /* var '?µ??W'; */ frdl.? = function( run, method, Fn, args/*mixed*/){ "use strict"; if('function'!==typeof Fn && 'object' !== typeof Fn)var Fn=Function; if(!Fn.prototype.partial){ Fn.prototype.partial = function(){ var fn = this, args = Array.prototype.slice.call(arguments); return function(){ var arg = 0; for ( var i = 0; i < args.length && arg < arguments.length; i++ ) if ( args[i] === undefined ) args[i] = arguments[arg++]; return fn.apply(this, args); }; }; } if(!Fn.prototype.curry){ Fn.prototype.curry = function () { var method = this, i = 0, len = this.length, args = []; function f() { args.push(arguments[0]); if (++i < len) { return f; } else { method.apply(this, args); } }; return f; }; } var args = Array.prototype.slice.call(arguments); args.shift(); args.shift(); args.shift(); if(run instanceof Fn){ if('p'===method || 'partial' === method) { return run.curry(args); }else if('c'===method || 'c' === method){ return run.partial(args); } } }; }()); /* wtf? modul.f$ = function( ){ "use strict"; }; */ /* testing http://stackoverflow.com/questions/9671995/javascript-custom-event-listener var Observable; (Observable = function() { }).prototype #http://stackoverflow.com/a/9672223 var obs = new Observable(); obs.plugFlow("myEvent", function(observable, eventType, data){ //handle myEvent }); obs.plugFlow("myEvent", listener.handler, listener); obs.plugFlow("myEvent", listener.handler, listener, context); Where listener is an instance of an object, which implements the method "handler". The Observable object can now call its fireEvent method whenever something happens that it wants to communicate to its listeners: this.hookFlow("myEvent", data); this.hookFlow("myEvent", data, context); */ var Flow = function() { }; Flow.prototype = { plugFlow: function(type, method, scope, context) { var listeners, handlers; if (!(listeners = this.listeners)) { listeners = this.listeners = {}; } if (!(handlers = listeners[type])){ handlers = listeners[type] = []; } scope = (scope ? scope : this); handlers.push({ method: method, scope: scope, context: (context ? context : scope) }); return scope; }, $$on : function(type, method, scope, context) { return this.plugFlow(type, method, scope, context); }, hookFlow: function(type, data, context) { var listeners, handlers, i, n, handler, scope; if (!(listeners = this.listeners)) { return; } if (!(handlers = listeners[type])){ return; } for (i = 0, n = handlers.length; i < n; i++){ handler = handlers[i]; if (typeof(context)!=="undefined" && context !== handler.context) continue; if (handler.method.call( handler.scope, this, type, data )===false) { return false; } } return true; }, $$trigger : function(type, data, context){ return this.hookFlow(type, data, context); }, $$run : function(type, data, context){ return this.hookFlow(type, data, context); } }; var $scope = {}; frdl.$s = function(s){ if('undefined'!==typeof s){ for(var k in s){ $scope[k]=s[k]; } } return $scope; }; /** * frdl.$ Observable */ frdl.$ = function(Observable){ if('object'!==typeof Observable || null===Observable){ if('string'===typeof Observable){ var o=document.querySelectorAll(Observable); }else if('undefined'===typeof Observable || null===Observable){ var o={}; }else{ var o=$(Observable); } } else{ var o = Observable; } var f = new Flow(); for(var k in f){ o[k]=f[k]; } return o; }; /* shortcuts */ frdl.ready(function(){ frdl.a = window.angular; }); frdl.$q = function(q, all, context){ if('undefined'===typeof context)var context=document; var m = ((false===all)?'querySelector':'querySelectorAll'); return context[m](q); }; frdl.$j = function(selector){ return new DomObject(selector); }; /* JSONP callbacks */ frdl.cbs ={}; /** * http://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically-from-javascript * * Get the keys of the paramaters of a function. * * @param {function} method Function to get parameter keys for * @return {array} */ /* function( a, b = 1, c ){}; => [ 'a', 'b' ] */ var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; var ARGUMENT_NAMES = /(?:^|,)\s*([^\s,=]+)/g; var getFunctionParameters = function( func, wrapStart, wrapEnd ) { var fnStr = func.toString().replace(STRIP_COMMENTS, ''); var argsList = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')); var result = argsList.match( ARGUMENT_NAMES ); if(result === null) { return []; } else { var stripped = []; for ( var i = 0; i < result.length; i++ ) { stripped.push( (('string'===typeof wrapStart)?wrapStart:'') + result[i].replace(/[\s,]/g, '') + (('string'===typeof wrapEnd)?wrapEnd:'')); } return stripped; } }; /* inject .angularAble shortcut */ /* angular.injector(['ng']).invoke(['$q', function($q) { $q.when('hello world').then(function(message) { window.alert(message); }); }]); frdl.$i(function(injectedArguments){ injectedArguments.process... }); invokes ...> frdl.a.injector(['ng']).invoke(injectedArguments,function(injectedArguments){ injectedArguments.process... }); (function(){ try{ frdl.$i( function( $q) { $q.when('hello world').then(function(message) { window.alert(message); }); }); }catch(err){ console.error(err); } }()); */ frdl.$i = function(fn){ frdl.whenEver(function(){return 'undefined' !== typeof angular;}, function(fn){ if('function'!==typeof fn){ frdl.Throw('framework', 'First argument of frdl.$i method must be a function!'); return undefined; } var s = getFunctionParameters(fn, null, null); s.push(fn); if(frdl.debug.mode() >2 )console.log('Invoke: ' +s); try{ angular.injector(['ng']).invoke(s); }catch(err){ console.error(err); } }, fn, 1); }; frdl.Event = Event; frdl.EventTarget = EventTarget; frdl.EventEmitter = EventEmitter; frdl.addReadyCheck(function(){ return ('undefined' !== typeof new frdl.EventEmitter().required) ? true : false; }); frdl.noConflict = function() { return frdl; }; webfan.noConflict = function() { return webfan; }; window.frdl = frdl; window.webfan = webfan;