function manageGroup(E,F,C){var B="/cbi/admin_manage/manage";var A=new Array(E,F,C);var D=new Ajax(B,{method:"post",data:Json.toString(A),onSuccess:function(G,H){window.location.reload()}});D.request()}function addToGroup(B,A){manageGroup("add_member",B,A)}function promoteInGroup(B,A){manageGroup("promote_member",B,A)}function demoteInGroup(B,A){manageGroup("demote_member",B,A)}function removeFromGroup(B,A){manageGroup("remove_member",B,A)}function makePublic(A){manageGroup("make_public",null,A)}function destroyGroup(B){var A=new DestroyGroupConfirmer({"group":B});A.show()}function restrictContent(B,A){manageGroup("restrict_content",B,A)}function saveToCollection(D,A){var B="/cbi/collection/collectionAddTo";var C;if(MooTools.version=="1.3.2"){C=new Request.JSON({"url":B,method:"post",data:JSON.stringify([D,A]),onSuccess:function(E){Log.logDebug("recvd at point response: "+String(E))}});C.send()}else{C=new Ajax(B,{method:"post",data:Json.toString(new Array(D,A)),onSuccess:function(E,F){Log.logDebug("recvd at point response: "+String(E))}});C.request()}}function saveAllCollection(B,D){var A="/cbi/collection/collectionAddAll";var C=new Ajax(A,{method:"post",data:Json.toString(new Array(B,D)),onSuccess:function(E,F){Log.logDebug("recvd at point response: "+String(E))}});C.request()}function saveAllViz(D,B){var A="/cbi/collection/collectionAddViz";var C=new Ajax(A,{method:"post",data:Json.toString(new Array(D,B)),onSuccess:function(E,F){Log.logDebug("recvd at point response: "+String(E))}});C.request()}function removeFromCollection(C,D){console.log("REMOVE FROM COLLECTION");console.log(C);console.log(D);var A="/cbi/collection/collectionRemove";var B=new Ajax(A,{method:"post",data:Json.toString(new Array(C,D)),onSuccess:function(E,F){if(String(E)=='["Success"]'){window.location.reload()}else{Log.logDebug("recvd at point response: "+String(E))}}});B.request()}function setDefaultView(E){var A=$("select_type").value;var G=$("select_view").value;var H=window.frames.table_frame;var D=H.document.sort;var B=D.sort_by_attr.value;var C="/cbi/collection/saveDefaultView";var F=new Ajax(C,{method:"post",data:Json.toString({"uuid":E,"filter":A,"view":G,"sort":B}),onSuccess:function(I,J){Log.logDebug("recvd at point response: "+String(I))}});F.request()}var DeleteConfirmer=new Class({options:{creatorId:"delete_confirmation",onComplete:Class.empty,url:"/cbi/collection/systemDelete",uuid:null},initialize:function(A){this.setOptions(A);this.node=$(this.options.creatorId);console.log("Got node: "+this.node);this.cancelButton=this.node.getElement("[id=cancel]");this.submitButton=this.node.getElement("[id=ok]");this.spinner=this.node.getElement("[id=spinner]");console.log("Got all ancillary elements");this.remoteCall=null;this.uuid=this.options.uuid;this.configure();this.registerhandlers()},configure:function(){},registerhandlers:function(){this.submitButton.removeEvents("click");this.submitButton.addEvent("click",(function(){this.submit()}).bind(this));this.cancelButton.removeEvents("click");this.cancelButton.addEvent("click",(function(){this.cancel()}).bind(this))},submit:function(){this.deleteEntity()},cancel:function(){this.hide()},show:function(){console.log("[delete confirmer] showing widget");var A=$("scroller");var B=null;if(!$defined(A)){B={x:0,y:0}}else{B=A.getPosition()}this.node.setStyles({display:"block",left:B.x+50,top:B.y+50});this.spinner.setStyles({display:"none"})},hide:function(){this.node.setStyle("display","none")},deleteEntity:function(){if(MooTools.version=="1.3.2"){this.remoteCall=new Request.JSON({url:this.options.url,method:"post",data:JSON.stringify([this.uuid]),autoCancel:true,onComplete:(function(A){var B=A[0];this.handleresponse(B)}).bind(this)});this.spinner.setStyles({display:"block"});this.remoteCall.send()}else{this.remoteCall=new Ajax(this.options.url,{method:"post",data:Json.toString([this.uuid]),autoCancel:true,onComplete:(function(A){var B=Json.evaluate(A)[0];this.handleresponse(B)}).bind(this)});this.spinner.setStyles({display:"block"});this.remoteCall.request()}},handleresponse:function(A){this.spinner.setStyle("display","none");if(A=="Success"){window.location.reload();this.hide()}else{this.hide()}}});DeleteConfirmer.implement(new Options,new Events);var DestroyGroupConfirmer=DeleteConfirmer.extend({options:{url:"/cbi/admin_manage/manage",creatorId:"delete_confirmation",onComplete:Class.empty,uuid:null},deleteEntity:function(){var A=new Array("destroy_group",this.options.group,null);var B=this;this.remoteCall=new Ajax(this.options.url,{method:"post",data:Json.toString(A),autoCancel:true,onComplete:function(C,D){B.handleresponse("Success")}});this.spinner.setStyles({display:"block"});this.remoteCall.request()}});function deleteEntity(B){var A=new DeleteConfirmer({uuid:B});A.show()}function removeFromViz(B,A){pageManager.removeDatasetFromSession(B);pageManager.remove(B)}function openDatasetBalloonStyle(E,D,A){if(!$defined(D)){D=pageManager.concept}var B="/cbi/template/present_template?session_uuid="+D+"&viz_rule_key="+E;if($defined(A)){B+="&record_uid="+A}var C=window.open(B,"template_binder","status=no,width=650px,height=860px,resizable=yes,scrollbars=yes",true);C.focus();return }function createNewCollectionAll(A){try{collectionMaker.options.onComplete=function(C){saveAllCollection(C,A)};collectionMaker.show()}catch(B){console.log("no local collectionMaker");parent.document.collectionMaker.options.onComplete=function(C){saveAllCollection(C,A)};parent.document.collectionMaker.show()}}function createNewCollection(A){try{collectionMaker.options.onComplete=function(C){saveToCollection(C,A)};collectionMaker.show()}catch(B){console.log("no local collectionMaker");parent.document.collectionMaker.options.onComplete=function(C){saveToCollection(C,A)};parent.document.collectionMaker.show()}}function createCollectionVizAll(A){collectionMaker.options.onComplete=function(B){saveAllViz(B,A)};collectionMaker.show()}function saveVisualization(A){namer.show({onSubmit:function(E,D,C){var B;console.log("op",E,"value",D);switch(E){case"save":B=new Ajax("/cbi/visualize/save",{method:"post",data:Json.toString({uuids:[A],render:false,name:D}),onSuccess:function(F){console.log("txt",F);var G=Json.evaluate(F)[0];C.hide();C._reset()}});C.loadingImg.setStyle("display","inline");B.request();break;default:console.assert(false,"unsupported opcode");break}}})}function createVisualization(D,A){if(!$defined(A)){A="map"}var C;var B=getScrimInstance();if(A=="map"){C=new Ajax("/cbi/visualize/create",{method:"post",data:Json.toString({uuids:[D],render:false,name:"Untitled"}),onSuccess:function(E){console.log("txt",E);var F=Json.evaluate(E)[0];top.location="/cbi/visualize/render?concept="+F}});B.show(true);C.request()}else{if(A=="chart"){C=new Ajax("/cbi/chartviz/createSession",{method:"post",data:Json.toString({dataset_uuid:D,name:"Untitled"}),onSuccess:function(E){console.log("txt",E);var F=Json.evaluate(E)[0]["uuid"];top.location="/cbi/chart-it/index?uuid="+F}});B.show(true);C.request()}}return }function copyVisualization(B){if(MooTools.version=="1.3.2"){var A=new Request.JSON({url:"/cbi/visualize/copy",data:JSON.stringify({concept:B,render:false}),onSuccess:function(C){var D=C[0];top.location="/cbi/visualize/render?concept="+D}}).send()}else{var A=new Ajax("/cbi/visualize/copy",{method:"post",data:Json.toString({concept:B,render:false}),onSuccess:function(C){console.log("txt",C);var D=Json.evaluate(C)[0];top.location="/cbi/visualize/render?concept="+D}}).request()}}function shareSnapshot(B){var A=new ShareSnapshot({uuid:B});A.show()}function shareCollection(A){var B=new ShareCollection({uuid:A});B.show()}function editBalloonStyle(A){A=A||{}}function synchronous_get(A){if(window.XMLHttpRequest){AJAX=new XMLHttpRequest()}else{AJAX=new ActiveXObject("Microsoft.XMLHTTP")}if(AJAX){AJAX.open("GET",A,false);AJAX.send();return AJAX.responseText}else{return false}}function createPresentationFromSnapshot(C,B,D){var A=synchronous_get("/cbi/presentation/new_presentation_from_snapshot?"+Object.toQueryString({"description":D,"uuid":C,"name":B}));console.log("result:",A);A=Json.evaluate(A)[0];top.location="/cbi/presentation/page?uuid="+A}function createPresentationFromCollection(C,B,D){var A=synchronous_get("/cbi/presentation/new_presentation_from_collection?"+Object.toQueryString({"description":D,"uuid":C,"name":B}));console.log("result:",A);A=Json.evaluate(A)[0];top.location="/cbi/presentation/page?uuid="+A}function createPresentationFromPresentation(C,B,D){var A=synchronous_get("/cbi/presentation/new_presentation_from_collection?"+Object.toQueryString({"description":D,"uuid":C,"name":B,"based_on":C}));console.log("result:",A);A=Json.evaluate(A)[0];top.location="/cbi/presentation/page?uuid="+A}
