dododidi
06-17-2009, 05:57 PM
Hi folks,
especially Venegal !!
TWO PROBLEMS:
I have come up with a problem regarding the onMouseUp in IE and FF.
Basicaly the problem is self explanatory if you take a look at this site : http://www.nigels.de/fia.html in both browser.
in FF it doesn't work, is there a way round this, it also has to be compatible with the following script:
if you can fix this for me first, I'll come to the second Problem which is somewhat more complicated.
function toggle(id, status){
document.getElementById(id).style.visibility = status;
}
function populateSearchField(){
var specialChars = "\\.+*?[^]$(){}=!<>|:,-=/";
var ignoreList = ["a", "the"];
var i, j, searchFld, keywords;
if (!(searchFld = document.getElementsByName('formcontent')[0])) return;
if (!(keywords = document.referrer.match(/[pq]=(.*?)&/))) return;
var preg_quote = function(str){return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");}
keywords = decodeURIComponent(keywords[1]).replace(new RegExp('[' + preg_quote(specialChars) + ']', 'g'), ' ').split(/[\+ ]/);
for (i = 0; i < keywords.length; i++){
for (j = 0; j < ignoreList.length; j++) if (!keywords[i] || (keywords[i] == ignoreList[j])) {
keywords.splice(i--, 1);
break;
}
}
searchFld.value = keywords.join(' ');
}
function keywordMatch(keywords, text) {
var result = 0;
for (var i in keywords) {
if (text.match(new RegExp("(^| )" + keywords[i] + "( |$)", "i"))) {
result++;
};
}
return result;
}
function showTextContent() {
var i, bestMatch, maxNumberOfMatches = 0;
var divs = document.getElementById("ts-1").getElementsByTagName('div');
var keywords = document.getElementsByName('formcontent')[0].value.split(' ');
for (i = 0; i < divs.length; i++) {
var div = divs[i];
var divcontent = div.lastChild.nodeValue;
if ((numberOfMatches = keywordMatch(keywords, divcontent)) > maxNumberOfMatches) {
maxNumberOfMatches = numberOfMatches;
bestMatch = div;
}
}
if (bestMatch)
bestMatch.onmouseover();
else {
alert("no match");
}
}
window.onload = function(){
populateSearchField();
showTextContent();
}
Thx
especially Venegal !!
TWO PROBLEMS:
I have come up with a problem regarding the onMouseUp in IE and FF.
Basicaly the problem is self explanatory if you take a look at this site : http://www.nigels.de/fia.html in both browser.
in FF it doesn't work, is there a way round this, it also has to be compatible with the following script:
if you can fix this for me first, I'll come to the second Problem which is somewhat more complicated.
function toggle(id, status){
document.getElementById(id).style.visibility = status;
}
function populateSearchField(){
var specialChars = "\\.+*?[^]$(){}=!<>|:,-=/";
var ignoreList = ["a", "the"];
var i, j, searchFld, keywords;
if (!(searchFld = document.getElementsByName('formcontent')[0])) return;
if (!(keywords = document.referrer.match(/[pq]=(.*?)&/))) return;
var preg_quote = function(str){return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");}
keywords = decodeURIComponent(keywords[1]).replace(new RegExp('[' + preg_quote(specialChars) + ']', 'g'), ' ').split(/[\+ ]/);
for (i = 0; i < keywords.length; i++){
for (j = 0; j < ignoreList.length; j++) if (!keywords[i] || (keywords[i] == ignoreList[j])) {
keywords.splice(i--, 1);
break;
}
}
searchFld.value = keywords.join(' ');
}
function keywordMatch(keywords, text) {
var result = 0;
for (var i in keywords) {
if (text.match(new RegExp("(^| )" + keywords[i] + "( |$)", "i"))) {
result++;
};
}
return result;
}
function showTextContent() {
var i, bestMatch, maxNumberOfMatches = 0;
var divs = document.getElementById("ts-1").getElementsByTagName('div');
var keywords = document.getElementsByName('formcontent')[0].value.split(' ');
for (i = 0; i < divs.length; i++) {
var div = divs[i];
var divcontent = div.lastChild.nodeValue;
if ((numberOfMatches = keywordMatch(keywords, divcontent)) > maxNumberOfMatches) {
maxNumberOfMatches = numberOfMatches;
bestMatch = div;
}
}
if (bestMatch)
bestMatch.onmouseover();
else {
alert("no match");
}
}
window.onload = function(){
populateSearchField();
showTextContent();
}
Thx