1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 21:28:00 +01:00

Make :viewsource a bit more robust

This commit is contained in:
Kris Maglione
2009-09-17 14:00:26 -04:00
parent 52378d8a9f
commit f6e130a93f
2 changed files with 20 additions and 12 deletions

View File

@@ -326,15 +326,7 @@ function Buffer() //{{{
mappings.add(myModes, ["\\"],
"Toggle between rendered and source view",
function ()
{
const scheme = "view-source";
if (util.newURI(buffer.URL).scheme == scheme)
liberator.open(buffer.URL.substr(scheme.length + 1));
else
liberator.open(scheme + ":" + buffer.URL);
});
function () { buffer.viewSource(null, false); });
mappings.add(myModes, ["gi"],
"Focus last used input field",
@@ -1593,7 +1585,14 @@ function Buffer() //{{{
if (useExternalEditor)
editor.editFileExternally(url);
else
liberator.open("view-source:" + url);
{
const PREFIX = "view-source:";
if (url.indexOf(PREFIX) == 0)
url = url.substr(PREFIX.length);
else
url = PREFIX + url;
liberator.open(url, { hide: true });
}
},
/**

View File

@@ -1527,7 +1527,7 @@ const liberator = (function () //{{{
* ["url1", "url2", "url3", ...]
* or:
* [["url1", postdata1], ["url2", postdata2], ...]
* @param {number} where If ommited, CURRENT_TAB is assumed but NEW_TAB
* @param {number|Object} where If ommited, CURRENT_TAB is assumed but NEW_TAB
* is set when liberator.forceNewTab is true.
* @param {boolean} force Don't prompt whether to open more than 20
* tabs.
@@ -1563,6 +1563,15 @@ const liberator = (function () //{{{
return true;
}
let flags = 0;
if (where instanceof Object)
{
for (let [opt, flag] in Iterator({ replace: "REPLACE_HISTORY", hide: "BYPASS_HISTORY" }))
if (where[opt])
flags |= Ci.nsIWebNavigation["LOAD_FLAGS_" + flag];
where = liberator.CURRENT_TAB;
}
if (urls.length == 0)
return false;
@@ -1577,7 +1586,7 @@ const liberator = (function () //{{{
switch (where)
{
case liberator.CURRENT_TAB:
browser.loadURIWithFlags(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, postdata);
browser.loadURIWithFlags(url, flags, null, null, postdata);
break;
case liberator.NEW_BACKGROUND_TAB: