home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 115
/
FreelogNo115-MaiJuin2013.iso
/
Internet
/
AvantBrowser
/
asetup.exe
/
_data
/
res
/
textfunc.tpl
< prev
next >
Wrap
Text File
|
2013-04-03
|
37KB
|
1,090 lines
var avtBrowserInfo = {
check: function(r) {
return r.test(this.ua);
},
init: function()
{
this.ua = navigator.userAgent.toLowerCase();
this.isChrome = this.check(/chrome/);
this.isIE = this.check(/msie/);
this.isIE6 = this.check(/msie 6/);
this.isIE7 = this.check(/msie 7/);
this.isIE8 = this.check(/msie 8/);
this.isIE9 = this.check(/msie 9/);
this.isIE10 = this.check(/msie 10/);
this.isWebKit = this.check(/webkit/);
this.isGecko = !this.isWebKit && this.check(/gecko/);
this.browserID = 0;
if (navigator.appName === 'Netscape')
{
if (this.ua.lastIndexOf('firefox/') > 0)
this.browserID = 1;
else if (this.ua.lastIndexOf('chrome/') > 0)
this.browserID = 2;
}
}
};
avtBrowserInfo.init();
var avtFindingVar = {
currentFindDoc: null,
isHighlight: false,
isFindAsSentence: false,
isIgnoreCase: true,
isFirstFind: true,
matchCount: 0,
keywords: "",
keywordsArray: [],
avantTagArray: [],
tagName: "mark", //span for ie678;
color: ['Yellow', 'Red', 'Aqua', 'Fuchsia', 'Blue', 'Lime'],
bkColor: ['Red', 'Aqua', 'Fuchsia', 'Blue', 'Lime', 'Yellow'],
notFoundKeywords: "",
lastFoundKeywords: "",
Recursive: false,
init: function()
{
if (avtBrowserInfo.isIE)
{
if ((avtBrowserInfo.isIE6) || (avtBrowserInfo.isIE7) || (avtBrowserInfo.isIE8))
avtBrowserInfo.tagName = "span";
else
avtBrowserInfo.tagName = "mark";
}
else
avtBrowserInfo.tagName = "mark";
}
};
avtFindingVar.init();
var avtUtility = {
GetWindow: function()
{
if(avtBrowserInfo.isGecko)
return gBrowser.contentWindow;
else
return window;
},
GetDocument: function()
{
if(avtBrowserInfo.isGecko)
return gBrowser.contentWindow.document;
else
return document;
},
trim: function(str)
{
for (var i = 0; i < str.length && str.charAt(i) === " "; i++)
;
for (var j = str.length; j > 0 && str.charAt(j - 1) === " "; j--)
;
if (i > j)
return "";
return str.substring(i, j);
},
isAvantTag: function(obj)
{
if (obj.getAttribute("isAvant") == "1")
return true;
else
return false;
},
markAvantTag: function(obj)
{
obj.setAttribute("isAvant", "1");
},
AvantStripVowelAccent: function(str)
{
var rExps = [/[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
/[\xD9-\xDB]/g, /[\xF9-\xFB]/g];
var repChar = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'];
for (var i = 0; i < rExps.length; ++i)
str = str.replace(rExps[i], repChar[i]);
return str;
},
EmptyArray: function(arrayObj)
{
for (var i = arrayObj.length - 1; i >= 0; i--)
{
var obj = arrayObj.pop();
obj = null;
}
},
SplitKeywordsBySpace: function()
{
var strs = new Array();
strs = avtFindingVar.keywords.split(" ");
this.EmptyArray(avtFindingVar.keywordsArray);
for (var i = 0; i < strs.length; i++)
{
if ((strs[i] !== "\"") && (strs[i] !== "\'"))
{
strs[i] = strs[i].replace("\"", "");
strs[i] = strs[i].replace("\'", "");
strs[i] = strs[i].replace(",", "");
strs[i] = strs[i].replace("\\", "");
strs[i] = strs[i].replace("/", "");
strs[i] = strs[i].replace(".", "");
strs[i] = strs[i].replace("(", "");
strs[i] = strs[i].replace(")", "");
strs[i] = this.trim(strs[i]);
if(strs[i] !== "")
avtFindingVar.keywordsArray.push(strs[i]);
}
}
this.EmptyArray(strs);
},
FindNextDoc: function(currentDoc, direction)
{
if (this.Undefined(currentDoc))
return null;
var win = null;
if (avtBrowserInfo.isIE)
win = currentDoc.parentWindow;
else
win = currentDoc.defaultView;
if (direction > 0)
{
if ((this.NotUndefined(win.frames)) && (win.frames.length > 0))
{
var doc = null;
if (avtBrowserInfo.isGecko)
{
if (this.NotUndefined(win.frames[0].document))
doc = win.frames[0].document;
else
doc = win.frames[0].contentDocument;
}
else
doc = win.frames[0].document;
if (this.NotUndefined(doc))
return doc;
else
return null;
}
else
{
return this.FindNextDocEx(currentDoc, direction);
}
}
else
{
var doc = this.FindNextDocEx(currentDoc, direction);
if (this.NotUndefined(doc))
return doc;
else
{
if (this.Undefined(win))
return null;
if (this.NotUndefined(win.parent) &&
((win.name !== win.parent.name) ||
(win.document.URL !== win.parent.document.URL)))
return win.parent.document;
else
return null;
}
}
},
FindNextDocEx: function(currentDoc, direction)
{
var F = false;
var doc = null;
var win = null;
if (avtBrowserInfo.isIE)
win = currentDoc.parentWindow;
else
win = currentDoc.defaultView;
if (this.Undefined(win))
return null;
if (this.NotUndefined(win.parent) &&
((win.name !== win.parent.name) ||
(win.document.URL !== win.parent.document.URL)))
{
if (direction > 0)
{
for (var n = 0; n <= win.parent.frames.length - 2; n++)
{
if (avtBrowserInfo.isGecko)
{
if (this.NotUndefined(win.parent.frames[n].document))
doc = win.parent.frames[n].document;
else
doc = win.parent.frames[n].contentDocument;
}
else
doc = win.parent.frames[n].document;
if (this.NotUndefined(doc))
{
var tmpWin = null;
if (avtBrowserInfo.isIE)
tmpWin = doc.parentWindow;
else
tmpWin = doc.defaultView;
if ((tmpWin.name === win.name) &&
(doc.URL === win.document.URL) &&
(doc == win.document))
{
if (avtBrowserInfo.isGecko)
{
if (this.NotUndefined(win.parent.frames[n + 1].document))
doc = win.parent.frames[n + 1].document;
else
doc = win.parent.frames[n + 1].contentDocument;
}
else
doc = win.parent.frames[n + 1].document;
if (this.NotUndefined(doc))
{
F = true;
break;
}
}
}
}
}
else
{
for (var n = 1; n <= win.parent.frames.length - 1; n++)
{
if (avtBrowserInfo.isGecko)
{
if(this.NotUndefined(win.parent.frames[n].contentDocument))
doc = win.parent.frames[n].contentDocument;
else
doc = win.parent.frames[n].document;
}
else
doc = win.parent.frames[n].document;
if (this.NotUndefined(doc))
{
var tmpWin = null;
if (avtBrowserInfo.isIE)
tmpWin = doc.parentWindow;
else
tmpWin = doc.defaultView;
if ((tmpWin.name === win.name) &&
(doc.URL === win.document.URL) &&
(doc == win.document))
{
if (avtBrowserInfo.isGecko)
{
if(this.NotUndefined(win.parent.frames[n - 1].contentDocument))
doc = win.parent.frames[n - 1].contentDocument;
else
doc = win.parent.frames[n - 1].document;
}
else
doc = win.parent.frames[n - 1].document;
if (this.NotUndefined(doc))
{
F = true;
break;
}
}
}
}
}
if (!F)
{
doc = win.parent.document;
if (direction > 0)
return this.FindNextDocEx(doc, direction);
}
}
else
doc = null;
return doc;
},
NotUndefined: function(obj)
{
if ((obj === null) || (typeof(obj) === 'undefined'))
return false;
else
return true;
},
Undefined: function(obj)
{
return !this.NotUndefined(obj);
},
RebuildSelection: function(win, range)
{
var selection = win.getSelection();
var rangeCopy = range.cloneRange();
if ((rangeCopy.endOffset == rangeCopy.startOffset) &&
this.NotUndefined(rangeCopy.commonAncestorContainer))
{
if ((rangeCopy.commonAncestorContainer.nodeType == 1) &&
(rangeCopy.commonAncestorContainer.childNodes.length > rangeCopy.startOffset))
{
var oEle = rangeCopy.commonAncestorContainer.childNodes[rangeCopy.startOffset];
if( (this.NotUndefined(oEle)) && (oEle.nodeType == 1) &&
(oEle.tagName.toLowerCase() == "input") && (oEle.type == "text"))
{
var oTextBox = range.commonAncestorContainer.childNodes[rangeCopy.startOffset];
if(oEle.selectionStart !== oEle.selectionEnd)
oTextBox.setSelectionRange(oEle.selectionStart, oEle.selectionEnd);
else
oTextBox.setSelectionRange(0, oEle.value.length);
}
else
selection.addRange(range);
}
else
selection.addRange(range);
}
else
selection.addRange(range);
rangeCopy.detach();
return selection;
},
FindNearestKeywords: function(win, matchCase, searchUpward)//chrome,ff
{
var results = [];
var selection = win.getSelection();
var curRange = null;
if (this.NotUndefined(selection) && (selection.rangeCount > 0))
curRange = selection.getRangeAt(0);
for (var i = 0; i < avtFindingVar.keywordsArray.length; i++)
{
var keywords = avtFindingVar.keywordsArray[i];
if (this.NotUndefined(selection))
{
selection.removeAllRanges();
if (this.NotUndefined(curRange))
{
this.RebuildSelection(win, curRange);
if(searchUpward)
selection.collapseToStart();
else
selection.collapseToEnd();
}
}
var bFound = false;
try{
bFound = win.find(keywords, matchCase, searchUpward, false, false, false, false);
}
catch(e)
{
//alert(e);
}
if (bFound)
{
if (this.NotUndefined(selection))
selection = win.getSelection();
if (selection.rangeCount > 0)
{
var keywordRange = selection.getRangeAt(0);
if (this.NotUndefined(keywordRange))
results.push({"range": keywordRange, "keyword": keywords});
}
}
}
var miniPosIdx = 0;
var ret = null;
if (results.length >= 1)
{
for (var i = 1; i < results.length; i++)
{
if (!searchUpward)
{
if (results[miniPosIdx].range.compareBoundaryPoints(0, results[i].range) === 1)
{
results[miniPosIdx].range.detach();
miniPosIdx = i;
}
else
results[i].range.detach();
}
else
{
if (results[miniPosIdx].range.compareBoundaryPoints(2, results[i].range) === -1)
{
results[miniPosIdx].range.detach();
miniPosIdx = i;
}
else
results[i].range.detach();
}
}
ret = {"range": results[miniPosIdx].range, "keyword": results[miniPosIdx].keyword};
}
else
ret = null;
if (this.NotUndefined(ret) && this.NotUndefined(ret.range))
{
selection.removeAllRanges();
//this.RebuildSelection(win, ret.range);
if (this.NotUndefined(curRange))
{
this.RebuildSelection(win, curRange);
if(searchUpward)
selection.collapseToStart();
else
selection.collapseToEnd();
}
try{
bFound = win.find(ret.keyword, matchCase, searchUpward, false, false, false, false);
}
catch(e)
{
//alert(e);
}
}
this.EmptyArray(results);
results = null;
return ret;
},
FindNearestKeywordsIE: function(direction, flag, currentDoc)
{
var results = [];
for (var i = 0; i < avtFindingVar.keywordsArray.length; i++)
{
var keywords = avtFindingVar.keywordsArray[i];
var textRangeCopy = currentDoc.parentWindow["textRange"].duplicate();
bFound = textRangeCopy.findText(keywords, direction, flag);
if (bFound)
results.push({"textRange": textRangeCopy, "keyword": keywords});
else
delete textRangeCopy;
}
var miniPosIdx = 0;
var ret = null;
if (results.length >= 1)
{
for (var i = 1; i < results.length; i++)
{
if (direction > 0)
{
if (results[miniPosIdx].textRange.compareEndPoints("StartToStart", results[i].textRange) == 1)
miniPosIdx = i;
}
else
{
if (results[miniPosIdx].textRange.compareEndPoints("EndToEnd", results[i].textRange) == -1)
miniPosIdx = i;
}
}
ret = {"textRange": results[miniPosIdx].textRange, "keyword": results[miniPosIdx].keyword};
}
else
ret = null;
this.EmptyArray(results);
results = null;
return ret;
},
PosNearestKeywords: function(text)
{
var tmpText = text;
if (avtFindingVar.isIgnoreCase)
tmpText = tmpText.toLowerCase();
var results = [];
for (var i = 0; i < avtFindingVar.keywordsArray.length; i++)
{
var pos = tmpText.indexOf(avtFindingVar.keywordsArray[i]);
var styleIdx = i % avtFindingVar.color.length;
results.push({"pos": pos, "keyword": avtFindingVar.keywordsArray[i], "styleIdx": styleIdx});
}
var miniPosIdx = 0;
var ret = null;
if (results.length > 1)
{
for (var i = 1; i < results.length; i++)
{
if (results[miniPosIdx].pos === -1)
miniPosIdx = i;
else if ((results[miniPosIdx].pos > results[i].pos) && (results[i].pos >= 0))
miniPosIdx = i;
}
ret = {"pos": results[miniPosIdx].pos, "keyword": results[miniPosIdx].keyword, "styleIdx": results[miniPosIdx].styleIdx};
}
else
ret = {"pos": results[0].pos, "keyword": results[0].keyword, "styleIdx": results[0].styleIdx};
this.EmptyArray(results);
results = null;
return ret;
},
DressUp: function(obj, styleIdx)
{
var color = avtFindingVar.color[styleIdx];
var bgColor = avtFindingVar.bkColor[styleIdx];
if (!avtBrowserInfo.isIE)
obj.style.display = "inline-block";
obj.style.marginLeft = "0px";
obj.style.marginRight = "0px";
obj.style.marginTop = "0px";
obj.style.marginBottom = "0px";
obj.style.paddingLeft = "0px";
obj.style.paddingTop = "0px";
obj.style.paddingRight = "0px";
obj.style.paddingBottom = "0px";
obj.style.width = "auto";
obj.style.height = "auto";
obj.style.color = color;
obj.style.textIndent = "0px";
obj.style.backgroundColor = bgColor;
},
FindInDoc: function(currentDoc, direction, isFirstFind)
{
var bFound = false;
var matchCase = !avtFindingVar.isIgnoreCase;
avtFindingVar.currentFindDoc = currentDoc;
if (avtBrowserInfo.browserID !== 0)
{
if (this.GetWindow().find)
{
var searchUpward = false;
if (direction > 0)
searchUpward = false;
else
searchUpward = true;
var win = currentDoc.defaultView;
var ret = this.FindNearestKeywords(win, matchCase, searchUpward);
if (this.NotUndefined(ret))
bFound = true;
}
}
else
{
if (currentDoc.body && currentDoc.body.createTextRange)
{
if (this.Undefined(currentDoc.parentWindow["textRange"]) || (isFirstFind))
{
currentDoc.parentWindow["textRange"] = currentDoc.body.createTextRange();
currentDoc.parentWindow["textRange"].setEndPoint("EndToStart", currentDoc.parentWindow["textRange"]);
}
else
{
currentDoc.parentWindow["textRange"].execCommand("UnSelect", true, "");
if (direction > 0)
currentDoc.parentWindow["textRange"].setEndPoint("StartToEnd", currentDoc.parentWindow["textRange"]);
else
currentDoc.parentWindow["textRange"].setEndPoint("EndToStart", currentDoc.parentWindow["textRange"]);
}
var flag = 0;
if (matchCase)
flag = flag + 4;
if (direction <= 0)
flag = flag + 1;
var ret = this.FindNearestKeywordsIE(direction, flag, currentDoc);
if (this.NotUndefined(ret) && this.NotUndefined(ret.textRange))
{
bFound = true;
currentDoc.parentWindow["textRange"] = ret.textRange;
currentDoc.parentWindow["textRange"].select();
}
}
}
return bFound;
},
HasBodyTag: function(doc)
{
var oBodyList = doc.getElementsByTagName("body");
if (this.Undefined(oBodyList))
return false;
else if (oBodyList.length <= 0)
return false;
else if (oBodyList[0].tagName.toLowerCase() === "frameset")
return false;
else
return true;
},
ResetFindCursor: function()
{
var doc = this.GetDocument();
if (avtBrowserInfo.isIE)
{
doc.parentWindow["textRange"] = null;
if(avtFindingVar.Recursive)
{
while (this.NotUndefined(doc))
{
doc = this.FindNextDoc(doc, 1);
while (this.NotUndefined(doc) && this.Undefined(doc.body))
doc = this.FindNextDoc(doc, 1);
if (this.NotUndefined(doc) && this.NotUndefined(doc.body))
{
doc.parentWindow["textRange"] = null;
}
else
break;
}
}
}
else
{
this.ClearSelection(doc);
if(avtFindingVar.Recursive)
{
while (this.NotUndefined(doc))
{
doc = this.FindNextDoc(doc, 1);
while (this.NotUndefined(doc) && this.Undefined(doc.body))
doc = this.FindNextDoc(doc, 1);
if (this.NotUndefined(doc) && this.NotUndefined(doc.body))
{
this.ClearSelection(doc);
}
else
break;
}
}
}
avtFindingVar.currentFindDoc = null;
},
ClearSelection: function(doc)
{
if (this.NotUndefined(doc) && this.NotUndefined(doc.defaultView))
{
var s = doc.defaultView.getSelection();
if(this.NotUndefined(s))
s.removeAllRanges();
}
},
Find: function(keywords, isFindAsSentence, direction, matchCase, isFirstFind)
{
avtFindingVar.isFindAsSentence = isFindAsSentence;
avtFindingVar.isIgnoreCase = !matchCase;
if (avtFindingVar.isIgnoreCase)
avtFindingVar.keywords = keywords.toLowerCase();
else
avtFindingVar.keywords = keywords;
//prepare keywords array
if (!isFindAsSentence)
this.SplitKeywordsBySpace();
else
{
this.EmptyArray(avtFindingVar.keywordsArray);
avtFindingVar.keywordsArray.push(avtFindingVar.keywords);
}
var bFound = false;
var currentDoc = this.GetDocument();
//remove all textranges
if (isFirstFind == true)
{
this.ResetFindCursor();
}
else if (this.NotUndefined(avtFindingVar.currentFindDoc))
currentDoc = avtFindingVar.currentFindDoc;
var bFound = this.FindInDoc(currentDoc, direction, isFirstFind);
if(avtFindingVar.Recursive)
{
while (!bFound)
{
currentDoc = this.FindNextDoc(currentDoc, direction);
while (this.NotUndefined(currentDoc) && (!this.HasBodyTag(currentDoc)))
currentDoc = this.FindNextDoc(currentDoc, direction);
if (this.NotUndefined(currentDoc) && this.HasBodyTag(currentDoc))
{
bFound = this.FindInDoc(currentDoc, direction, isFirstFind);
}
else
break;
}
}
return bFound;
},
Highlight: function(keywords, isFindAsSentence, isIgnoreCase)
{
avtFindingVar.isFindAsSentence = isFindAsSentence;
avtFindingVar.isIgnoreCase = isIgnoreCase;
if (isIgnoreCase)
avtFindingVar.keywords = keywords.toLowerCase();
else
avtFindingVar.keywords = keywords;
if (!isFindAsSentence)
this.SplitKeywordsBySpace();
else
{
this.EmptyArray(avtFindingVar.keywordsArray);
avtFindingVar.keywordsArray.push(avtFindingVar.keywords);
}
var currentDoc = this.GetDocument();
avtFindingVar.matchCount = 0;
this.HighlightInDoc(currentDoc);
if(avtFindingVar.Recursive)
{
while (this.NotUndefined(currentDoc))
{
currentDoc = this.FindNextDoc(currentDoc, 1);
while (this.NotUndefined(currentDoc) && this.Undefined(currentDoc.body))
currentDoc = this.FindNextDoc(currentDoc, 1);
if (this.NotUndefined(currentDoc) && this.NotUndefined(currentDoc.body))
{
this.HighlightInDoc(currentDoc);
}
else
break;
}
}
return avtFindingVar.matchCount;
},
HighlightInNode: function(node, currentDoc)
{
if (this.Undefined(node))
return 0;
if (node.hasChildNodes)
{
for (var i = 0; i < node.childNodes.length; i++)
{
if (this.HighlightInNode(node.childNodes[i], currentDoc) == 1)
i++;
}
}
if (node.nodeType == 3)
{
var text = this.GetTransformedValue(node);
var findResult = this.PosNearestKeywords(text);
if (findResult.pos !== -1)
{
var nv = node.nodeValue;
var ni = findResult.pos;
var before = currentDoc.createTextNode(nv.substr(0, ni));
var docWordVal = nv.substr(ni, findResult.keyword.length);
var after = currentDoc.createTextNode(nv.substr(ni + findResult.keyword.length));
var hiwordtext = currentDoc.createTextNode(docWordVal);
var hiword = currentDoc.createElement(avtFindingVar.tagName);
hiword.id = "avantTag_" + avtFindingVar.matchCount;
hiword.appendChild(hiwordtext);
this.DressUp(hiword, findResult.styleIdx);
var pn = node.parentNode;
before = pn.insertBefore(before, node);
hiword = pn.insertBefore(hiword, node);
this.markAvantTag(hiword);
after = pn.insertBefore(after, node);
pn.removeChild(node);
avtFindingVar.matchCount++;
return 1;
}
}
return 0;
},
HighlightInDoc: function(currentDoc)
{
var pn = null;
var fromPos = 0;
pn = currentDoc.body;
fromPos = 0;
var matchCount = 0;
if (this.NotUndefined(pn) && (pn.hasChildNodes))
{
for (var i = fromPos; i < pn.childNodes.length; i++)
{
if (this.HighlightInNode(pn.childNodes[i], currentDoc) == 1)
i++;
}
}
return matchCount;
},
UnHighlight: function()
{
var currentDoc = this.GetDocument();
var matchCount = this.UnHighlightInDoc(currentDoc);
try
{
if(avtFindingVar.Recursive)
{
while (this.NotUndefined(currentDoc))
{
currentDoc = this.FindNextDoc(currentDoc, 1);
while (this.NotUndefined(currentDoc) && this.Undefined(currentDoc.getElementsByTagName("body")))
currentDoc = this.FindNextDoc(currentDoc, 1);
if (this.NotUndefined(currentDoc) && this.NotUndefined(currentDoc.body))
{
matchCount += this.UnHighlightInDoc(currentDoc);
}
else
break;
}
}
}
catch (e) {
//alert("unhighlight:" + e);
}
for (var i = 0; i < avtFindingVar.avantTagArray.length; i++)
{
var pn = avtFindingVar.avantTagArray[i].parentNode;
pn.removeChild(avtFindingVar.avantTagArray[i]);
}
this.EmptyArray(avtFindingVar.avantTagArray);
avtFindingVar.matchCount = 0;
this.ResetFindCursor();
return matchCount;
},
GetNodeValue: function(node)
{
var nodeValue = "";
if (this.NotUndefined(node))
{
if (this.NotUndefined(node.nodeValue))
nodeValue = node.nodeValue;
else
nodeValue = node.innerHTML;
}
return nodeValue;
},
SetNodeValue: function(node, value)
{
if (this.NotUndefined(node))
{
if (node.nodeType == 3)
node.nodeValue = value;
else
node.innerHTML = value;
}
},
UnHighlightNode: function(node)
{
var matchCount = 0;
if (node.hasChildNodes)
{
try
{
for (var i = 0; i < node.childNodes.length; i++)
matchCount += this.UnHighlightNode(node.childNodes[i]);
}
catch(e)
{
//alert(e);
}
}
if (node.nodeType == 3) {
var pn = node.parentNode;
if (this.isAvantTag(pn))
{
try{
avtFindingVar.avantTagArray.push(pn);
var pnValue = "";
{
var prevSib = pn.previousSibling;
var nextSib = pn.nextSibling;
nextSib.nodeValue = prevSib.nodeValue + node.nodeValue + nextSib.nodeValue;
prevSib.nodeValue = '';
node.nodeValue = '';
}
matchCount++;
}
catch(e)
{
//alert(e);
}
}
}
return matchCount;
},
UnHighlightInDoc: function(currentDoc)
{
var pn = null;
var matchCount = 0;
pn = currentDoc.body;
if (avtBrowserInfo.isIE && this.NotUndefined(currentDoc.parentWindow) && this.NotUndefined(currentDoc.parentWindow["textRange"]))
{
currentDoc.parentWindow["textRange"].setEndPoint("StartToEnd", currentDoc.parentWindow["textRange"]);
currentDoc.parentWindow["textRange"].execCommand("UnSelect", false, "");
currentDoc.parentWindow["textRange"] = null;
}
matchCount = this.UnHighlightNode(pn);
return matchCount;
},
GetTextTransform: function(obj)
{
var textTransform = "";
if (this.NotUndefined(obj))
{
if (avtBrowserInfo.isIE)
{
if (this.NotUndefined(obj.currentStyle))
{
if (this.NotUndefined(obj.currentStyle.textTransform))
textTransform = obj.currentStyle.textTransform;
}
}
else
{
var win = obj.ownerDocument.defaultView;
if (this.NotUndefined(win))
{
var style = win.getComputedStyle(obj);
if (this.NotUndefined(style))
{
if (this.NotUndefined(style.textTransform))
textTransform = style.textTransform;
}
}
}
}
if (this.Undefined(textTransform))
textTransform = "";
textTransform = textTransform.toLowerCase();
return textTransform;
},
GetTransformedValue: function(textNode)
{
var pn = textNode.parentNode;
while (this.NotUndefined(pn))
{
if (pn.nodeType == 3)
pn = pn.parentNode;
else
break;
}
if (this.Undefined(pn))
{
return textNode.value;
}
else
{
var textTransform = this.GetTextTransform(pn);
if (textTransform === "lowercase")
return textNode.nodeValue.toLowerCase();
else if (textTransform === "uppercase")
return textNode.nodeValue.toUpperCase();
else
return textNode.nodeValue;
}
}
};
function avtHighlight(keywords, ARecursive)
{
if(avtUtility.Undefined(ARecursive))
ARecursive = true;
avtFindingVar.Recursive = ARecursive;
try{
keywords = unescape(keywords).replace(/^\s+|\s+$/g, "");
avtUtility.UnHighlight(ARecursive);
var matchCount = avtUtility.Highlight(keywords, false, true, ARecursive);
if (avtBrowserInfo.isIE)
{
if (matchCount > 0)
window.external.TextFound;
return "0";
}
if(matchCount > 0)
return "1";
else
return "0";
}
catch(e)
{
//alert(e);
return "0";
}
}
function avtFind(keywords, isFindAsSentence, matchCase, direction, isFirstFind, ARecursive)
{
if(avtUtility.Undefined(ARecursive))
ARecursive = true;
avtFindingVar.Recursive = ARecursive;
var bFound = false;
keywords = unescape(keywords).replace(/^\s+|\s+$/g, "");
if (avtUtility.Undefined(isFirstFind))
isFirstFind = false;
if(!matchCase)
keywords = keywords.toLowerCase();
if (keywords !== avtFindingVar.keywords)
isFirstFind = true;
if (isFirstFind)
avtUtility.ResetFindCursor();
if (avtFindingVar.notFoundKeywords === keywords)
{
isFindAsSentence = false;
bFound = avtUtility.Find(keywords, isFindAsSentence, direction, matchCase, isFirstFind);
}
else
{
bFound = avtUtility.Find(keywords, isFindAsSentence, direction, matchCase, isFirstFind);
if(isFirstFind && (direction < 0) && (!bFound) )
{
var nFound = 0;
while(true)
{
bFound = avtUtility.Find(keywords, isFindAsSentence, 1, matchCase, false);
if(bFound == false)
break;
else
nFound ++;
}
if(nFound > 0)
bFound = true;
}
if (isFindAsSentence && !bFound)
{
if (isFirstFind)
{
avtFindingVar.notFoundKeywords = keywords;
avtUtility.ResetFindCursor();
isFindAsSentence = false;
bFound = avtUtility.Find(keywords, isFindAsSentence, direction, matchCase, isFirstFind);
}
}
}
if (bFound)
avtFindingVar.lastFoundKeywords = keywords;
else
{
if (avtFindingVar.lastFoundKeywords == keywords)
{
if(direction > 0)
{
avtFindingVar.matchCount = 0;
avtUtility.ResetFindCursor();
bFound = avtUtility.Find(keywords, isFindAsSentence, direction, matchCase, true);
}
else
{
while(true)
{
bFound = avtUtility.Find(keywords, isFindAsSentence, 1, matchCase, isFirstFind);
if(bFound == false)
break;
}
bFound = true;
}
}
}
if (avtBrowserInfo.isIE)
{
if (bFound)
window.external.TextFound;
return "0";
}
if(bFound)
return "1";
else
return "0";
}