2 <?xml-stylesheet href=
"chrome://global/skin/" type=
"text/css"?>
3 <dialog xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
5 windowtype=
"guerilla:newpkg"
7 buttons=
"accept,cancel"
9 buttonlabelcancel=
"Cancel"
10 ondialogaccept=
"onAccept();"
11 ondialogcancel=
"onCancel();"
21 <label control=
"name" value=
"Package name:" accesskey=
"n" style=
"text-align:right" />
22 <textbox id=
"name" type=
"text" tooltiptext=
"Internal package name (no spaces, please)" flex=
"1"/>
25 <label control=
"url" value=
"Package url:" accesskey=
"u" style=
"text-align:right" />
26 <textbox id=
"url" type=
"text" tooltiptext=
"URL to download the package" flex=
"1"/>
31 <script type=
"application/javascript"><![CDATA[
33 window.sizeToContent();
34 if (typeof(window.arguments[
0].name) ===
"string") {
35 document.getElementById(
"name").value = window.arguments[
0].name;
37 if (typeof(window.arguments[
0].url) ===
"string") {
38 document.getElementById(
"url").value = window.arguments[
0].url;
42 function onCancel () {
43 window.arguments[
0].closeReason =
"cancel";
46 function onAccept () {
47 let name = document.getElementById(
"name").value.replace(/^\s+/,
"").replace(/\s+$/,
"");
48 if (name.length ===
0 || /\s/.test(name)) {
49 alert(
"Invalid package name!");
52 if (window.arguments[
0].isPkgExists(name)) {
53 alert(
"Duplicate package name!");
56 let url = document.getElementById(
"url").value.replace(/^\s+/,
"").replace(/\s+$/,
"");
57 if (url.length ===
0 || !(/^https?:/.test(url))) {
58 alert(
"Invalid package URL!");
61 let pname = window.arguments[
0].isUrlExists(url);
63 alert(
"Duplicate package url; package '"+pname+
"' already using it!");
66 window.arguments[
0].name = name;
67 window.arguments[
0].url = url;
68 window.arguments[
0].closeReason =
"accept";