1/* RunCommand - script.js */ 2/** 3* Clear id div contents. 4* 5* ChangeLog: 6* 2014/03/12: Fixed wait image deactivation after command execution 7* 2014/03/20: Added rcObjectId argument to argmap 8* 2014/03/30: Added toolbar facility to simply runcommand use 9*/ 10 11function rcDoDownload(filename) { 12 var url = window.location.href; 13 url=url.replace("http://",""); 14 var begin = url.indexOf("/"); 15 var end = url.indexOf("?")-8; // remove 8 characther for "doku.php" text. 16 url = url.substring(begin,end)+"lib/plugins/runcommand/"; 17 18 jQuery('DIV#rcResult'+id).wrapInner('<IMG SRC="'+url+'wait.gif" width="200px" height="75px">'); 19 20 var argmap = new Object(); 21 jQuery('FORM#rcform'+id+' hidden, FORM#rcform'+id+' input, FORM#rcform'+id+' select').each( 22 function (el) { 23 if (this.type != 'button') argmap[this.id]=this.value; 24 } 25 ); 26 location.href=url+'postaction.php' 27} 28 29function rcDoClear(id) { 30 jQuery('DIV#rcResult'+id).empty(); 31 jQuery('DIV#rcResult'+id).append(' '); 32} 33 34function rcDoLoad(id) { 35 var url = window.location.href; 36 url=url.replace("http://",""); 37 var begin = url.indexOf("/"); 38 var end = url.indexOf("?")-8; // remove 8 characther for "doku.php" text. 39 url = url.substring(begin,end)+"lib/plugins/runcommand/"; 40 41 jQuery('DIV#rcResult'+id).wrapInner('<IMG SRC="'+url+'wait.gif" width="200px" height="75px">'); 42 43 var argmap = new Object(); 44 argmap['rcObjectId']=id; 45 jQuery('FORM#rcform'+id+' hidden, FORM#rcform'+id+' input, FORM#rcform'+id+' select').each( 46 function (el) { 47 if (this.type != 'button') argmap[this.id]=this.value; 48 } 49 ); 50 //alert(JSON.stringify(argmap)); 51 jQuery.post(url+'postaction.php', argmap, 52 function(data){ jQuery('DIV#rcResult'+id).empty(); jQuery('DIV#rcResult'+id).wrapInner(data); } 53 ); 54} 55 56if (typeof window.toolbar !== 'undefined') { 57 var runcommand_arr = { 58 // 'insertion string as key' : '[path/]filename.extension of the icon' 59 "<runcommand>\ncommand|<command>\n</runcommand>\n": 'basetag.png', 60 "outputType|choice\n": 'outputtype.png', 61 "runButtonText|Execute Label\n": 'runbutton.png', 62 "cancelButtonText|Cancel Label\n": 'cancelbutton.png', 63 "arg_hidden|||hidden=Fixed value\n": 'hidden.png', 64 "arg_textbox|TextBox field|newline|text=Default value\n": 'textbox.png', 65 "arg_list|List field|newline|list=item1:label1;item2:label2;\n": 'list.png', 66 "arg_autocomp|Autocomplete field|newline|autocomplete=value1;value2;\n": 'autocomplete.png', 67 "arg_slider|Slider field|newline|slider=min:0;max:100;value:50;step:10;\n": 'slider.png', 68 "arg_spinner|Spinner field|newline|spinner=min:0;max:10;value:5;\n": 'spinner.png', 69 "arg_date|Date field|newline|date=format:dd/mm/yyyy;\n": 'date.png', 70 "<runcommand>\ncommand|<command>\noutputType|choice\nrunButtonText|Execute Label\ncancelButtonText|Cancel Label\narg_hidden|||hidden=Fixed value\narg_textbox|TextBox field|newline|text=Default value\narg_list|List field|newline|list=item1:label1;item2:label2;\narg_autocomp|Autocomplete field|newline|autocomplete=value1;value2;\narg_slider|Slider field|newline|slider=min:0;max:100;value:50;step:10;\narg_spinner|Spinner field|newline|spinner=min:0;max:10;value:5;\narg_date|Date field|newline|date=format:dd/mm/yyyy;\n</runcommand>": 'fullruncommand.png' 71 }; 72 73 toolbar[toolbar.length] = { 74 type: "picker", 75 title: "RunCommand", // localisation 76 icon: '../../plugins/runcommand/images/toolbar_16.png', //where in lib/images/toolbar/ the images are located 77 key: "r", //access key 78 list: runcommand_arr, 79 icobase: '../plugins/runcommand/images' 80 }; 81 82} // End - RunCommand script.js