From 793e45ea8346129f060e2b751df0d3a315528afa Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 23 Oct 2008 14:06:39 +0000 Subject: [PATCH] add the platform to config.features --- content/completion.js | 6 ++---- content/io.js | 2 +- content/liberator.js | 14 +++++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/content/completion.js b/content/completion.js index 3d91ab91..9d5f8681 100644 --- a/content/completion.js +++ b/content/completion.js @@ -39,8 +39,6 @@ function Completion() //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - const WINDOWS = navigator.platform == "Win32"; - try { var completionService = Components.classes["@mozilla.org/browser/global-history;2"] @@ -842,7 +840,7 @@ function Completion() //{{{ environment: function environment(filter) { - let command = WINDOWS ? "set" : "export"; + let command = liberator.has("Win32") ? "set" : "export"; let lines = io.system(command).split("\n"); lines.splice(lines.length - 1, 1); @@ -1080,7 +1078,7 @@ function Completion() //{{{ const environmentService = Components.classes["@mozilla.org/process/environment;1"] .getService(Components.interfaces.nsIEnvironment); - let dirNames = environmentService.get("PATH").split(RegExp(WINDOWS ? ";" : ":")); + let dirNames = environmentService.get("PATH").split(RegExp(liberator.has("Win32") ? ";" : ":")); let commands = []; for (let [,dirName] in Iterator(dirNames)) diff --git a/content/io.js b/content/io.js index 1a79edcf..62b5fcf9 100644 --- a/content/io.js +++ b/content/io.js @@ -34,7 +34,7 @@ function IO() //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - const WINDOWS = navigator.platform == "Win32"; + const WINDOWS = liberator.has("Win32"); const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator" const environmentService = Components.classes["@mozilla.org/process/environment;1"] diff --git a/content/liberator.js b/content/liberator.js index 571b47f8..d337eb24 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -860,8 +860,8 @@ const liberator = (function () //{{{ // return true, if this liberator extension has a certain feature has: function (feature) { - var features = config.features || []; - return features.some(function (feat) feat == feature); + let features = config.features || []; + return features.indexOf(feature) >= 0; }, help: function (topic) @@ -1130,6 +1130,9 @@ const liberator = (function () //{{{ let start = Date.now(); 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 loadModule("commands", Commands); addCommands(); loadModule("options", Options); addOptions(); @@ -1143,7 +1146,7 @@ const liberator = (function () //{{{ loadModule("io", IO); 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) config.init(); @@ -1154,11 +1157,12 @@ const liberator = (function () //{{{ liberator.registerCallback("complete", modes.EX, function (str) { return completion.ex(str); }); // 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 () { liberator.help(); - options.setPref("extensions." + config.name.toLowerCase() + ".firsttime", false); + options.setPref(firstTime, false); }, 1000); }