Skip to content

Commit

Permalink
- Fixed autosuggestions after adding Array.prototype.inArray
Browse files Browse the repository at this point in the history
- Some js code improvements
  • Loading branch information
alecpl committed Mar 4, 2011
1 parent b6ffc1d commit c81da36
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 40 deletions.
12 changes: 3 additions & 9 deletions img/ClickShowHideMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ClickShowHideMenu(id) {
if (nodes[i].className) {
if ("box1" == nodes[i].className.substr(0, 4)) {
nodes[i].id = id + "-" + tree.length;
tree[tree.length] = new Array();
tree[tree.length] = [];
eval('nodes[i].onmouseover = function() { self.box1over("'+nodes[i].id+'"); }');
eval('nodes[i].onmouseout = function() { self.box1out("'+nodes[i].id+'"); }');
eval('nodes[i].onclick = function() { self.box1click("'+nodes[i].id+'"); }');
Expand All @@ -47,7 +47,7 @@ function ClickShowHideMenu(id) {
}
if ("box2" == nodes[i].className.substr(0, 4)) {
nodes[i].id = id + "-" + tree.length;
tree[tree.length] = new Array();
tree[tree.length] = [];
eval('nodes[i].onmouseover = function() { self.box2over("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
eval('nodes[i].onmouseout = function() { self.box2out("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
}
Expand Down Expand Up @@ -172,14 +172,8 @@ function ClickShowHideMenu(id) {

var self = this;
this.id = id;
this.tree = new Array();
this.tree = [];
this.cookie = new Cookie();
this.id_openbox = "";
}

if (typeof String.prototype.trim == "undefined") {
String.prototype.trim = function() {
var s = this.replace(/^\s*/, "");
return s.replace(/\s*$/, "");
}
}
16 changes: 9 additions & 7 deletions img/autosuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function AutoSuggest(form,elem,uri,autosubmit) {
this.autosubmit = autosubmit;

//Arrow to store a subset of eligible suggestions that match the user's input
this.eligible = new Array();
this.eligible = [];

//The text input by the user.
this.inputText = null;
Expand Down Expand Up @@ -213,7 +213,7 @@ function AutoSuggest(form,elem,uri,autosubmit) {
var ul = document.createElement('ul');

//Create an array of LI's for the words.
for (i in this.eligible) {
for (var i=0, len=this.eligible.length; i<len; i++) {
var word = this.eligible[i];
var desc = (this.descriptions[i])?this.descriptions[i]:'';
var dest = (this.actions[i])?this.actions[i]:'';
Expand Down Expand Up @@ -303,12 +303,14 @@ function AutoSuggest(form,elem,uri,autosubmit) {
try { eval(xmlhttp.responseText); }
catch(x) { this.eligible = Array(); }

for (i in this.suggestions) {
var suggestion = this.suggestions[i];
if (this.suggestions) {
for (var i=0, len=this.suggestions.length; i<len; i++) {
var suggestion = this.suggestions[i];

if(suggestion.toLowerCase().indexOf(this.inputText.toLowerCase()) == "0") {
this.eligible[this.eligible.length] = suggestion;
}
if(suggestion.toLowerCase().indexOf(this.inputText.toLowerCase()) == "0") {
this.eligible[this.eligible.length] = suggestion;
}
}
}
};

Expand Down
16 changes: 8 additions & 8 deletions img/overlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
// PRE-INIT
// Ignore these lines, configuration is below.
////////
var olLoaded = 0;var pmStart = 10000000; var pmUpper = 10001000; var pmCount = pmStart+1; var pmt=''; var pms = new Array(); var olInfo = new Info('4.21', 1);
var olLoaded = 0;var pmStart = 10000000; var pmUpper = 10001000; var pmCount = pmStart+1; var pmt=''; var pms = []; var olInfo = new Info('4.21', 1);
var FREPLACE = 0; var FBEFORE = 1; var FAFTER = 2; var FALTERNATE = 3; var FCHAIN=4;
var olHideForm=0; // parameter for hiding SELECT and ActiveX elements in IE5.5+
var olHautoFlag = 0; // flags for over-riding VAUTO and HAUTO if corresponding
var olVautoFlag = 0; // positioning commands are used on the command line
var hookPts = new Array(), postParse = new Array(), cmdLine = new Array(), runTime = new Array();
var hookPts = [], postParse = [], cmdLine = [], runTime = [];
// for plugins
registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass');

Expand Down Expand Up @@ -960,7 +960,7 @@ function isExclusive(args) {

// Sets cellpadding style string value
function setCellPadStr(parameter) {
var Str='', j=0, ary = new Array(), top, bottom, left, right;
var Str='', j=0, ary = [], top, bottom, left, right;

Str+='padding: ';
ary=parameter.replace(/\s+/g,'').split(',');
Expand Down Expand Up @@ -1187,7 +1187,7 @@ function argToString(array, strtInd, argName) {

// Places a hook in the correct position in a hook point.
function reOrder(hookPt, fnRef, order) {
var newPt = new Array(), match, i, j;
var newPt = [], match, i, j;

if (!order || typeof order == 'undefined' || typeof order == 'number') return hookPt;

Expand Down Expand Up @@ -1435,10 +1435,10 @@ function runHook(fnHookTo, hookType) {
// Object for handling hooks.
function FunctionReference() {
this.ovload = null;
this.before = new Array();
this.after = new Array();
this.alt = new Array();
this.chain = new Array();
this.before = [];
this.after = [];
this.alt = [];
this.chain = [];
}

// Object for simple access to the overLIB version used.
Expand Down
4 changes: 2 additions & 2 deletions modules/customeradd.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
$descriptions[$row['item']] = escape_js($row['entries'].' '.trans('entries'));
}
if ($eglible) {
print preg_replace('/$/',"\");\n","this.eligible = new Array(\"".implode('","',$eglible));
print preg_replace('/$/',"\");\n","this.descriptions = new Array(\"".implode('","',$descriptions));
print "this.eligible = [\"".implode('","',$eglible)."\"];\n";
print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n";
} else {
print "false;\n";
}
Expand Down
4 changes: 2 additions & 2 deletions modules/nodeadd.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
$descriptions[$row['item']] = escape_js($row['entries'].' '.trans('entries'));
}
if ($eglible) {
print preg_replace('/$/',"\");\n","this.eligible = new Array(\"".implode('","',$eglible));
print preg_replace('/$/',"\");\n","this.descriptions = new Array(\"".implode('","',$descriptions));
print "this.eligible = [\"".implode('","',$eglible)."\"];\n";
print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n";
} else {
print "false;\n";
}
Expand Down
24 changes: 12 additions & 12 deletions modules/quicksearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ function macformat($mac)
}
header('Content-type: text/plain');
if ($eglible) {
print preg_replace('/$/',"\");\n","this.eligible = new Array(\"".implode('","',$eglible));
print preg_replace('/$/',"\");\n","this.descriptions = new Array(\"".implode('","',$descriptions));
print preg_replace('/$/',"\");\n","this.actions = new Array(\"".implode('","',$actions));
print "this.eligible = [\"".implode('","',$eglible)."\"];\n";
print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n";
print "this.actions = [\"".implode('","',$actions)."\"];\n";
} else {
print "false;\n";
}
Expand Down Expand Up @@ -209,9 +209,9 @@ function macformat($mac)
}
header('Content-type: text/plain');
if ($eglible) {
print preg_replace('/$/',"\");\n","this.eligible = new Array(\"".implode('","',$eglible));
print preg_replace('/$/',"\");\n","this.descriptions = new Array(\"".implode('","',$descriptions));
print preg_replace('/$/',"\");\n","this.actions = new Array(\"".implode('","',$actions));
print "this.eligible = [\"".implode('","',$eglible)."\"];\n";
print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n";
print "this.actions = [\"".implode('","',$actions)."\"];\n";
} else {
print "false;\n";
}
Expand Down Expand Up @@ -268,9 +268,9 @@ function macformat($mac)
}
header('Content-type: text/plain');
if ($eglible) {
print preg_replace('/$/',"\");\n","this.eligible = new Array(\"".implode('","',$eglible));
print preg_replace('/$/',"\");\n","this.descriptions = new Array(\"".implode('","',$descriptions));
print preg_replace('/$/',"\");\n","this.actions = new Array(\"".implode('","',$actions));
print "this.eligible = [\"".implode('","',$eglible)."\"];\n";
print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n";
print "this.actions = [\"".implode('","',$actions)."\"];\n";
} else {
print "false;\n";
}
Expand Down Expand Up @@ -322,9 +322,9 @@ function macformat($mac)
}
header('Content-type: text/plain');
if ($eglible) {
print preg_replace('/$/',"\");\n","this.eligible = new Array(\"".implode('","',$eglible));
print preg_replace('/$/',"\");\n","this.descriptions = new Array(\"".implode('","',$descriptions));
print preg_replace('/$/',"\");\n","this.actions = new Array(\"".implode('","',$actions));
print "this.eligible = [\"".implode('","',$eglible)."\"];\n";
print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n";
print "this.actions = [\"".implode('","',$actions)."\"];\n";
} else {
print "false;\n";
}
Expand Down

0 comments on commit c81da36

Please sign in to comment.