OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus 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 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 709 |
710 for (var key in settings) | 710 for (var key in settings) |
711 { | 711 { |
712 var item = mapFunc(key, settings[key]); | 712 var item = mapFunc(key, settings[key]); |
713 if (item) | 713 if (item) |
714 { | 714 { |
715 delete settings[key]; | 715 delete settings[key]; |
716 settings[item.key] = item.value; | 716 settings[item.key] = item.value; |
717 } | 717 } |
718 } | 718 } |
| 719 }, |
| 720 |
| 721 // While moving away from the FileSystem API on Chrome the data structure |
| 722 // for files on Safari changed as well, in order to keep thing consistent. |
| 723 migrateFiles: function(callback) |
| 724 { |
| 725 var settings = safari.extension.settings; |
| 726 |
| 727 for (var key in settings) |
| 728 { |
| 729 var match = key.match(/^(.*)\/lastModified$/) |
| 730 |
| 731 if (match) |
| 732 { |
| 733 var filename = match[1]; |
| 734 var content = settings[filename]; |
| 735 |
| 736 if (typeof content == "string") |
| 737 { |
| 738 settings["file:" + filename] = { |
| 739 content: content.split(/[\r\n]+/), |
| 740 lastModified: settings[key] |
| 741 }; |
| 742 |
| 743 delete settings[key]; |
| 744 delete settings[filename]; |
| 745 } |
| 746 } |
| 747 } |
| 748 |
| 749 callback(); |
719 } | 750 } |
720 }; | 751 }; |
721 | 752 |
722 safari.extension.settings.addEventListener("change", function(event) | 753 safari.extension.settings.addEventListener("change", function(event) |
723 { | 754 { |
724 var changes = {}; | 755 var changes = {}; |
725 var change = changes[event.key] = {}; | 756 var change = changes[event.key] = {}; |
726 | 757 |
727 if (event.oldValue != null) | 758 if (event.oldValue != null) |
728 change.oldValue = event.oldValue; | 759 change.oldValue = event.oldValue; |
(...skipping 20 matching lines...) Expand all Loading... |
749 tab.activate(); | 780 tab.activate(); |
750 if (callback) | 781 if (callback) |
751 callback(page); | 782 callback(page); |
752 return; | 783 return; |
753 } | 784 } |
754 } | 785 } |
755 | 786 |
756 ext.pages.open(optionsUrl, callback); | 787 ext.pages.open(optionsUrl, callback); |
757 }; | 788 }; |
758 })(); | 789 })(); |
OLD | NEW |