mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 09:07:58 +01:00
move global isDirectory() to Commands()
This commit is contained in:
@@ -1258,30 +1258,6 @@ String.prototype.toURLArray = function()
|
|||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns true if the currently loaded URI is
|
|
||||||
* a directory or false if it is a file
|
|
||||||
*/
|
|
||||||
function isDirectory(url)
|
|
||||||
{
|
|
||||||
if (url.match(/^file:\/\//) || url.match(/^\//))
|
|
||||||
{
|
|
||||||
var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
|
||||||
var file = vimperator.fopen(stripedFilename, '<');
|
|
||||||
if (!file)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (file.localFile.isDirectory())
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// for all other locations just check if the URL ends with /
|
|
||||||
if (url.match(/\/$/))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////}}}
|
||||||
// misc helper functions ///////////////////////////////////////////////
|
// misc helper functions ///////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|||||||
@@ -759,6 +759,26 @@ function Mappings() //{{{
|
|||||||
flags: Mappings.flags.COUNT
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
function isDirectory(url)
|
||||||
|
{
|
||||||
|
if (url.match(/^file:\/\//) || url.match(/^\//))
|
||||||
|
{
|
||||||
|
var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
||||||
|
var file = vimperator.fopen(stripedFilename, '<');
|
||||||
|
if (!file)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (file.localFile.isDirectory())
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// for all other locations just check if the URL ends with /
|
||||||
|
if (url.match(/\/$/))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gu", "<BS>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gu", "<BS>"],
|
||||||
function(count)
|
function(count)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user