OpenForum
* function getVersion() - Get the version number of this script
Returns: - The version number as a string. eg. 1.0.0
* function getBuildDate() - Get the build date and time of this script as a UTC date and time string
Returns: - UTC date and time string. eg. Wed Feb 10 2016 15:04:02 GMT-0000 (UTC)
* function includeScript(scriptFileName - the full path of the script to dynamically load) - Dynamically loads a script
* function getDepemdencies()
* function getRoot()
* function addNodeProcessor(arg0)
* function addScanner(arg0)
* function addInitialiser(arg0)
* function addHashCall(arg0,arg1)
* function addTable(arg0)
* function getTable(arg0)
* function getNextId()
* function getObject(arg0)
* function scan()
* function crawl(arg0)
* function preparePage(arg0)
* function crawlParts(arg0,arg1)
* function crawlTables(arg0)
* function parseText(arg0,arg1,arg2)
* function parseParts(arg0,arg1,arg2)
* function loadScript(arg0)
* function loadCSS(arg0)
* function onHash(arg0)
* function init()
* function close()
* function onload(arg0)
* function waitForReady()
* function stopAutoScan()
* function startAutoScan(arg0)
* function onunload()
* function getObjects()
* function getTables()
* function listData()
* function createData()
* function createParents(arg0)
* function createObjectSignature(arg0)
* function childCount(arg0)
* function addTab(arg0)
* function showTab(arg0)
* function getTabs()
* function getTab(arg0)
* function evaluate(arg0)
* function globalExists(arg0)
* function getGlobal(arg0)
* function setGlobal(arg0,arg1,arg2)
* function getSystemTime(arg0)
* function loadScripts(arg0,arg1)
* function getAttachments(arg0,arg1,arg2,arg3)
* function loadFile(arg0,arg1,arg2)
* function loadJSON(arg0,arg1,arg2)
* function loadXML(arg0,arg1,arg2)
* function saveFile(arg0,arg1,arg2)
* function saveJSON(arg0,arg1,arg2)
* function saveXML(arg0,arg1,arg2)
* function appendFile(arg0,arg1,arg2)
* function deleteFile(arg0,arg1,arg2)
* function copyFile(arg0,arg1,arg2)
* function moveFile(arg0,arg1,arg2)
* function fileExists(arg0)
* function uploadFile(arg0,arg1,arg2)
* function setDebugToConsole(arg0)
* function debug(arg0,arg1,arg2)
* function createFileTree(arg0,arg1)
* function copyElement(arg0)
* function copyData(arg0)
* function setElement(arg0,arg1)
* function appendToElement(arg0,arg1)
* function showElement(arg0)
* function hideElement(arg0)
* function toggleElement(arg0)
* function getParameter(arg0)
* function getCookie(arg0)
* function isEqual(arg0,arg1)
* function copyDifferencesFromTo(arg0,arg1,arg2,arg3,arg4)
* function clone(arg0)
* function clean(arg0)
* function setInterval(arg0,arg1,arg2,arg3,arg4)
* function waitFor(arg0,arg1,arg2,arg3)
* function runAsync(arg0)
* function queue(arg0,arg1)
* function jsonToCsv(arg0,arg1)
DependencyService
* function createNewDependency()
* function scriptLoaded(arg0)
Process
* function call(arg0)
* function waitFor(arg0)
* function then(arg0)
* function run(arg0)
JSON
* function get(arg0,arg1,arg2)
* function post(arg0,arg1,arg2)
* function onSuccess(arg0)
* function onError(arg0)
* function go()
OFX
* function get(arg0)
* function post(arg0)
Built Thu Jul 25 2019 07:20:10 GMT-0000 (GMT)//==============================================================================================================//
/* Version 1.8.6*/
/* Built on Thu Jul 25 2019 07:20:10 GMT-0000 (GMT) */
/* Built by /OpenForum/Javascript/Builder.*/
/* Do not edit as changes may be overwritten */
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-dependency.js*/
//==============================================================================================================//
//---- DependencyService ----
if(typeof OpenForum == "undefined") OpenForum = {};
var DependencyService = new function() {
var dependencies = [];
var loadedScripts = [];
var requestedScripts = [];
this.createNewDependency = function() {
var dependency = new function() {
var id = dependencies.length;
var self = this;
var scriptsToLoad = [];
var requiredScripts = [];
var onLoadTrigger = function() {};
var loaded = false;
self.addDependency = function(script) {
requiredScripts.push(script);
if( requestedScripts.includes(script) ) return this;
requestedScripts.push(script);
scriptsToLoad.push(script);
return this;
};
self.setOnLoadTrigger = function(triggerFunction) {
onLoadTrigger = triggerFunction;
return this;
};
self.loadDependencies = function() {
if(requiredScripts.length===0) {
self.setLoaded();
return;
}
if(scriptsToLoad.length==0) {
DependencyService.scriptLoaded(id);
return;
}
var fileName = "";
for(var i=0;i0) fileName+=",";
fileName+=scriptsToLoad[i];
}
OpenForum.loadScript("/OpenForum/Javascript/Services?script="+fileName+"&callback=DependencyService.scriptLoaded&callbackId="+id);
};
self.checkLoaded = function() {
return loaded;
};
self.setLoaded = function() {
for(var i in requiredScripts) {
if(!loadedScripts[requiredScripts[i]]) {
setTimeout(self.setLoaded,100);
return;
}
}
loaded = true;
onLoadTrigger();
};
self.getScriptsToLoad = function() {
return scriptsToLoad;
};
};
dependencies.push(dependency);
return dependency;
};
this.scriptLoaded = function(id) {
var newScripts = dependencies[id].getScriptsToLoad();
for(var i in newScripts) {
loadedScripts[newScripts[i]]=true;
}
dependencies[id].setLoaded();
};
};
/* End of: /OpenForum/Javascript/Core/open-forum-dependency.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-scanner.js*/
//==============================================================================================================//
//---- OpenForum ----
var OpenForum = new function(){
this.FIELD_DELIMETER_START = "{"+"{";
this.FIELD_DELIMETER_END = "}"+"}";
var self = this;
var objects= [];
var tables = [];
var tabs = [];
var nextId = 0;
var hash;
var hashCalls = [];
var nodeProcessors = [];
var scanners = [];
var initialisers = [];
var dependencies = [];
var watchers = [];
var defaultScanPeriod = 500;
self.interval = null;
self.getVersion = function() {
return "1.8.6";
};
self.getBuildDate = function() {
return "Thu Jul 25 2019 07:20:10 GMT-0000 (GMT)";
};
self.initDependencies = DependencyService.createNewDependency();
self.includeScript = function( scriptName ) {
if(dependencies[scriptName]) return;
dependencies[scriptName] = self.initDependencies.addDependency( scriptName );
};
self.getDepemdencies = function() {
return dependencies;
};
self.getRoot = function() {
var root = document.location.toString();
root = root.substring( root.indexOf("://")+3 );
root = root.substring( root.indexOf("/")+1 );
root = "/"+root.substring( 0,root.indexOf("/") );
return root;
};
self.addNodeProcessor = function(processor) {
nodeProcessors.push(processor);
};
self.addScanner = function(scanner) {
scanners.push(scanner);
};
self.addInitialiser = function( fn ) {
initialisers.push(fn);
};
self.addHashCall = function(hash,callFn) {
hashCalls[hash] = callFn;
};
self.addTable = function(table) {
tables[table.getId()]=table;
};
self.getTable = function(ofId) {
return tables[ofId];
};
self.getNextId = function() {
nextId++;
return nextId;
};
self.getObject= function(id) {
//id = id.replace(/\./g,"_dot_");
if(objects[id]===undefined) {
objects[id] = new OpenForumObject(id);
}
return objects[id];
};
self.scan = function() {
if(self.hash != window.location.hash) {
self.hash = window.location.hash;
self._onHash(self.hash);
}
for(var tableIndex in tables) {
tables[tableIndex].refresh();
}
for(var objectIndex in objects) {
object = objects[objectIndex];
if(typeof(object)=="undefined") {
} else {
object.scan();
}
}
for(var scanner in scanners) {
try{
scanners[scanner]();
} catch(e) {
console.log(e);
}
}
self.preparePage(document.body);
};
self.addNodeProcessor( function(node) {
if(node.attributes==undefined) return;
for(var a=0; a0) || node.type=="select-one" || node.type=="select-multiple") {
if(node.attributes && node.attributes['of-id']) {
var nodeName = node.attributes['of-id'].value;
if(prefix.length>0) {
nodeName = prefix+"."+nodeName;
}
var object = OpenForum.getObject(nodeName).add( node );
objects[objects.length]=object;
}
if( typeof(node.innerHTML)!="undefined" && node.innerHTML.indexOf(OpenForum.FIELD_DELIMETER_START)!=-1) {
self.parseParts(node,objects,prefix);
}
if( node.nodeName=="#text" && node.nodeValue.indexOf(OpenForum.FIELD_DELIMETER_START)!=-1) {
self.parseText(node,objects,prefix);
}
}
for(var nodeIndex=0; nodeIndex "+
data.substring(data.indexOf(OpenForum.FIELD_DELIMETER_END)+2);
spans[spans.length] = {id: 'OpenForumId'+nextId,name: name};
nextId++;
}
//node.nodeValue = data;
newNode = document.createElement("span");
node.parentNode.replaceChild(newNode,node);
newNode.innerHTML = data;
for(var spanIndex in spans) {
var span = spans[spanIndex];
var object = self.getObject( span.name );
object.add( document.getElementById(span.id) );
objects[objects.length]=object;
}
};
self.parseParts= function(node,objects,prefix) {
var data = node.innerHTML;
var spans = [];
while(data.indexOf(OpenForum.FIELD_DELIMETER_START)!=-1) {
name = data.substring(data.indexOf(OpenForum.FIELD_DELIMETER_START)+2,data.indexOf(OpenForum.FIELD_DELIMETER_END));
data = data.substring(0,data.indexOf(OpenForum.FIELD_DELIMETER_START))+
" "+
data.substring(data.indexOf(OpenForum.FIELD_DELIMETER_END)+2);
spans.push( {id: 'OpenForumId'+nextId,name: name} );
nextId++;
}
node.innerHTML = data;
for(var spanIndex = 0; spanIndex0) {
id+=".";
}
id+=parts[index];
if( OpenForum.evaluate("typeof("+id+")")=="undefined" ) {
OpenForum.evaluate(id+"={};");
}
}
};
self.createObjectSignature = function(object) {
var cache = [];
var signature = JSON.stringify(object, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
}
return value;
});
cache = null;
return signature;
};
self.childCount = function(object) {
var count=0;
for(var index in object) {
count++;
}
return count;
};
self.addTab = function(id) {
tabs[id] = document.getElementById(id);
};
self.showTab = function(id){
for(var index in tabs) {
tabs[index].style.display="none";
}
tabs[id].style.display="block";
};
self.getTabs = function(){
return tabs;
};
self.getTab = function(id){
return tabs[id];
};
//Keep all the evil in one place
self.evaluate = function(script) {
try{
return eval(script);
} catch (e) {
OpenForum.debug( "ERROR", "Exception evaluating '" + script + "'",e );
throw e;
}
};
self.globalExists = function( name ) {
name = name.replace(/\[/g,".").replace(/\]/g,"").replace(/'/g,"").replace(/\(.*\)/g,"");
var parts = name.split(".");
var obj = window;
for(var part in parts) {
if( typeof obj[parts[part]] === "undefined" ) return false;
obj = obj[parts[part]];
}
return true;
};
self.getGlobal = function( name ) {
name = name.replace(/\[/g,".").replace(/\]/g,"").replace(/'/g,"").replace(/\(.*\)/g,"");
var parts = name.split(".");
var obj = window;
for(var part in parts) obj = obj[parts[part]];
if(typeof obj === "function") return obj();
else return obj;
};
self.setGlobal = function( name,value,create ) {
name = name.replace(/\[/g,".").replace(/\]/g,"").replace(/'/g,"");
var parts = name.split(".");
var obj = window;
var i=0;
for(i=0; i0) {
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) );
}
};
/* End of: /OpenForum/Javascript/Core/open-forum-json.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-ajax-request.js*/
//==============================================================================================================//
//---- 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;" );
}
};
}
/* End of: /OpenForum/Javascript/Core/open-forum-ajax-request.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-ajax.js*/
//==============================================================================================================//
//---- 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");
}
};
};
/* End of: /OpenForum/Javascript/Core/open-forum-ajax.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-ajax-post.js*/
//==============================================================================================================//
//---- Post ----
function Post()
{
this.data = [];
this.addItem = function(name,value)
{
this.item = [];
this.data[this.data.length] = this.item;
this.item[0] = name;
this.item[1] = value;
return this;
};
this.addForm = function(formId) {
form = document.getElementById(formId);
for(var loop=0;loop0) {
this.addItem(name,form.elements[loop].value);
}
}
return this;
};
this.getData = function() {
var dataString = "";
for(var entry in this.data) {
if(dataString.length>0) {
dataString +="&";
}
dataString += this.data[entry][0]+"="+encodeURIComponent(this.data[entry][1]);
}
return dataString;
};
//TODO add get parameters method like
/*
this.data="";
for(this.loop=0;this.loop"+
"";
return data;
};
}
function TreeNode(name,attributes,newParent,jsonModifier) {
var self = this;
var id = "TreeNode"+NextTreeNodeIndex;
NextTreeNodeIndex++;
TreeNodes[id] = self;
var children = [];
var expanded = false;
var SPACE = " ";
var localDepth = 0;
var lazyLoad = null;
var parent = newParent;
var paint = function() {
document.getElementById(id).innerHTML = self.render(localDepth);
};
self.paint = paint;
self.getId = function() {
return id;
};
self.setLazyLoad = function(lazyLoadFn) {
lazyLoad = lazyLoadFn;
return this;
};
self.getParent = function() {
return parent;
};
self.setParent = function(newParent) {
parent = newParent;
};
self.addChild = function(name,attributes) {
var newChild = new TreeNode(name,attributes,self,jsonModifier);
children[children.length] = newChild;
newChild.parent = self;
return newChild;
};
self.addJSON = function(node) {
if(jsonModifier!==null) jsonModifier(node);
var child = self.addChild( node.name,node.attributes );
if(node.leaves) {
for(var i in node.leaves) {
child.addJSON( node.leaves[i] );
}
}
return child;
};
self.importJSON = function(url,action,parameters) {
JSON.get(url,action,parameters).onSuccess(
function(response) {
for(var i in response.leaves) {
self.addJSON( response.leaves[i] );
}
paint();
}
).go();
};
self.deleteChild = function(node) {
for(var index in children) {
if(children[index].getId()===node.getId()) {
children.splice(index,1);
return this;
}
}
return this;
};
self.isExpanded = function() {
return expanded;
};
self.expand = function() {
if(lazyLoad!==null) {
lazyLoad(self);
lazyLoad = null;
return this;
}
if(parent && parent.isExpanded()===false) {
parent.expand();
}
expanded=true;
paint();
return this;
};
self.collapse = function() {
expanded=false;
paint();
return this;
};
self.toggle = function() {
expanded=!expand;
paint();
return this;
};
self.render = function(depth) {
if(!depth) {
depth=0;
}
localDepth = depth;
var data = "";
data+="";
for(var count=0;count0) {
if(expanded===false) {
data+=""+
"";
} else {
data+=""+
"";
}
} else {
data+=" ";
}
if(attributes && attributes.link) {
if(attributes.toolTip) {
data += "";
} else {
data += "";
}
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.actions[actionIndex];
var action = new Action(actionConfig);
data+=action.render("TreeNodes[\""+id+"\"]");
}
}
data+="
";
if(expanded===true) {
for(var childIndex in children) {
data+=children[childIndex].render(depth+1);
}
}
data+="";
return data;
};
self.getName = function() {
return name;
};
self.setName = function(newName) {
name = newName;
};
self.getAttribute = function(name) {
return attributes[name];
};
self.applyToChildren = function( fn ) {
children.forEach( function(child) { fn(child); } );
};
self.getChildren = function() {
return children;
};
}
OpenForum.createFileTree = function(id,root) {
var tree = new Tree(id,"Loading...","");
JSON.get("/OpenForum/Javascript/Tree","getPageTree","pageName="+root).onSuccess(
function(result) {
tree.setJSON(result);
tree.render();
tree.getRoot().expand();
tree.init();
}
).go();
return tree;
};
/* End of: /OpenForum/Javascript/Core/open-forum-tree.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-js-extensions.js*/
//==============================================================================================================//
//---- 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.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.after = function (start) {
if(!this.contains(start)) return;
return this.substring(this.indexOf(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(this.lengthdate.getTime());
};
Date.prototype.isBefore = function(date) {
return (this.getTime()maxDepth) {
return null;
}
if( typeof a === "object" ) {
for(var i in a) {
if(!b[i]) {
//If it doesn't exist, create it
if(typeof a[i] === "object") {
var value;
if(a[i].length) value = OpenForum.copyDifferencesFromTo(a[i],[],depth+1,minDepth,maxDepth);
else value = OpenForum.copyDifferencesFromTo(a[i],{},depth+1,minDepth,maxDepth);
if(value!=null) {
if(depth<=maxDepth) {
b[i] = a[i];
} else {
return null;
}
} else {
b[i] = value;
}
} else {
b[i] = a[i];
}
} else if( OpenForum.isEqual(a[i],b[i])===false) {
//If it exists but is not equal, copy differences
var value = OpenForum.copyDifferencesFromTo(a[i],b[i],depth,minDepth,maxDepth);
if(value!=null) {
if(depth<=maxDepth) {
b[i] = a[i];
} else {
return null;
}
}
}
}
for(var i in b) {
if(!a[b]) {
delete b[a];
}
}
} else {
return a;
}
return b;
};
OpenForum.clone = function(a) {
var b = {};
if(a.length) b = [];
OpenForum.copyDifferencesFromTo(a,b);
return b;
};
OpenForum.clean = function(a) {
if( typeof a === "object" ) {
for(var i in a) {
if(typeof a[i] === "object") {
a[i] = OpenForum.clean(a[i]);
} else if(typeof a[i] === "number") {
a[i] = 0;
} else if(typeof a[i] === "boolean") {
a[i] = true;
} else {
a[i] = "";
}
}
}
return a;
};
OpenForum.setInterval = function(fn,timePeriod,immediate,blocking,doesCallback) {
if(blocking) {
var blocked = false;
if(immediate) {
blocked = true;
try{
if(doesCallback) {
fn( function() {blocked = false;} );
} else {
fn();
blocked = false;
}
} catch (e) {
blocked = false;
}
}
return setInterval( function() {
if(blocked) return;
blocked = true;
try{
if(doesCallback) {
fn( function() {blocked = false;} );
} else {
fn();
blocked = false;
}
} catch (e) {
blocked = false;
}
}, timePeriod );
} else {
if(immediate) {
fn();
return setInterval(fn,timePeriod);
}
}
};
OpenForum.waitFor = function(test,callback,pause,timeout) {
if(!pause) pause=200;
if(!timeout) timeout = new Date().getTime()+30000;
else if( new Date().getTime()>timeout ) throw "Timeout waiting for " + test;
if(test()===true) {
callback();
} else {
setTimeout(
function(test,callback,pause,timeout){
return function() {
OpenForum.waitFor(test,callback,pause,timeout);
};
}(
test,
callback,
pause
),
pause
);
}
};
OpenForum.runAsync = function(fn) {
setTimeout( function() { fn(); },1 );
};
OpenForum.queue = function(process,supplyState) {
var test = OpenForum.queue.ready;
if(!test) test = function() { return true; };
OpenForum.queue.ready = function() { return (!OpenForum.processing); };
var state = {complete: false};
if(supplyState===true) {
OpenForum.queue.ready = function() {
if(state.complete===true) delete OpenForum.processing;
return (state.complete);
};
}
OpenForum.waitFor(
test,
function() {
OpenForum.processing = process;
process(state);
if(!supplyState) {
delete OpenForum.processing;
}
}
);
};
OpenForum.Table = {};
OpenForum.Table.setCell = function(table,row,column,value) {
if(value) {
table[row][column] = value;
} else {
//Is simple array so value is column
table[row] = column;
}
};
OpenForum.Table.editRow = function(table,index) {
for(var i in table) {
table[i].view = "display: block;";
table[i].edit = "display: none;";
}
table[index].edit = "display: block;";
table[index].view = "display: none;";
};
OpenForum.jsonToCsv = function(json,delimiter) {
if(!delimiter) delimiter = "\t";
var csv = "";
if(Array.isArray(json)) {
for(var i in json) {
var row = json[i];
//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 += row[r];
}
csv += csvRow +"\n";
}
} else if(typeof json === "object") {
for(var name in json) {
csv += name + delimiter + json[name] + "\n";
}
}
return csv;
};
OpenForum.Table.closeTable = function(table) {
for(var i in table) {
table[i].view = "display: block;";
table[i].edit = "display: none;";
}
};
OpenForum.Table.addRow = function(table) {
var newRow = OpenForum.clone( table[table.length-1] );
OpenForum.clean( newRow );
table.push( newRow );
OpenForum.Table.editRow(table,table.length-1);
};
OpenForum.Table.removeRow = function(table,index) {
var oldRow = table[index];
table.splice(index,1);
return oldRow;
};
/* End of: /OpenForum/Javascript/Core/open-forum-utils.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-storage.js*/
//==============================================================================================================//
if(!OpenForum) {
OpenForum = {};
}
OpenForum.Storage = {};
OpenForum.Storage.get = function(key) {
return localStorage.getItem(key);
};
OpenForum.Storage.set = function(key,value) {
localStorage.setItem(key,value);
};
OpenForum.Storage.find = function(regex) {
var found = [];
for(var i in localStorage) {
if( i.match(regex)) {
found.push( {key: i, value: localStorage[i]} );
}
}
return found;
};
/* End of: /OpenForum/Javascript/Core/open-forum-storage.js*/
//==============================================================================================================//
//==============================================================================================================//
/* Source: /OpenForum/Javascript/Core/open-forum-ofx.js*/
//==============================================================================================================//
/*
* Author: Nik Cross
* Description: A replacement for OpenForum JSON.get and JSON.post
*/
var OFX = {
get: function(url) {
var GET = function(url) {
var self = this;
var action;
var data;
var callBack;
var callOnError;
self.withAction = function(newAction) {
action = newAction;
return self;
};
self.withData = function(newData) {
data = newData;
return self;
};
self.onSuccess = function(newCallBack) {
callBack = newCallBack;
return self;
};
self.onError = function(newCallOnError) {
callOnError = newCallOnError;
return self;
};
self.go = function() {
if(action) {
if(data) {
if(typeof data == "object") {
var dataString = "";
for(var name in data) {
if(dataString.length>0) dataString += "&";
dataString += name + "="+ data[name];
}
data = dataString;
}
}
var get = JSON.get(url,action,data);
if(callBack) {
get = get.onSuccess( callBack );
}
if(callOnError) {
get = get.onError(callOnError);
}
get.go();
} else {
JSON.loadFile(url,callBack);
}
};
};
return new GET(url);
},
post: function(url) {
var POST = function(url) {
var self = this;
var action;
var data;
var callBack;
var callOnError;
self.withAction = function(newAction) {
action = newAction;
return self;
};
self.withData = function(newData) {
data = newData;
return self;
};
self.onSuccess = function(newCallBack) {
callBack = newCallBack;
return self;
};
self.onError = function(newCallOnError) {
callOnError = newCallOnError;
return self;
};
self.go = function() {
if(action) {
if(data) {
if(typeof data == "object") {
var dataString = "";
for(var name in data) {
if(dataString.length>0) dataString += "&";
dataString += name + "="+ data[name];
}
data = dataString;
}
}
var post = JSON.post(url,action,data);
if(callBack) {
post = post.onSuccess( callBack );
}
if(callOnError) {
post = post.onError(callOnError);
}
post.go();
} else {
JSON.saveFile(url,data);
}
};
};
return new POST(url);
}
};
/* End of: /OpenForum/Javascript/Core/open-forum-ofx.js*/
//==============================================================================================================//