function getController(){ var url=window.location.href; var parts=url.split('.cgi'); url=parts[0]; var parts=url.split('/'); var usecase=parts[parts.length-1]; return usecase; } function set_studio(id){ var url=window.location.href; //split by # var comment= url.split(/\#/); url=comment.shift(); comment=comment.join('#'); //split by ? var parts= url.split(/\?/); url=parts.shift(); //split by & parts=parts.join('?').split(/\&+/); var params=[]; if (parts.length>0){ for (index in parts){ //add all name value pairs but studio id var pair=parts[index]; if(! pair.match(/^studio_id=/)) params.push(pair); } } //add studio id if(id==null)id=-1; if(id=='')id=-1; params.push('studio_id='+id); //append parameters to url url+='?'+params.join('&'); if ((comment!=null)&&(comment!='')) url+='#'+comment; window.location.href=url; } function set_project(id){ var url=window.location.href; //split by # var comment= url.split(/\#/); url=comment.shift(); comment=comment.join('#'); //split by ? var parts= url.split(/\?/); url=parts.shift(); //split by & parts=parts.join('?').split(/\&+/); var params=[]; if (parts.length>0){ for (index in parts){ //add all name value pairs but project id var pair=parts[index]; if( (! pair.match(/^project_id=/)) && (! pair.match(/^studio_id=/)) )params.push(pair); } } //add project id if(id==null)id=-1; if(id=='')id=-1; params.push('project_id='+id); //append parameters to url url+='?'+params.join('&'); if ((comment!=null)&&(comment!='')) url+='#'+comment; window.location.href=url; } function contains(s,t){ if (s==false) return false; if (t==false) return false; return s.indexOf(t) != -1; } function updateContainer(id, url, callback){ if (id==null) return; if ($("#"+id).length==0) return; url = parseUrl(url); $("#"+id).load(url, callback); } function load(url){ window.location = parseUrl(url); } function parseUrl(uri){ if (uri.startsWith("/")) { uri = window.location.origin + uri; } else if (!uri.startsWith("http")) { var path = window.location.pathname.replace(/\/$/, ""); path = path.split("/"); path.pop(); uri = window.location.origin + path.join("/") + "/" + uri; } var url = new URL(uri); url.searchParams.append("_", Date.now()); return url.toString(); } function postContainer(url, parameters, callback){ if (url!='') $.post(url, parameters, callback); } // init getTextWidth function initTextWidth(){ if ($('#textWidth').length>0) return; $('#content').append('') } // get width of selected text function getTextWidth(s){ $("#textWidth").html(s); return $("#textWidth").width(); } // check width of all selected elements and set width to max of it function setTextWidth(select, minValue){ var maxWidth=minValue; $(select).each( function(){ var width=getTextWidth($(this).val())-8; if (width>maxWidth) maxWidth=width; } ); $(select).each( function(){ $(this).css('width', maxWidth); } ); } // trigger action on commit function commitAction (title, action){ if ( title == null ) { alert("missing title");return; } if ( action == null ) { alert("missing action");return; } showDialog({ title : 'Are you sure?

', buttons : { OK : function(){ action(); }, Cancel : function(){ $(this).parent().remove(); } } }); } function showDialog(options){ if ($("#dialog").length>0) $("#dialog").remove(); $("#content").append( '
' + (options.title ? '
'+options.title+'
' :'') + (options.content ? options.content :'') +'
' ); var dialog = $('#content #dialog'); if (options.width) dialog.css("width", options.width); if (options.height) dialog.css("height", options.height); if (options.buttons) { Object.keys(options.buttons).forEach( function (key) { var value = options.buttons[key]; dialog.append("