home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
- <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
- <?xul-overlay href="chrome://greasemonkey/content/pages-overlay.xul"?>
-
-
-
- <dialog
- id="manage-window"
- buttons="accept,cancel"
- ondialogaccept="return handleOkButton()"
- title="Manage User Scripts"
- orient="vertical"
- style="max-width:650px;"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <script type="application/x-javascript" src="chrome://greasemonkey/content/utils.js" />
- <script type="application/x-javascript" src="chrome://greasemonkey/content/prefmanager.js" />
- <script type="application/x-javascript" src="chrome://greasemonkey/content/config.js" />
- <script type="application/x-javascript">
- <![CDATA[
- var config = new Config(getScriptFile("config.xml"));
- var uninstallList = [];
-
- function handleOkButton() {
- for (var i = 0, script = null; (script = uninstallList[i]); i++) {
- var idx = config.find(script.namespace, script.name);
- config.scripts.splice(idx, 1);
- }
- config.save();
-
- var chkUninstallPrefs = document.getElementById('chkUninstallPrefs');
- for (var i = 0, script = null; (script = uninstallList[i]); i++) {
- getScriptFile(script.filename).remove(false);
- if (chkUninstallPrefs.checked) {
- // Remove saved preferences
- var scriptPrefRoot = ["scriptvals.",
- script.namespace,
- "/",
- script.name,
- "."].join("");
- GM_prefRoot.remove(scriptPrefRoot);
- }
- }
- return true;
- }
- var listbox, header, description, chkEnabled, btnEdit, btnUninstall;
- var selectedScript;
- var pagesControl;
-
- window.addEventListener("load", function(ev) {
- config.load();
- loadControls();
-
- if (!config.scripts.length == 0) {
- populateChooser();
- chooseScript(0);
- }
- }, false);
-
- function loadControls() {
- listbox = document.getElementById("lstScripts");
- header = document.getElementById("ctlHeader");
- description = document.getElementById("ctlDescription");
- btnEdit = document.getElementById("btnEdit");
- btnUninstall = document.getElementById("btnUninstall");
- pagesControl = new PagesControl(document.getElementById("pages-control"));
- chkEnabled = document.getElementById("chkEnabled");
-
- listbox.addEventListener("select", function() { updateDetails(); }, false);
- btnEdit.addEventListener("command", function() { handleEditButton(); }, false);
- btnUninstall.addEventListener("command", function() { handleUninstallButton(); }, false);
- chkEnabled.addEventListener("command", function() {
- if (selectedScript) {
- selectedScript.enabled = chkEnabled.checked;
- if (selectedScript.enabled) {
- listbox.selectedItem.style.color = '';
- } else {
- listbox.selectedItem.style.color = 'gray';
- }
- }
- }, false);
- }
-
- function updateDetails() {
- if (listbox.selectedCount == 0) {
- selectedScript = null;
- header.textContent = " ";
- description.textContent = " ";
- chkEnabled.checked = true;
- pagesControl.clear();
- document.documentElement.getButton("accept").disabled = false;
- }
- else {
- selectedScript = listbox.getSelectedItem(0).script;
- header.textContent = selectedScript.name;
- description.textContent = selectedScript.description;
- chkEnabled.checked = selectedScript.enabled;
- pagesControl.populate(selectedScript);
- }
- }
-
- function handleEditButton() {
- openInEditor(getScriptFile(selectedScript.filename));
- }
-
- function handleUninstallButton() {
- uninstallList.push(selectedScript);
- listbox.removeChild(listbox.childNodes[listbox.selectedIndex]);
-
- if (listbox.childNodes.length > 0) {
- chooseScript(Math.max(Math.min(listbox.selectedIndex, listbox.childNodes.length - 1), 0));
- }
- }
-
- function populateChooser() {
- for (var i = 0, script = null; (script = config.scripts[i]); i++) {
- var listitem = document.createElement("listitem");
-
- listitem.setAttribute("label", script.name);
- listitem.setAttribute("crop", "end");
- listitem.script = script;
- if (!script.enabled) {
- listitem.style.color = 'gray';
- }
- listbox.appendChild(listitem);
- }
- }
-
- function chooseScript(index) {
- listbox.selectedIndex = index;
- listbox.focus();
- }
-
- function toggleScript(index, enableFlag) {
- var listitem = listbox.childNodes[index];
- if (enableFlag) {
- listitem.script.enabled = true;
- listitem.style.color = '';
- } else {
- listitem.script.enabled = false;
- listitem.style.color = 'gray';
- }
- }
-
- ]]>
- </script>
-
- <grid style="margin-bottom:2em" flex="1" orient="vertical">
- <columns>
- <column flex="1"/>
- <column flex="3"/>
- </columns>
-
- <rows>
- <row flex="1" orient="horizontal">
- <listbox id="lstScripts" style="min-width:140px; margin-top:0" flex="1"/>
- <vbox flex="3">
- <description id="ctlHeader" style=" margin: 0px 5px 5px 5px;
- border: 2px solid;
- -moz-border-top-colors: ThreeDShadow ThreeDDarkShadow;
- -moz-border-right-colors: ThreeDHighlight ThreeDDarkShadow;
- -moz-border-bottom-colors: ThreeDHighlight ThreeDDarkShadow;
- -moz-border-left-colors: ThreeDShadow ThreeDDarkShadow;
- padding: 5px 8px;
- background-color: Highlight;
- color: HighlightText;
- font-size: 1.5em;
- height: 2em;"/>
- <description id="ctlDescription" style="margin:.5em;
- height:3em;
- max-height:3em;"/>
- <vbox id="pages-control" />
- </vbox>
- </row>
- <row>
- <hbox>
- <hbox>
- <checkbox id="chkEnabled" label="Enabled" checked="true" />
- <button flex="1" id="btnEdit" label="Edit" />
- </hbox>
- </hbox>
- <hbox>
- <hbox>
- <button flex="1" id="btnUninstall" label="Uninstall" />
- <checkbox id="chkUninstallPrefs"
- label="Also uninstall associated preferences" checked="false" />
- </hbox>
- </hbox>
- </row>
- </rows>
- </grid>
-
- </dialog>
-
-