1/* Right Context Menu configuration for anonymous 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
6   Some usefull variables:
7   node.hns = headpage id;
8   node.isdir = node is namespace;
9   node.dokuid = the DW id (namespace parent in case of headpage);
10   id = the DW id of the selected node (headpage id in case of headpage);
11   this.config.urlbase = Url Base;
12   this.config.sepchar = Url separator;
13*/
14
15var indexmenu_contextmenu=new Array(
16				    //Standard right menu
17				    new Array(
18					      '<b><em>Page action:</em></b>',0,1,0,
19					      '<b><em>Namespace action:</em></b>',0,0,1,
20					      'Search','"javascript: indexmenu_srchpage(\'"+this.config.urlbase+"\',\'"+this.config.sepchar+"\',\'"+node.isdir+"\',\'"+node.dokuid+"\');"',1,1,
21					      'Toc preview','"javascript: indexmenu_createTocMenu(\'req=toc&id="+id+"\',\'picker_"+this.obj+"\',\'s"+this.obj+node.id+"\');"',1,0,
22					      'Revisions','indexmenu_getid(this.config.urlbase,id)+"do=revisions"',1,0
23					      ),
24
25				    //Right menu in edit mode.
26				    new Array(
27					      '<b><em>Edit action:</em></b>',0,1,0,
28					      'Insert as DWlink','"javascript: indexmenu_insertTags(\'"+id+"\',\'"+this.config.sepchar+"\');"+this.obj+".divdisplay(\'r\',0);"',1,0,
29					      'Edit','indexmenu_getid(this.config.urlbase,id)+"do=edit"',1,0
30					      )
31				    );
32
33/*Custom User Functions
34Insert your custom functions here.
35*/
36
37function indexmenu_srchpage(u,s,isdir,nid) {
38    var r = prompt("Insert keyword(s) to search for within this namespace","");
39    if (r)
40        {
41	    var fnid = nid;
42	    if (isdir == "0") {
43		fnid = fnid.substring(0,nid.lastIndexOf(s));
44	    }
45	    var b=u,re = new RegExp(s, 'g');
46	    fnid = fnid.replace(re, ":");
47	    b += (u.indexOf("?id=") < 0) ? '?id=': '';
48	    window.location.href = indexmenu_getid(b,r+" @"+fnid)+"do=search";
49	}
50}
51
52function indexmenu_getid(u,id) {
53    var url=(u||'')+encodeURI(id||'');
54    url += (u.indexOf("?") < 0) ? '?': '&';
55    return url;
56}
57