1 2 var xcomSites; 3 var xcomHeaders; 4 var xcom_action_url; 5 var xcom_srch_str; 6 function xcom_localSave(a_id) { 7 8 var fn_sel = document.getElementById('xcom_sel'); 9 /* if function selected, apply function to remote file */ 10 if(fn_sel.selectedIndex > 0) { 11 xcom_setValue('xcom_pageid',a_id); 12 xmlrpc('xcom_action'); 13 return; 14 } 15 16 /* save remote file to local 17 * first ask if this is what is wanted 18 */ 19 if(a_id) { 20 xcom_setValue('xcom_pageid',a_id); 21 if(!window.confirm(JSINFO['savelocalfile'] + ' ' + a_id)) return; 22 } 23 24 var params = ""; 25 26 var id =a_id ? a_id : xcom_getInputValue('xcom_pageid'); 27 var params = 'id='+id; 28 29 var jobj = xcom_json_ini('xcom_localpwd','xcom_locuser'); 30 jobj['url'] = JSINFO['url']; 31 var str =JSON.stringify(jobj); 32 params +='&local=' + str; 33 34 var jobj = xcom_json_ini('xcom_pwd','xcom_url','xcom_user'); 35 str =JSON.stringify(jobj); 36 params +='&remote=' + str; 37 //if(!confirm("params: " + params)) return; 38 39 var status =new Array("Save remote: ("+ id + ") to Local wiki"); 40 xcom_query_status(status); 41 42 jQuery.ajax({ 43 url: DOKU_BASE + 'lib/plugins/xcom/scripts/xcom_save.php', 44 data: params, 45 type: 'POST', 46 dataType: 'html', 47 success: function(data) 48 { 49 data = decodeURIComponent(data); 50 xcom_show('xcom_results'); 51 xcom_print_data('dokuwiki.copy', data, false,""); 52 } 53 }); 54 } 55 56 function xmlrpc() { 57 var xcom_action = arguments.length ? 'xcom_action' : ""; 58 xcom_hide_all_views(xcom_action); 59 /* xcom_hide('xcom_action'); 60 xcom_hide('xcom_view'); 61 xcom_hide('xcom_pre_title'); 62 xcom_hide('xcom_htm_title'); 63 xcom_hide('xcom_editable_title'); 64 xcom_hide('xcom_action_title');*/ 65 xcom_action_url = xcom_getInputValue('xcom_url'); 66 xcom_action_url = xcom_action_url.replace(/[\/\\]$/,""); 67 xcom_action_url += '/doku.php?'; 68 69 xcom_clear('xcom_qstatus',false); 70 var options = xcom_params(); 71 72 var func = options[0]; 73 xcom_query_status(options); 74 75 var other=false; 76 var params = 'params=' + JSON.stringify(options); 77 params = params.replace(/\s*__comma__\s*/g,','); 78 if(typeof options[2] == 'object' && options[2] !== null ) { 79 try { 80 if(options[2].hasOwnProperty('hash')) { 81 other = 'hash'; 82 } 83 } catch(e) { 84 } 85 } 86 var array_types = {'dokuwiki.getPagelist':1,'plugin.xcom.pageVersions':1,'plugin.xcom.getPageInfo':1,'wiki.getAllPages':1, 'wiki.getAttachmentInfo':1,'wiki.getAttachments':1, 'wiki.getRecentChanges':1,'wiki.listLinks':1,'dokuwiki.search':1,'plugin.xcom.getMedia':1, 'plugin.xcom.listNamespaces':1,'wiki.getBackLinks':1,}; 87 var jobj = xcom_json_ini('xcom_pwd','xcom_url','xcom_user'); 88 str =JSON.stringify(jobj); 89 params += '&credentials=' + str; 90 params += '&debug=' + document.getElementById('xcom_debug').checked; 91 92 // if(!confirm(params)) return; 93 jQuery.ajax({ 94 url: DOKU_BASE + 'lib/plugins/xcom/scripts/xml.php', 95 data: params, 96 type: 'POST', 97 dataType: 'html', 98 success: function(data) 99 { 100 if(data.match(/XCOM_LAG/)) return; 101 if(!array_types.hasOwnProperty(func)) { 102 try { 103 data = decodeURIComponent(data); 104 } 105 catch(err){ 106 console.log("By-passed decoding string returned by " + func + ': ' + err.message ); 107 } 108 } 109 xcom_show('xcom_results'); 110 xcom_print_data(func, data,other,xcom_action); 111 } 112 }); 113 114 var fn_sel = document.getElementById('xcom_sel'); 115 fn_sel.selectedIndex = 0; 116 return false; 117 } 118 119 function xcom_print_data(fn, data,other,xcom_action) { 120 var id = 'xcom_pre'; 121 122 var table_calls = { 123 'dokuwiki_getPagelist': (other=='hash') ? ['id','rev', 'mtime' ,'size','hash'] : ['id','rev', 'mtime' ,'size'] , 124 'plugin_xcom_pageVersions': ['user','ip','type','sum','modified','version' ], 125 'plugin_xcom_getPageInfo': ['name','lastModified','author','version'], 126 'wiki_getAllPages': ['id', 'perms', 'size', 'lastModified'], 127 'dokuwiki_search': ['id', 'score', 'rev', 'mtime','size','snippet'], 128 'plugin_xcom_getMedia': ['Media files'], 129 'wiki_getAttachments': ['id','size','lastModified'], 130 'wiki_listLinks': ['type', 'page','href'], 131 'wiki_getAttachmentInfo': ['id','lastModified','size'], 132 'plugin_xcom_listNamespaces': ['Namespace Directories'], 133 'wiki_getBackLinks': ['Backlinks'], 134 'wiki_getRecentChanges': ['name', 'lastModified', 'author','version','size'], 135 'wiki_getBackLinks' : ['Backlinks'], 136 }; 137 xcomHeaders = table_calls; 138 139 switch(fn) 140 { 141 case 'wiki.getPage': // (string) raw Wiki text 142 case 'wiki.getPageVersion': // (string) raw Wiki text 143 id = 'xcom_editable' ; 144 break; 145 case 'plugin.xcom.GetMetaData': 146 case 'wiki.getPageHTML': // (string) rendered HTML 147 id = 'xcom_htm'; 148 break; 149 case 'dokuwiki.getPagelist': 150 case 'plugin.xcom.pageVersions': 151 case 'plugin.xcom.getPageInfo': 152 case 'wiki.getAllPages': 153 case 'dokuwiki.search': 154 case 'plugin.xcom.getMedia': 155 case 'wiki.getAttachments': 156 case 'wiki.listLinks': 157 case 'wiki.getAttachmentInfo': 158 case 'plugin.xcom.listNamespaces': 159 case 'wiki.getRecentChanges': 160 case 'wiki.getBackLinks': 161 id = xcom_action ? 'xcom_action':'xcom_htm'; 162 try { 163 var obj = jQuery.parseJSON(data); 164 } catch(e) { 165 id = 'xcom_pre'; // not a table, use code view, probably error msg 166 obj = decodeURIComponent(data); 167 break; 168 } 169 170 // handle tables 171 172 if(obj || fn == 'wiki.getBackLinks') 173 { 174 var fncall = fn.replace(/\./g,'_'); 175 data = xcom_thead(table_calls[fncall]); 176 if(fn == 'plugin.xcom.getPageInfo' || fn == 'wiki.getAttachmentInfo') { 177 data += xcom_hash(obj); //straight single hash 178 } 179 else if (fn == 'plugin.xcom.getMedia' || fn =='plugin.xcom.listNamespaces' 180 || fn == 'wiki.getBackLinks') { 181 data += xcom_onedim(obj); 182 } 183 else { 184 data+=xcom_multidim(obj,fn); // array of arrays 185 } 186 } 187 data += xcom_tclose(); //end tables 188 break; 189 case 'wiki.putPage': 190 case 'dokuwiki.appendPage': 191 id = 'xcom_editable'; 192 break; 193 default: 194 break; 195 } // end switch 196 197 var d = document.getElementById(id); 198 if(id == 'xcom_editable') { 199 xcom_setValue(id,data); 200 } 201 else { 202 d.innerHTML= data; 203 } 204 xcom_show(id); 205 var title = id + '_title'; 206 xcom_show(title); 207 } 208 209 function xcom_multidim(obj,func) { 210 var data = ""; 211 212 for(var i in obj) { 213 data +="\n<tr>"; 214 for(var j in obj[i]) { 215 var r = obj[i][j]; 216 if(j == 'lastModified' && func == 'wiki.getRecentChanges' 217 || j == 'modified' && func == 'plugin.xcom.pageVersions') { 218 r = obj[i]['version']; 219 var date_time = new Date(r * 1000); 220 var month = (date_time.getMonth() + 1) > 9 ? (date_time.getMonth() + 1) : '0' + (date_time.getMonth() + 1); 221 var day = date_time.getDate() > 9 ? date_time.getDate() : '0'+ date_time.getDate(); 222 r = date_time.getFullYear() + "-" + month + "-" + day + " " + date_time.getHours() + ":" + date_time.getMinutes() + ":" + date_time.getSeconds() 223 224 } 225 row = xcom_td(j,r,func); //type, value, function 226 if(row) data += row; 227 } 228 } 229 230 return data; 231 } 232 233 function xcom_hash(obj) { 234 var data ="\n<tr>"; 235 for(var i in obj) { 236 data += xcom_td(i,obj[i]); 237 } 238 return data; 239 } 240 241 function xcom_onedim(obj) { 242 var data ="\n<tr>"; 243 for(var i in obj) { 244 data += xcom_td(i,obj[i]) + "\n<tr>"; 245 } 246 return data; 247 } 248 249 function xcom_thead(args) { 250 var row = "<table class ='xcom_center'>\n<tr>"; 251 for (i=0; i<args.length; i++) { 252 row += '<th>' + args[i] + '</th>'; 253 } 254 return row + "</tr>\n"; 255 } 256 257 function xcom_td(type,val,fn) { 258 259 if(fn) 260 { 261 var is_header = false; 262 var fncall = fn.replace(/\./g,'_'); 263 var headers = xcomHeaders[fncall]; 264 for(var i = 0; i< headers.length; i++) { 265 if(type == headers[i]) { 266 is_header=true; 267 break; 268 } 269 } 270 if(!is_header) return; 271 } 272 273 //alert(type + '=' + val); 274 if(type == 'modified' || type == 'lastModified' && typeof val == 'object') { 275 // var min =val['minute'] ? val['minute'] : val['minute']; 276 if (typeof val !== 'undefined' && val['year']) { 277 var d = new Date( val['year'],val['month']-1,val['day'],val['hour'],val['minute'], val['second']); 278 val = d.toUTCString(); 279 } 280 281 } 282 else if(type == 'rev' || type == 'mtime') { 283 var d = new Date(val*1000); 284 val = d.toUTCString(); 285 } 286 else if(type == 'size') { 287 val += ' bytes'; 288 } 289 else if(type == 'id' && fn=='dokuwiki.search') { 290 return '<td class ="xcom_id">'+ xcom_search_url(val) +'</td>'; 291 } 292 else if(type == 'id' || type == 'href' || (type =='page' && fn == 'wiki.listLinks')) { 293 var display = val; 294 if(val.length > 40) { 295 var a = val.substring(0,40) + ". . . .<br />"; 296 var b = val.substring(40); 297 if(b.length > 7) { 298 display = a + ' ' + b; 299 } 300 } 301 if(type == 'id') { 302 return '<td><a href="javascript:xcom_localSave(\'' + val + '\');void 0;">' +display +'</a></td>'; 303 } 304 val =display; 305 } 306 else if(type == 'snippet') { 307 return '<tr><td class="xcom_none"> </td><td colspan = "4" class="xcom_snippet">' + val + '</td>'; 308 } 309 else if(type == 'title' && fn=='dokuwiki.search') return ""; //skip title, screws up the table design 310 if(typeof val == 'object') val = "none"; 311 return '<td>' + val + '</td>' 312 } 313 314 function xcom_tclose() { 315 return "</table>\n"; 316 } 317 318 function xcom_search_url(pageid) { 319 if ( typeof xcom_srch_str == 'undefined' ) { 320 xcom_srch_str =xcom_getInputValue('xcom_opts'); 321 } 322 var qs = '&'+ xcom_srch_opts(); 323 return '<a href = "' + xcom_action_url + 'id=' +pageid + qs +'" target = \"_blank\">' + pageid + '</a>'; 324 } 325 326 function xcom_srch_opts() { // for search function 327 var srch_str =xcom_getInputValue('xcom_opts'); 328 srch_str = srch_str.replace(/^\s+/,""); 329 srch_str = srch_str.replace(/\s+$/,""); 330 srch_str = srch_str.replace(/\s+\"/,'\"'); 331 srch_str = srch_str.replace(/\"\s+/,'\"'); 332 333 var tmp = srch_str.split('\"'); 334 if(tmp.length == 1) { 335 tmp = srch_str.split(/\s+/g); 336 } 337 var result = ""; 338 for(i=0; i<tmp.length; i++) { 339 if(tmp[i]) { 340 result += "s[]=" + tmp[i]; 341 if(tmp[i+1]) { 342 result += '&'; 343 } 344 } 345 } 346 result = result.replace(/=\s+/g, '='); 347 result = result.replace(/\s*&\s*/g, '&'); 348 return result; 349 } 350 function xcom_check_opts(fn,page,opts, tmp) { 351 page = page.trim(); 352 var regex; 353 var skip_opts_cnt = false; 354 switch(fn) { 355 case 'wiki.getAllPages': 356 case 'dokuwiki.getTitle': 357 if((!page || page.trim().length === 0) && !opts) { 358 return true; 359 } 360 xcom_err_msg('wrong_count',fn,'no_opts'); 361 return false; 362 case 'wiki.aclCheck': 363 skip_opts_cnt = true; 364 case 'wiki.getPage': 365 case 'plugin.xcom.getMedia': 366 case 'wiki.getAttachmentInfo': 367 case 'wiki.deleteAttachment': 368 case 'wiki.listLinks': 369 case 'wiki.getBackLinks': 370 case 'plugin.xcom.getPageInfo': 371 case 'wiki.getPageHTML': 372 if(opts && !skip_opts_cnt) { 373 xcom_err_msg('wrong_count',fn,'no_opts'); 374 return false; 375 } 376 377 if(page.match(/[^0-9a-z_\:\.\-]+/g)) { 378 xcom_err_msg('bad_id'); 379 return false; 380 } 381 return true; 382 383 case 'wiki.getRecentChanges': 384 case 'wiki.getRecentMediaChanges': 385 if(page || page.length) { 386 xcom_err_msg('wrong_count',fn, 'date_only'); 387 return false; 388 } 389 regex = RegExp('^\s*\\d\\d\\d\\d-\\d\\d-\\d\\d\s*$'); 390 opt = opts.trim(); 391 if(!regex.test(opt)) { 392 xcom_err_msg('date_err'); 393 return false; 394 } 395 break; 396 397 case 'dokuwiki.getPagelist': //(hash),(depth:n) 398 if(!opts) { 399 tmp.push({hash:1}); 400 } 401 if(!page) { 402 xcom_err_msg(fn,'param-err'); 403 return false; 404 } 405 break; 406 407 case 'dokuwiki.search': //string query 408 if(!opts) { 409 xcom_err_msg('srch_string'); 410 return false; 411 } 412 break; 413 case 'dokuwiki.appendPage': 414 case 'wiki.putPage': 415 if(!page) { 416 alert("Page id missing"); 417 return false; 418 } 419 var regex_m = RegExp('\(minor;\s*(1|true)\s*\)'); 420 var regex_s = RegExp('\\(sum;[\\w\\s\\d;\\.\\:\\[\\]\\{\\}]+\\)'); 421 if(regex_m.test(opts) || regex_s.test(opts)) break; 422 alert("needs sum or minor edit statement"); 423 return false; 424 425 break; 426 /* 427 428 case 'plugin.xcom.pageVersions': (string) [[doku>:pagename]] , (int) offset 429 break; 430 case 'wiki.getAttachments': (String) namespace, (array) options (#pattern#) 431 break; 432 case 'plugin.acl.addAcl': (String) scope, (String) user|@group 433 break; 434 case 'plugin.acl.delAcl':String) scope, (String) user|@group, (int) permission 435 break; 436 case 'plugin.xcom.listNamespaces':(String) namespace id, (Array) (id1;id2. . .) 437 break; */ 438 default: 439 440 } 441 return true; 442 } 443 444 function xcom_params() { 445 var params = new Array(),i=0; 446 var optstring = xcom_getInputValue('xcom_opts'); //Params from User-created Query/Options box 447 448 449 var opts = ""; 450 var matches; 451 optstring = optstring.replace(/\s+$/,""); 452 optstring = optstring.replace(/^\s+/,""); 453 optstring = optstring.replace(/;\s+/,";"); 454 455 optstring = optstring.replace(/\((.*?)\)/g,function(a) { 456 return a.replace(/,/g,' __comma__ '); 457 }); 458 459 optstring = optstring.replace(/\#(.*?)\#/g,function(a) { 460 return a.replace(/,/g,'__comma__'); 461 }); 462 463 if(optstring) opts = optstring.split(/,/); 464 465 466 for(var p=0; p<opts.length; p++) { 467 if(!opts[p] || !opts[p].match(/^\s*\(/)) break; 468 var isarray = xcom_getArray(opts[p]); 469 if(isarray) { 470 if(isarray[0] == 'hash') { 471 opts[p] ={'hash':'1'}; 472 break; 473 } 474 else if(isarray[0].match(/#/)) { 475 opts[p] ={'pattern' : isarray[0]}; 476 break; 477 } 478 else if(isarray[0].match(/sum/)) { 479 opts[p] ={'sum' : isarray[1]}; 480 break; 481 } 482 else if(matches = isarray[0].match(/minor/)) { 483 opts[p] ={'minor': isarray[1]}; 484 break; 485 } 486 else { 487 opts[p] =isarray; 488 break; 489 } 490 } 491 } 492 493 var fn_sel = document.getElementById('xcom_sel'); 494 495 for(var n=0; n<opts.length; n++) { 496 opts[n] = xcom_timeStamp(opts[n]); 497 } 498 499 if(fn_sel.selectedIndex > 0) { 500 params[i] = fn_sel.options[fn_sel.selectedIndex].value; 501 } 502 else 503 { 504 var regex = RegExp('(wiki|plugin|dokuwiki|xcom)\.'); 505 if(!optstring.match(regex)) { 506 xcom_err_msg('nofunc'); 507 return false; 508 } 509 else { 510 // alert(optstring); 511 } 512 return params[i] = opts; 513 } 514 var tmpar = new Array(); 515 var page = document.getElementById('xcom_pageid').value; 516 var opstatus = xcom_check_opts(params[i],page,optstring,tmpar); 517 if(tmpar.length > 0) { 518 opts = new Array(); 519 opts.push(tmpar[0]); 520 } 521 if(!opstatus) return false; 522 if(page) { 523 if(params[0] == 'dokuwiki.search') { // add page to search query 524 opts[0] = opts[0] + " " + page; 525 } 526 else params[++i] = page; 527 } 528 else { 529 if(params[0]=='plugin.xcom.listNamespaces') { 530 params[++i] = '0'; 531 } 532 } 533 if(params[0]=='wiki.putPage' || params[0]=='dokuwiki.appendPage') { 534 params[++i] = xcom_escape(xcom_getInputValue('xcom_editable')); 535 } 536 537 //assign options to parameter array 538 if(opts.length) { 539 for(j=0;j<opts.length;j++) { 540 opts[j] = xcom_timeStamp(opts[j]); 541 params[++i] = opts[j]; 542 } 543 } 544 545 return params; 546 } 547 548 function xcom_getArray(opt) { 549 550 if(!opt) return false; 551 var matches; 552 try{ 553 if(matches = opt.match(/\((.*?)\)/)) { 554 ar = matches[1].split(/;/); 555 return ar; 556 } 557 } 558 catch(e) { } 559 return false; 560 } 561 562 /* returns formatted timestamp if date, otherwise returns the option */ 563 function xcom_timeStamp(opt) { 564 try{ 565 if(opt.match(/\d\d\d\d-\d\d-\d\d/)) { 566 var d = new Date(opt); 567 var unixtime = parseInt(d.getTime() / 1000); 568 if(unixtime) { 569 unixtime += 86400; //needs added day for accurate time 570 return unixtime; 571 } 572 } 573 }catch(e) { 574 } 575 return opt; 576 } 577 578 function xcom_escape(data) { 579 data = data.replace(/&/g,"%26"); 580 return data; 581 } 582 /** 583 Format and output query on status line 584 */ 585 function xcom_query_status(options) { 586 587 if(typeof options != 'object' && !(options instanceof Array)) return; 588 589 var q = options.join(', '); 590 591 if(q.length > 70) { 592 q = q.substring(0,70) + '. . .'; 593 } 594 document.getElementById('xcom_qstatus').innerHTML = q; 595 596 } 597 598 function xcom_select(sel) { 599 var which =sel.options[sel.selectedIndex].value; 600 if(!which) return; 601 xcom_setValue('xcom_url',xcomSites[which]['url']); 602 xcom_setValue('xcom_pwd',xcomSites[which]['pwd']); 603 xcom_setValue('xcom_user',xcomSites[which]['user']); 604 } 605 606 function xcom_toggle(which) { 607 jQuery(which).toggle(); 608 var state = jQuery(which).css('display'); 609 if(state != 'none') { 610 xcom_show('xcom_results'); 611 } 612 var title = which + '_title'; 613 jQuery(title).toggle(); 614 } 615 616 function xcom_show(which) { 617 var d = document.getElementById(which); 618 if(d) d.style.display = 'block'; 619 } 620 621 function xcom_hide(which) { 622 var d = document.getElementById(which); 623 if(d) d.style.display = 'none'; 624 } 625 function xcom_hide_all_views(xcom_action) { 626 xcom_hide('xcom_editable'); 627 xcom_hide('xcom_pre'); 628 if(!xcom_action) { 629 xcom_hide('xcom_htm'); 630 } 631 xcom_hide('xcom_editable_title'); 632 xcom_hide('xcom_pre_title'); 633 xcom_hide('xcom_htm_title'); 634 xcom_hide('xcom_results'); 635 xcom_hide('xcom_action_title'); 636 } 637 638 function xcom_clear(which) { 639 if(which == 'xcom_editable') { 640 xcom_setValue(which,""); 641 return; 642 } 643 document.getElementById(which).innerHTML= ''; 644 if(arguments.length > 1) return; 645 xcom_hide(which); 646 } 647 /** 648 creates credentials array for Json encoding 649 */ 650 function xcom_json_ini() { 651 jobj = {}; 652 for (i=0; i<arguments.length; i++) { 653 var val = xcom_getInputValue(arguments[i]); 654 var key = (arguments[i].split(/_/))[1]; 655 key = key.replace(/local/,""); 656 key = key.replace(/loc/,""); 657 jobj[key] = val; 658 } 659 return jobj; 660 } 661 662 function xcom_getInputValue(item) { 663 var d = document.getElementById(item); 664 if(!d) return; 665 return d.value; 666 } 667 668 669 function xcom_setValue(item,val) { 670 var d = document.getElementById(item); 671 if(!d) return; 672 d.value = val; 673 } 674 675 /* used for checking options */ 676 function xcom_msg(msg) { 677 id ='xcom_pre'; 678 xcom_show('xcom_results'); 679 var d = document.getElementById(id); 680 d.innerHTML = msg; 681 xcom_show('xcom_pre'); 682 } 683 684 /** 685 JSON.stringify combines elements from both of below: 686 http://blogs.sitepointstatic.com/examples/tech/json-serialization/json-serialization.js 687 https://gist.github.com/chicagoworks/754454 688 */ 689 var JSON = JSON || {}; 690 // implement JSON.stringify serialization 691 JSON.stringify = JSON.stringify || function (obj) { 692 var t = typeof (obj); 693 if (t != "object" || obj === null) { 694 // simple data type 695 if (t == "string") obj = '"'+obj+'"'; 696 return String(obj); 697 } else { 698 699 // recurse array or object 700 var n, v, json = [], arr = (obj && obj.constructor == Array); 701 for (n in obj) { 702 v = obj[n]; 703 t = typeof(v); 704 if (obj.hasOwnProperty(n)) { 705 if (t == "string") { 706 v = '"' + v + '"'; 707 } else if (t == "object" && v !== null){ 708 v = jQuery.stringify(v); 709 } 710 711 json.push((arr ? "" : '"' + n + '":') + String(v)); 712 } 713 } 714 715 return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}"); 716 } 717 }; 718 719 720 jQuery( document ).ready(function() { 721 /* drop-down function menu with tool tips */ 722 /* xcom_query_types is array of xmlrpc functions below */ 723 var sel = document.getElementById('xcom_sel'); 724 if(sel) { 725 var titles = JSINFO['xcom_qtitles']; 726 for(i=0; i<xcom_query_types.length; i++) { 727 var text = xcom_query_types[i].match(/^plugin\./) ? xcom_query_types[i].replace(/^plugin\./,"") : (xcom_query_types[i].split('.'))[1]; 728 var newopt = new Option(text,xcom_query_types[i]); 729 if(titles[xcom_query_types[i]]) newopt.title = titles[xcom_query_types[i]]; 730 else newopt.title = xcom_query_types[i]; 731 sel.add(newopt); 732 } 733 734 var selsites = document.getElementById('xcom_selsites'); 735 if(selsites) { 736 xcomSites = JSINFO['xcom_sites']; 737 for (var i in xcomSites) { 738 var newopt = new Option(i,i); 739 selsites.add(newopt); 740 } 741 } 742 } // drop-down menu end 743 744 var img_path = DOKU_BASE + 'lib/plugins/xcom/images/'; 745 var eyes = { 746 'black': img_path + 'eye_blk.png', 747 'blue': img_path + 'eye_blue.png', 748 }; 749 750 jQuery("img").click(function () { 751 if(jQuery(this).attr("src").match(/eye_blue/)) { 752 var which = jQuery(this).attr("id").match(/loc/) ? "#xcom_localpwd" : "#xcom_pwd"; 753 jQuery(this).attr("src",eyes.black); 754 jQuery(which).attr("type","password"); 755 jQuery(this).attr("title",JSINFO['pwdview']); 756 } 757 else if(jQuery(this).attr("src").match(/eye_blk/)) { 758 var which = jQuery(this).attr("id").match(/loc/) ? "#xcom_localpwd" : "#xcom_pwd"; 759 jQuery(this).attr("src",eyes.blue); 760 jQuery(which).attr("type","text"); 761 jQuery(this).attr("title",JSINFO['pwdhide']); 762 } 763 }); 764 765 jQuery( "#xcom_eye" ).on( "mouseover", function() { 766 jQuery( this ).css( "cursor", "pointer" ); 767 }); 768 769 jQuery( "#xcom_eye" ).on( "mouseout", function() { 770 jQuery( this ).css( "cursor", "default" ); 771 }); 772 773 jQuery( "#xcom_loceye").on( "mouseover", function() { 774 jQuery( this ).css( "cursor", "pointer" ); 775 }); 776 777 jQuery( "#xcom_loceye" ).on( "mouseout", function() { 778 jQuery( this ).css( "cursor", "default" ); 779 }); 780 781 }); 782 783 function xcom_rollover(el,underline) { 784 if(underline) 785 el.style.textDecoration ='underline'; 786 else el.style.textDecoration = 'none'; 787 788 } 789 var xcom_query_types=new Array( 790 'dokuwiki.getPagelist', 791 'dokuwiki.search', 792 'dokuwiki.getTitle', 793 'dokuwiki.appendPage', 794 'wiki.aclCheck', 795 'wiki.getPage', 796 'wiki.getPageVersion', 797 'plugin.xcom.pageVersions', 798 'plugin.xcom.getPageInfo', 799 'wiki.getPageHTML', 800 'wiki.putPage', 801 'wiki.listLinks', 802 'wiki.getAllPages', 803 'wiki.getBackLinks', 804 'wiki.getRecentChanges', 805 'wiki.getAttachments', 806 'wiki.getAttachmentInfo', 807 'wiki.getRecentMediaChanges', 808 'plugin.acl.addAcl', 809 'plugin.acl.delAcl', 810 'plugin.xcom.getMedia', 811 'plugin.xcom.listNamespaces', 812 'plugin.xcom.GetMetaData', 813 ); 814 815 function xcom_err_msg() { 816 var i,msg=""; 817 if(arguments.length == 1) { 818 xcom_msg(LANG.plugins.xcom[arguments[0]]); 819 return; 820 } 821 822 for(i=0; i<arguments.length;i++) { 823 if(typeof LANG.plugins.xcom[arguments[i]] == 'undefined') { 824 msg += '<b>'+ arguments[i] + "</b> "; 825 } 826 else msg+=LANG.plugins.xcom[arguments[i]] + " "; 827 } 828 xcom_msg(msg); 829 }