OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the URL Fixer, | 2 * This file is part of the URL Fixer, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * URL Fixer is free software: you can redistribute it and/or modify | 5 * URL Fixer is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * URL Fixer is distributed in the hope that it will be useful, | 9 * URL Fixer is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 21 matching lines...) Expand all Loading... |
32 let updateTimer = null; | 32 let updateTimer = null; |
33 updateTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); | 33 updateTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
34 updateTimer.initWithCallback(onTimer, 1000 * 60 * 5, Ci.nsITimer.TYPE_REPEATING_
SLACK); | 34 updateTimer.initWithCallback(onTimer, 1000 * 60 * 5, Ci.nsITimer.TYPE_REPEATING_
SLACK); |
35 onShutdown.add(() => updateTimer.cancel()); | 35 onShutdown.add(() => updateTimer.cancel()); |
36 | 36 |
37 function loadRules() | 37 function loadRules() |
38 { | 38 { |
39 loadRulesFrom(Services.io.newFileURI(getRuleFile()).spec, false, function(succ
ess) | 39 loadRulesFrom(Services.io.newFileURI(getRuleFile()).spec, false, function(succ
ess) |
40 { | 40 { |
41 if (!success) | 41 if (!success) |
42 loadRulesFrom(require("info").addonRoot + "defaults/typoRules.json", true)
; | 42 loadRulesFrom("chrome://" + require("info").addonName + "/content/typoRule
s.json", true); |
43 }); | 43 }); |
44 } | 44 } |
45 | 45 |
46 function loadRulesFrom(url, ignoreVersion, callback) | 46 function loadRulesFrom(url, ignoreVersion, callback) |
47 { | 47 { |
48 if (typeof callback != "function") | 48 if (typeof callback != "function") |
49 callback = function() {}; | 49 callback = function() {}; |
50 | 50 |
51 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.
nsIXMLHttpRequest); | 51 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.
nsIXMLHttpRequest); |
52 request.open("GET", url); | 52 request.open("GET", url); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 bestSuggestionDistance = distance; | 413 bestSuggestionDistance = distance; |
414 bestSuggestionMatched = matchedLen; | 414 bestSuggestionMatched = matchedLen; |
415 bestSuggestionPriority = priority; | 415 bestSuggestionPriority = priority; |
416 } | 416 } |
417 } | 417 } |
418 if (bestSuggestion) | 418 if (bestSuggestion) |
419 return input.substr(0, input.length - bestSuggestionMatched) + bestSuggestio
n; | 419 return input.substr(0, input.length - bestSuggestionMatched) + bestSuggestio
n; |
420 else | 420 else |
421 return input; | 421 return input; |
422 } | 422 } |
OLD | NEW |