1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 15:02:26 +01:00

*** empty log message ***

This commit is contained in:
Kris Maglione
2008-10-03 15:22:27 +00:00
parent 07643baebe
commit 2e16ddc8f1
2 changed files with 31 additions and 52 deletions

View File

@@ -564,7 +564,6 @@ liberator.CommandLine = function () //{{{
historyIndex = UNINITIALIZED; historyIndex = UNINITIALIZED;
completionIndex = UNINITIALIZED; completionIndex = UNINITIALIZED;
autocompleteTimer.reset();
liberator.modes.push(liberator.modes.COMMAND_LINE, currentExtendedMode); liberator.modes.push(liberator.modes.COMMAND_LINE, currentExtendedMode);
setHighlightGroup(this.HL_NORMAL); setHighlightGroup(this.HL_NORMAL);
@@ -812,7 +811,6 @@ liberator.CommandLine = function () //{{{
completions.sort(function (a, b) String.localeCompare(a[0], b[0])); completions.sort(function (a, b) String.localeCompare(a[0], b[0]));
completionList.setItems(completions); completionList.setItems(completions);
statusTimer.reset();
} }
if (completions.length == 0) if (completions.length == 0)
@@ -1234,8 +1232,15 @@ liberator.ItemList = function (id) //{{{
catch (e) {} // for muttator! catch (e) {} // for muttator!
// TODO: temporary, to be changed/removed // TODO: temporary, to be changed/removed
function createRow(a, b, c, dom) function createRow(b, c, dom)
{ {
try
{
let uri = ioService.newURI(b, null, null);
var a = faviconService.getFaviconImageForPage(uri).spec;
}
catch (e) {}
let row = let row =
<tr class="liberator-compitem"> <tr class="liberator-compitem">
<td style="width: 16px"/> <td style="width: 16px"/>
@@ -1258,9 +1263,8 @@ liberator.ItemList = function (id) //{{{
if (completionElements.length == 0) if (completionElements.length == 0)
return doc.height; return doc.height;
var wanted = maxItems + listOffset; var wanted = Math.min(maxItems + listOffset,
if (wanted > completionElements.length) completionElements.length);
wanted = completionElements.length;
return completionElements[wanted - 1].getBoundingClientRect().bottom; return completionElements[wanted - 1].getBoundingClientRect().bottom;
} }
@@ -1285,38 +1289,25 @@ liberator.ItemList = function (id) //{{{
if (listIndex > -1 && offset == listOffset + 1) if (listIndex > -1 && offset == listOffset + 1)
{ {
listOffset = offset; listOffset = offset;
var icon = ""; var row = createRow(completions[offset + maxItems - 1][0], completions[offset + maxItems - 1][1], true);
try
{
var uri = ioService.newURI(completions[offset][0], null, null);
icon = faviconService.getFaviconImageForPage(uri).spec;
}
catch (e) {}
var row = createRow(icon, completions[offset + maxItems - 1][0], completions[offset + maxItems - 1][1], true);
var e = doc.getElementsByTagName("tbody"); var e = doc.getElementsByTagName("tbody");
e = e[e.length - 1]; e = e[e.length - 1];
e.removeChild(e.firstChild); e.removeChild(e.firstChild);
e.appendChild(row); e.appendChild(row);
completionElements = doc.getElementsByClassName("liberator-compitem"); // TODO: make faster completionElements = e.children;
return; return;
} }
else if (listIndex > -1 && offset == listOffset - 1) else if (listIndex > -1 && offset == listOffset - 1)
{ {
listOffset = offset; listOffset = offset;
var icon = ""; var row = createRow(completions[offset][0], completions[offset][1], true);
try
{
var uri = ioService.newURI(completions[offset][0], null, null);
icon = faviconService.getFaviconImageForPage(uri).spec;
}
catch (e) {}
var row = createRow(icon, completions[offset][0], completions[offset][1], true);
var e = doc.getElementsByTagName("tbody"); var e = doc.getElementsByTagName("tbody");
e = e[e.length - 1]; e = e[e.length - 1];
e.removeChild(e.lastChild); e.removeChild(e.lastChild);
e.insertBefore(row, e.firstChild); e.insertBefore(row, e.firstChild);
completionElements = doc.getElementsByClassName("liberator-compitem"); // TODO: make faster completionElements = e.children;
return; return;
} }
@@ -1331,21 +1322,12 @@ liberator.ItemList = function (id) //{{{
</div>; </div>;
let tbody = div..tbody; let tbody = div..tbody;
for (let [i, elem] in Iterator(completions)) for (let i in liberator.util.range(offset, Math.min(offset + maxItems,
completions.length)))
{ {
if (i >= listOffset && i - listOffset < maxItems) let elem = completions[i];
{ tbody.* += createRow(elem[0], elem[1]);
let icon = ""; }
try
{
let uri = ioService.newURI(elem[0], null, null);
icon = faviconService.getFaviconImageForPage(uri).spec;
}
catch (e) {}
tbody.* += createRow(icon, elem[0], elem[1]);
}
};
doc.body.appendChild(liberator.util.xmlToDom(div, doc)); doc.body.appendChild(liberator.util.xmlToDom(div, doc));

View File

@@ -30,41 +30,38 @@ liberator.util = { //{{{
Timer: function Timer(minInterval, maxInterval, callback) Timer: function Timer(minInterval, maxInterval, callback)
{ {
let self = this;
let timer = Components.classes["@mozilla.org/timer;1"] let timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer); .createInstance(Components.interfaces.nsITimer);
this.first = true; /* When set, trigger immediately. */ this.doneAt = 0;
this.latest = 0; this.latest = 0;
this.notify = function (aTimer) this.notify = function (aTimer)
{ {
timer.cancel(); timer.cancel();
if (this.latest || this.first) this.doneAt = Date.now() + minInterval;
callback(this.arg);
else /* Don't trigger. Set this.first after the minimum interval. */
timer.initWithCallback(this, minInterval, timer.TYPE_ONE_SHOT);
this.first = (this.latest == 0);
this.latest = 0; this.latest = 0;
callback(this.arg);
} }
this.tell = function (arg) this.tell = function (arg)
{ {
if (arg != undefined) if (arg !== undefined)
this.arg = arg; this.arg = arg;
if (this.first || this.latest > Date.now()) if (this.doneAt == -1)
return this.notify();
if (this.latest)
timer.cancel(); timer.cancel();
else if (Date.now() >= this.doneAt)
return this.notify();
let timeout = minInterval; let timeout = minInterval;
if (this.latest) if (this.latest)
timeout = Math.min(minInterval, this.latest - Date.now()); timeout = Math.min(minInterval, this.latest - Date.now());
else else
this.latest = Date.now() + maxInterval; this.latest = Date.now() + maxInterval;
this.timer = timer.initWithCallback(this, timeout, timer.TYPE_ONE_SHOT); timer.initWithCallback(this, timeout, timer.TYPE_ONE_SHOT);
this.doneAt = -1;
} }
this.reset = function () this.reset = function ()
{ {
timer.cancel(); timer.cancel();
this.first = true; this.doneAt = 0;
} }
this.flush = function () this.flush = function ()
{ {