Core
OpenForum Javascript {{version}}
Latest build {{buildDate}}
- Lines of code {{lines}}
- Size {{size}} KB
DependencyService
if(typeof OpenForum == "undefined") OpenForum = {}; var DependencyService = new function() { //All sets of dependencies var dependencies =



















OpenForum
var OpenForum = new function(){ this.FIELD_DELIMETER_START = "{"+"{"; this.FIELD_DELIMETER_END = "}"+"}"; this.pageVersion = "build-" + new Date(document.lastModified).getTime(); var self = this; var objects=










./g,"_dot_"); if(objectsid===undefined) { objectsid = new OpenForumObject(id); } return objectsid; }; self.removeObject = function(id) { if(objectsid!=undefined) { delete objectsid; } }; self.persistObject = function(id) { persistentObjectIds.push(id); }; self.storePersistentState = function( key ) { if( typeof key == "undefined" ) { key = window.location.pathname; } if( persistentObjectIds.length==0 ) return; var json = {}; for( var i in persistentObjectIds) { var object = OpenForum.getObject( persistentObjectIdsi ); if( isUndefined(object) ) continue; try{ //Test can be stringified JSON.stringify( object.getValue() ); json = object.getValue(); } catch(e) {} } OpenForum.Storage.set( key + ".persist", JSON.stringify(json) ); }; self.restorePersistentState = function( key ) { if( typeof key == "undefined" ) { key = window.location.pathname; } var data = OpenForum.Storage.get( key + ".persist" ); if(data!=null) { try{ var json = JSON.parse( data ); for(var j in json) { //OpenForum.getObject(j).setValue( jsonj ); try{ OpenForum.evaluate( j + "=" + JSON.stringify( jsonj ) ); } catch(e) { console.log(e); } } } catch(e) { console.log(e); } } }; self.addListener = function(id,listener) { self.getObject(id).addListener(listener); }; self.removeListener = function(id,listener) { self.getObject(id).removeListener(listener); }; self.scan = function(firstTime) { for(var tableIndex in tables) { tablestableIndex.refresh(); } self.hash = window.location.hash; self._onHash(self.hash); for(var objectIndex in objects) { object = objects; if(typeof(object)=="undefined") { } else { object.scan(); } } for(var scanner in scanners) { try{ scannersscanner(); } catch(e) { console.log(e); } } if(document.body && document.body!=null && firstTime==true) { self.preparePage(document.body); } }; self.addNodeProcessor( function(node) { if(node.attributes==undefined) return; for(var a=0; a



"
";"); object.setValue(""); } else { object.setValue( OpenForum.evaluate(object.getId()) ); } } }; self.createParents = function(id) { if(id.indexOf(".")==-1) { return; } var parts = id.split("."); id = ""; for(var index=0;index

"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/g,".").replace(/
does not exist. Click to create it.">/g,".").replace(/
/g,"").replace(/'/g,"").replace(/
(.*
)/g,""); var parts = name.split("."); var obj = window; for(var part in parts) { if( typeof obj






"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/g,".").replace(/
does not exist. Click to create it.">/g,".").replace(/
/g,"").replace(/'/g,"").replace(/
(.*
)/g,""); var parts = name.split("."); var obj = window; for(var part in parts) obj = obj



"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/g,".").replace(/
does not exist. Click to create it.">/g,".").replace(/
/g,"").replace(/'/g,""); var parts = name.split("."); var obj = window; var i=0; for(i=0; i













/g,"/"); fileName = fileName.substring(fileName.lastIndexOf("/")+1); var result = OpenForum.loadFile("/OpenForum/Actions/AttachmentExists?pageName="+pageName+"&fileName="+fileName); if(result==="true" && confirm("Attachment "+fileName+" exists","Replace this attachment ?")===false ) { return; } var formData = new FormData(document.getElementById( id )); var xhr = new XMLHttpRequest(); if(callBack) { xhr.onload = function() { callBack(); }; } if(errorCallBack) { xhr.onerror = function() { errorCallBack(); }; } if(progressCallback) { xhr.onprogress = function(event) { progressCallback( event.loaded, event.total ); }; } xhr.open('POST', "/OpenForum/Actions/Attach?page="+pageName, true); xhr.send(formData); }; //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// //
JSON
if( typeof(JSON)=="undefined" ) { JSON = {}; } JSON.get = function( page,action,parameters ) { var request = {method: 'GET',page: page,action: action,parameters: parameters, onSuccess: JSON.onSuccess, onError: JSON.onError, go: JSON.go}; return request; }; JSON.post = function( page,action,parameters ) { var request = {method: 'POST',page: page,action: action,parameters: parameters, onSuccess: JSON.onSuccess, onError: JSON.onError, go: JSON.go}; return request; }; JSON.onSuccess = function(onSuccess) { this.onSuccess = function(data) { //var object = JSON.parse(data); var object = OpenForum.evaluate("("+data+")"); onSuccess(object); }; return this; }; JSON.onError = function(onError) { this.onError = function(error) { onError(error); }; return this; }; JSON.go = function() { var request = null; if(this.action && this.action !== null && this.action !== "") request = "action="+this.action; if(this.method=="GET") { if(this.parameters && this.parameters.length>0) { request+="&"+this.parameters; } OpenForum.debug("INFO","JSON.get page:" + this.page + " request:" + request); Ajax.sendRequest( new AjaxRequest(this.method,this.page,request,"",this.onSuccess,this.onError,true) ); } else { if(this.parameters.length<200) { OpenForum.debug("INFO","JSON.post page:" + this.page + " request:" + request + " parameters:" + this.parameters); } else { OpenForum.debug("INFO","JSON.post page:" + this.page + " request:" + request + " parameters:"+this.parameters.substring(0,200)+"... p;arameters size:" + this.parameters.length); } Ajax.sendRequest( new AjaxRequest(this.method,this.page,request,this.parameters,this.onSuccess,this.onError,true) ); } }; JSON.findPath = function( json, path ) { var currentNode = json; path = path.split("."); for( var p in path ) { var found = false; var name = pathp; for(var n in currentNode) { if( n == name ) { found = true; currentNode = currentNodename; break; } } if( found == false ) return;OpenForum.includeScript("/OpenForum/Editor/Editors/StandaloneEditor.js"); } return currentNode; }; JSON.createPath = function( json, path ) { var currentNode = json; path = path.split("."); for( var p in path ) { var found = false; var name = pathp; for(var n in currentNode) { if( n == name ) { found = true; currentNode = currentNodename; break; } } if( found == false ) { currentNodename = {}; currentNode = currentNodename; } } return currentNode; }; JSON.webStringify = function( json ) { return JSON.stringify( json , null , " " ).replaceAll("
n","
").replaceAll(" "," "); }; //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// //
AjaxRequest
requestCount = 0; function AjaxRequest(method,url,request,data,onSuccess,onError,asynchronous) { var self=this; self.id = "request_"+requestCount; requestCount++; eval( self.id+"=this;" ); self.method = method; self.url = url; self.request = request; self.data = data; self.onSuccess = onSuccess; self.onError = onError; self.asynchronous = asynchronous; self.transaction = null; this.processTransactionStateChange = function processTransactionStateChange(ev) { if (self.transaction.readyState == 4) { if (self.transaction.status == 200) { onSuccess(self.transaction.responseText); } else if (self.transaction.status === 0) { } else { onError( self.transaction.status,self.transaction.statusText ); } eval( self.id+"=null;" ); } }; } //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// //
Ajax
Ajax = new function() { this.sendRequest = function sendRequest(request) { request.transaction = false; if(window.XMLHttpRequest) { try { request.transaction = new XMLHttpRequest(); } catch(e) { alert(e); request.transaction = false; } } else if(window.ActiveXObject) { try { request.transaction = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { alert(e); try { request.transaction = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert(e); request.transaction = false; } } } if(request.transaction) { if(request.asynchronous === true) { var fn = eval(request.id+".processTransactionStateChange"); request.transaction.onreadystatechange= function(ev){ fn(ev); }; if(request.request!==null && request.request.length>0) { request.transaction.open(request.method, request.url+"?"+request.request,true); request.transaction.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); //request.transaction.setRequestHeader("If-Modified-Since", new Date(0)); request.transaction.send(request.data); } else { request.transaction.open(request.method, request.url,true); request.transaction.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); //request.transaction.setRequestHeader("If-Modified-Since", new Date(0)); request.transaction.send(request.data); } } else { if(request.request!==null && request.request.length>0) { request.transaction.open(request.method, request.url+"?"+request.request,false); request.transaction.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } else { request.transaction.open(request.method, request.url,false); request.transaction.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } //request.transaction.setRequestHeader("If-Modified-Since", new Date(0)); request.transaction.send(request.data); this.currentRequest=null; return request.transaction.responseText; } } else { alert("failed"); } }; }; //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// //
Post
function Post() { this.data =


Tree
var NextTreeNodeIndex = 0; var TreeNodes =




" title=
""+ attributes.toolTip +"
" target=
"_pageView
">"; } else { data += """ + attributes.link + "
" target=
"_pageView
">"; } if(attributes.icon) { data += ""; } data += name; data += ""; } else { if(attributes && attributes.icon) { data += ""; } data += name; } if(attributes && attributes.actions) { for(var actionIndex in attributes.actions) { var actionConfig = attributes.actionsactionIndex; var action = new Action(actionConfig); data+=action.render("TreeNodes""target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/OpenForum/Javascript/Core/
""+id+"
" does not exist. Click to create it.">
""+id+"
""); } } data+="
"; if(expanded===true) { for(var childIndex in children) { data+=childrenchildIndex.render(depth+1); } } data+="
."+fileExtension).onSuccess( function(result) { tree.setJSON(result); tree.render(); tree.getRoot().expand(); tree.init(); } ).go(); } return tree; }; //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// //Global extra methods function typeOf( thing ) { return Object.prototype.toString.call( thing ).slice(8, -1).toLowerCase(); } function isArray( thing ) { return typeOf( thing ) == "array"; } function isObject( thing ) { return typeOf( thing ) == "object"; } function isFunction( thing ) { return typeOf( thing ) == "function"; } function isUndefined( thing ) { return typeOf( thing ) == "undefined"; } function isString( thing ) { return typeOf( thing ) == "string"; } function isNumber( thing ) { return typeOf( thing ) == "number"; } function isFloat( thing ) { return thing === +thing && thing !== (thing|0); } function isInteger( thing ) { return thing === +thing && thing === (thing|0); } function isNullOrBlank( thing ) { return ( isUndefined(thing) || thing == null || ( isString( thing ) && thing.trim().length == 0) ); } //
Math extra methods
Math.degToRad = function( deg ) { return (deg * Math.PI)/180; }; Math.radToDeg = function( rad ) { return (rad * 180)/Math.PI; }; //
String extra methods
String.prototype.contains = function(start) { return (this.indexOf(start)!==-1); }; String.prototype.startsWith = function(start) { return (this.indexOf(start)===0); }; String.prototype.endsWith = function(start) { if(!this.contains(start)) return false; return (this.indexOf(start)===this.length-start.length); }; String.prototype.between = function(start,end) { if(!this.contains(start) || !this.contains(end)) return; return this.substring(this.indexOf(start)+start.length,this.indexOf(end)); }; String.prototype.before = function (end) { if(!this.contains(end)) return; return this.substring(0,this.indexOf(end)); }; String.prototype.beforeLast = function (end) { if(!this.contains(end)) return; return this.substring(0,this.lastIndexOf(end)); }; String.prototype.after = function (start) { if(!this.contains(start)) return; return this.substring(this.indexOf(start)+start.length); }; String.prototype.afterLast = function (start) { if(!this.contains(start)) return; return this.substring(this.lastIndexOf(start)+start.length); }; String.prototype.replaceAll = function(find,replace) { return this.replace( new RegExp(find,"g"), replace); }; String.prototype.padBefore = function(padding,targetLength) { var result = this; while(result.length
hours * 3600) + (minutes * 60) + seconds)*1000; }; self.plusSeconds = function( newSeconds ) { seconds += parseInt(newSeconds); minutes += Math.floor(seconds/60); seconds = seconds % 60; hours += Math.floor(minutes/60); minutes = minutes % 60; }; self.getHours = function() { return hours; }; self.getMinutes = function() { return minutes; }; self.getSeconds = function() { return seconds; }; self.setHours = function(newHours) { hours=newHours; }; self.setMinutes = function(newMinutes) { minutes=newMinutes; }; self.setSeconds = function(newSeconds) { seconds=newSeconds; }; self.plusMinutes = function( newMinutes ) { minutes += parseInt(newMinutes); hours += Math.floor(minutes/60); minutes = minutes % 60; }; self.plusHours = function( newHours ) { hours += parseInt(newHours); }; self.isAtOrAfter = function(time) { if( self.getTime() >= time.getTime() ) return true; else return false; }; self.isAfter = function(time) { if( self.getTime() > time.getTime() ) return true; else return false; }; self.isAtOrBefore = function(time) { if( self.getTime() <= time.getTime() ) return true; else return false; }; self.isBefore = function(time) { if( self.getTime() < time.getTime() ) return true; else return false; }; self.toString = function() { return ("" + hours).padBefore("0",2) + ":" + ("" + minutes).padBefore("0",2) + ":" + ("" + seconds).padBefore("0",2); }; self.toShortString = function() { return ("" + hours).padBefore("0",2) + ":" + ("" + minutes).padBefore("0",2); }; }; //
Async processing helper function Process() { var callFn; var waitTest; var thenFn; var self = this; self.call = function(newCallFn) { callFn = newCallFn; return self; }; self.waitFor = function(newWaitTest) { waitTest = newWaitTest; return self; }; self.then = function(newThenFn) { thenFn = newThenFn; return self; }; var wait = function() { if(waitTest()===false) { setTimeout(wait,100); } else { if(thenFn) thenFn(); } }; self.run = function(data) { if(callFn) callFn(data); wait(); }; } //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// //
OpenForumObject
function OpenForumObject(objectId) { var self = this; var id = objectId; var value = null; var targets=



OpenForumTable
function OpenForumTable(node) { var self = this; var rowNode = node; var tableNode = node.parentNode; var value; var id; if(tableNode.attributes && tableNode.attributes'of-id') { id=tableNode.attributes'of-id'.value; } else if(tableNode.id) { id=tableNode.id; } else { id="OFTable"+OpenForum.getNextId(); } node.parentNode.removeChild(node); var temp = document.createElement("table"); temp.appendChild(node); var rowHTML = temp.innerHTML; var repeatFor = node.attributes'of-repeatFor'.value; var target = repeatFor.substring(repeatFor.indexOf(" in ")+4); var element = repeatFor.substring(0,repeatFor.indexOf(" in ")); var targetObject = OpenForum.getObject(target); var targetObjectSignature = OpenForum.createObjectSignature( targetObject.getValue() ); if(id.indexOf("OFTable")===0) id += "_" + repeatFor.replaceAll(" ","_"); OpenForum.debug("INFO","Added OpenForum table " + repeatFor + " as " + id); var tableTop = tableNode.innerHTML; tableNode.id = id; self.setTableNode = function(newTableNode) { tableNode = newTableNode; }; self.reset = function() { targetObjectSignature = null; value = null; }; self.updateQuietly = function() { targetObjectSignature = OpenForum.createObjectSignature( targetObject.getValue() ); }; self.refresh = function() { try { if(tableNode.attributes && tableNode.attributes'of-id' && typeof tableNode.value != "undefined" ) { //Not sure what the empty string was there for, but it stops select working //if( this.tableNode.value!=this.value && this.value!="") { if( tableNode.value!=value) { value = tableNode.value; OpenForum.setGlobal(tableNode.id,value); OpenForum.debug("INFO","Table " + id + " value changed to " + value); } else { var newValue = OpenForum.getGlobal(tableNode.id); if( typeof tableNode.value !== "undefined" && tableNode.value!=newValue && typeof newValue !== "undefined" && newValue !== null ) { tableNode.value=newValue; value = newValue; if(tableNode.value === newValue) { OpenForum.debug("INFO","Table " + id + " value changed to " + value); } } } } } catch(e) { OpenForum.debug("ERROR","Table " + id + " set value failed.", e); } //check if changed var objectSignature = OpenForum.createObjectSignature( targetObject.getValue() ); if(objectSignature==targetObjectSignature) { return; } var errors = false; var tableData = tableTop; var collection = targetObject.getValue(); for( var elementIndex in collection ) { try { var item = {}; itemelement= collectionelementIndex; itemelement.index = elementIndex; var data = ""+rowHTML; while(data.indexOf(OpenForum.FIELD_DELIMETER_START)!=-1) { var name = data.substring(data.indexOf(OpenForum.FIELD_DELIMETER_START)+2,data.indexOf(OpenForum.FIELD_DELIMETER_END)); var rowValue; if(name.indexOf(".")===-1) { if(name==element) { rowValue = itemelement; } else { rowValue = OpenForum.getGlobal(name); } } else { var parts = name.split("."); rowValue = item; for(var part in parts) { if(partspart.indexOf("(")!==-1) { var fn = partspart.substring(0,partspart.indexOf("(")); var call = partspart.substring(partspart.indexOf("("),partspart.indexOf(")")).split(","); rowValue = rowValuefn.apply( this,call ); } else if(partspart.indexOf("=")!==-1) { var pName = partspart.substring(0,partspart.indexOf("=")); var value = partspart.substring(partspart.indexOf("=")+1).split("?"); if( rowValuepName == value0 ) { rowValue = value1; } else { rowValue = ""; } }else { rowValue = rowValue



"")==dataStart.length-7) { data = dataStart.substring(0,dataStart.indexOf("of-if=
""))+ rowValue+ dataEnd.substring(1); } else { data = dataStart + rowValue + dataEnd; } if( tableNode.type=="select-one") { if(OpenForum.getGlobal(id) === rowValue ) { data = data.replace("selected=
"
"","selected"); OpenForum.debug("INFO","Table " + id + " selected = " + rowValue); } else { data = data.replace("selected=
"
"",""); } } } tableData += data; } catch(e) { OpenForum.debug("ERROR","Table " + id + " refresh failed.", e); //Fail quietly errors = true; } } OpenForum.debug("INFO","Table " + id + " updated."); tableNode.innerHTML=tableData; //Only update the signature once the data is in the view without errors if(errors==false) { targetObjectSignature=objectSignature; } }; self.getId = function() { return id; }; } //==============================================================================================================// //==============================================================================================================// //==============================================================================================================// if(!OpenForum) { OpenForum = {}; } OpenForum.Browser={}; OpenForum.Browser.download = function(fileName,data){ var hiddenElement = document.createElement('a'); hiddenElement.href = 'data:attachment/text,' + encodeURIComponent(data); hiddenElement.target = '_blank'; hiddenElement.style.display = "none"; hiddenElement.download = fileName; document.body.appendChild(hiddenElement); hiddenElement.click(); }; OpenForum.Browser.upload = function(callback,onError) { var hiddenElement = document.createElement('input'); hiddenElement.type = "file"; hiddenElement.style.display = "none"; hiddenElement.onchange = function(event) { var reader = new FileReader(); reader.onload = function(event) { if(event.target.readyState != 2) return; if(event.target.error) { if(onError) { onError('Error while reading file'); } else { alert('Error while reading file'); } return; } callback( event.target.result ); }; reader.readAsText(event.target.files0); }; document.body.appendChild(hiddenElement); hiddenElement.click(); }; OpenForum.Browser.uploadDataUrl = function(callback,onError) { var hiddenElement = document.createElement('input'); hiddenElement.type = "file"; hiddenElement.style.display = "none"; hiddenElement.onchange = function(event) { var reader = new FileReader(); reader.onload = function(event) { if(event.target.readyState != 2) return; if(event.target.error) { if(onError) { onError('Error while reading file'); } else { alert('Error while reading file'); } return; } callback( event.target.result ); }; reader.readAsDataURL(event.target.files0); }; document.body.appendChild(hiddenElement); hiddenElement.click(); }; OpenForum.Browser.overrideSave = function(fn) { $(document).bind('keydown', function(e) { if(e.ctrlKey && (e.which == 83)) { e.preventDefault(); fn(); return false; } }); }; OpenForum.Browser.enableBrowserStorage = function() { OpenForum.getBrowserFileTree = function() { var data = OpenForum.Storage.get("browserFS"); if(data == null) { data = "{}"; } return JSON.parse( data ); }; OpenForum.findBrowserFileTreeNode = function( fileName, nodeData ) { var path = fileName.replaceAll( "
.","-dot-" ).replaceAll( "/","." ); var json = OpenForum.getBrowserFileTree(); var node = JSON.findPath( json , path ); if( isUndefined( node ) ) { node = JSON.createPath( json , path ); OpenForum.Storage.set( "browserFS", JSON.stringify( json ) ); } if( !isUndefined( nodeData ) ){ for( var n in nodeData ) { noden = nodeDatan; } OpenForum.Storage.set( "browserFS", JSON.stringify( json ) ); } return node; }; OpenForum.remoteSave = OpenForum.saveFile; OpenForum.saveFile = function(fileName,data,callBack) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); OpenForum.Storage.set(fileName,data); var simpleFileName = fileName.substring( fileName.lastIndexOf("/")+1 ); var extension = simpleFileName.substring( simpleFileName.lastIndexOf(".")+1 ); OpenForum.findBrowserFileTreeNode( fileName, { type: "file", size: data.length, created: new Date().getTime(), updated: new Date().getTime(), fileName: simpleFileName, extension: extension } ); if(callBack) { callBack( {"result":"ok","message":"Saved " + fileName,"saved":true} ); } } else { return OpenForum.remoteSave(fileName,data,callBack); } }; OpenForum.remoteDelete = OpenForum.deleteFile; OpenForum.deleteFile = function(pageName,fileName,callBack) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); OpenForum.findBrowserFileTreeNode( fileName, { deleted: true } ); if(callBack) { callBack( {"result":"ok","message":"Deleted " + fileName,"deleted":true} ); } } else { return OpenForum.remoteDelete(pageName,fileName,callBack); } }; OpenForum.remoteLoad = OpenForum.loadFile; OpenForum.loadFile = function(fileName,callBack,noCache) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); var data = OpenForum.Storage.get(fileName); if(callBack) { callBack( data ); } return data; } else { return OpenForum.remoteLoad(fileName,callBack,noCache); } }; OpenForum.remoteAppend = OpenForum.appendFile; OpenForum.appendFile = function(fileName,data,callBack) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); var currentData = OpenForum.Storage.get(fileName); if( currentData == null ) { return OpenForum.saveFile(fileName,data,callBack); } data = currentData + data; OpenForum.Storage.set(fileName,data); OpenForum.findBrowserFileTreeNode( fileName, { modified: new Date().getTime(), size: data.length } ); if(callBack) { callBack( {"result":"ok","message":"Appended " + fileName,"appended":true} ); } } else { return OpenForum.remoteAppend(fileName,data,callBack); } }; OpenForum.remoteCopy = OpenForum.copyFile; OpenForum.copyFile = function(fileName,toFileName,callBack) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); var data = OpenForum.Storage.get(fileName); OpenForum.saveFile(toFileName,data); if(callBack) { callBack( {"result":"ok","message":"Copied " + fileName,"copied":true} ); } } else { return OpenForum.remoteCopy(fileName,toFileName,callBack); } }; OpenForum.remoteMove = OpenForum.moveFile; OpenForum.moveFile = function(fileName,toFileName,callBack) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); var data = OpenForum.Storage.get(fileName); OpenForum.saveFile(toFileName,data); OpenForum.deleteFile(fileName); if(callBack) { callBack( {"result":"ok","message":"Moved " + fileName,"moved":true} ); } } else { return OpenForum.remoteMove(fileName,toFileName,callBack); } }; OpenForum.remoteFileExists = OpenForum.fileExists; OpenForum.fileExists = function(fileName) { if(fileName.startsWith("browser://")) { fileName = fileName.replace("browser:/","browserFS "); return OpenForum.Storage.get(fileName) != null; } else { return OpenForum.remoteFileExists(fileName); } }; OpenForum.remoteGetAttachments = OpenForum.getAttachments; OpenForum.getAttachments = function(pageName,callBack,matching,withMetaData) { if(pageName.startsWith("browser://")) { pageName = pageName.replace("browser:/","browserFS "); //TODO if(callBack) { callBack( {"result":"ok","message":"Saved " + fileName,"saved":true} ); } } else { return OpenForum.remoteGetAttachments(pageName,callBack,matching,withMetaData); } }; OpenForum.remoteCreateFileTree = OpenForum.createFileTree; OpenForum.createFileTree = function(id,root,fileExtension,modifier) { if(root.startsWith("browser://")) { var tree = new Tree(id,"Loading...","",modifier); var fsJson = OpenForum.findBrowserFileTreeNode( root.replace("browser:/","browserFS ") ); //Copy //https://open-forum.onestonesoup.org/OpenForum/Javascript/Tree?action=getPageTree&pageName=/TheLab/Experiments/BrowserFileStorage var toFileTree = function( name, json, path ) { if( isUndefined( path ) ) { path = ""; } var newNode = {}; newNode.name = name; newNode.attributes = { type: "page", pageName: path, link: path, icon: "book", toolTip: "Open page" }; newNode.leaves =

." + fileExtension ) ) { continue; } var jsonNode = {}; jsonNode.name = node.fileName; jsonNode.leaves =






" alt="").replace(/

" title="").replace(/

"/>]/g,"
]"); var regexS = "
?&"+name+"=(^*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results === null ) return ""; else return results1; }; OpenForum.getCookie = function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = cai; while (c.charAt(0)==' ') { c = c.substring(1,c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length,c.length); } } return null; }; //Keep all the evil in one place OpenForum.evaluate = function(script) { try{ return eval(script); } catch (e) { OpenForum.debug( "ERROR", "Exception evaluating '" + script + "'",e ); throw e; } }; OpenForum.globalExists = function( name ) { name = name.replace(/
"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/g,".").replace(/
does not exist. Click to create it.">/g,".").replace(/
/g,"").replace(/'/g,"").replace(/
(.*
)/g,""); var parts = name.split("."); var obj = window; for(var part in parts) { if( typeof obj






"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/g,".").replace(/
does not exist. Click to create it.">/g,".").replace(/
/g,"").replace(/'/g,"").replace(/
(.*
)/g,""); var parts = name.split("."); var obj = window; for(var part in parts) obj = obj



"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/g,".").replace(/
does not exist. Click to create it.">/g,".").replace(/
/g,"").replace(/'/g,""); var parts = name.split("."); var obj = window; var i=0; for(i=0; i














t"; var csv = ""; if(Array.isArray(json)) { for(var i in json) { var row = jsoni; //add column name row if(csv.length===0) { for (var c in row) { if(csv.length>0) { csv+=delimiter; } csv += c; } csv += "
n"; } //add row var csvRow = ""; for (var r in row) { if(csvRow.length>0) { csvRow+=delimiter; } csvRow += rowr; } csv += csvRow +"
n"; } } else if(typeof json === "object") { for(var name in json) { csv += name + delimiter + jsonname + "
n"; } } return csv; }; OpenForum.Table.closeTable = function(table) { for(var i in table) { tablei.view = "display: block;"; tablei.edit = "display: none;"; } }; OpenForum.Table.addRow = function(table,templateRow,clean) { if(!templateRow) { templateRow = tabletable.length-1; } if(!templateRow.view) { templateRow.view = "display: block;"; templateRow.edit = "display: none;"; } var newRow = OpenForum.clone( templateRow ); if(clean) { OpenForum.clean( newRow ); } table.push( newRow ); OpenForum.Table.editRow(table,table.length-1); }; OpenForum.Table.removeRow = function(table,index) { return table.splice(index,1)0; }; OpenForum.Table.moveRowUp = function(table,index) { if(index<=0) return; var row = table.splice(index,1)0; table.splice(index-1,0,row); }; OpenForum.Table.moveRowDown = function(table,index) { if(index>=table.length-1) return; var row = table.splice(index,1)0; table.splice(index+1,0,row); }; OpenForum.Table.applyRowFilter = function(tableName,tableData,fieldName,fieldFilter) { var table = document.getElementById(tableName); var filters =




" + n.replaceAll("_"," ") + " | "; } html += "
" + cell + " | "; } html += "


























Child Pages
Build Script
Script elements
- /OpenForum/Javascript/Core/open-forum-storage.js
- /OpenForum/Javascript/Core/open-forum-ajax.js
- /OpenForum/Javascript/Core/open-forum-ofx.js
- /OpenForum/Javascript/Core/open-forum-scanner.js
- /OpenForum/Javascript/Core/open-forum-table.js
- /OpenForum/Javascript/Core/data.json
- /OpenForum/Javascript/Core/open-forum-client.js
- /OpenForum/Javascript/Core/open-forum-backup.js
- /OpenForum/Javascript/Core/page.js
- /OpenForum/Javascript/Core/open-forum-dependency.js
- /OpenForum/Javascript/Core/open-forum-utils.js
- /OpenForum/Javascript/Core/open-forum-ajax-request.js
- /OpenForum/Javascript/Core/open-forum.help.js
- /OpenForum/Javascript/Core/script.build.json
- /OpenForum/Javascript/Core/open-forum-files.js
- /OpenForum/Javascript/Core/release-info.json
- /OpenForum/Javascript/Core/open-forum-debug.js
- /OpenForum/Javascript/Core/open-forum-object.js
- /OpenForum/Javascript/Core/open-forum-js-extensions.js
- /OpenForum/Javascript/Core/open-forum-action.js
- /OpenForum/Javascript/Core/open-forum-ajax-post.js
- /OpenForum/Javascript/Core/open-forum-tree.js
- /OpenForum/Javascript/Core/open-forum.build.json
- /OpenForum/Javascript/Core/open-forum-json.js
- /OpenForum/Javascript/Core/open-forum-google-font.js
- /OpenForum/Javascript/Core/open-forum-browser.js