Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start indexing once clear() function has returned

Avoid return ambiguous '1' on success
Respect colours from style.ini of template
  • Loading branch information...
commit ad1455d0bf3d741eefcaef1faed109bf32126ad7 1 parent 73c6efc
@MrBertie MrBertie authored
Showing with 37 additions and 32 deletions.
  1. +22 −22 ajax.php
  2. +12 −7 script.js
  3. +3 −3 style.css
View
44 ajax.php
@@ -31,9 +31,9 @@
//call the requested function
$call = 'ajax_'.$_POST['call'];
-if(function_exists($call)){
+if (function_exists($call)) {
$call();
-}else{
+} else {
print "The called function '".htmlspecialchars($call)."' does not exist!";
}
@@ -45,9 +45,9 @@
function ajax_pagelist(){
global $conf;
$data = array();
- search($data,$conf['datadir'],'search_allpages',array());
+ search($data,$conf['datadir'], 'search_allpages', array());
- foreach($data as $val){
+ foreach($data as $val) {
print $val['id']."\n";
}
}
@@ -55,18 +55,18 @@ function ajax_pagelist(){
/**
* Clear all index files
*/
-function ajax_clearindex(){
+function ajax_clearindex() {
global $conf;
// keep running
@ignore_user_abort(true);
// acquire a lock
- $lock = $conf['lockdir'].'/_indexer.lock';
- while(!@mkdir($lock)){
- if(time()-@filemtime($lock) > 60*5){
+ $lock = $conf['lockdir'] . '/_indexer.lock';
+ while (!@mkdir($lock)){
+ if (time()-@filemtime($lock) > 60*5) {
// looks like a stale lock - remove it
@rmdir($lock);
- }else{
+ } else {
print 'indexer is locked.';
exit;
}
@@ -77,9 +77,9 @@ function ajax_clearindex(){
io_saveFile($conf['indexdir'].'/pageword.idx','');
io_saveFile($conf['indexdir'].'/metadata.idx','');
$dir = @opendir($conf['indexdir']);
- if($dir!==false){
- while(($f = readdir($dir)) !== false){
- if(substr($f,-4)=='.idx' &&
+ if ($dir!==false) {
+ while (($f = readdir($dir)) !== false) {
+ if (substr($f,-4)=='.idx' &&
(substr($f,0,1)=='i' || substr($f,0,1)=='w'
|| substr($f,-6)=='_w.idx' || substr($f,-6)=='_i.idx' || substr($f,-6)=='_p.idx'))
@unlink($conf['indexdir']."/$f");
@@ -90,7 +90,7 @@ function ajax_clearindex(){
// we're finished
@rmdir($lock);
- print 1;
+ print 'true';
}
/**
@@ -99,11 +99,11 @@ function ajax_clearindex(){
* We're doing basicly the same as the real indexer but ignore the
* last index time here
*/
-function ajax_indexpage(){
+function ajax_indexpage() {
global $conf;
- if(!$_POST['page']){
- print 1;
+ if (!$_POST['page']) {
+ print 'true';
exit;
}
@@ -111,13 +111,13 @@ function ajax_indexpage(){
@ignore_user_abort(true);
// try to aquire a lock (newer releases do the locking in idx_addPage)
- if(INDEXER_VERSION < 4){
+ if (INDEXER_VERSION < 4){
$lock = $conf['lockdir'].'/_indexer.lock';
- while(!@mkdir($lock)){
- if(time()-@filemtime($lock) > 60*5){
+ while (!@mkdir($lock)){
+ if (time()-@filemtime($lock) > 60*5) {
// looks like a stale lock - remove it
@rmdir($lock);
- }else{
+ } else {
print 'indexer is locked.';
exit;
}
@@ -128,11 +128,11 @@ function ajax_indexpage(){
$success = idx_addPage($_POST['page'], false, false);
// we're finished
- if(INDEXER_VERSION < 4){
+ if (INDEXER_VERSION < 4){
io_saveFile(metaFN($id,'.indexed'),'');
@rmdir($lock);
}
- print ($success !== false) ? 1 : 0;
+ print ($success !== false) ? 'true' : '';
}
View
19 script.js
@@ -57,7 +57,7 @@ var plugin_searchindex = (function() {
jQuery.post(url, 'call=indexpage&page=' + encodeURI(page), function(response) {
var wait = 250;
var status = lang.indexed;
- if (response !== 1) {
+ if (response !== 'true') {
// either up-to-date or error: skipped
status = '<p class="status">' + lang.notindexed + '</p>';
}
@@ -89,10 +89,13 @@ var plugin_searchindex = (function() {
var clear = function() {
message(lang.clearing);
jQuery.post(url, 'call=clearindex', function(response) {
- if (response !== 1) {
+ if (response !== 'true') {
message(response);
// retry
window.setTimeout(clear,5000);
+ } else {
+ // start indexing
+ window.setTimeout(index,1000);
}
});
};
@@ -109,7 +112,7 @@ var plugin_searchindex = (function() {
throbber_on();
message(lang.finding);
jQuery.post(url, 'call=pagelist', function(response) {
- if (response != 1) {
+ if (response !== 'true') {
pages = response.split("\n");
count = pages.length;
message(lang.pages.replace(/%d/, pages.length));
@@ -118,10 +121,12 @@ var plugin_searchindex = (function() {
page = pages.shift();
// complete index rebuild?
- if (rebuild === true) clear();
-
- // start indexing
- window.setTimeout(index,1000);
+ if (rebuild === true) {
+ clear();
+ } else {
+ // just start indexing
+ window.setTimeout(index,1000);
+ }
} else {
finished();
}
View
6 style.css
@@ -19,8 +19,8 @@
float: left;
}
#plugin__searchindex .msg {
- color: #A0A0A0;
- border: 0px solid #D7D5D4;
+ color: __text__;
+ border: 0px solid __border__;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
@@ -39,7 +39,7 @@
font-weight: bold;
}
#plugin__searchindex .msg p.status {
- color: #D7D5D4;
+ color: __text_neu__;
font-style: italic;
}
Please sign in to comment.
Something went wrong with that request. Please try again.