mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 17:57:59 +01:00
change tabs->4 spaces
This commit is contained in:
@@ -7,27 +7,27 @@
|
|||||||
|
|
||||||
function getProperty( aInput, aArc, DS )
|
function getProperty( aInput, aArc, DS )
|
||||||
{
|
{
|
||||||
var node;
|
var node;
|
||||||
node = DS.GetTarget( aInput, aArc, true );
|
node = DS.GetTarget( aInput, aArc, true );
|
||||||
if( node instanceof Components.interfaces.nsIRDFResource ) {
|
if( node instanceof Components.interfaces.nsIRDFResource ) {
|
||||||
return node.Value;
|
return node.Value;
|
||||||
}
|
}
|
||||||
if( node instanceof Components.interfaces.nsIRDFLiteral ) {
|
if( node instanceof Components.interfaces.nsIRDFLiteral ) {
|
||||||
return node.Value;
|
return node.Value;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function addBookmark(title, uri)
|
function addBookmark(title, uri)
|
||||||
{
|
{
|
||||||
folder = RDF.GetResource("NC:BookmarksRoot");
|
folder = RDF.GetResource("NC:BookmarksRoot");
|
||||||
var rSource = BookmarksUtils.createBookmark(title, uri, null, title);
|
var rSource = BookmarksUtils.createBookmark(title, uri, null, title);
|
||||||
var selection = BookmarksUtils.getSelectionFromResource(rSource);
|
var selection = BookmarksUtils.getSelectionFromResource(rSource);
|
||||||
var target = BookmarksUtils.getTargetFromFolder(folder);
|
var target = BookmarksUtils.getTargetFromFolder(folder);
|
||||||
BookmarksUtils.insertAndCheckSelection("newbookmark", selection, target);
|
BookmarksUtils.insertAndCheckSelection("newbookmark", selection, target);
|
||||||
|
|
||||||
//also update bookmark cache
|
//also update bookmark cache
|
||||||
g_bookmarks.unshift([uri, title]);
|
g_bookmarks.unshift([uri, title]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no idea what it does, it Just Works (TM)
|
/* no idea what it does, it Just Works (TM)
|
||||||
@@ -36,47 +36,47 @@ function addBookmark(title, uri)
|
|||||||
*/
|
*/
|
||||||
function deleteBookmark(url)
|
function deleteBookmark(url)
|
||||||
{
|
{
|
||||||
var deleted = 0;
|
var deleted = 0;
|
||||||
|
|
||||||
// gNC_NS for trunk, NC_NS for 1.X
|
// gNC_NS for trunk, NC_NS for 1.X
|
||||||
try {var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;}
|
try {var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;}
|
||||||
if(! BMSVC || ! BMDS || ! RDF || ! pNC_NS ) return null;
|
if(! BMSVC || ! BMDS || ! RDF || ! pNC_NS ) return null;
|
||||||
if ( !url) return null; // just in case
|
if ( !url) return null; // just in case
|
||||||
|
|
||||||
var curfolder = RDF.GetResource("NC:BookmarksRoot");
|
var curfolder = RDF.GetResource("NC:BookmarksRoot");
|
||||||
var urlArc = RDF.GetResource(pNC_NS+"URL");
|
var urlArc = RDF.GetResource(pNC_NS+"URL");
|
||||||
var urlLiteral = RDF.GetLiteral(url);
|
var urlLiteral = RDF.GetLiteral(url);
|
||||||
if (BMDS.hasArcIn(urlLiteral, urlArc)) {
|
if (BMDS.hasArcIn(urlLiteral, urlArc)) {
|
||||||
var bmResources, bmResource, title, uri, type, ptype;
|
var bmResources, bmResource, title, uri, type, ptype;
|
||||||
bmResources = BMSVC.GetSources(urlArc, urlLiteral, true);
|
bmResources = BMSVC.GetSources(urlArc, urlLiteral, true);
|
||||||
while (bmResources.hasMoreElements()) {
|
while (bmResources.hasMoreElements()) {
|
||||||
bmResource = bmResources.getNext();
|
bmResource = bmResources.getNext();
|
||||||
type = BookmarksUtils.resolveType(bmResource);
|
type = BookmarksUtils.resolveType(bmResource);
|
||||||
if (type != "ImmutableBookmark") {
|
if (type != "ImmutableBookmark") {
|
||||||
ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource));
|
ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource));
|
||||||
// alert(type);
|
// alert(type);
|
||||||
// if ( type == "Folder") // store the current folder
|
// if ( type == "Folder") // store the current folder
|
||||||
// curfolder = bmResource;
|
// curfolder = bmResource;
|
||||||
if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark") {
|
if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark") {
|
||||||
title = BookmarksUtils.getProperty(bmResource, pNC_NS+"Name");
|
title = BookmarksUtils.getProperty(bmResource, pNC_NS+"Name");
|
||||||
uri = BookmarksUtils.getProperty(bmResource, pNC_NS+"URL");
|
uri = BookmarksUtils.getProperty(bmResource, pNC_NS+"URL");
|
||||||
|
|
||||||
if (uri == url)
|
if (uri == url)
|
||||||
{
|
{
|
||||||
RDFC.Init(BMDS, BMSVC.getParent(bmResource));
|
RDFC.Init(BMDS, BMSVC.getParent(bmResource));
|
||||||
RDFC.RemoveElement(bmResource, true);
|
RDFC.RemoveElement(bmResource, true);
|
||||||
deleted++;
|
deleted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// also update bookmark cache, if we removed at least one bookmark
|
// also update bookmark cache, if we removed at least one bookmark
|
||||||
if(deleted > 0)
|
if(deleted > 0)
|
||||||
bookmarks_loaded = false;
|
bookmarks_loaded = false;
|
||||||
|
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call the function like this:
|
/* call the function like this:
|
||||||
@@ -90,65 +90,65 @@ function deleteBookmark(url)
|
|||||||
*/
|
*/
|
||||||
function parseBookmarkString(str, res)
|
function parseBookmarkString(str, res)
|
||||||
{
|
{
|
||||||
res.tags = [];
|
res.tags = [];
|
||||||
res.title = null;
|
res.title = null;
|
||||||
res.url = null;
|
res.url = null;
|
||||||
|
|
||||||
var re_title = /^\s*((-t|--title)\s+(\w+|\".*\"))(.*)/;
|
var re_title = /^\s*((-t|--title)\s+(\w+|\".*\"))(.*)/;
|
||||||
var re_tags = /^\s*((-T|--tags)\s+((\w+)(,\w+)*))(.*)/;
|
var re_tags = /^\s*((-T|--tags)\s+((\w+)(,\w+)*))(.*)/;
|
||||||
var re_url = /^\s*(\".+\"|\S+)(.*)/;
|
var re_url = /^\s*(\".+\"|\S+)(.*)/;
|
||||||
|
|
||||||
var match_tags = null;
|
var match_tags = null;
|
||||||
var match_title = null;
|
var match_title = null;
|
||||||
var match_url = null;
|
var match_url = null;
|
||||||
|
|
||||||
while(!str.match(/^\s*$/))
|
while(!str.match(/^\s*$/))
|
||||||
{
|
{
|
||||||
/* first check for --tags */
|
/* first check for --tags */
|
||||||
match_tags = str.match(re_tags);
|
match_tags = str.match(re_tags);
|
||||||
if(match_tags != null)
|
if(match_tags != null)
|
||||||
{
|
{
|
||||||
str = match_tags[match_tags.length-1]; // the last captured parenthesis is the rest of the string
|
str = match_tags[match_tags.length-1]; // the last captured parenthesis is the rest of the string
|
||||||
tags = match_tags[3].split(",");
|
tags = match_tags[3].split(",");
|
||||||
res.tags = res.tags.concat(tags);
|
res.tags = res.tags.concat(tags);
|
||||||
}
|
}
|
||||||
else /* then for --titles */
|
else /* then for --titles */
|
||||||
{
|
{
|
||||||
|
|
||||||
match_title = str.match(re_title);
|
match_title = str.match(re_title);
|
||||||
if(match_title != null)
|
if(match_title != null)
|
||||||
{
|
{
|
||||||
// only one title allowed
|
// only one title allowed
|
||||||
if (res.title != null)
|
if (res.title != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
str = match_title[match_title.length-1]; // the last captured parenthesis is the rest of the string
|
str = match_title[match_title.length-1]; // the last captured parenthesis is the rest of the string
|
||||||
title = match_title[3];
|
title = match_title[3];
|
||||||
if(title.charAt(0) == '"')
|
if(title.charAt(0) == '"')
|
||||||
title = title.substring(1,title.length-1);
|
title = title.substring(1,title.length-1);
|
||||||
res.title = title;
|
res.title = title;
|
||||||
}
|
}
|
||||||
else /* at last check for an url */
|
else /* at last check for an url */
|
||||||
{
|
{
|
||||||
match_url = str.match(re_url);
|
match_url = str.match(re_url);
|
||||||
if (match_url != null)
|
if (match_url != null)
|
||||||
{
|
{
|
||||||
// only one url allowed
|
// only one url allowed
|
||||||
if (res.url != null)
|
if (res.url != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
str = match_url[match_url.length-1]; // the last captured parenthesis is the rest of the string
|
str = match_url[match_url.length-1]; // the last captured parenthesis is the rest of the string
|
||||||
url = match_url[1];
|
url = match_url[1];
|
||||||
if(url.charAt(0) == '"')
|
if(url.charAt(0) == '"')
|
||||||
url = url.substring(1,url.length-1);
|
url = url.substring(1,url.length-1);
|
||||||
res.url = url;
|
res.url = url;
|
||||||
}
|
}
|
||||||
else return false; // no url, tag or title found but still text left, abort
|
else return false; // no url, tag or title found but still text left, abort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -37,74 +37,74 @@ var comp_history_index = -1;
|
|||||||
* returns the number of items */
|
* returns the number of items */
|
||||||
function completion_fill_list(startindex)/*{{{*/
|
function completion_fill_list(startindex)/*{{{*/
|
||||||
{
|
{
|
||||||
// remove all old items first
|
// remove all old items first
|
||||||
var items = completion_list.getElementsByTagName("listitem");
|
var items = completion_list.getElementsByTagName("listitem");
|
||||||
while (items.length > 0) { completion_list.removeChild(items[0]);}
|
while (items.length > 0) { completion_list.removeChild(items[0]);}
|
||||||
|
|
||||||
// find start index
|
// find start index
|
||||||
//var i = index - 3; // 3 lines of context
|
//var i = index - 3; // 3 lines of context
|
||||||
if (startindex + COMPLETION_MAXITEMS > g_completions.length)
|
if (startindex + COMPLETION_MAXITEMS > g_completions.length)
|
||||||
startindex = g_completions.length - COMPLETION_MAXITEMS;
|
startindex = g_completions.length - COMPLETION_MAXITEMS;
|
||||||
if (startindex < 0)
|
if (startindex < 0)
|
||||||
startindex = 0;
|
startindex = 0;
|
||||||
|
|
||||||
for(i=startindex; i<g_completions.length && i < startindex + COMPLETION_MAXITEMS; i++)
|
for(i=startindex; i<g_completions.length && i < startindex + COMPLETION_MAXITEMS; i++)
|
||||||
{
|
{
|
||||||
completion_add_to_list(g_completions[i], false);
|
completion_add_to_list(g_completions[i], false);
|
||||||
}
|
}
|
||||||
//completion_list.hidden = true;
|
//completion_list.hidden = true;
|
||||||
// completion_list.setAttribute("rows", (i-startindex).toString());
|
// completion_list.setAttribute("rows", (i-startindex).toString());
|
||||||
// showStatusbarMessage ( (i-startindex).toString(), 1);
|
// showStatusbarMessage ( (i-startindex).toString(), 1);
|
||||||
// if ( i-startindex > 0) // XXX: respect completetopt setting
|
// if ( i-startindex > 0) // XXX: respect completetopt setting
|
||||||
// completion_list.hidden = false;
|
// completion_list.hidden = false;
|
||||||
// else
|
// else
|
||||||
// completion_list.hidden = true;
|
// completion_list.hidden = true;
|
||||||
// completion_list.setAttribute("rows", (i-startindex).toString());
|
// completion_list.setAttribute("rows", (i-startindex).toString());
|
||||||
|
|
||||||
return (i-startindex);
|
return (i-startindex);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function completion_show_list()/*{{{*/
|
function completion_show_list()/*{{{*/
|
||||||
{
|
{
|
||||||
var items = g_completions.length;
|
var items = g_completions.length;
|
||||||
if (items > COMPLETION_MAXITEMS)
|
if (items > COMPLETION_MAXITEMS)
|
||||||
items = COMPLETION_MAXITEMS;
|
items = COMPLETION_MAXITEMS;
|
||||||
if (items > 1) // FIXME
|
if (items > 1) // FIXME
|
||||||
{
|
{
|
||||||
//alert(completion_list.getRowCount().toString());
|
//alert(completion_list.getRowCount().toString());
|
||||||
completion_list.setAttribute("rows", items.toString());
|
completion_list.setAttribute("rows", items.toString());
|
||||||
//completion_list.rowCountChanged(0, items);
|
//completion_list.rowCountChanged(0, items);
|
||||||
completion_list.hidden = false;
|
completion_list.hidden = false;
|
||||||
//completion_list.selectedIndex = selected_index;
|
//completion_list.selectedIndex = selected_index;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
completion_list.hidden = true;
|
completion_list.hidden = true;
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
/* add a single completion item to the list */
|
/* add a single completion item to the list */
|
||||||
function completion_add_to_list(completion_item, at_beginning)/*{{{*/
|
function completion_add_to_list(completion_item, at_beginning)/*{{{*/
|
||||||
{
|
{
|
||||||
var item = document.createElement("listitem");
|
var item = document.createElement("listitem");
|
||||||
var cell1 = document.createElement("listcell");
|
var cell1 = document.createElement("listcell");
|
||||||
var cell2 = document.createElement("listcell");
|
var cell2 = document.createElement("listcell");
|
||||||
|
|
||||||
cell1.setAttribute("label", completion_item[0]);
|
cell1.setAttribute("label", completion_item[0]);
|
||||||
cell1.setAttribute("width", "200");
|
cell1.setAttribute("width", "200");
|
||||||
cell2.setAttribute("label", completion_item[1]);
|
cell2.setAttribute("label", completion_item[1]);
|
||||||
cell2.setAttribute("style", "color:green; font-family: sans");
|
cell2.setAttribute("style", "color:green; font-family: sans");
|
||||||
|
|
||||||
item.appendChild(cell1);
|
item.appendChild(cell1);
|
||||||
item.appendChild(cell2);
|
item.appendChild(cell2);
|
||||||
if (at_beginning == true)
|
if (at_beginning == true)
|
||||||
{
|
{
|
||||||
var items = completion_list.getElementsByTagName("listitem");
|
var items = completion_list.getElementsByTagName("listitem");
|
||||||
if (items.length > 0)
|
if (items.length > 0)
|
||||||
completion_list.insertBefore(item, items[0]);
|
completion_list.insertBefore(item, items[0]);
|
||||||
else
|
else
|
||||||
completion_list.appendChild(item);
|
completion_list.appendChild(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
completion_list.appendChild(item);
|
completion_list.appendChild(item);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
/* select the next index, refill list if necessary
|
/* select the next index, refill list if necessary
|
||||||
@@ -112,36 +112,36 @@ function completion_add_to_list(completion_item, at_beginning)/*{{{*/
|
|||||||
* changes 'comp_tab_index' */
|
* changes 'comp_tab_index' */
|
||||||
function completion_select_next_item()/*{{{*/
|
function completion_select_next_item()/*{{{*/
|
||||||
{
|
{
|
||||||
comp_tab_index++;
|
comp_tab_index++;
|
||||||
if (comp_tab_index >= g_completions.length) /* wrap around */
|
if (comp_tab_index >= g_completions.length) /* wrap around */
|
||||||
{
|
{
|
||||||
comp_tab_index = -1;
|
comp_tab_index = -1;
|
||||||
completion_list.selectedIndex = -1;
|
completion_list.selectedIndex = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comp_tab_index == 0) // at the top of the list
|
if (comp_tab_index == 0) // at the top of the list
|
||||||
{
|
{
|
||||||
completion_fill_list(0);
|
completion_fill_list(0);
|
||||||
comp_tab_list_offset = 0;
|
comp_tab_list_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var listindex = comp_tab_index - comp_tab_list_offset;
|
var listindex = comp_tab_index - comp_tab_list_offset;
|
||||||
// only move the list, if there are still items we can move
|
// only move the list, if there are still items we can move
|
||||||
if (listindex >= COMPLETION_MAXITEMS - COMPLETION_CONTEXTLINES &&
|
if (listindex >= COMPLETION_MAXITEMS - COMPLETION_CONTEXTLINES &&
|
||||||
comp_tab_list_offset < g_completions.length - COMPLETION_MAXITEMS)
|
comp_tab_list_offset < g_completions.length - COMPLETION_MAXITEMS)
|
||||||
{
|
{
|
||||||
// for speed reason: just remove old item, and add new at the end of the list
|
// for speed reason: just remove old item, and add new at the end of the list
|
||||||
var items = completion_list.getElementsByTagName("listitem");
|
var items = completion_list.getElementsByTagName("listitem");
|
||||||
completion_list.removeChild(items[0]);
|
completion_list.removeChild(items[0]);
|
||||||
completion_add_to_list(g_completions[comp_tab_index + COMPLETION_CONTEXTLINES], false);
|
completion_add_to_list(g_completions[comp_tab_index + COMPLETION_CONTEXTLINES], false);
|
||||||
comp_tab_list_offset++;
|
comp_tab_list_offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
listindex = comp_tab_index - comp_tab_list_offset;
|
listindex = comp_tab_index - comp_tab_list_offset;
|
||||||
completion_list.selectedIndex = listindex;
|
completion_list.selectedIndex = listindex;
|
||||||
|
|
||||||
showStatusbarMessage(" match " + (comp_tab_index+1).toString() + " of " + g_completions.length.toString() + " ", STATUSFIELD_PROGRESS);
|
showStatusbarMessage(" match " + (comp_tab_index+1).toString() + " of " + g_completions.length.toString() + " ", STATUSFIELD_PROGRESS);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
/* select the previous index, refill list if necessary
|
/* select the previous index, refill list if necessary
|
||||||
@@ -149,37 +149,37 @@ function completion_select_next_item()/*{{{*/
|
|||||||
* changes 'comp_tab_index' */
|
* changes 'comp_tab_index' */
|
||||||
function completion_select_previous_item()/*{{{*/
|
function completion_select_previous_item()/*{{{*/
|
||||||
{
|
{
|
||||||
comp_tab_index--;
|
comp_tab_index--;
|
||||||
if (comp_tab_index == -1)
|
if (comp_tab_index == -1)
|
||||||
{
|
{
|
||||||
completion_list.selectedIndex = -1;
|
completion_list.selectedIndex = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comp_tab_index < -1) // go to the end of the list
|
if (comp_tab_index < -1) // go to the end of the list
|
||||||
{
|
{
|
||||||
comp_tab_index = g_completions.length -1;
|
comp_tab_index = g_completions.length -1;
|
||||||
completion_fill_list(g_completions.length - COMPLETION_MAXITEMS);
|
completion_fill_list(g_completions.length - COMPLETION_MAXITEMS);
|
||||||
comp_tab_list_offset = g_completions.length - COMPLETION_MAXITEMS;//COMPLETION_MAXITEMS - 1;
|
comp_tab_list_offset = g_completions.length - COMPLETION_MAXITEMS;//COMPLETION_MAXITEMS - 1;
|
||||||
if (comp_tab_list_offset < 0)
|
if (comp_tab_list_offset < 0)
|
||||||
comp_tab_list_offset = 0;
|
comp_tab_list_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var listindex = comp_tab_index - comp_tab_list_offset;
|
var listindex = comp_tab_index - comp_tab_list_offset;
|
||||||
// only move the list, if there are still items we can move
|
// only move the list, if there are still items we can move
|
||||||
if (listindex < COMPLETION_CONTEXTLINES && comp_tab_list_offset > 0)
|
if (listindex < COMPLETION_CONTEXTLINES && comp_tab_list_offset > 0)
|
||||||
{
|
{
|
||||||
// for speed reason: just remove old item, and add new at the end of the list
|
// for speed reason: just remove old item, and add new at the end of the list
|
||||||
var items = completion_list.getElementsByTagName("listitem");
|
var items = completion_list.getElementsByTagName("listitem");
|
||||||
completion_list.removeChild(items[items.length-1]);
|
completion_list.removeChild(items[items.length-1]);
|
||||||
completion_add_to_list(g_completions[comp_tab_index - COMPLETION_CONTEXTLINES], true);
|
completion_add_to_list(g_completions[comp_tab_index - COMPLETION_CONTEXTLINES], true);
|
||||||
comp_tab_list_offset--;
|
comp_tab_list_offset--;
|
||||||
}
|
}
|
||||||
|
|
||||||
listindex = comp_tab_index - comp_tab_list_offset;
|
listindex = comp_tab_index - comp_tab_list_offset;
|
||||||
completion_list.selectedIndex = listindex;
|
completion_list.selectedIndex = listindex;
|
||||||
|
|
||||||
showStatusbarMessage("item " + (comp_tab_index+1).toString() + " of " + g_completions.length.toString(), STATUSFIELD_PROGRESS);
|
showStatusbarMessage("item " + (comp_tab_index+1).toString() + " of " + g_completions.length.toString(), STATUSFIELD_PROGRESS);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
|
|
||||||
@@ -192,235 +192,235 @@ function completion_select_previous_item()/*{{{*/
|
|||||||
*/
|
*/
|
||||||
function get_url_completions(filter)/*{{{*/
|
function get_url_completions(filter)/*{{{*/
|
||||||
{
|
{
|
||||||
g_completions = [];
|
g_completions = [];
|
||||||
|
|
||||||
var cpt = get_pref("complete");
|
var cpt = get_pref("complete");
|
||||||
// join all completion arrays together
|
// join all completion arrays together
|
||||||
for (var i = 0; i < cpt.length; i++)
|
for (var i = 0; i < cpt.length; i++)
|
||||||
{
|
{
|
||||||
if (cpt[i] == 's')
|
if (cpt[i] == 's')
|
||||||
g_completions = g_completions.concat(get_search_completions(filter));
|
g_completions = g_completions.concat(get_search_completions(filter));
|
||||||
else if (cpt[i] == 'b')
|
else if (cpt[i] == 'b')
|
||||||
g_completions = g_completions.concat(get_bookmark_completions(filter));
|
g_completions = g_completions.concat(get_bookmark_completions(filter));
|
||||||
else if (cpt[i] == 'h')
|
else if (cpt[i] == 'h')
|
||||||
g_completions = g_completions.concat(get_history_completions(filter));
|
g_completions = g_completions.concat(get_history_completions(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_completions;
|
return g_completions;
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
/* discard all entries in the 'urls' array, which don't match 'filter */
|
/* discard all entries in the 'urls' array, which don't match 'filter */
|
||||||
function filter_url_array(urls, filter, use_regex)/*{{{*/
|
function filter_url_array(urls, filter, use_regex)/*{{{*/
|
||||||
{
|
{
|
||||||
var filtered = [];
|
var filtered = [];
|
||||||
// completions which don't match the url but just the description
|
// completions which don't match the url but just the description
|
||||||
// list them add the end of the array
|
// list them add the end of the array
|
||||||
var additional_completions = [];
|
var additional_completions = [];
|
||||||
|
|
||||||
var reg, reg2;
|
var reg, reg2;
|
||||||
if (use_regex)
|
if (use_regex)
|
||||||
{
|
{
|
||||||
reg = new RegExp("^" + filter, "i");
|
reg = new RegExp("^" + filter, "i");
|
||||||
reg2 = new RegExp(filter, "i");
|
reg2 = new RegExp(filter, "i");
|
||||||
}
|
}
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
for (var i = 0; i < urls.length; ++i)
|
for (var i = 0; i < urls.length; ++i)
|
||||||
{
|
{
|
||||||
if (filter != null && filter.length > 0)
|
if (filter != null && filter.length > 0)
|
||||||
{
|
{
|
||||||
// first check if the filter matches in the main part of the URL
|
// first check if the filter matches in the main part of the URL
|
||||||
var bm = urls[i][0].replace(/^.*:\/\/(www)?/, "");
|
var bm = urls[i][0].replace(/^.*:\/\/(www)?/, "");
|
||||||
bm = bm.replace(/\/.*$/, "");
|
bm = bm.replace(/\/.*$/, "");
|
||||||
var tokens = bm.split(".");
|
var tokens = bm.split(".");
|
||||||
for (var k = 0; k < tokens.length-1; k++) // -1 because we don't search the domain (like .com)
|
for (var k = 0; k < tokens.length-1; k++) // -1 because we don't search the domain (like .com)
|
||||||
{
|
{
|
||||||
if (use_regex)
|
if (use_regex)
|
||||||
{
|
{
|
||||||
if(tokens[k].search(reg) != -1)
|
if(tokens[k].search(reg) != -1)
|
||||||
{
|
{
|
||||||
filtered.push([urls[i][0], urls[i][1] ]);
|
filtered.push([urls[i][0], urls[i][1] ]);
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tokens[k].indexOf(filter) == 0)
|
if (tokens[k].indexOf(filter) == 0)
|
||||||
{
|
{
|
||||||
filtered.push([urls[i][0], urls[i][1] ]);
|
filtered.push([urls[i][0], urls[i][1] ]);
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise check if the filter matches in the description of the bookmark
|
// otherwise check if the filter matches in the description of the bookmark
|
||||||
if (use_regex)
|
if (use_regex)
|
||||||
{
|
{
|
||||||
if(urls[i][0].search(reg2) == -1 && urls[i][1].search(reg2) == -1)
|
if(urls[i][0].search(reg2) == -1 && urls[i][1].search(reg2) == -1)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (urls[i][0].indexOf(filter) == -1 && urls[i][1].indexOf(filter) == -1)
|
if (urls[i][0].indexOf(filter) == -1 && urls[i][1].indexOf(filter) == -1)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
additional_completions.push([urls[i][0], urls[i][1] ]);
|
additional_completions.push([urls[i][0], urls[i][1] ]);
|
||||||
}
|
}
|
||||||
return filtered.concat(additional_completions);
|
return filtered.concat(additional_completions);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function get_search_completions(filter)/*{{{*/
|
function get_search_completions(filter)/*{{{*/
|
||||||
{
|
{
|
||||||
var search_completions = [];
|
var search_completions = [];
|
||||||
|
|
||||||
var reg = new RegExp("^" + filter, "i");
|
var reg = new RegExp("^" + filter, "i");
|
||||||
for (var i = 0; i < g_searchengines.length; i++)
|
for (var i = 0; i < g_searchengines.length; i++)
|
||||||
{
|
{
|
||||||
if (g_searchengines[i][0].search(reg) != -1)
|
if (g_searchengines[i][0].search(reg) != -1)
|
||||||
search_completions.push([g_searchengines[i][0] + " ", g_searchengines[i][1] ]);
|
search_completions.push([g_searchengines[i][0] + " ", g_searchengines[i][1] ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return search_completions;
|
return search_completions;
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function get_bookmark_completions(filter)/*{{{*/
|
function get_bookmark_completions(filter)/*{{{*/
|
||||||
{
|
{
|
||||||
if (!bookmarks_loaded)
|
if (!bookmarks_loaded)
|
||||||
{
|
{
|
||||||
// update our bookmark cache
|
// update our bookmark cache
|
||||||
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService( Components.interfaces.nsIRDFService );
|
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService( Components.interfaces.nsIRDFService );
|
||||||
var root = RDF.GetResource( "NC:BookmarksRoot" );
|
var root = RDF.GetResource( "NC:BookmarksRoot" );
|
||||||
bookmarks = []; // here getAllChildren will store the bookmarks
|
bookmarks = []; // here getAllChildren will store the bookmarks
|
||||||
g_bookmarks = []; // also clear our bookmark cache
|
g_bookmarks = []; // also clear our bookmark cache
|
||||||
BookmarksUtils.getAllChildren(root, bookmarks);
|
BookmarksUtils.getAllChildren(root, bookmarks);
|
||||||
for(var i = 0; i < bookmarks.length; i++)
|
for(var i = 0; i < bookmarks.length; i++)
|
||||||
{
|
{
|
||||||
if (bookmarks[i][0] && bookmarks[i][1])
|
if (bookmarks[i][0] && bookmarks[i][1])
|
||||||
g_bookmarks.push([bookmarks[i][1].Value, bookmarks[i][0].Value ]);
|
g_bookmarks.push([bookmarks[i][1].Value, bookmarks[i][0].Value ]);
|
||||||
}
|
}
|
||||||
bookmarks_loaded = true;
|
bookmarks_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter_url_array(g_bookmarks, filter, true);
|
return filter_url_array(g_bookmarks, filter, true);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function get_history_completions(filter)/*{{{*/
|
function get_history_completions(filter)/*{{{*/
|
||||||
{
|
{
|
||||||
var history = document.getElementById("hiddenHistoryTree");
|
var history = document.getElementById("hiddenHistoryTree");
|
||||||
|
|
||||||
// build our history cache
|
// build our history cache
|
||||||
if (history_loaded == false)
|
if (history_loaded == false)
|
||||||
{
|
{
|
||||||
if (history.hidden)
|
if (history.hidden)
|
||||||
{
|
{
|
||||||
history.hidden = false;
|
history.hidden = false;
|
||||||
var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIRDFDataSource);
|
var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIRDFDataSource);
|
||||||
history.database.AddDataSource(globalHistory);
|
history.database.AddDataSource(globalHistory);
|
||||||
history_completions = [];
|
history_completions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!history.ref)
|
if (!history.ref)
|
||||||
history.ref = "NC:HistoryRoot";
|
history.ref = "NC:HistoryRoot";
|
||||||
|
|
||||||
const NC_NS = "http://home.netscape.com/NC-rdf#";
|
const NC_NS = "http://home.netscape.com/NC-rdf#";
|
||||||
if (!gRDF)
|
if (!gRDF)
|
||||||
gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
||||||
.getService(Components.interfaces.nsIRDFService);
|
.getService(Components.interfaces.nsIRDFService);
|
||||||
|
|
||||||
var nameResource = gRDF.GetResource(NC_NS + "Name");
|
var nameResource = gRDF.GetResource(NC_NS + "Name");
|
||||||
var builder = history.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
|
var builder = history.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
|
||||||
|
|
||||||
var count = history.view.rowCount;
|
var count = history.view.rowCount;
|
||||||
for (var i = count-1; i >= 0; i--)
|
for (var i = count-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var res = builder.getResourceAtIndex(i);
|
var res = builder.getResourceAtIndex(i);
|
||||||
var url = res.Value;
|
var url = res.Value;
|
||||||
// var col = history.columns["Name"];
|
// var col = history.columns["Name"];
|
||||||
//var title = history.view.getCellText(i, col);
|
//var title = history.view.getCellText(i, col);
|
||||||
var title;
|
var title;
|
||||||
var titleRes = history.database.GetTarget(res, nameResource, true);
|
var titleRes = history.database.GetTarget(res, nameResource, true);
|
||||||
if (!titleRes)
|
if (!titleRes)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var titleLiteral = titleRes.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
var titleLiteral = titleRes.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||||
if(titleLiteral)
|
if(titleLiteral)
|
||||||
title = titleLiteral.Value;
|
title = titleLiteral.Value;
|
||||||
else
|
else
|
||||||
title = "";
|
title = "";
|
||||||
|
|
||||||
g_history.push([url, title]);
|
g_history.push([url, title]);
|
||||||
}
|
}
|
||||||
// if(url.toLowerCase().indexOf(filter.toLowerCase()) > -1)
|
// if(url.toLowerCase().indexOf(filter.toLowerCase()) > -1)
|
||||||
history_loaded = true;
|
history_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter_url_array(g_history, filter, true);
|
return filter_url_array(g_history, filter, true);
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function get_command_completions(filter)/*{{{*/
|
function get_command_completions(filter)/*{{{*/
|
||||||
{
|
{
|
||||||
g_completions = [];
|
g_completions = [];
|
||||||
for(var i=0; i<g_commands.length; i++)
|
for(var i=0; i<g_commands.length; i++)
|
||||||
{
|
{
|
||||||
for(var j=0; j<g_commands[i][0].length; j++)
|
for(var j=0; j<g_commands[i][0].length; j++)
|
||||||
{
|
{
|
||||||
//var re = new RegExp("^" + filter);
|
//var re = new RegExp("^" + filter);
|
||||||
if (g_commands[i][0][j].indexOf(filter) == 0)
|
if (g_commands[i][0][j].indexOf(filter) == 0)
|
||||||
{
|
{
|
||||||
g_completions.push([g_commands[i][0][j], g_commands[i][1]]);
|
g_completions.push([g_commands[i][0][j], g_commands[i][1]]);
|
||||||
break; // only add a command once
|
break; // only add a command once
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// commands should be sorted anyway, but it doesn't really hurt -> it DOES hurt :(
|
// commands should be sorted anyway, but it doesn't really hurt -> it DOES hurt :(
|
||||||
//g_completions.sort();
|
//g_completions.sort();
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function get_settings_completions(filter)/*{{{*/
|
function get_settings_completions(filter)/*{{{*/
|
||||||
{
|
{
|
||||||
settings_completions = [];
|
settings_completions = [];
|
||||||
var no_mode = false;
|
var no_mode = false;
|
||||||
|
|
||||||
if (filter.indexOf("no") == 0) // boolean option
|
if (filter.indexOf("no") == 0) // boolean option
|
||||||
{
|
{
|
||||||
no_mode = true;
|
no_mode = true;
|
||||||
filter = filter.substr(2);
|
filter = filter.substr(2);
|
||||||
}
|
}
|
||||||
// check if filter ends with =, then complete current value
|
// check if filter ends with =, then complete current value
|
||||||
else if(filter.length > 0 && filter.lastIndexOf("=") == filter.length -1)
|
else if(filter.length > 0 && filter.lastIndexOf("=") == filter.length -1)
|
||||||
{
|
{
|
||||||
filter = filter.substr(0, filter.length-1);
|
filter = filter.substr(0, filter.length-1);
|
||||||
for(var i=0; i<g_settings.length; i++)
|
for(var i=0; i<g_settings.length; i++)
|
||||||
{
|
{
|
||||||
for(var j=0; j<g_settings[i][0].length; j++)
|
for(var j=0; j<g_settings[i][0].length; j++)
|
||||||
{
|
{
|
||||||
if (g_settings[i][0][j] == filter)
|
if (g_settings[i][0][j] == filter)
|
||||||
{
|
{
|
||||||
settings_completions.push([filter + "=" + g_settings[i][4].call(this), ""]);
|
settings_completions.push([filter + "=" + g_settings[i][4].call(this), ""]);
|
||||||
return settings_completions;
|
return settings_completions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return settings_completions;
|
return settings_completions;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i=0; i<g_settings.length; i++)
|
for(var i=0; i<g_settings.length; i++)
|
||||||
{
|
{
|
||||||
if (filter == "" || g_settings[i][0][0].indexOf(filter) > -1)
|
if (filter == "" || g_settings[i][0][0].indexOf(filter) > -1)
|
||||||
{
|
{
|
||||||
// for 'no'-mode only return bool options
|
// for 'no'-mode only return bool options
|
||||||
if (no_mode)
|
if (no_mode)
|
||||||
{
|
{
|
||||||
if (g_settings[i][5] == "bool")
|
if (g_settings[i][5] == "bool")
|
||||||
settings_completions.push(["no" + g_settings[i][0][0], g_settings[i][1]]);
|
settings_completions.push(["no" + g_settings[i][0][0], g_settings[i][1]]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
settings_completions.push([g_settings[i][0][0], g_settings[i][1]]);
|
settings_completions.push([g_settings[i][0][0], g_settings[i][1]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings_completions;
|
return settings_completions;
|
||||||
}/*}}}*/
|
}/*}}}*/
|
||||||
|
|
||||||
function get_buffer_completions(filter)
|
function get_buffer_completions(filter)
|
||||||
@@ -428,28 +428,28 @@ function get_buffer_completions(filter)
|
|||||||
var reg = new RegExp("^"+filter,"i");
|
var reg = new RegExp("^"+filter,"i");
|
||||||
items = new Array();
|
items = new Array();
|
||||||
var num = getBrowser().browsers.length;
|
var num = getBrowser().browsers.length;
|
||||||
var title, url;
|
var title, url;
|
||||||
|
|
||||||
for(var i=0; i<num;i++)
|
for(var i=0; i<num;i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
title = getBrowser().getBrowserAtIndex(i).contentDocument.getElementsByTagName('title')[0].text;
|
title = getBrowser().getBrowserAtIndex(i).contentDocument.getElementsByTagName('title')[0].text;
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
title = "";
|
title = "";
|
||||||
}
|
}
|
||||||
if (title == "")
|
if (title == "")
|
||||||
title = "(Untitled)";
|
title = "(Untitled)";
|
||||||
|
|
||||||
url = getBrowser().getBrowserAtIndex(i).contentDocument.location.href;
|
url = getBrowser().getBrowserAtIndex(i).contentDocument.location.href;
|
||||||
|
|
||||||
if(title.search(reg) != -1 || url.search(reg) != -1)
|
if(title.search(reg) != -1 || url.search(reg) != -1)
|
||||||
{
|
{
|
||||||
items.push([(i+1)+": "+title, url]);
|
items.push([(i+1)+": "+title, url]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,20 +457,20 @@ function get_buffer_completions(filter)
|
|||||||
|
|
||||||
function add_to_command_history(str)
|
function add_to_command_history(str)
|
||||||
{
|
{
|
||||||
/* add string to the command line history */
|
/* add string to the command line history */
|
||||||
if (str.length >= 2 && comp_history.push(str) > COMMAND_LINE_HISTORY_SIZE)
|
if (str.length >= 2 && comp_history.push(str) > COMMAND_LINE_HISTORY_SIZE)
|
||||||
comp_history.shift();
|
comp_history.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_history()
|
function save_history()
|
||||||
{
|
{
|
||||||
set_pref("comp_history", comp_history.join("\n"));
|
set_pref("comp_history", comp_history.join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_history()
|
function load_history()
|
||||||
{
|
{
|
||||||
var hist = get_pref("comp_history", "");
|
var hist = get_pref("comp_history", "");
|
||||||
comp_history = hist.split("\n");
|
comp_history = hist.split("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -479,39 +479,39 @@ function load_history()
|
|||||||
/* uses the entries in completions to fill the listbox */
|
/* uses the entries in completions to fill the listbox */
|
||||||
function preview_window_fill(completions)
|
function preview_window_fill(completions)
|
||||||
{
|
{
|
||||||
// remove all old items first
|
// remove all old items first
|
||||||
var items = preview_window.getElementsByTagName("listitem");
|
var items = preview_window.getElementsByTagName("listitem");
|
||||||
while (items.length > 0) { preview_window.removeChild(items[0]);}
|
while (items.length > 0) { preview_window.removeChild(items[0]);}
|
||||||
|
|
||||||
for(i=0; i<completions.length; i++)
|
for(i=0; i<completions.length; i++)
|
||||||
{
|
{
|
||||||
var item = document.createElement("listitem");
|
var item = document.createElement("listitem");
|
||||||
var cell1 = document.createElement("listcell");
|
var cell1 = document.createElement("listcell");
|
||||||
var cell2 = document.createElement("listcell");
|
var cell2 = document.createElement("listcell");
|
||||||
|
|
||||||
cell1.setAttribute("label", completions[i][0]);
|
cell1.setAttribute("label", completions[i][0]);
|
||||||
cell2.setAttribute("label", completions[i][1]);
|
cell2.setAttribute("label", completions[i][1]);
|
||||||
//cell2.setAttribute("style", "color:green; font-family: sans; text-align:right");
|
//cell2.setAttribute("style", "color:green; font-family: sans; text-align:right");
|
||||||
cell2.setAttribute("style", "color:green; font-family: sans;");
|
cell2.setAttribute("style", "color:green; font-family: sans;");
|
||||||
|
|
||||||
item.appendChild(cell1);
|
item.appendChild(cell1);
|
||||||
item.appendChild(cell2);
|
item.appendChild(cell2);
|
||||||
preview_window.appendChild(item);
|
preview_window.appendChild(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function preview_window_select(event)
|
function preview_window_select(event)
|
||||||
{
|
{
|
||||||
var listcell = document.getElementsByTagName("listcell");
|
var listcell = document.getElementsByTagName("listcell");
|
||||||
// 2 columns for now, use the first column
|
// 2 columns for now, use the first column
|
||||||
var index = (preview_window.selectedIndex * 2) + 0;
|
var index = (preview_window.selectedIndex * 2) + 0;
|
||||||
var val = listcell[index].getAttribute("label");
|
var val = listcell[index].getAttribute("label");
|
||||||
if (val && event.button == 0 && event.type == "dblclick") // left double click
|
if (val && event.button == 0 && event.type == "dblclick") // left double click
|
||||||
openURLs(val);
|
openURLs(val);
|
||||||
else if (val && event.button == 1) // middle click
|
else if (val && event.button == 1) // middle click
|
||||||
openURLsInNewTab(val);
|
openURLsInNewTab(val);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -26,197 +26,197 @@ var opt_fullscreen = false;
|
|||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
var g_settings = [/*{{{*/
|
var g_settings = [/*{{{*/
|
||||||
[
|
[
|
||||||
["activate"],
|
["activate"],
|
||||||
"Define when tabs are automatically activated",
|
"Define when tabs are automatically activated",
|
||||||
"Not implemented yet",
|
"Not implemented yet",
|
||||||
function(value) { set_pref("activate", value); },
|
function(value) { set_pref("activate", value); },
|
||||||
function() { return get_pref("activate"); },
|
function() { return get_pref("activate"); },
|
||||||
"stringlist",
|
"stringlist",
|
||||||
"quickmark,tabopen,paste",
|
"quickmark,tabopen,paste",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["beep"],
|
["beep"],
|
||||||
"Emit a pc speaker beep on certain errors",
|
"Emit a pc speaker beep on certain errors",
|
||||||
null,
|
null,
|
||||||
function(value) { set_pref("beep", value); },
|
function(value) { set_pref("beep", value); },
|
||||||
function() { return get_pref("beep"); },
|
function() { return get_pref("beep"); },
|
||||||
"boolean",
|
"boolean",
|
||||||
true,
|
true,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["complete", "cpt"],
|
["complete", "cpt"],
|
||||||
"Order and items which are completed at the :[tab]open prompt",
|
"Order and items which are completed at the :[tab]open prompt",
|
||||||
"Available items:<br>"+
|
"Available items:<br>"+
|
||||||
"<ul><li><b>s</b>: Search machines</li><li>"+
|
"<ul><li><b>s</b>: Search machines</li><li>"+
|
||||||
" <b>b</b>: Bookmarks</li><li>"+
|
" <b>b</b>: Bookmarks</li><li>"+
|
||||||
" <b>h</b>: History</li></ul>"+
|
" <b>h</b>: History</li></ul>"+
|
||||||
"The order is important, so <code class=command>:set complete=bs</code> would list bookmarks first, and then any available quick searches.",
|
"The order is important, so <code class=command>:set complete=bs</code> would list bookmarks first, and then any available quick searches.",
|
||||||
function(value) { set_pref("complete", value); },
|
function(value) { set_pref("complete", value); },
|
||||||
function() { return get_pref("complete"); },
|
function() { return get_pref("complete"); },
|
||||||
"charlist",
|
"charlist",
|
||||||
"sbh",
|
"sbh",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["completeopt", "cot"],
|
["completeopt", "cot"],
|
||||||
"Define how command line completion works",
|
"Define how command line completion works",
|
||||||
"Not implemented yet.",
|
"Not implemented yet.",
|
||||||
function(value) { set_pref("completeopt", value); },
|
function(value) { set_pref("completeopt", value); },
|
||||||
function() { return get_pref("completeopt"); },
|
function() { return get_pref("completeopt"); },
|
||||||
"stringlist",
|
"stringlist",
|
||||||
"menu",
|
"menu",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["extendedhinttags", "eht"],
|
["extendedhinttags", "eht"],
|
||||||
"XPath string of hintable elements activated by ';'",
|
"XPath string of hintable elements activated by ';'",
|
||||||
null,
|
null,
|
||||||
function(value) { set_pref("extendedhinttags", value); },
|
function(value) { set_pref("extendedhinttags", value); },
|
||||||
function() { return get_pref("extendedhinttags"); },
|
function() { return get_pref("extendedhinttags"); },
|
||||||
"string",
|
"string",
|
||||||
"//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select",
|
"//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["focusedhintstyle", "fhs"],
|
["focusedhintstyle", "fhs"],
|
||||||
"CSS specification of focused hints appearance",
|
"CSS specification of focused hints appearance",
|
||||||
null,
|
null,
|
||||||
function(value) { set_pref("focusedhintstyle", value); },
|
function(value) { set_pref("focusedhintstyle", value); },
|
||||||
function() { return get_pref("focusedhintstyle"); },
|
function() { return get_pref("focusedhintstyle"); },
|
||||||
"string",
|
"string",
|
||||||
"z-index:5000;font-family:monospace;font-size:12;color:ButtonText;background-color:ButtonShadow;border-color:ButtonShadow;border-width:1px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;",
|
"z-index:5000;font-family:monospace;font-size:12;color:ButtonText;background-color:ButtonShadow;border-color:ButtonShadow;border-width:1px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["fullscreen", "fs"],
|
["fullscreen", "fs"],
|
||||||
"Shows the current window fullscreen",
|
"Shows the current window fullscreen",
|
||||||
null,
|
null,
|
||||||
function(value) { opt_fullscreen = value; BrowserFullScreen(); },
|
function(value) { opt_fullscreen = value; BrowserFullScreen(); },
|
||||||
function() { return opt_fullscreen; },
|
function() { return opt_fullscreen; },
|
||||||
"boolean",
|
"boolean",
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["guioptions", "go"],
|
["guioptions", "go"],
|
||||||
"Shows or hides the menu, toolbar and scrollbars",
|
"Shows or hides the menu, toolbar and scrollbars",
|
||||||
"Supported characters:<br><ul><li><b>m</b>: menubar</li><li><b>T</b>: toolbar<li><b>b</b>: bookmark bar</li><li><b>s</b>: original Firefox statusbar</ul>",
|
"Supported characters:<br><ul><li><b>m</b>: menubar</li><li><b>T</b>: toolbar<li><b>b</b>: bookmark bar</li><li><b>s</b>: original Firefox statusbar</ul>",
|
||||||
function(value) { set_pref("guioptions", value); set_guioptions(value); },
|
function(value) { set_pref("guioptions", value); set_guioptions(value); },
|
||||||
function() { return get_pref("guioptions"); },
|
function() { return get_pref("guioptions"); },
|
||||||
"charlist",
|
"charlist",
|
||||||
"",
|
"",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["hintchars", "hc"],
|
["hintchars", "hc"],
|
||||||
"String of single characters which can be used to follow hints",
|
"String of single characters which can be used to follow hints",
|
||||||
null,
|
null,
|
||||||
function(value) { set_pref("hintchars", value); },
|
function(value) { set_pref("hintchars", value); },
|
||||||
function() { return get_pref("hintchars"); },
|
function() { return get_pref("hintchars"); },
|
||||||
"charlist",
|
"charlist",
|
||||||
"hjklasdfgyuiopqwertnmzxcvb",
|
"hjklasdfgyuiopqwertnmzxcvb",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["hintstyle", "hs"],
|
["hintstyle", "hs"],
|
||||||
"CSS specification of unfocused hints appearance",
|
"CSS specification of unfocused hints appearance",
|
||||||
null,
|
null,
|
||||||
function(value) { set_pref("hintstyle", value); },
|
function(value) { set_pref("hintstyle", value); },
|
||||||
function() { return get_pref("hintstyle"); },
|
function() { return get_pref("hintstyle"); },
|
||||||
"string",
|
"string",
|
||||||
"z-index:5000;font-family:monospace;font-size:12;color:black;background-color:yellow;border-color:ButtonShadow;border-width:0px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;",
|
"z-index:5000;font-family:monospace;font-size:12;color:black;background-color:yellow;border-color:ButtonShadow;border-width:0px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["hinttags"],
|
["hinttags"],
|
||||||
"XPath string of hintable elements activated by 'f'",
|
"XPath string of hintable elements activated by 'f'",
|
||||||
null,
|
null,
|
||||||
function(value) { set_pref("hinttags", value); },
|
function(value) { set_pref("hinttags", value); },
|
||||||
function() { return get_pref("hinttags"); },
|
function() { return get_pref("hinttags"); },
|
||||||
"string",
|
"string",
|
||||||
"//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select",
|
"//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["maxhints", "mh"],
|
["maxhints", "mh"],
|
||||||
"Maximum of simultanously shown hints",
|
"Maximum of simultanously shown hints",
|
||||||
"If you want to speed up display of hints, choose a smaller value",
|
"If you want to speed up display of hints, choose a smaller value",
|
||||||
function(value) { set_pref("maxhints", value); },
|
function(value) { set_pref("maxhints", value); },
|
||||||
function() { return get_pref("maxhints"); },
|
function() { return get_pref("maxhints"); },
|
||||||
"number",
|
"number",
|
||||||
250,
|
250,
|
||||||
function (value) { if (value>=1 && value <=1000) return true; else return false; },
|
function (value) { if (value>=1 && value <=1000) return true; else return false; },
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["preload"],
|
["preload"],
|
||||||
"Speed up first time history/bookmark completion",
|
"Speed up first time history/bookmark completion",
|
||||||
"History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.<br>"+
|
"History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.<br>"+
|
||||||
"In order to also speed up first time access, it is cached at startup, if this option is set (recommended).",
|
"In order to also speed up first time access, it is cached at startup, if this option is set (recommended).",
|
||||||
function(value) { set_pref("preload", value); },
|
function(value) { set_pref("preload", value); },
|
||||||
function() { return get_pref("preload"); },
|
function() { return get_pref("preload"); },
|
||||||
"boolean",
|
"boolean",
|
||||||
true,
|
true,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["showtabline", "stal"],
|
["showtabline", "stal"],
|
||||||
"Control when to show the tab bar of opened web pages",
|
"Control when to show the tab bar of opened web pages",
|
||||||
"Available items:<br>"+
|
"Available items:<br>"+
|
||||||
"<ul><li><b>0</b>: Never show tab bar</li><li>"+
|
"<ul><li><b>0</b>: Never show tab bar</li><li>"+
|
||||||
" <b>1</b>: Show tab bar only if more than one tab is open</li><li>"+
|
" <b>1</b>: Show tab bar only if more than one tab is open</li><li>"+
|
||||||
" <b>2</b>: Always show tab bar</li></ul>"+
|
" <b>2</b>: Always show tab bar</li></ul>"+
|
||||||
"Not implemented yet.",
|
"Not implemented yet.",
|
||||||
function(value) { set_pref("showtabline", value); set_showtabline(value); },
|
function(value) { set_pref("showtabline", value); set_showtabline(value); },
|
||||||
function() { return get_pref("showtabline"); },
|
function() { return get_pref("showtabline"); },
|
||||||
"number",
|
"number",
|
||||||
2,
|
2,
|
||||||
function (value) { if (value>=0 && value <=2) return true; else return false; },
|
function (value) { if (value>=0 && value <=2) return true; else return false; },
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
["usermode", "um"],
|
["usermode", "um"],
|
||||||
"Show current website with a minimal stylesheet to make it easily accessible",
|
"Show current website with a minimal stylesheet to make it easily accessible",
|
||||||
"Note that this is a local setting for now, later it may be split into a global and <code style=command>:setlocal</code> part",
|
"Note that this is a local setting for now, later it may be split into a global and <code style=command>:setlocal</code> part",
|
||||||
function(value) { opt_usermode = value; setStyleDisabled(value); },
|
function(value) { opt_usermode = value; setStyleDisabled(value); },
|
||||||
function() { return opt_usermode; },
|
function() { return opt_usermode; },
|
||||||
"boolean",
|
"boolean",
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
]/*}}}*/
|
]/*}}}*/
|
||||||
|
|
||||||
// return null, if the cmd cannot be found in our g_settings array, or
|
// return null, if the cmd cannot be found in our g_settings array, or
|
||||||
// otherwise a refernce to our command
|
// otherwise a refernce to our command
|
||||||
function get_setting(cmd)
|
function get_setting(cmd)
|
||||||
{
|
{
|
||||||
for (var i=0; i < g_settings.length; i++)
|
for (var i=0; i < g_settings.length; i++)
|
||||||
{
|
{
|
||||||
for (var j=0; j < g_settings[i][0].length; j++)
|
for (var j=0; j < g_settings[i][0].length; j++)
|
||||||
{
|
{
|
||||||
if (g_settings[i][0][j] == cmd)
|
if (g_settings[i][0][j] == cmd)
|
||||||
{
|
{
|
||||||
return g_settings[i];
|
return g_settings[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
@@ -224,64 +224,64 @@ function get_setting(cmd)
|
|||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
function get_pref(name, forced_default)
|
function get_pref(name, forced_default)
|
||||||
{
|
{
|
||||||
var pref = null;
|
var pref = null;
|
||||||
var default_value = "";
|
var default_value = "";
|
||||||
|
|
||||||
// sometimes this var is not yet inititialized, make sure, it is
|
// sometimes this var is not yet inititialized, make sure, it is
|
||||||
if (!g_vimperator_prefs)
|
if (!g_vimperator_prefs)
|
||||||
g_vimperator_prefs = g_firefox_prefs.getBranch("extensions.vimperator.");
|
g_vimperator_prefs = g_firefox_prefs.getBranch("extensions.vimperator.");
|
||||||
|
|
||||||
if (forced_default) // this argument sets defaults for non-user settable options (like comp_history)
|
if (forced_default) // this argument sets defaults for non-user settable options (like comp_history)
|
||||||
default_value = forced_default;
|
default_value = forced_default;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var i=0; i<g_settings.length; i++)
|
for (var i=0; i<g_settings.length; i++)
|
||||||
{
|
{
|
||||||
if (g_settings[i][0][0] == name) // only first name is searched
|
if (g_settings[i][0][0] == name) // only first name is searched
|
||||||
{
|
{
|
||||||
default_value = g_settings[i][6];
|
default_value = g_settings[i][6];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (typeof(default_value) == "string")
|
if (typeof(default_value) == "string")
|
||||||
pref = g_vimperator_prefs.getCharPref(name);
|
pref = g_vimperator_prefs.getCharPref(name);
|
||||||
else if (typeof(default_value) == "number")
|
else if (typeof(default_value) == "number")
|
||||||
pref = g_vimperator_prefs.getIntPref(name);
|
pref = g_vimperator_prefs.getIntPref(name);
|
||||||
else if (typeof(default_value) == "boolean")
|
else if (typeof(default_value) == "boolean")
|
||||||
pref = g_vimperator_prefs.getBoolPref(name);
|
pref = g_vimperator_prefs.getBoolPref(name);
|
||||||
else
|
else
|
||||||
pref = default_value;
|
pref = default_value;
|
||||||
} catch (e)
|
} catch (e)
|
||||||
{
|
{
|
||||||
//alert("error: " + e);
|
//alert("error: " + e);
|
||||||
pref = default_value;
|
pref = default_value;
|
||||||
}
|
}
|
||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_firefox_pref(name, default_value)
|
function get_firefox_pref(name, default_value)
|
||||||
{
|
{
|
||||||
var pref;
|
var pref;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (typeof(default_value) == "string")
|
if (typeof(default_value) == "string")
|
||||||
pref = g_firefox_prefs.getCharPref(name);
|
pref = g_firefox_prefs.getCharPref(name);
|
||||||
else if (typeof(default_value) == "number")
|
else if (typeof(default_value) == "number")
|
||||||
pref = g_firefox_prefs.getIntPref(name);
|
pref = g_firefox_prefs.getIntPref(name);
|
||||||
else if (typeof(default_value) == "boolean")
|
else if (typeof(default_value) == "boolean")
|
||||||
pref = g_firefox_prefs.getBoolPref(name);
|
pref = g_firefox_prefs.getBoolPref(name);
|
||||||
else
|
else
|
||||||
pref = default_value;
|
pref = default_value;
|
||||||
} catch (e)
|
} catch (e)
|
||||||
{
|
{
|
||||||
pref = default_value;
|
pref = default_value;
|
||||||
}
|
}
|
||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
@@ -289,32 +289,32 @@ function get_firefox_pref(name, default_value)
|
|||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
function set_pref(name, value)
|
function set_pref(name, value)
|
||||||
{
|
{
|
||||||
// sometimes this var is not yet inititialized, make sure, it is
|
// sometimes this var is not yet inititialized, make sure, it is
|
||||||
if (!g_vimperator_prefs)
|
if (!g_vimperator_prefs)
|
||||||
g_vimperator_prefs = g_firefox_prefs.getBranch("extensions.vimperator.");
|
g_vimperator_prefs = g_firefox_prefs.getBranch("extensions.vimperator.");
|
||||||
|
|
||||||
if (typeof(value) == "string")
|
if (typeof(value) == "string")
|
||||||
g_vimperator_prefs.setCharPref(name, value);
|
g_vimperator_prefs.setCharPref(name, value);
|
||||||
else if (typeof(value) == "number")
|
else if (typeof(value) == "number")
|
||||||
g_vimperator_prefs.setIntPref(name, value);
|
g_vimperator_prefs.setIntPref(name, value);
|
||||||
else if (typeof(value) == "boolean")
|
else if (typeof(value) == "boolean")
|
||||||
g_vimperator_prefs.setBoolPref(name, value);
|
g_vimperator_prefs.setBoolPref(name, value);
|
||||||
else
|
else
|
||||||
echoerr("Unkown typeof pref: " + value);
|
echoerr("Unkown typeof pref: " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_firefox_pref(name, value)
|
function set_firefox_pref(name, value)
|
||||||
{
|
{
|
||||||
// NOTE: firefox prefs are always inititialized, no need to re-init
|
// NOTE: firefox prefs are always inititialized, no need to re-init
|
||||||
|
|
||||||
if (typeof(value) == "string")
|
if (typeof(value) == "string")
|
||||||
g_firefox_prefs.setCharPref(name, value);
|
g_firefox_prefs.setCharPref(name, value);
|
||||||
else if (typeof(value) == "number")
|
else if (typeof(value) == "number")
|
||||||
g_firefox_prefs.setIntPref(name, value);
|
g_firefox_prefs.setIntPref(name, value);
|
||||||
else if (typeof(value) == "boolean")
|
else if (typeof(value) == "boolean")
|
||||||
g_firefox_prefs.setBoolPref(name, value);
|
g_firefox_prefs.setBoolPref(name, value);
|
||||||
else
|
else
|
||||||
echoerr("Unkown typeof pref: " + value);
|
echoerr("Unkown typeof pref: " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -324,35 +324,35 @@ function set_firefox_pref(name, value)
|
|||||||
|
|
||||||
function set_guioptions(value)
|
function set_guioptions(value)
|
||||||
{
|
{
|
||||||
// hide menubar
|
// hide menubar
|
||||||
document.getElementById("toolbar-menubar").collapsed = value.indexOf("m") > -1 ? false : true;
|
document.getElementById("toolbar-menubar").collapsed = value.indexOf("m") > -1 ? false : true;
|
||||||
document.getElementById("toolbar-menubar").hidden = value.indexOf("m") > -1 ? false : true;
|
document.getElementById("toolbar-menubar").hidden = value.indexOf("m") > -1 ? false : true;
|
||||||
// and main toolbar
|
// and main toolbar
|
||||||
document.getElementById("nav-bar").collapsed = value.indexOf("T") > -1 ? false : true;
|
document.getElementById("nav-bar").collapsed = value.indexOf("T") > -1 ? false : true;
|
||||||
document.getElementById("nav-bar").hidden = value.indexOf("T") > -1 ? false : true;
|
document.getElementById("nav-bar").hidden = value.indexOf("T") > -1 ? false : true;
|
||||||
// and bookmarks toolbar
|
// and bookmarks toolbar
|
||||||
document.getElementById("PersonalToolbar").collapsed = value.indexOf("b") > -1 ? false : true;
|
document.getElementById("PersonalToolbar").collapsed = value.indexOf("b") > -1 ? false : true;
|
||||||
document.getElementById("PersonalToolbar").hidden = value.indexOf("b") > -1 ? false : true;
|
document.getElementById("PersonalToolbar").hidden = value.indexOf("b") > -1 ? false : true;
|
||||||
// and original status bar (default), but show it, e.g. when needed for extensions
|
// and original status bar (default), but show it, e.g. when needed for extensions
|
||||||
document.getElementById("status-bar").collapsed = value.indexOf("s") > -1 ? false : true;
|
document.getElementById("status-bar").collapsed = value.indexOf("s") > -1 ? false : true;
|
||||||
document.getElementById("status-bar").hidden = value.indexOf("s") > -1 ? false : true;
|
document.getElementById("status-bar").hidden = value.indexOf("s") > -1 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_showtabline(value)
|
function set_showtabline(value)
|
||||||
{
|
{
|
||||||
// hide tabbar
|
// hide tabbar
|
||||||
if(value == 0)
|
if(value == 0)
|
||||||
{
|
{
|
||||||
gBrowser.mStrip.collapsed = true;
|
gBrowser.mStrip.collapsed = true;
|
||||||
gBrowser.mStrip.hidden = true;
|
gBrowser.mStrip.hidden = true;
|
||||||
}
|
}
|
||||||
else if(value == 1)
|
else if(value == 1)
|
||||||
echo("show tabline only with > 1 page open not impl. yet");
|
echo("show tabline only with > 1 page open not impl. yet");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gBrowser.mStrip.collapsed = false;
|
gBrowser.mStrip.collapsed = false;
|
||||||
gBrowser.mStrip.hidden = false;
|
gBrowser.mStrip.hidden = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user