Support for update URL and support for removing paths (made fields editable)

This commit is contained in:
mkaply%us.ibm.com 2005-09-19 18:35:30 +00:00
parent 368222d869
commit 14aa82d0b5
3 changed files with 70 additions and 28 deletions

View File

@ -102,13 +102,17 @@ function chooseimage(labelname, imagename)
function initimage(labelname, imagename)
{
var sourcefile = Components.classes["@mozilla.org/file/local;1"]
var sourcefile = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
sourcefile.initWithPath(document.getElementById(labelname).value);
var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var foo = ioServ.newFileURI(sourcefile);
document.getElementById(imagename).src = foo.spec;
try {
sourcefile.initWithPath(document.getElementById(labelname).value);
var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var foo = ioServ.newFileURI(sourcefile);
document.getElementById(imagename).src = foo.spec;
} catch (e) {
document.getElementById(imagename).src = '';
}
}
@ -856,6 +860,7 @@ function CCKWriteInstallRDF(destdir)
var descriptionline = "<em:description>%description%</em:description>";
var creatorline = "<em:creator>%creator%</em:creator>";
var homepageURLline = "<em:homepageURL>%homepageURL%</em:homepageURL>";
var updateURLline = "<em:updateURL>%updateURL%</em:updateURL>";
var iconURLline = "<em:iconURL>chrome://cck/content/%iconURL%</em:iconURL>";
@ -928,6 +933,14 @@ function CCKWriteInstallRDF(destdir)
str = str.replace(/%homepageURLline%/g, "");
}
var updateURL = document.getElementById("updateURL").value;
if (updateURL && (updateURL.length > 0)) {
str = str.replace(/%updateURLline%/g, updateURLline);
str = str.replace(/%updateURL%/g, document.getElementById("updateURL").value);
} else {
str = str.replace(/%updateURLline%/g, "");
}
var iconURL = document.getElementById("iconURL").value;
if (iconURL && (iconURL.length > 0)) {
var sourcefile = Components.classes["@mozilla.org/file/local;1"]
@ -1127,6 +1140,29 @@ function Validate(field, message)
return true;
}
function ValidateFile()
{
for (var i=0; i < arguments.length; i++) {
var filename = document.getElementById(arguments[i]).value;
if (filename.length > 0) {
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
try {
file.initWithPath(filename);
} catch (e) {
alert("File " + filename + " not found");
return false;
}
if (!file.exists() || file.isDirectory()) {
alert("File " + filename + " not found");
return false;
}
}
}
return true;
}
function toggleProxySettings()
{
var http = document.getElementById("HTTPproxyname");

View File

@ -89,7 +89,7 @@
</groupbox>
</wizardpage>
<wizardpage description="Extension Information" onpageshow="initimage('iconURL','icon');">
<wizardpage description="Extension Information" onpageshow="initimage('iconURL','icon');" onpageadvanced="return ValidateFile('iconURL')">
<groupbox>
<caption label="Extension Information"/>
<description>
@ -125,11 +125,16 @@
<label>Homepage URL:</label>
<textbox id="homepageURL" style="width: 350px;"/>
</hbox>
<hbox align="center">
<spacer flex="1"/>
<label>Update URL:</label>
<textbox id="updateURL" style="width: 350px;"/>
</hbox>
<hbox align="center">
<spacer flex="1"/>
<label>Icon:</label>
<hbox>
<textbox style="min-width: 226px;" flex="1" readonly="true" id="iconURL"/>
<textbox style="min-width: 226px;" flex="1" id="iconURL"/>
</hbox>
<hbox>
<image id="icon" src='' width='32' height='32'/>
@ -181,7 +186,7 @@
<wizardpage onpageshow="initimage('LargeStillPath','LargeStill');initimage('LargeAnimPath','LargeAnim');">
<wizardpage onpageshow="initimage('LargeStillPath','LargeStill');initimage('LargeAnimPath','LargeAnim');" onpageadvanced="return ValidateFile('LargeAnimPath','LargeStillPath');">
<groupbox>
<caption label="Animated Logo"/>
<description>
@ -202,7 +207,7 @@
Path to Your Animated GIF File (16x16 pixels):
</description>
<hbox align="center">
<textbox readonly="true" id="LargeAnimPath" flex="1"/>
<textbox id="LargeAnimPath" flex="1"/>
<image id="LargeAnim" src='' width='16' height='16'/>
<button label="Choose File..." oncommand="chooseimage('LargeAnimPath','LargeAnim');"/>
</hbox>
@ -210,7 +215,7 @@
Path to Your At Rest GIF or PNG File (16x16 pixels):
</description>
<hbox align="center">
<textbox readonly="true" id="LargeStillPath" flex="1"/>
<textbox id="LargeStillPath" flex="1"/>
<image id="LargeStill" src='' width='16' height='16'/>
<button label="Choose File..." oncommand="chooseimage('LargeStillPath','LargeStill');"/>
</hbox>
@ -253,36 +258,36 @@
</wizardpage>
<wizardpage>
<wizardpage onpageadvanced="return ValidateFile('BrowserPluginPath1','BrowserPluginPath2','BrowserPluginPath3','BrowserPluginPath4','BrowserPluginPath5');">
<groupbox>
<caption label="Browser Plug-ins"/>
<description>
You may select up to five browser plug-ins to be preinstalled.
</description>
<hbox>
<textbox readonly="true" id="BrowserPluginPath1" flex="1"/>
<textbox id="BrowserPluginPath1" flex="1"/>
<button label="Choose File..." oncommand="choosefile('BrowserPluginPath1');"/>
</hbox>
<hbox>
<textbox readonly="true" id="BrowserPluginPath2" flex="1"/>
<textbox id="BrowserPluginPath2" flex="1"/>
<button label="Choose File..." oncommand="choosefile('BrowserPluginPath3');"/>
</hbox>
<hbox>
<textbox readonly="true" id="BrowserPluginPath3" flex="1"/>
<textbox id="BrowserPluginPath3" flex="1"/>
<button label="Choose File..." oncommand="choosefile('BrowserPluginPath3');"/>
</hbox>
<hbox>
<textbox readonly="true" id="BrowserPluginPath4" flex="1"/>
<textbox id="BrowserPluginPath4" flex="1"/>
<button label="Choose File..." oncommand="choosefile('BrowserPluginPath4');"/>
</hbox>
<hbox>
<textbox readonly="true" id="BrowserPluginPath5" flex="1"/>
<textbox id="BrowserPluginPath5" flex="1"/>
<button label="Choose File..." oncommand="choosefile('BrowserPluginPath5');"/>
</hbox>
</groupbox>
</wizardpage>
<wizardpage>
<wizardpage onpageadvanced="return ValidateFile('SearchPlugin1','SearchPluginIcon1','SearchPlugin2','SearchPluginIcon2','SearchPlugin3','SearchPluginIcon3','SearchPlugin4','SearchPluginIcon4','SearchPlugin5','SearchPluginIcon5');">
<groupbox>
<caption label="Search Plugins"/>
<description>
@ -292,65 +297,65 @@
<hbox align="center">
<spacer flex="1"/>
<label>File:</label>
<textbox readonly="true" id="SearchPlugin1" style="min-width: 375px;" flex="1" />
<textbox id="SearchPlugin1" style="min-width: 375px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPlugin1');"/>
</hbox>
<hbox style="width: 350px;">
<spacer flex="1"/>
<label>Icon:</label>
<textbox readonly="true" id="SearchPluginIcon1" style="min-width: 380px;" flex="1" />
<textbox id="SearchPluginIcon1" style="min-width: 380px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPluginIcon1');"/>
</hbox>
<html:hr/>
<hbox align="center">
<spacer flex="1"/>
<label>File:</label>
<textbox readonly="true" id="SearchPlugin2" style="min-width: 375px;" flex="1" />
<textbox id="SearchPlugin2" style="min-width: 375px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPlugin2');"/>
</hbox>
<hbox style="width: 350px;">
<spacer flex="1"/>
<label>Icon:</label>
<textbox readonly="true" id="SearchPluginIcon2" style="min-width: 380px;" flex="1" />
<textbox id="SearchPluginIcon2" style="min-width: 380px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPluginIcon2');"/>
</hbox>
<html:hr/>
<hbox align="center">
<spacer flex="1"/>
<label>File:</label>
<textbox readonly="true" id="SearchPlugin3" style="min-width: 375px;" flex="1" />
<textbox id="SearchPlugin3" style="min-width: 375px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPlugin3');"/>
</hbox>
<hbox style="width: 350px;">
<spacer flex="1"/>
<label>Icon:</label>
<textbox readonly="true" id="SearchPluginIcon3" style="min-width: 380px;" flex="1" />
<textbox id="SearchPluginIcon3" style="min-width: 380px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPluginIcon3');"/>
</hbox>
<html:hr/>
<hbox align="center">
<spacer flex="1"/>
<label>File:</label>
<textbox readonly="true" id="SearchPlugin4" style="min-width: 375px;" flex="1" />
<textbox id="SearchPlugin4" style="min-width: 375px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPlugin4');"/>
</hbox>
<hbox style="width: 350px;">
<spacer flex="1"/>
<label>Icon:</label>
<textbox readonly="true" id="SearchPluginIcon4" style="min-width: 380px;" flex="1" />
<textbox id="SearchPluginIcon4" style="min-width: 380px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPluginIcon4');"/>
</hbox>
<html:hr/>
<hbox align="center">
<spacer flex="1"/>
<label>File:</label>
<textbox readonly="true" id="SearchPlugin5" style="min-width: 375px;" flex="1" />
<textbox id="SearchPlugin5" style="min-width: 375px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPlugin5');"/>
</hbox>
<hbox style="width: 350px;">
<spacer flex="1"/>
<label>Icon:</label>
<textbox readonly="true" id="SearchPluginIcon5" style="min-width: 380px;" flex="1" />
<textbox id="SearchPluginIcon5" style="min-width: 380px;" flex="1" />
<button label="Choose File..." oncommand="choosefile('SearchPluginIcon5');"/>
</hbox>
<html:hr/>

View File

@ -9,6 +9,7 @@ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
%descriptionline%
%creatorline%
%homepageURLline%
%updateURLline%
%iconURLline%
<em:targetApplication>