2 * Javascript for tagindex management
4 * @author Gina Haeussge, Michael Klier <dokuwiki@chimeric.de>
5 * @author Andreas Gohr <andi@splitbrain.org>
9 * Class to hold some values
11 function plugin_tagindex_class(){
18 var pl_si
= new plugin_tagindex_class();
19 pl_si
.sack
= new sack(DOKU_BASE
+ 'lib/plugins/tag/ajax.php');
20 pl_si
.sack
.AjaxFailedAlert
= '';
21 pl_si
.sack
.encodeURIString
= false;
24 * Display the loading gif
26 function plugin_tagindex_throbber(on
){
27 obj
= document
.getElementById('pl_si_throbber');
29 obj
.style
.visibility
='visible';
31 obj
.style
.visibility
='hidden';
36 * Gives textual feedback
38 function plugin_tagindex_status(text
){
39 obj
= document
.getElementById('pl_si_out');
44 * Callback. Gets the list of all pages
46 function plugin_tagindex_cb_clear(){
50 window
.setTimeout("plugin_tagindex_index()",1000);
52 plugin_tagindex_status(ok
);
54 window
.setTimeout("plugin_tagindex_clear()",5000);
59 * Callback. Gets the list of all pages
61 function plugin_tagindex_cb_pages(){
63 pl_si
.pages
= data
.split("\n");
64 pl_si
.count
= pl_si
.pages
.length
;
65 plugin_tagindex_status(pl_si
.pages
.length
+" pages found");
67 pl_si
.page
= pl_si
.pages
.shift();
68 window
.setTimeout("plugin_tagindex_clear()",1000);
72 * Callback. Gets the info if indexing of a page was successful
74 * Calls the next index run.
76 function plugin_tagindex_cb_index(){
79 pl_si
.page
= pl_si
.pages
.shift();
82 window
.setTimeout("plugin_tagindex_index()",1000);
84 plugin_tagindex_status(ok
);
86 window
.setTimeout("plugin_tagindex_index()",5000);
91 * Starts the indexing of a page.
93 function plugin_tagindex_index(){
95 plugin_tagindex_status('indexing<br />'+pl_si
.page
+'<br />('+pl_si
.done
+'/'+pl_si
.count
+')<br />');
96 pl_si
.sack
.onCompletion
= plugin_tagindex_cb_index
;
97 pl_si
.sack
.URLString
= '';
98 pl_si
.sack
.runAJAX('call=indexpage&page='+encodeURI(pl_si
.page
));
100 plugin_tagindex_status('finished');
101 plugin_tagindex_throbber(false);
108 function plugin_tagindex_clear(){
109 plugin_tagindex_status('clearing index...');
110 pl_si
.sack
.onCompletion
= plugin_tagindex_cb_clear
;
111 pl_si
.sack
.URLString
= '';
112 pl_si
.sack
.runAJAX('call=clearindex');
116 * Starts the whole index rebuild process
118 function plugin_tagindex_go(){
119 document
.getElementById('pl_si_gobtn').style
.display
= 'none';
120 plugin_tagindex_throbber(true);
122 plugin_tagindex_status('Finding all pages');
123 pl_si
.sack
.onCompletion
= plugin_tagindex_cb_pages
;
124 pl_si
.sack
.URLString
= '';
125 pl_si
.sack
.runAJAX('call=pagelist');
128 //Setup VIM: ex: et ts=4 enc=utf-8 :