mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:47:59 +01:00
add the platform to config.features
This commit is contained in:
@@ -39,8 +39,6 @@ function Completion() //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
const WINDOWS = navigator.platform == "Win32";
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var completionService = Components.classes["@mozilla.org/browser/global-history;2"]
|
var completionService = Components.classes["@mozilla.org/browser/global-history;2"]
|
||||||
@@ -842,7 +840,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
environment: function environment(filter)
|
environment: function environment(filter)
|
||||||
{
|
{
|
||||||
let command = WINDOWS ? "set" : "export";
|
let command = liberator.has("Win32") ? "set" : "export";
|
||||||
let lines = io.system(command).split("\n");
|
let lines = io.system(command).split("\n");
|
||||||
|
|
||||||
lines.splice(lines.length - 1, 1);
|
lines.splice(lines.length - 1, 1);
|
||||||
@@ -1080,7 +1078,7 @@ function Completion() //{{{
|
|||||||
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
.getService(Components.interfaces.nsIEnvironment);
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
|
|
||||||
let dirNames = environmentService.get("PATH").split(RegExp(WINDOWS ? ";" : ":"));
|
let dirNames = environmentService.get("PATH").split(RegExp(liberator.has("Win32") ? ";" : ":"));
|
||||||
let commands = [];
|
let commands = [];
|
||||||
|
|
||||||
for (let [,dirName] in Iterator(dirNames))
|
for (let [,dirName] in Iterator(dirNames))
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function IO() //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
const WINDOWS = navigator.platform == "Win32";
|
const WINDOWS = liberator.has("Win32");
|
||||||
const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator"
|
const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator"
|
||||||
|
|
||||||
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
|
|||||||
@@ -860,8 +860,8 @@ const liberator = (function () //{{{
|
|||||||
// return true, if this liberator extension has a certain feature
|
// return true, if this liberator extension has a certain feature
|
||||||
has: function (feature)
|
has: function (feature)
|
||||||
{
|
{
|
||||||
var features = config.features || [];
|
let features = config.features || [];
|
||||||
return features.some(function (feat) feat == feature);
|
return features.indexOf(feature) >= 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
help: function (topic)
|
help: function (topic)
|
||||||
@@ -1130,6 +1130,9 @@ const liberator = (function () //{{{
|
|||||||
let start = Date.now();
|
let start = Date.now();
|
||||||
liberator.log("Initializing liberator object...", 0);
|
liberator.log("Initializing liberator object...", 0);
|
||||||
|
|
||||||
|
// TODO: only checked for "Win32" currently, other values should be normalised
|
||||||
|
config.features.push(navigator.platform);
|
||||||
|
|
||||||
// commands must always be the first module to be initialized
|
// commands must always be the first module to be initialized
|
||||||
loadModule("commands", Commands); addCommands();
|
loadModule("commands", Commands); addCommands();
|
||||||
loadModule("options", Options); addOptions();
|
loadModule("options", Options); addOptions();
|
||||||
@@ -1143,7 +1146,7 @@ const liberator = (function () //{{{
|
|||||||
loadModule("io", IO);
|
loadModule("io", IO);
|
||||||
loadModule("completion", Completion);
|
loadModule("completion", Completion);
|
||||||
|
|
||||||
// This adds options/mappings/commands which are only valid in this particular extension
|
// add options/mappings/commands which are only valid in this particular extension
|
||||||
if (config.init)
|
if (config.init)
|
||||||
config.init();
|
config.init();
|
||||||
|
|
||||||
@@ -1154,11 +1157,12 @@ const liberator = (function () //{{{
|
|||||||
liberator.registerCallback("complete", modes.EX, function (str) { return completion.ex(str); });
|
liberator.registerCallback("complete", modes.EX, function (str) { return completion.ex(str); });
|
||||||
|
|
||||||
// first time intro message
|
// first time intro message
|
||||||
if (options.getPref("extensions." + config.name.toLowerCase() + ".firsttime", true))
|
const firstTime = "extensions." + config.name.toLowerCase() + ".firsttime";
|
||||||
|
if (options.getPref(firstTime, true))
|
||||||
{
|
{
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
liberator.help();
|
liberator.help();
|
||||||
options.setPref("extensions." + config.name.toLowerCase() + ".firsttime", false);
|
options.setPref(firstTime, false);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user