Mercurial > hg > digilib
comparison xul/content/settings.js @ 199:49cb8a445126
restarting with version control of xul sidebar/toolbar
| author | luginbue |
|---|---|
| date | Fri, 27 Feb 2004 11:24:53 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 198:c50e0e77d697 | 199:49cb8a445126 |
|---|---|
| 1 /* | |
| 2 Copyright (C) 2003 WTWG, Uni Bern | |
| 3 | |
| 4 This program is free software; you can redistribute it and/or | |
| 5 modify it under the terms of the GNU General Public License | |
| 6 as published by the Free Software Foundation; either version 2 | |
| 7 of the License, or (at your option) any later version. | |
| 8 | |
| 9 This program is distributed in the hope that it will be useful, | |
| 10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 GNU General Public License for more details. | |
| 13 | |
| 14 You should have received a copy of the GNU General Public License | |
| 15 along with this program; if not, write to the Free Software | |
| 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
| 17 | |
| 18 Author: Christian Luginbuehl, 24.01.2004 , Version Alcatraz 0.5 | |
| 19 */ | |
| 20 | |
| 21 | |
| 22 include(jslib_dirutils); | |
| 23 include(jslib_file); | |
| 24 | |
| 25 var du = new DirUtils(); | |
| 26 var f = new File('alcatraz.pref'); | |
| 27 | |
| 28 f.initPath(du.getPrefsDir()); | |
| 29 f.append('alcatraz.pref'); | |
| 30 | |
| 31 function getSetting(name) { | |
| 32 | |
| 33 if (f.exists()) { | |
| 34 | |
| 35 f.open(); | |
| 36 var content = f.read(); | |
| 37 f.close(); | |
| 38 | |
| 39 var lines = content.split(/\n/); | |
| 40 | |
| 41 for (i = 0; i <lines.length; i++) { | |
| 42 var line = lines[i].split('='); | |
| 43 if (line[0] == name) { | |
| 44 return line[1]; | |
| 45 } | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 return null; | |
| 50 } | |
| 51 | |
| 52 | |
| 53 function saveSetting(name, value) { | |
| 54 | |
| 55 var content = ""; | |
| 56 | |
| 57 if (f.exists()) { | |
| 58 f.open(); | |
| 59 content = f.read(); | |
| 60 f.close(); | |
| 61 f.remove(); | |
| 62 } | |
| 63 | |
| 64 f.create(); | |
| 65 f.open('w'); | |
| 66 f.write(name + '=' + value + '\n'); | |
| 67 | |
| 68 var lines = content.split(/\n/); | |
| 69 | |
| 70 for (i = 0; i < lines.length; i++) { | |
| 71 var line = lines[i].split('='); | |
| 72 if (line[0] != name && line[0] != '') { | |
| 73 f.write(line[0] + '=' + line[1] + '\n'); | |
| 74 } | |
| 75 } | |
| 76 f.close(); | |
| 77 } |
