mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 19:27:58 +01:00
move the global evaluateXPath() function to vimperator.buffer
This commit is contained in:
@@ -138,6 +138,28 @@ function Buffer() //{{{
|
|||||||
return window.content.document.title;
|
return window.content.document.title;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// returns an XPathResult object
|
||||||
|
this.evaluateXPath = function(expression, doc, ordered)
|
||||||
|
{
|
||||||
|
if (!doc)
|
||||||
|
doc = window.content.document;
|
||||||
|
|
||||||
|
var result = doc.evaluate(expression, doc,
|
||||||
|
function lookupNamespaceURI(prefix) {
|
||||||
|
switch (prefix) {
|
||||||
|
case 'xhtml':
|
||||||
|
return 'http://www.w3.org/1999/xhtml';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ordered ? XPathResult.ORDERED_NODE_SNAPSHOT_TYPE : XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: move to v.buffers.list()
|
// TODO: move to v.buffers.list()
|
||||||
this.list = function(fullmode)
|
this.list = function(fullmode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1237,12 +1237,12 @@ function Commands() //{{{
|
|||||||
//}}}
|
//}}}
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
/* takes a string like 'google bla, www.osnews.com'
|
// takes a string like 'google bla, www.osnews.com'
|
||||||
* and returns an array ['www.google.com/search?q=bla', 'www.osnews.com']
|
// and returns an array ['www.google.com/search?q=bla', 'www.osnews.com']
|
||||||
*/
|
String.prototype.toURLArray = function() // {{{
|
||||||
String.prototype.toURLArray = function()
|
|
||||||
{
|
{
|
||||||
var urls = this.split(/\s*\,\s+/);
|
var urls = this.split(/\s*\,\s+/);
|
||||||
|
|
||||||
begin: for (var url = 0; url < urls.length; url++)
|
begin: for (var url = 0; url < urls.length; url++)
|
||||||
{
|
{
|
||||||
// FIXME: not really that good (doesn't handle .. in the middle), also problems with trailing slashes
|
// FIXME: not really that good (doesn't handle .. in the middle), also problems with trailing slashes
|
||||||
@@ -1311,33 +1311,8 @@ String.prototype.toURLArray = function()
|
|||||||
// if we are here let Firefox handle the url and hope it does
|
// if we are here let Firefox handle the url and hope it does
|
||||||
// something useful with it :)
|
// something useful with it :)
|
||||||
}
|
}
|
||||||
|
|
||||||
return urls;
|
return urls;
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////}}}
|
|
||||||
// misc helper functions ///////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////{{{
|
|
||||||
|
|
||||||
// returns an XPathResult object
|
|
||||||
function evaluateXPath(expression, doc, ordered)
|
|
||||||
{
|
|
||||||
if (!doc)
|
|
||||||
doc = window.content.document;
|
|
||||||
|
|
||||||
var res = doc.evaluate(expression, doc,
|
|
||||||
function lookupNamespaceURI(prefix) {
|
|
||||||
switch (prefix) {
|
|
||||||
case 'xhtml':
|
|
||||||
return 'http://www.w3.org/1999/xhtml';
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ordered ? XPathResult.ORDERED_NODE_SNAPSHOT_TYPE : XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
//}}}
|
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ vimperator.help = function(section, easter) //{{{
|
|||||||
{
|
{
|
||||||
function findSectionElement(section)
|
function findSectionElement(section)
|
||||||
{
|
{
|
||||||
return evaluateXPath('//code[@class="tag" and text()="' + section + '"]')
|
return vimperator.buffer.evaluateXPath('//code[@class="tag" and text()="' + section + '"]')
|
||||||
.snapshotItem(0);
|
.snapshotItem(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function Hints() //{{{
|
|||||||
wins.push(win);
|
wins.push(win);
|
||||||
}
|
}
|
||||||
// logMessage("winId:"+win.winId);
|
// logMessage("winId:"+win.winId);
|
||||||
win.res = evaluateXPath(vimperator.options["hinttags"], doc);
|
win.res = vimperator.buffer.evaluateXPath(vimperator.options["hinttags"], doc);
|
||||||
win.coordLoaderId = window.setTimeout("vimperator.hints.loadCoord(" + win.winId + ", 0);", 1);
|
win.coordLoaderId = window.setTimeout("vimperator.hints.loadCoord(" + win.winId + ", 0);", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ function Hints() //{{{
|
|||||||
area[3] = area[1] + win.innerHeight;
|
area[3] = area[1] + win.innerHeight;
|
||||||
|
|
||||||
var doc = win.document;
|
var doc = win.document;
|
||||||
var res = evaluateXPath(vimperator.options["hinttags"], doc);
|
var res = vimperator.buffer.evaluateXPath(vimperator.options["hinttags"], doc);
|
||||||
|
|
||||||
var elem, i;
|
var elem, i;
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ function Hints() //{{{
|
|||||||
win = window.content;
|
win = window.content;
|
||||||
|
|
||||||
var doc = win.document;
|
var doc = win.document;
|
||||||
var res = evaluateXPath("//HINTS/SPAN", doc)
|
var res = vimperator.buffer.evaluateXPath("//HINTS/SPAN", doc)
|
||||||
var elem, i;
|
var elem, i;
|
||||||
|
|
||||||
for (i = 0; i < res.snapshotLength; i++)
|
for (i = 0; i < res.snapshotLength; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user