git-svn-id: svn://euphorik.ch/pompage@45 02bbb61a-6d21-0410-aba0-cb053bdfd66a
[pompage.git] / doc / webdeveloper / upgrade.js
1 // Migrate the extension to 1.0
2 function webdeveloper_migrateTo1()
3 {
4 var toolbar = document.getElementById("webdeveloper-toolbar");
5
6 webdeveloper_deletePreferenceBranch("webdeveloper.color");
7 webdeveloper_deletePreferenceBranch("webdeveloper.edit.css");
8 webdeveloper_deletePreferenceBranch("webdeveloper.tidied");
9 webdeveloper_deletePreferenceBranch("webdeveloper.validator");
10
11 // Remove the disabled preference
12 if(webdeveloper_isPreferenceSet("webdeveloper.disabled"))
13 {
14 webdeveloper_deletePreference("webdeveloper.disabled");
15 }
16
17 // Migrate the populate form fields email
18 if(webdeveloper_getStringPreference("webdeveloper.populate.form.fields.email", true) == "noemail@noemail.org")
19 {
20 webdeveloper_deletePreference("webdeveloper.populate.form.fields.email");
21 }
22
23 // Migrate the validate feed url
24 if(webdeveloper_getStringPreference("webdeveloper.tool.2.url", true) == "http://feedvalidator.org/check.cgi?url=")
25 {
26 webdeveloper_deletePreference("webdeveloper.tool.2.url");
27 }
28
29 // Migrate the view speed report
30 if(webdeveloper_getStringPreference("webdeveloper.tool.7.url", true) == "http://www.websiteoptimization.com/cgi-bin/wso/wso.pl?url=")
31 {
32 webdeveloper_deletePreference("webdeveloper.tool.7.description");
33 webdeveloper_deletePreference("webdeveloper.tool.7.url");
34 }
35
36 // Migrate the tool count
37 if(webdeveloper_getIntegerPreference("webdeveloper.tool.count", true) < 8)
38 {
39 webdeveloper_deletePreference("webdeveloper.tool.count");
40 }
41
42 toolbar.collapsed = false;
43 toolbar.hidden = false;
44
45 document.persist("webdeveloper-toolbar", "collapsed");
46 document.persist("webdeveloper-toolbar", "hidden");
47 }
48
49 // Migrate the extension to 1.1
50 function webdeveloper_migrateTo11()
51 {
52 // Migrate DOM Inspector sidebar
53 if(webdeveloper_isPreferenceSet("webdeveloper.dom.inspector.sidebar"))
54 {
55 webdeveloper_setBooleanPreference("webdeveloper.dom.inspector.dashboard", webdeveloper_getBooleanPreference("webdeveloper.dom.inspector.sidebar", true));
56 webdeveloper_deletePreference("webdeveloper.dom.inspector.sidebar");
57 }
58
59 // Migrate JavaScript console dashboard
60 if(webdeveloper_isPreferenceSet("webdeveloper.javascript.console.dashboard"))
61 {
62 webdeveloper_setBooleanPreference("webdeveloper.error.console.dashboard", webdeveloper_getBooleanPreference("webdeveloper.javascript.console.dashboard", true));
63 webdeveloper_deletePreference("webdeveloper.javascript.console.dashboard");
64 }
65
66 // Migrate JavaScript console key
67 if(webdeveloper_isPreferenceSet("webdeveloper.javascript.console.key"))
68 {
69 webdeveloper_setStringPreference("webdeveloper.error.console.key", webdeveloper_getStringPreference("webdeveloper.javascript.console.key", true));
70 webdeveloper_deletePreference("webdeveloper.javascript.console.key");
71 }
72
73 // Migrate JavaScript console sidebar
74 if(webdeveloper_isPreferenceSet("webdeveloper.javascript.console.sidebar"))
75 {
76 webdeveloper_setBooleanPreference("webdeveloper.error.console.dashboard", webdeveloper_getBooleanPreference("webdeveloper.javascript.console.sidebar", true));
77 webdeveloper_deletePreference("webdeveloper.javascript.console.sidebar");
78 }
79
80 // Migrate persist styles
81 if(webdeveloper_isPreferenceSet("webdeveloper.styles.persist"))
82 {
83 webdeveloper_setBooleanPreference("webdeveloper.persist.features", webdeveloper_getBooleanPreference("webdeveloper.styles.persist", true));
84 webdeveloper_deletePreference("webdeveloper.styles.persist");
85 }
86
87 // Migrate view style information dashboard
88 if(webdeveloper_isPreferenceSet("webdeveloper.view.style.information.sidebar"))
89 {
90 webdeveloper_setBooleanPreference("webdeveloper.style.information.dashboard", webdeveloper_getBooleanPreference("webdeveloper.view.style.information.sidebar", true));
91 webdeveloper_deletePreference("webdeveloper.view.style.information.sidebar");
92 }
93 }
94
95 // Migrate the extension to 1.1.2
96 function webdeveloper_migrateTo112()
97 {
98 // Migrate validate CSS
99 if(webdeveloper_getStringPreference("webdeveloper.tool.1.url", true) == "http://jigsaw.w3.org/css-validator/validator?profile=css2&warning=0&uri=")
100 {
101 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.1.url", "http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=");
102 }
103 }
104
105 // Parses the version number
106 function webdeveloper_parseVersion(version)
107 {
108 // If the version is set
109 if(version)
110 {
111 var splitVersion = version.split(".");
112 var parsedVersion = splitVersion[0] + ".";
113 var splitVersionLength = splitVersion.length;
114
115 // Loop through the remaining parts of the version
116 for(var i = 1; i < splitVersionLength; i++)
117 {
118 parsedVersion += splitVersion[i];
119 }
120
121 return parseFloat(parsedVersion);
122 }
123 else
124 {
125 return 0;
126 }
127 }
128
129 // Check if the extension is being upgraded
130 function webdeveloper_upgrade()
131 {
132 var previousVersion = webdeveloper_parseVersion(webdeveloper_getStringPreference("webdeveloper.version", true));
133 var version = webdeveloper_parseVersion("1.1.4");
134
135 // If the versions do not match
136 if(previousVersion != version)
137 {
138 // If the previous version is less than 1.0.2
139 if(previousVersion < webdeveloper_parseVersion("1.0.2"))
140 {
141 webdeveloper_migrateTo1();
142 }
143
144 // If the previous version is less than 1.1
145 if(previousVersion < webdeveloper_parseVersion("1.1"))
146 {
147 webdeveloper_migrateTo11();
148 }
149
150 // If the previous version is less than 1.1.2
151 if(previousVersion < webdeveloper_parseVersion("1.1.2"))
152 {
153 webdeveloper_migrateTo112();
154 }
155
156 webdeveloper_setStringPreference("webdeveloper.version", version);
157 }
158 }