show README on first install
[guerillascript.git] / main / prefs / prefs.js
blobb3c50e8db13b869aa15517a9b94fddc6f51a3c24
1 /* coded by Ketmar // Invisible Vector (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software. It comes without any warranty, to
5 * the extent permitted by applicable law. You can redistribute it
6 * and/or modify it under the terms of the Do What The Fuck You Want
7 * To Public License, Version 2, as published by Sam Hocevar. See
8 * http://www.wtfpl.net/txt/copying/ for more details.
9 */
10 ////////////////////////////////////////////////////////////////////////////////
11 const PREFS_BRANCH = "extensions.guerilla.";
13 let PREFS = {
14 fsoReadmeViewed: false, // readme viewed?
15 debugMode: false,
16 debugCache: false,
17 logEnabled: true,
18 active: true,
19 // all pathes are relative to profile dir
20 jsdir: "guerillajs/scripts",
21 libdir: "guerillajs/libs",
22 dbdir: "guerillajs/data",
23 pkgdir: "guerillajs/packages",
24 pkgdbdir: "guerillajs/packages/_0data",
25 pkgtempdir: "guerillajs/packages/_0temp",
28 const PREFS_DIR_NAMES = {
29 jsdir: "JSDir",
30 libdir: "LibDir",
31 dbdir: "DBDir",
32 pkgdir: "PkgDir",
33 pkgdbdir: "PkgDBDir",
34 pkgtempdir: "PkgTempDir",
38 ////////////////////////////////////////////////////////////////////////////////
39 // restore old values if user has some old dirs
40 (function () {
41 const PREFS_OLD_DIRS = {
42 jsdir: "guerillajs",
43 libdir: "guerillajs_libs",
44 dbdir: "guerillajs_data",
45 pkgdir: "guerillajs_packages",
46 pkgdbdir: "guerillajs_packages/_0data",
47 pkgtempdir: "guerillajs_packages/_0temp",
50 const dirSvcProps = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
51 let oldFound = false;
52 for (let [n, v] of Iterator(PREFS_OLD_DIRS)) {
53 if (n === "jsdir" || v === "guerillajs") continue;
54 // get profile directory
55 let df = dirSvcProps.get("ProfD", Ci.nsIFile);
56 if (v.length) for (let d of v.split("/")) if (d.length) df.append(d);
57 if (df.exists()) {
58 Cu.reportError("GS: old directory ('", n, "' [", v, "]) found!");
59 oldFound = true;
60 break;
63 // found? restore old values
64 if (oldFound) for (let [n, v] of Iterator(PREFS_OLD_DIRS)) PREFS[n] = v;
65 })();