1 // Migrate the extension to 1.0
2 function webdeveloper_migrateTo1()
4 var toolbar
= document
.getElementById("webdeveloper-toolbar");
6 webdeveloper_deletePreferenceBranch("webdeveloper.color");
7 webdeveloper_deletePreferenceBranch("webdeveloper.edit.css");
8 webdeveloper_deletePreferenceBranch("webdeveloper.tidied");
9 webdeveloper_deletePreferenceBranch("webdeveloper.validator");
11 // Remove the disabled preference
12 if(webdeveloper_isPreferenceSet("webdeveloper.disabled"))
14 webdeveloper_deletePreference("webdeveloper.disabled");
17 // Migrate the populate form fields email
18 if(webdeveloper_getStringPreference("webdeveloper.populate.form.fields.email", true) == "noemail@noemail.org")
20 webdeveloper_deletePreference("webdeveloper.populate.form.fields.email");
23 // Migrate the validate feed url
24 if(webdeveloper_getStringPreference("webdeveloper.tool.2.url", true) == "http://feedvalidator.org/check.cgi?url=")
26 webdeveloper_deletePreference("webdeveloper.tool.2.url");
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=")
32 webdeveloper_deletePreference("webdeveloper.tool.7.description");
33 webdeveloper_deletePreference("webdeveloper.tool.7.url");
36 // Migrate the tool count
37 if(webdeveloper_getIntegerPreference("webdeveloper.tool.count", true) < 8)
39 webdeveloper_deletePreference("webdeveloper.tool.count");
42 toolbar
.collapsed
= false;
43 toolbar
.hidden
= false;
45 document
.persist("webdeveloper-toolbar", "collapsed");
46 document
.persist("webdeveloper-toolbar", "hidden");
49 // Migrate the extension to 1.1
50 function webdeveloper_migrateTo11()
52 // Migrate DOM Inspector sidebar
53 if(webdeveloper_isPreferenceSet("webdeveloper.dom.inspector.sidebar"))
55 webdeveloper_setBooleanPreference("webdeveloper.dom.inspector.dashboard", webdeveloper_getBooleanPreference("webdeveloper.dom.inspector.sidebar", true));
56 webdeveloper_deletePreference("webdeveloper.dom.inspector.sidebar");
59 // Migrate JavaScript console dashboard
60 if(webdeveloper_isPreferenceSet("webdeveloper.javascript.console.dashboard"))
62 webdeveloper_setBooleanPreference("webdeveloper.error.console.dashboard", webdeveloper_getBooleanPreference("webdeveloper.javascript.console.dashboard", true));
63 webdeveloper_deletePreference("webdeveloper.javascript.console.dashboard");
66 // Migrate JavaScript console key
67 if(webdeveloper_isPreferenceSet("webdeveloper.javascript.console.key"))
69 webdeveloper_setStringPreference("webdeveloper.error.console.key", webdeveloper_getStringPreference("webdeveloper.javascript.console.key", true));
70 webdeveloper_deletePreference("webdeveloper.javascript.console.key");
73 // Migrate JavaScript console sidebar
74 if(webdeveloper_isPreferenceSet("webdeveloper.javascript.console.sidebar"))
76 webdeveloper_setBooleanPreference("webdeveloper.error.console.dashboard", webdeveloper_getBooleanPreference("webdeveloper.javascript.console.sidebar", true));
77 webdeveloper_deletePreference("webdeveloper.javascript.console.sidebar");
80 // Migrate persist styles
81 if(webdeveloper_isPreferenceSet("webdeveloper.styles.persist"))
83 webdeveloper_setBooleanPreference("webdeveloper.persist.features", webdeveloper_getBooleanPreference("webdeveloper.styles.persist", true));
84 webdeveloper_deletePreference("webdeveloper.styles.persist");
87 // Migrate view style information dashboard
88 if(webdeveloper_isPreferenceSet("webdeveloper.view.style.information.sidebar"))
90 webdeveloper_setBooleanPreference("webdeveloper.style.information.dashboard", webdeveloper_getBooleanPreference("webdeveloper.view.style.information.sidebar", true));
91 webdeveloper_deletePreference("webdeveloper.view.style.information.sidebar");
95 // Migrate the extension to 1.1.2
96 function webdeveloper_migrateTo112()
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=")
101 webdeveloper_setStringPreferenceIfNotSet("webdeveloper.tool.1.url", "http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=");
105 // Parses the version number
106 function webdeveloper_parseVersion(version
)
108 // If the version is set
111 var splitVersion
= version
.split(".");
112 var parsedVersion
= splitVersion
[0] + ".";
113 var splitVersionLength
= splitVersion
.length
;
115 // Loop through the remaining parts of the version
116 for(var i
= 1; i
< splitVersionLength
; i
++)
118 parsedVersion
+= splitVersion
[i
];
121 return parseFloat(parsedVersion
);
129 // Check if the extension is being upgraded
130 function webdeveloper_upgrade()
132 var previousVersion
= webdeveloper_parseVersion(webdeveloper_getStringPreference("webdeveloper.version", true));
133 var version
= webdeveloper_parseVersion("1.1.4");
135 // If the versions do not match
136 if(previousVersion
!= version
)
138 // If the previous version is less than 1.0.2
139 if(previousVersion
< webdeveloper_parseVersion("1.0.2"))
141 webdeveloper_migrateTo1();
144 // If the previous version is less than 1.1
145 if(previousVersion
< webdeveloper_parseVersion("1.1"))
147 webdeveloper_migrateTo11();
150 // If the previous version is less than 1.1.2
151 if(previousVersion
< webdeveloper_parseVersion("1.1.2"))
153 webdeveloper_migrateTo112();
156 webdeveloper_setStringPreference("webdeveloper.version", version
);