admmenu.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Right Context Menu configuration for admin users:
  2. Menu is built from four array items: title, link, show if page or headpage, show if namespace.
  3. Link is not created if it's 0, otherwise it's evaluated.
  4. Second array is displayed only in edit mode.
  5. Some usefull variables:
  6. node.hns = headpage id;
  7. node.isdir = node is namespace;
  8. node.dokuid = the DW id (namespace parent in case of headpage);
  9. id = the DW id of the selected node (headpage id in case of headpage);
  10. this.config.urlbase = Url Base;
  11. this.config.sepchar = Url separator;
  12. */
  13. var indexmenu_contextmenu=new Array(
  14. //Standard right menu
  15. new Array(
  16. '<b><em>Page action:</em></b>',0,1,0,
  17. '<b><em>Namespace action:</em></b>',0,0,1,
  18. 'New page here','"javascript: indexmenu_reqpage(\'"+this.config.urlbase+"\',\'"+this.config.sepchar+"\',\'"+node.dokuid+"\');"',1,1,
  19. 'Headpage here','"javascript: indexmenu_reqpage(\'"+this.config.urlbase+"\',\'"+this.config.sepchar+"\',\'"+node.dokuid+"\',\'"+node.name+"\');"',0,1,
  20. 'Edit','indexmenu_getid(this.config.urlbase,id)+"do=edit"',1,0,
  21. 'Search','"javascript: indexmenu_srchpage(\'"+this.config.urlbase+"\',\'"+this.config.sepchar+"\',\'"+node.isdir+"\',\'"+node.dokuid+"\');"',1,1,
  22. 'Toc preview','"javascript: indexmenu_createTocMenu(\'req=toc&id="+id+"\',\'picker_"+this.obj+"\',\'s"+this.obj+node.id+"\');"',1,0,
  23. 'Revisions','indexmenu_getid(this.config.urlbase,id)+"do=revisions"',1,0,
  24. 'Purge cache','indexmenu_getid(this.config.urlbase,id)+"purge=true"',1,0,
  25. 'Acls','indexmenu_getid(this.config.urlbase,id)+"do=admin&page=acl"',1,1
  26. ),
  27. //Right menu in edit mode.
  28. new Array(
  29. '<b><em>Edit action:</em></b>',0,1,0,
  30. 'Insert as DWlink','"javascript: indexmenu_insertTags(\'"+id+"\',\'"+this.config.sepchar+"\');"+this.obj+".divdisplay(\'r\',0);"',1,0
  31. )
  32. );
  33. /*Custom User Functions
  34. Insert your custom functions here.
  35. */
  36. function indexmenu_reqpage(b,s,id,n) {
  37. var r,u=b;
  38. if (n) {
  39. r = id + s + n;
  40. } else {
  41. r = prompt("Insert the pagename to create","");
  42. if (!r) {return;}
  43. r = id + s + r;
  44. }
  45. if (r) window.location.href = indexmenu_getid(u,r)+"do=edit";
  46. }
  47. function indexmenu_srchpage(u,s,isdir,nid) {
  48. var r = prompt("Insert keyword(s) to search for within this namespace","");
  49. if (r)
  50. {
  51. var fnid = nid;
  52. if (isdir == "0") {
  53. fnid = fnid.substring(0,nid.lastIndexOf(s));
  54. }
  55. var b=u,re = new RegExp(s, 'g');
  56. fnid = fnid.replace(re, ":");
  57. b += (u.indexOf("?id=") < 0) ? '?id=': '';
  58. window.location.href = indexmenu_getid(b,r+" @"+fnid)+"do=search";
  59. }
  60. }
  61. function indexmenu_getid(u,id) {
  62. var url=(u||'')+encodeURI(id||'');
  63. url += (u.indexOf("?") < 0) ? '?': '&';
  64. return url;
  65. }