dojo.provide("ikewiki.IkeWikiReadStore");dojo.declare("ikewiki.IkeWikiReadStore",null,{constructor:function(B,C,A){if(C){this.updateProgressBar=C}else{this.updateProgressBar=function(D){}}this._fetchQueue=[];this._init(B,A)},reLoad:function(A){this.close();this._fetchQueue=[];this._init(A)},_init:function(actionHandlerFunction,errorHandler){if(actionHandlerFunction){this._ready=false;this._items={};this._newitems={};this._moditems={};this._fetchQueue=[];var self=this;var callback=function(result,exception){if(exception){var e=new Error("error while initialising IkeWikiReadStore server connection"+exception);if(errorHandler){errorHandler(e)}else{throw e}}else{self._storename=result;self._ready=true;self.runQueue()}};var myF=actionHandlerFunction.replace(/\(([a-zA-Z0-9-\'\,])/,"(callback,$1").replace(/\(\)/,"(callback)");console.log(myF);eval("ActionHandler."+myF)}},runQueue:function(){var B=this._fetchQueue;this._fetchQueue=[];for(var C=0;C<B.length;C++){var A=B[C];A.fun.call(this,A.args)}},getValue:function(D,C,A){var B=this.getValues(D,C);return(B.length>0)?B[0]:A},getValues:function(C,B){if(!this.isItem(C)){throw new Error("Item is not loaded rom this store")}var A=C.attributes.map[B].list;return A?A:[]},getAttributes:function(B){if(!this.isItem(B)){throw new Error("Item is not loaded rom this store")}var A=[];for(attr in B.attributes.map){A.push(attr)}return A},hasAttribute:function(B,A){return this.getValues(B,A).length>0},containsValue:function(B,A,C){return this.getValues(B,A).indexOf(C)>-1},isItem:function(A){return A&&A.id&&A.attributes.map&&this._items[A.id]},isItemLoaded:function(A){return A&&A.id&&this._items[A.id]},loadItem:function(A){if(!this.isItem(A.item)&&!this.isItemLoaded(A.item)){if(A.onError){A.onError("the given argument is not an item of this store")}else{throw new Error("the given argument is not an item of this store")}}else{if(A.onItem){A.onItem(A.item)}}},close:function(A){if(!this._ready){}else{var B=function(C,D){if(D){console.log(D)}};ActionHandler.ReadStoreAction.close(B,this._storename)}},getLabel:function(A){if(!this.isItem(A)){throw new Error("Item is not loaded rom this store")}return A.label},getLabelAttributes:function(A){return null},fetch:function(I){this.updateProgressBar("10%");if(this.ready){try{ActionHandler.ReadStoreAction.ping(this._storename)}catch(E){this.reLoad()}}this.updateProgressBar("20%");if(!this._ready){this._fetchQueue.push({fun:this.fetch,args:I});return I}else{var B=I;var G=I.scope?I.scope:dojo.global;var H=this;var A;var D={javaClass:"java.util.HashMap",map:I.query};var C=I.count?I.count:-1;var F=function(J,L){if(J){console.info("result set size: "+J.list.length);H.updateProgressBar("50%");var K=J.list;if(I.onBegin){I.onBegin.call(G,K.length,B)}for(var M=0;M<K.length;M++){var N=K[M];H._items[N.id]=N;if(I.onItem){I.onItem.call(G,N,B)}}if(I.onComplete){I.onComplete.call(G,K,B)}H.updateProgressBar("100%")}else{if(I.onError){I.onError.call(G,L,I)}else{console.error(L)}}};A=ActionHandler.ReadStoreAction.fetch(F,this._storename,D,I.start?I.start:0,-1);B.abort=function(){console.log("aborting ...");ActionHandler.cancelRequest(A)};return B}},getFeatures:function(){return{"dojo.data.api.Read":true,"dojo.data.api.Identity":true,"dojo.data.api.Write":true,"dojo.data.api.Notification":true}},getIdentity:function(A){if(!this.isItem(A)){throw new Error("Item is not loaded rom this store")}return A.id},getIdentityAttributes:function(A){return null},fetchItemByIdentity:function(A){if(this.ready){try{ActionHandler.ReadStoreAction.ping(this._storename)}catch(C){this.reLoad()}}if(!this._ready){this._fetchQueue.push({fun:this.fetchItemByIdentity,args:A});return A}else{if(this._items[A.identity]){A.onItem.call(B,this._items[A.identity],A)}else{var B=A.scope?A.scope:dojo.global;var D=function(F,E){if(F){this._items[F.id]=F;A.onItem.call(B,F,A)}else{if(A.onError){A.onError.call(B,E,A)}}};ActionHandler.ReadStoreAction.fetchItemByIdentity(D,this._storename,A.identity)}}},newItem:function(C,B){var D=ActionHandler.ReadStoreAction.newItem(this._storename);var E=false;for(attr in C){if(!D.attributes.map[attr]){D.attributes.map[attr]={javaClass:"java.util.LinkedList",list:[]}}D.attributes.map[attr].list=[C[attr]];E=true}this._newitems[D.id]=D;this._items[D.id]=D;if(E){var A=this;this.save({onComplete:function(){A.onNew(D,B)}})}else{this.onNew(D,B)}return D},deleteItem:function(B){if(!this.isItem(B)){throw new Error("item does not belong to this store: "+B)}else{showStatus("Deleting ...");var A=this;var C=function(D,E){if(E){showError("Error while deleting item",E)}else{showStatus("Finished.");A.onDelete(B)}};ActionHandler.ReadStoreAction.deleteItem(C,this._storename,B);return true}},setValue:function(B,A,C){return this.setValues(B,A,[C])},setValues:function(E,D,B){if(!this.isItem(E)){throw new Error("item does not belong to this store: "+E)}else{if(!E.attributes.map[D]){E.attributes.map[D]={javaClass:"java.util.LinkedList",list:[]}}var A=E.attributes.map[D].list;E.attributes.map[D].list=B;if(!this._newitems[E.id]){this._moditems[E.id]=E}this.save({});var C=(A&&A.length==1)?A[0]:A;var F=(B&&B.length==1)?B[0]:B;this.onSet(E,D,C,F)}return true},unsetAttribute:function(B,A){return this.setValues(B,A,null)},save:function(D){showStatus("Saving ...");var E=D.scope?D.scope:dojo.global;var C=this;var H=function(I,J){if(J){if(D.onError){D.onError.call(E,J)}else{throw new Error(J)}showError("FAILED!",J)}else{if(D.onComplete){D.onComplete.call(E)}showStatus("Finished.")}C._newitems={};C._moditems={}};var A=[];for(id in this._moditems){A.push(this._moditems[id])}var B={javaClass:"java.util.LinkedList",list:A};var G=[];for(id in this._newitems){G.push(this._newitems[id])}var F={javaClass:"java.util.LinkedList",list:G};ActionHandler.ReadStoreAction.save(H,this._storename,F,B)},revert:function(){for(var A=0;A<this._newitems.length;A++){}this._newitems={};this._moditems={}},isDirty:function(A){if(A){return this._newitems[A.id]||this._moditems[A.id]}else{return this._newitems!={}||this._moditems!={}}},onSet:function(C,B,A,D){},onNew:function(B,A){},onDelete:function(A){}});var escapeJSONChar=function(){var A=["\b","\t","\n","\f","\r"];return function(C){if(C=='"'||C=="\\"){return"\\"+C}if(C.charCodeAt(0)>=32){return C}for(var B=0;B<A.length;B++){if(C==A[B]){return"\\"+C}}return C}}();function escapeJSONString(B){var C=B.split("");for(var A=0;A<C.length;A++){C[A]=escapeJSONChar(C[A])}return'"'+C.join("")+'"'}function toJSON(F){var A="$_$jabsorbed$813492";var H;var E=[];function C(){var I;while(H){I=H[A].prev;delete H[A];H=I}}var G={};var B;function D(J,I,K){var R=[],M,L,Q,O,N;if(J===null||J===undefined){return"null"}else{if(typeof J==="string"){return escapeJSONString(J)}else{if(typeof J==="number"){return J.toString()}else{if(typeof J==="boolean"){return J.toString()}else{if(J[A]){M=[K];Q=I;while(Q){if(L){L.unshift(Q[A].ref)}if(Q===J){O=Q;L=[O[A].ref]}M.unshift(Q[A].ref);Q=Q[A].parent}if(O){if(JSONRpcClient.fixupCircRefs){M.shift();L.shift();E.push([M,L]);return G}else{C();throw new Error("circular reference detected!")}}else{if(JSONRpcClient.fixupDuplicates){L=[J[A].ref];Q=J[A].parent;while(Q){L.unshift(Q[A].ref);Q=Q[A].parent}M.shift();L.shift();E.push([M,L]);return G}}}else{J[A]={parent:I,prev:H,ref:K};H=J}if(J.constructor===Date){return'{javaClass: "java.util.Date", time: '+J.valueOf()+"}"}else{if(J.constructor===Array){for(N=0;N<J.length;N++){B=D(J[N],J,N);R.push(B===G?null:B)}return"["+R.join(", ")+"]"}else{for(var P in J){if(P===A){}else{if(J[P]===null||J[P]===undefined){R.push('"'+P+'": null')}else{if(typeof J[P]=="function"){}else{B=D(J[P],J,P);if(B!==G){R.push(escapeJSONString(P)+": "+B)}}}}}return"{"+R.join(", ")+"}"}}}}}}}B=D(F,null,"root");C();if(E.length){return{json:B,fixups:E}}else{return{json:B}}}function JSONRpcClient(){var B=0,F,A,D,C;if(typeof arguments[0]=="function"){this.readyCB=arguments[0];B++}this.serverURL=arguments[B];this.user=arguments[B+1];this.pass=arguments[B+2];this.objectID=arguments[B+3];this.javaClass=arguments[B+4];this.JSONRPCType=arguments[B+5];if(JSONRpcClient.knownClasses[this.javaClass]&&(this.JSONRPCType=="CallableReference")){for(var E in JSONRpcClient.knownClasses[this.javaClass]){A=JSONRpcClient.knownClasses[this.javaClass][E];this[E]=JSONRpcClient.bind(A,this)}}else{if(this.objectID){this._addMethods(["listMethods"],this.javaClass);F=this._makeRequest("listMethods",[])}else{this._addMethods(["system.listMethods"],this.javaClass);F=this._makeRequest("system.listMethods",[])}if(this.readyCB){C=this;F.cb=function(G,H){if(!H){C._addMethods(G)}C.readyCB(G,H)}}D=this._sendRequest(F);if(!this.readyCB){this._addMethods(D,this.javaClass)}}}JSONRpcClient.knownClasses={};JSONRpcClient.Exception=function(E,D,C){this.code=E;var B,A;if(C){this.javaStack=C;A=C.match(/^([^:]*)/);if(A){B=A[0]}}if(B){this.name=B}else{this.name="JSONRpcClientException"}this.message=D};JSONRpcClient.Exception.CODE_REMOTE_EXCEPTION=490;JSONRpcClient.Exception.CODE_ERR_CLIENT=550;JSONRpcClient.Exception.CODE_ERR_PARSE=590;JSONRpcClient.Exception.CODE_ERR_NOMETHOD=591;JSONRpcClient.Exception.CODE_ERR_UNMARSHALL=592;JSONRpcClient.Exception.CODE_ERR_MARSHALL=593;JSONRpcClient.Exception.prototype=new Error();JSONRpcClient.Exception.prototype.toString=function(A,B){return this.name+": "+this.message};JSONRpcClient.default_ex_handler=function(A){console.dir(A);alert("JSON Exception: "+A)};JSONRpcClient.toplevel_ex_handler=JSONRpcClient.default_ex_handler;JSONRpcClient.profile_async=false;JSONRpcClient.max_req_active=1;JSONRpcClient.requestId=1;JSONRpcClient.fixupCircRefs=true;JSONRpcClient.fixupDuplicates=true;JSONRpcClient.bind=function(B,A){return function(){return B.apply(A,arguments)}};JSONRpcClient.prototype._createMethod=function(B){var A=function(){var C=[],F;for(var D=0;D<arguments.length;D++){C.push(arguments[D])}if(typeof C[0]=="function"){F=C.shift()}var E=this._makeRequest.call(this,B,C,F);if(!F){return this._sendRequest.call(this,E)}else{JSONRpcClient.async_requests.push(E);JSONRpcClient.kick_async();return E.requestId}};return A};JSONRpcClient.prototype._addMethods=function(C,H){var A,E,D,G,F;if(H){JSONRpcClient.knownClasses[H]={}}for(var B=0;B<C.length;B++){E=this;D=C[B].split(".");for(G=0;G<D.length-1;G++){A=D[G];if(E[A]){E=E[A]}else{E[A]={};E=E[A]}}A=D[D.length-1];if(!E[A]){F=this._createMethod(C[B]);E[A]=JSONRpcClient.bind(F,this);if(H&&(A!="listMethods")){JSONRpcClient.knownClasses[H][A]=F}}}};JSONRpcClient._getCharsetFromHeaders=function(A){var E,D,B;try{E=A.getResponseHeader("Content-type");D=E.split(/\s*;\s*/);for(B=0;B<D.length;B++){if(D[B].substring(0,8)=="charset="){return D[B].substring(8,D[B].length)}}}catch(C){}return"UTF-8"};JSONRpcClient.async_requests=[];JSONRpcClient.async_inflight={};JSONRpcClient.async_responses=[];JSONRpcClient.async_timeout=null;JSONRpcClient.num_req_active=0;JSONRpcClient._async_handler=function(){var A,B;JSONRpcClient.async_timeout=null;while(JSONRpcClient.async_responses.length>0){A=JSONRpcClient.async_responses.shift();if(A.canceled){continue}if(A.profile){A.profile.dispatch=new Date()}try{A.cb(A.result,A.ex,A.profile)}catch(C){JSONRpcClient.toplevel_ex_handler(C)}}while(JSONRpcClient.async_requests.length>0&&JSONRpcClient.num_req_active<JSONRpcClient.max_req_active){B=JSONRpcClient.async_requests.shift();if(B.canceled){continue}B.client._sendRequest.call(B.client,B)}};JSONRpcClient.kick_async=function(){if(!JSONRpcClient.async_timeout){JSONRpcClient.async_timeout=setTimeout(JSONRpcClient._async_handler,0)}};JSONRpcClient.cancelRequest=function(B){if(JSONRpcClient.async_inflight[B]){JSONRpcClient.async_inflight[B].canceled=true;return true}var A;for(A in JSONRpcClient.async_requests){if(JSONRpcClient.async_requests[A].requestId==B){JSONRpcClient.async_requests[A].canceled=true;return true}}for(A in JSONRpcClient.async_responses){if(JSONRpcClient.async_responses[A].requestId==B){JSONRpcClient.async_responses[A].canceled=true;return true}}return false};JSONRpcClient.prototype._makeRequest=function(B,D,A){var E={};E.client=this;E.requestId=JSONRpcClient.requestId++;var F='{"id":'+E.requestId+',"method":';if(this.objectID){F+='".obj#'+this.objectID+"."+B+'"'}else{F+='"'+B+'"'}if(A){E.cb=A}if(JSONRpcClient.profile_async){E.profile={submit:new Date()}}var C=toJSON(D);F+=',"params":'+C.json;if(C.fixups){F+=',"fixups":'+toJSON(C.fixups).json}E.data=F+"}";return E};JSONRpcClient.prototype._sendRequest=function(C){var B,A;if(C.profile){C.profile.start=new Date()}B=JSONRpcClient.poolGetHTTPRequest();JSONRpcClient.num_req_active++;B.open("POST",this.serverURL,!!C.cb,this.user,this.pass);try{B.setRequestHeader("Content-type","text/plain")}catch(D){}if(C.cb){A=this;B.onreadystatechange=function(){var E;if(B.readyState==4){B.onreadystatechange=function(){};E={cb:C.cb,result:null,ex:null};if(C.profile){E.profile=C.profile;E.profile.end=new Date()}else{E.profile=false}try{E.result=A._handleResponse(B)}catch(F){E.ex=F}if(!JSONRpcClient.async_inflight[C.requestId].canceled){JSONRpcClient.async_responses.push(E)}delete JSONRpcClient.async_inflight[C.requestId];JSONRpcClient.kick_async()}}}else{B.onreadystatechange=function(){}}JSONRpcClient.async_inflight[C.requestId]=C;try{B.send(C.data)}catch(D){JSONRpcClient.poolReturnHTTPRequest(B);JSONRpcClient.num_req_active--;throw new JSONRpcClient.Exception(JSONRpcClient.Exception.CODE_ERR_CLIENT,"Connection failed")}if(!C.cb){delete JSONRpcClient.async_inflight[C.requestId];return this._handleResponse(B)}return null};JSONRpcClient.prototype._handleResponse=function(http){function applyFixups(obj,fixups){function findOriginal(ob,original){for(var i=0,j=original.length;i<j;i++){ob=ob[original[i]]}return ob}function applyFixup(ob,fixups,value){var j=fixups.length-1;for(var i=0;i<j;i++){ob=ob[fixups[i]]}ob[fixups[j]]=value}for(var i=0,j=fixups.length;i<j;i++){applyFixup(obj,fixups[i][0],findOriginal(obj,fixups[i][1]))}}if(!this.charset){this.charset=JSONRpcClient._getCharsetFromHeaders(http)}var status,statusText,data;try{status=http.status;statusText=http.statusText;data=http.responseText}catch(e){JSONRpcClient.poolReturnHTTPRequest(http);JSONRpcClient.num_req_active--;JSONRpcClient.kick_async();throw new JSONRpcClient.Exception(JSONRpcClient.Exception.CODE_ERR_CLIENT,"Connection failed")}JSONRpcClient.poolReturnHTTPRequest(http);JSONRpcClient.num_req_active--;if(status!=200){throw new JSONRpcClient.Exception(status,statusText)}var obj;try{eval("obj = "+data)}catch(e){throw new JSONRpcClient.Exception(550,"error parsing result")}if(obj.error){throw new JSONRpcClient.Exception(obj.error.code,obj.error.msg,obj.error.trace)}var r=obj.result;var i,tmp;if(r){if(r.objectID&&r.JSONRPCType=="CallableReference"){return new JSONRpcClient(this.serverURL,this.user,this.pass,r.objectID,r.javaClass,r.JSONRPCType)}r=JSONRpcClient.extractCallableReferences(this,r)}if(obj.fixups){applyFixups(r,obj.fixups)}return r};JSONRpcClient.extractCallableReferences=function(B,A){var D,C,E;for(D in A){if(typeof (A[D])=="object"){C=JSONRpcClient.makeCallableReference(B,A[D]);if(C){A[D]=C}else{C=JSONRpcClient.extractCallableReferences(B,A[D]);A[D]=C}}if(typeof (D)=="object"){C=JSONRpcClient.makeCallableReference(B,D);if(C){E=A[D];delete A[D];A[C]=E}else{C=JSONRpcClient.extractCallableReferences(B,D);E=A[D];delete A[D];A[C]=E}}}return A};JSONRpcClient.makeCallableReference=function(A,B){if(B&&B.objectID&&B.javaClass&&B.JSONRPCType=="CallableReference"){return new JSONRpcClient(A.serverURL,A.user,A.pass,B.objectID,B.javaClass,B.JSONRPCType)}return null};JSONRpcClient.http_spare=[];JSONRpcClient.http_max_spare=8;JSONRpcClient.poolGetHTTPRequest=function(){if(JSONRpcClient.http_spare.length>0){return JSONRpcClient.http_spare.pop()}return JSONRpcClient.getHTTPRequest()};JSONRpcClient.poolReturnHTTPRequest=function(A){if(JSONRpcClient.http_spare.length>=JSONRpcClient.http_max_spare){delete A}else{JSONRpcClient.http_spare.push(A)}};JSONRpcClient.msxmlNames=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","Microsoft.XMLHTTP"];JSONRpcClient.getHTTPRequest=function(){try{JSONRpcClient.httpObjectName="XMLHttpRequest";return new XMLHttpRequest()}catch(B){}for(var A=0;A<JSONRpcClient.msxmlNames.length;A++){try{JSONRpcClient.httpObjectName=JSONRpcClient.msxmlNames[A];return new ActiveXObject(JSONRpcClient.msxmlNames[A])}catch(B){}}JSONRpcClient.httpObjectName=null;throw new JSONRpcClient.Exception(0,"Can't create XMLHttpRequest object")};dojo.require("dojo.parser");dojo.require("dojo.string");dojo.require("dojo.fx");dojo.require("dojo.io.iframe");dojo.require("dojo.back");dojo.require("dojo.data.ItemFileReadStore");dojo.require("dijit.Tree");dojo.require("dijit.layout.LayoutContainer");dojo.require("dijit.layout.TabContainer");dojo.require("dijit.TitlePane");dojo.require("dijit.layout.LinkPane");dojo.require("dijit.layout.ContentPane");dojo.require("dojox.layout.ContentPane");dojo.require("dijit.form.Button");dojo.require("dijit.Dialog");dojo.require("dijit.form.CheckBox");dojo.require("dijit.Tooltip");dojo.require("dojox.layout.FloatingPane");dojo.require("dijit.InlineEditBox");dojo.require("dijit.form.ValidationTextBox");dojo.require("dijit.form.TextBox");dojo.require("dijit.form.ComboBox");dojo.require("dijit.form.FilteringSelect");dojo.require("dijit.form.Textarea");dojo.require("dijit.layout.AccordionContainer");dojo.require("dijit.ProgressBar");dojo.require("dojox.xml.DomParser");dojo.require("dojox.widget.Toaster");dojo.require("dojox.grid.Grid");dojo.require("dojox.grid._data.model");dojo.require("dojox.grid._data.dijitEditors");var _id=1;var conversation;var mouseX;var mouseY;function getMouseX(){return mouseX}function getMouseY(){return mouseY}function handleMouseMove(e){mouseX=(document.all)?window.event.x+document.body.scrollLeft:e.pageX;mouseY=(document.all)?window.event.y+document.body.scrollTop:e.pageY}dojo.connect(document,"onmousemove",handleMouseMove);var ActionHandler;dojo.addOnLoad(function(){try{var jsonrpc=new JSONRpcClient("JSON-RPC");ActionHandler=jsonrpc}catch(e){alert("JSON-RPC initialisation error: "+e)}});dijit.layout.ContentPane.onDownloadEnd=function(url,data){this.setContent(data)};dojo.string.paramString=function(str,pairs,killExtra){for(var name in pairs){var re=new RegExp("\\%\\{"+name+"\\}","g");str=str.replace(re,pairs[name]);var re2=new RegExp("\\$\\{"+name+"\\}","g");str=str.replace(re2,pairs[name])}if(killExtra){str=str.replace(/%\{([^\}\s]+)\}/g,"")}return str};dojo.string.startsWith=function(str,start,ignoreCase){if(ignoreCase){str=str.toLowerCase();start=start.toLowerCase()}return str.indexOf(start)==0};function showWindow(caption,content,width,height,noCloseButton){if(!width){width=400}if(!height){height=250}var srcNode=document.createElement("div");srcNode.innerHTML=content;dojo.parser.parse(srcNode);document.body.appendChild(srcNode);var closeButton=true;if(noCloseButton){closeButton=false}var tooltip=new dijit.Dialog({title:caption,displayCloseAction:closeButton,hasShadow:true},srcNode);tooltip.resize(width,height);dijit.placeOnScreen(tooltip.domNode,{x:getMouseX(),y:getMouseY()},["TL","BL"],true);tooltip.show();return tooltip}var getAncestors=function(node,filterFunction,returnFirstHit){var ancestors=[];var isFunction=(filterFunction&&(filterFunction instanceof Function||typeof filterFunction=="function"));while(node){if(!isFunction||filterFunction(node)){ancestors.push(node)}if(returnFirstHit&&ancestors.length>0){return ancestors[0]}node=node.parentNode}if(returnFirstHit){return null}return ancestors};function findParentWindow(domNode){var node=getAncestors(domNode,function(n){if(n.nodeType==1){var classv=n.getAttribute("class");if(classv&&classv.indexOf("dijitContentPane")>-1){return true}}return false},true);var id_v=node.getAttribute("widgetid");var widget=dijit.byId(id_v);return widget}function init(){}function showStatus(message){dijit.byId("toast").setContent(message,"message",2000);dijit.byId("toast").show()}function clearStatus(){updateProgressBar("0%")}var timerId;function delayClearStatus(delay){timerId=setTimeout("clearStatus(); clearTimeout(timerId);",delay)}var updateProgressBar=function(progress){var pb_widget=dijit.byId("status-progress");if(progress=="0%"||progress=="0"){pb_widget.domNode.style.display="none"}else{pb_widget.domNode.style.display=""}pb_widget.update({progress:progress,maximum:100})};dojo.addOnLoad(function(){dojo.connect(document,"onclick",function(){delayClearStatus(5000)})});function showError(title,message){console.error(message);var et=document.getElementById("errbox-title");var em=document.getElementById("errbox-message");et.innerHTML=title;if(message&&message.message){em.innerHTML=message.message}else{em.innerHTML=message}dialog_error.show()}function showConfirmationDialog(title,message){var et=document.getElementById("confirm-title");var em=document.getElementById("confirm-message");et.innerHTML=title;em.innerHTML=message;dialog_confirm.show()}function showWaitMessage(title,message){var em=document.getElementById("waitbox-message");em.innerHTML=message;dialog_wait.show()}function hideWaitMessage(){dialog_wait.hide()}function showTooltip(qtitle,target){return true}function showTextTooltip(text,target){target.onmouseover=null;if(!target.getAttribute("id")){_id++;target.setAttribute("id","id-"+_id)}var myid=target.getAttribute("id");var mx=getMouseX();var my=getMouseY();var tooltip_area=dojo.byId("tooltip-area");var elem=document.createElement("div");if(tooltip_area){tooltip_area.appendChild(elem)}elem.innerHTML=text;var tooltip=new dijit.Tooltip({connectId:myid,label:text,showDelay:100},elem);tooltip.open()}function switchLanguage(language){var callback=function(result,exception){if(exception){showStatus("Error while switching to language "+language)}else{refresh()}};ActionHandler.RefreshAction.switchLanguage(callback,conversation,language)}var context_changed=false;function refresh(context_qtitle,nohistory){if(context_qtitle){var callback=function(result,exception){if(exception){if(exception.name=="at.srfg.ikewiki.permission.InsufficientPermissionsException"){showStatus("Insufficient privileges for accessing resource "+context_qtitle)}else{var href=window.location.href;href.replace(/title=[^&]+/,"title="+context_qtitle);window.location.href=href}}else{context_changed=true;refreshPerspectives(true);refreshPortlets();refreshForms();refreshComponentLayout();fixupArticleLinks();fixupPageHeader();if(!nohistory){var mystate={back:function(){refresh(context_qtitle,1)},forward:function(){refresh(context_qtitle,1)}};dojo.back.addToHistory(mystate)}if(!result){selectPerspective("perspective-edit_content")}}};ActionHandler.RefreshAction.refreshContext(callback,conversation,context_qtitle)}else{try{context_changed=true;refreshPerspectives(true);refreshPortlets();refreshForms();refreshComponentLayout();fixupArticleLinks()}catch(e){window.location.reload(true)}}}function refreshUri(context_uri,nohistory){if(context_uri){var callback=function(result,exception){if(exception){if(exception.name=="at.srfg.ikewiki.permission.InsufficientPermissionsException"){showStatus("Insufficient privileges for accessing resource "+context_uri)}else{var href=window.location.href;href.replace(/title=[^&]+/,"uri="+context_uri);window.location.href=href}}else{context_changed=true;refreshPerspectives(true);refreshPortlets();refreshForms();refreshComponentLayout();fixupArticleLinks();fixupPageHeader();if(!nohistory){var mystate={back:function(){refreshUri(context_uri,1)},forward:function(){refreshUri(context_uri,1)}};dojo.back.addToHistory(mystate)}if(!result){selectPerspective("perspective-edit_content")}}};ActionHandler.RefreshAction.refreshContextByUri(callback,conversation,context_uri)}else{try{refreshPerspectives(true);refreshPortlets();refreshForms();refreshComponentLayout();fixupArticleLinks()}catch(e){window.location.reload(true)}}}function refreshPerspectives(really){var ep=dijit.byId("perspectives");try{hideContextGraph()}catch(e){}for(var i=0;i<ep.getChildren().length;i++){var child=ep.getChildren()[i];if(child&&(really||child!=ep.selectedChildWidget)){child.isLoaded=false;child.setHref(child.hasHref)}}}function refreshPortlets(){}var forms=new Array();function registerForm(form){forms.push(form)}function refreshForms(){for(var i=0;i<forms.length;i++){forms[i].isLoaded=false;forms[i].setHref(forms[i].hasHref);forms[i].cacheContent=false}}var permission_components=new Object();var components_disabled=new Object();function refreshComponentLayout(){var callback=function(permissions,exception){if(exception){showStatus("error while retrieving component list");showStatus("Exception",exception+"");console.error("error while retrieving component list: "+exception)}else{for(var i in permission_components){var perm_id=i;var widget_id=permission_components[i];var widget=dijit.byId(widget_id);if(widget){if(permissions.map[perm_id]){widget.enable();components_disabled[widget_id]=false}else{widget.disable();components_disabled[widget_id]=true}}else{alert("Widget "+widget_id+" not defined!")}}var tabs=dijit.byId("perspectives");tabs.layout();context_changed=false}};ActionHandler.LayoutAction.listEnabledComponents(callback,conversation)}function fixupArticleLinks(){var page=dojo.byId("mainContent");if(page){var links=page.getElementsByTagName("a");for(var i=0;i<links.length;i++){var link=links[i];if(link.getAttribute("lTarget")){link.onclick=function(){refresh(this.getAttribute("lTarget"));return false}}}}}function getPageTitle(contextTitle){return"IkeWiki - "+contextTitle}function fixupPageHeader(){var metadata_callback=function(metadata,exception){if(exception){log.error("error while retrieving context metadata"+exception)}else{var context_title=metadata.map.context_qtitle;var context_uri=metadata.map.context_uri;var dcmap=metadata.map.context_dublincore;try{document.title=getPageTitle(context_title);var pagetitle=dojo.byId("hd-title");pagetitle.innerHTML=getPageTitle(context_title)}catch(e){}var rdfexport=dojo.byId("hd-rdf-export");rdfexport.setAttribute("href",rdfexport.getAttribute("base")+"components/actions/export.jsp?format=rdf/xml&scope=resource&uri="+escape(context_uri));var metas=document.getElementsByTagName("meta");for(var i=0;i<metas.length;i++){if(metas[i].getAttribute("name")&&metas[i].getAttribute("name").substr(0,3)=="DC."){metas[i].parentNode.removeChild(metas[i])}}for(var key in dcmap.map){var head=document.getElementsByTagName("head")[0];var meta=document.createElement("meta");meta.setAttribute("name","DC."+key);meta.setAttribute("content",dcmap.map[key]);head.appendChild(meta)}}};ActionHandler.RefreshAction.getContextMetadata(metadata_callback,conversation)}function selectPerspective(id){var ep=dijit.byId("perspectives");var tab=dijit.byId(id);ep.selectChild(id);tab.startup()}function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString()}else{var expires=""}document.cookie=name+"="+value+expires+"; path=/"}function readCookie(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}function eraseCookie(name){createCookie(name,"",-1)}var fillTemplate=function(template,new_id,map,mode){var entry=template.cloneNode(true);if(new_id!=null){entry.setAttribute("id",new_id)}else{entry.removeAttribute("id")}entry.removeAttribute("parseWidgets");template.parentNode.insertBefore(entry,template);entry.style.display=mode;entry.innerHTML=dojo.string.paramString(entry.innerHTML,map,false);entry.innerHTML=entry.innerHTML.replace(/ikewikitype/gi,"dojoType");dojo.parser.parse(entry);return entry};var init_form=function(id,permission_id,href){eval("form"+id+' = dijit.byId("form-'+id+'");');var widget=dijit.byId("form-"+id);var form_content=dijit.byId("form-"+id+"-content");widget.enable=function(){};widget.disable=function(){};widget.closeWindow=function(){widget.hide()};dojo.connect(widget,"hide",function(){form_content.hide();setTimeout("refreshForms()",1)});widget.ikewikiShow=function(){form_content.show();form_content._loadCheck(true);dojo.connect(form_content,"onLoad",function(){widget.show()})};widget.ikewikiLoad=function(){form_content._loadCheck(true)};widget.ikewikiContent=form_content;form_content.hasHref=href;form_content.cacheContent=false;registerForm(form_content);widget.hide();permission_components[permission_id]="form-"+id};var init_perspective=function(id,permission_id,href){var container=dijit.byId("perspectives");var widget=dijit.byId("perspective-"+id);widget.hasHref=href;permission_components[permission_id]="perspective-"+id;widget.disable=function(){var tabs=container.tablist;var button=tabs.pane2button[this];button.onClickSaved=button.onClick;button.onClick=function(){dojo.addClass(button.domNode,"button-disabled")};button.setDisabled(true);dojo.removeClass(button.domNode,"button-enabled");dojo.addClass(button.domNode,"button-disabled")};widget.enable=function(){var tabs=container.tablist;var button=tabs.pane2button[this];if(button.onClickSaved){button.onClick=button.onClickSaved}button.setDisabled(false);dojo.removeClass(button.domNode,"button-disabled");dojo.addClass(button.domNode,"button-enabled")};dojo.connect(widget,"onLoad",function(){var content=dojo.query(".perspective-body",widget.domNode)[0];var height=content.clientHeight+100;container.resize({h:height})})};var fixPerspectiveSize=function(){var content=dojo.query(".perspective-body",dojo.byId("column-center"))[0];var height=content.clientHeight+100;var container=dijit.byId("perspectives");container.resize({h:height})};var init_portlet=function(id,permission_id,href){var widget=dijit.byId("portlet-"+id);var pane=dijit.byId("portlet-pane-"+id);widget.hasHref=href;permission_components[permission_id]="portlet-"+id;widget.enable=function(){widget.show();pane.show();this.setHref(this.hasHref)};widget.disable=function(){pane.hide()};widget._handleDefaults=function(e,handler,messageType){}};var wrap_function_component_onload=function(component_id,f){var widget=dijit.byId(component_id);var fun=dojo.connect(widget,"onLoad",function(){f();dojo.disconnect(fun)})};var hideWidgetById=function(id){var widget=dijit.byId(id);widget.hide()};var showWidgetById=function(id){var widget=dijit.byId(id);widget.show()};var checkFormButton=function(form_id,button_id){var form=dijit.byId(form_id);var button=dijit.byId(button_id);button.setDisabled(!form.isValid())};dijit._Widget.prototype.show=function(){this.domNode.style.display=""};dijit._Widget.prototype.hide=function(){this.domNode.style.display="none"};var switchTheme=function(theme){var theme_callback=function(context_title,exception){if(!exception){try{window.location.reload()}catch(e){}}};ActionHandler.RefreshAction.switchTheme(theme_callback,theme)};