Rewrote QuickLink box, now supports nice shorturls instead
authorKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Thu, 6 Dec 2007 01:57:57 +0000 (02:57 +0100)
committerKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Thu, 6 Dec 2007 01:57:57 +0000 (02:57 +0100)
and auto selected environment and action occuring to them.

content/browser_overlay.xul
content/quickbox.xul
content/tv2developer-quickbox.js [new file with mode: 0644]
content/tv2developer-util.js [new file with mode: 0644]
content/tv2developer.js
locale/da-DK/tv2developer.dtd
locale/en-US/tv2developer.dtd
version

index f8cd06ef5dadf60441a8eb591f2a61f65b192aa8..ed8b83539bcd0c9ec4d8b9324339abc3ebf7a407 100755 (executable)
@@ -5,6 +5,7 @@
 <overlay id="tv2developer_overlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
+<script type="application/x-javascript" src="tv2developer-util.js" />
 <script type="application/x-javascript" src="tv2developer.js" />
 <script type="application/x-javascript" src="tv2developer-main.js" />
 <stringbundleset id="stringbundleset">
index b43ba49bbd4b512a2eab98ad5af5e72a1f6af013..611017924f8c00f1167a2aea18040ca8a84e13f7 100755 (executable)
@@ -3,35 +3,63 @@
 <!DOCTYPE prefwindow SYSTEM "chrome://tv2developer/locale/tv2developer.dtd">
 <dialog
     id="tv2developer_quickbox"
-       title="&quickbox.title;"
+       title=""
        buttons="accept,cancel"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-       onload="TV2Developer.updateQuickbox()"
-       ondialogaccept="TV2Developer.goQuickbox()">
-<script type="application/x-javascript" src="tv2developer.js" />
+       onload="TV2DeveloperQuickBox.setupQuickbox()"
+       ondialogaccept="TV2DeveloperQuickBox.goQuickbox()">
+<script type="application/x-javascript" src="tv2developer-util.js" />
+<script type="application/x-javascript" src="tv2developer-quickbox.js" />
+
+<dialogheader title="&quickbox.title;"/>
 
 <stringbundleset id="stringbundleset">
     <stringbundle id="tv2developer_strings" src="chrome://tv2developer/locale/tv2developer.properties"/>
 </stringbundleset>
 
-<groupbox>
-<label value="&quickbox.enterprefix;" control="tv2prefix"/>
-<textbox id="tv2prefix"/>
+<vbox>
+    <label value="&quickbox.entershorturl;" control="shorturl" accesskey="&quickbox.entershorturl.accesskey;"/>
+    <textbox id="shorturl" size="80" oninput="TV2DeveloperQuickBox.updateQuickbox()" crop="end"/>
+    <label id="url" label="url" style="width:20em" value="" crop="end"/>
+</vbox>
 
-<radiogroup id="tv2postfix">
-  <grid>
-    <columns>
-       <column/><column/><column/>
-    </columns>
-       <rows id="radiobox-rows" />
-  </grid>
-  <checkbox id="php4site" label="&quickbox.php4site;" accesskey="4" tooltiptext="&quickbox.php4site.tooltiptext;" />
-  <separator class="groove"/>
-  <radio id="go-node" label="&quickbox.nodeid;" accesskey="&quickbox.nodeid.accesskey;"/>
-  <radio id="go-content-id" label="&quickbox.contentid;" accesskey="&quickbox.contentid.accesskey;"/>
-  <radio id="go-ttv-page" label="&quickbox.ttvpage;" accesskey="&quickbox.ttvpage.accesskey;"/>
-</radiogroup>
+    <hbox>
+       <groupbox flex="2">
+        <caption label="Site type" />
+        <radiogroup id="sitetype" onselect="TV2DeveloperQuickBox.setManuel(this)">
+          <radio id="webroot"    label="webroot"    accesskey="w"/>
+          <radio id="opdatering" label="opdatering" accesskey="o"/>
+          <radio id="robot"      label="robot"      accesskey="r"/>
+          <radio id="template"   label="template"   accesskey="e"/>
+        </radiogroup>
+      </groupbox>
+      <groupbox flex="1">
+       <caption label="Environment"/>
+       <radiogroup id="environment" onselect="TV2DeveloperQuickBox.setManuel(this)">
+          <radio id="live"      label="Live site"       accesskey="l"/>
+          <radio id="test"      label="Test site"       accesskey="t"/>
+          <radio id="snapshot"  label="Snapshot site"   accesskey="s"/>
+          <hbox>
+            <radio id="othertest" label="&quickbox.othertestsite;" accesskey="&quickbox.othertestsite.accesskey;"/>
+            <textbox id="testname" size="10" maxlength="20" disabled="true"
+                onclick="TV2DeveloperQuickBox.setManuel(this)"
+                oninput="TV2DeveloperQuickBox.setManuel(this)"/>
+          </hbox>
+        </radiogroup>
+      </groupbox>
+    </hbox>
 
-</groupbox>
+    <groupbox>
+      <caption label="Action"/>
+      <radiogroup id="action" onselect="TV2DeveloperQuickBox.setManuel(this)">
+      <hbox>
+      <radio id="go-site" label="&quickbox.makeurl;" accesskey="&quickbox.makeurl.accesskey;"/>
+        <checkbox id="php4site" label="&quickbox.php4site;" accesskey="&quickbox.php4site.accesskey;" tooltiptext="&quickbox.php4site.tooltiptext;"/>
+      </hbox>
+      <radio id="go-node" label="&quickbox.nodeid;" accesskey="&quickbox.nodeid.accesskey;"/>
+      <radio id="go-content-id" label="&quickbox.contentid;" accesskey="&quickbox.contentid.accesskey;"/>
+      <radio id="go-ttv-page" label="&quickbox.ttvpage;" accesskey="&quickbox.ttvpage.accesskey;"/>
+      </radiogroup>
+    </groupbox>
 
 </dialog>
diff --git a/content/tv2developer-quickbox.js b/content/tv2developer-quickbox.js
new file mode 100644 (file)
index 0000000..4ea6beb
--- /dev/null
@@ -0,0 +1,277 @@
+/* Functionality for the quick link box */\r
+/* @author Kristian Kræmmer Nielsen <jkkn@tv2.dk> */\r
+\r
+var TV2DeveloperQuickBox = {\r
+       \r
+       _addCheckbox: function(here, id, label, accesskey) {\r
+               var radio = document.createElement('radio');\r
+               radio.setAttribute('id', id);\r
+               radio.setAttribute('label', label);\r
+               radio.setAttribute('accesskey', accesskey);\r
+               here.appendChild(radio);\r
+       },\r
+       \r
+       _autoChange: false,\r
+       _saveInitials: false, /* safe the alternative initials field */\r
+       \r
+       setManuel: function(target) {\r
+        if (target.id == 'environment') {\r
+            document.getElementById('testname').disabled = (target.selectedItem.id != 'othertest');\r
+            if (!this._autoChange) {\r
+                document.getElementById('testname').select();\r
+                document.getElementById('testname').focus();\r
+            }\r
+        }\r
+        if (target.id == 'action') {\r
+            document.getElementById('sitetype').disabled = (target.selectedItem.id != 'go-site');\r
+            document.getElementById('php4site').disabled = (target.selectedItem.id != 'go-site');\r
+        }\r
+           if (!this._autoChange) { /* avoid updating if this was trigged by updateQuickbox() */\r
+               if (target.id == 'testname' &&\r
+                   document.getElementById('environment').selectedItem.id != 'othertest') {\r
+                       document.getElementById('environment').selectedItem =\r
+                           document.getElementById('othertest');\r
+               }\r
+               this.updateQuickbox(true);\r
+           }\r
+       },\r
+\r
+    _reg_nodeid: /^(?!1234$)[0-9]+$/,\r
+    _reg_ttv: /^[0-9]{3}$/,\r
+    _reg_extract_nums: /([0-9]+)/g,\r
+    _reg_shortlink: /^((https?):\/?\/?)?([^/]*?)(tv2\.dk)?(\/.*)?$/,\r
+    _sitetypes: ['opdatering', 'robot', 'template'],\r
+    _envs:      ['test', 'snapshot'],\r
+       updateQuickbox: function(manual) {\r
+           if (!manual) manual = false;\r
+           var current_user = TV2Util.getPref('developer-initials');\r
+               var username = current_user;\r
+               var shorturl = document.getElementById('shorturl').value;\r
+               var auto_action;\r
+               \r
+        var tv2 = this._reg_shortlink.exec(shorturl);\r
+        if (tv2) {\r
+            var protocol = tv2[2];\r
+            var domain   = tv2[3];\r
+            var uri      = tv2[5];\r
+            var url      = '';\r
+            \r
+            var site = null;\r
+            var auto_sitetype = 'webroot';\r
+            var auto_env      = 'live';\r
+            var auto_username = null;\r
+            var auto_php4     = false;\r
+            var validState    = true;\r
+            \r
+            var parts = domain.split('.');\r
+            for (var i=0; i<parts.length; i++) {\r
+                var part = parts[i];\r
+                if (part.length == 0) continue;\r
+\r
+                // first take site name\r
+                if (!site) {\r
+                    site = part;\r
+                    continue;\r
+                }\r
+                \r
+                // detect short env (.t, .s, .dk,.. )\r
+                var used = false;\r
+                var env_part = part;\r
+                var env_php4 = false;\r
+                if (part.substr(part.length-1, 1) == '3') {\r
+                    env_part = part.substr(0, -1); // handle t3, te3, test3, snapshot3\r
+                    env_php4 = true;\r
+                }\r
+                for (var j=0; j<this._envs.length; j++) {\r
+                    if (this._envs[j].substr(0, env_part.length) == env_part) {\r
+                        auto_env = this._envs[j];\r
+                        used = true; break;\r
+                    }\r
+                }\r
+                if (used) {\r
+                    auto_php4 = env_php4;\r
+                    continue;\r
+                }\r
+\r
+                // optional username\r
+                if (part.length == 4 && !auto_username) {\r
+                    auto_username = part;\r
+                    if (auto_env == 'live') {\r
+                        auto_env = 'test';\r
+                    }\r
+                    continue;\r
+                }\r
+\r
+                // detect short sitetype (.o, .op, .opd,.. )\r
+                var used = false;\r
+                for (var j=0; j<this._sitetypes.length; j++) {\r
+                    if (this._sitetypes[j].substr(0, part.length) == part) {\r
+                        auto_sitetype = this._sitetypes[j];\r
+                        used = true; break;\r
+                    }\r
+                }\r
+                if (used) continue;\r
+          \r
+            }\r
+            \r
+            // defaults\r
+            if (!protocol) protocol = 'http';\r
+            if (!uri) uri = '/';\r
+            if (!site) site = '';\r
+            \r
+            // determind action and options set\r
+            var env;\r
+            var sitetype;\r
+            var php4;\r
+            var action;\r
+            if (manual) {\r
+                // read options\r
+                env = document.getElementById('environment').selectedItem.id;\r
+                sitetype = document.getElementById('sitetype').selectedItem.id;\r
+                action = document.getElementById('action').selectedItem.id;\r
+                php4 = document.getElementById('php4site').checked;\r
+                if (env == 'othertest') {\r
+                    env = 'test';\r
+                    username = document.getElementById('testname').value;\r
+                }\r
+            } else {\r
+                // determind action\r
+                       if (this._reg_ttv.exec(site)) {\r
+                       auto_action = 'go-ttv-page';\r
+                       } else if (this._reg_nodeid.exec(site)) {\r
+                       auto_action = 'go-node';\r
+                   } else {\r
+                       auto_action = 'go-site';\r
+                }\r
+                // set options\r
+                env = auto_env;\r
+                /* sitetype and php5 is only relevant if we are creating a link for a site */\r
+                if (auto_action == 'go-site') {\r
+                    sitetype = auto_sitetype;\r
+                    php4 = auto_php4;\r
+                } else {\r
+                    sitetype = 'opdatering';\r
+                    php4 = false;\r
+                }\r
+                action = auto_action;\r
+                \r
+                this._autoChange = true;\r
+                if (auto_username && auto_username != username) {\r
+                    username = auto_username;\r
+                    document.getElementById('environment').selectedItem=document.getElementById('othertest');\r
+                    document.getElementById('testname').value=username;\r
+                } else {\r
+                    document.getElementById('environment').selectedItem=document.getElementById(env);\r
+                }\r
+                document.getElementById('sitetype').selectedItem=document.getElementById(sitetype);\r
+                document.getElementById('action').selectedItem=document.getElementById(action);\r
+                document.getElementById('php4site').checked = php4;\r
+                this._autoChange = false;\r
+            }\r
+\r
+            // Handle actions\r
+            var longest_id = null;\r
+            switch (action) {\r
+            case 'go-node':\r
+            case 'go-content-id':\r
+            case 'go-ttv-page':\r
+                site = 'i2';\r
+                sitetype = 'opdatering';\r
+                php4 = false;\r
+                // find longest id in entered url\r
+                var max_len = 0;\r
+                var cur_id;\r
+                while ((cur_id = this._reg_extract_nums.exec(shorturl)) != null) {\r
+                    if (cur_id[1].length > max_len) {\r
+                        max_len = cur_id[1].length;\r
+                        longest_id = cur_id[1];\r
+                    }\r
+                }\r
+                if (!longest_id) {\r
+                    validState = false;\r
+                    longest_id = '?';\r
+                }\r
+                break;\r
+            }\r
+            switch (action) {\r
+            case 'go-node':\r
+                uri = '/tool/node/?id=' + longest_id;\r
+                break;\r
+            case 'go-content-id':\r
+                uri = '/tool/query/?id=&2=&3=&_checkbox=1&content_id='+longest_id+'&4=&5=0&6=&action=Query&timeout=1';\r
+                break;\r
+            case 'go-ttv-page':\r
+                uri = '/tool/ttv/?1=' + longest_id + '&2=0';\r
+                break;\r
+            }\r
+\r
+            // Assemble domain\r
+            // handle www.tv2.dk\r
+            if (env == 'live' && sitetype == 'webroot') {\r
+                if (site == '' || site == 'www') {\r
+                    domain = '';\r
+                } else {\r
+                    domain = site + '.';\r
+                }\r
+            } else {\r
+                if (site == '') {\r
+                    domain = 'www.';\r
+                } else {\r
+                    domain = site + '.';\r
+                }\r
+            }\r
+            // handle environment\r
+            if (env == 'test') {\r
+                if (username == '') {\r
+                    validState = false;\r
+                    username = '?';\r
+                }\r
+                domain += username + '.';\r
+            }\r
+            // handle site type\r
+            if (sitetype != 'webroot') domain += sitetype + '.';\r
+            if (env != 'live') {\r
+                domain += env;\r
+                if (php4) domain += '3';\r
+                domain += '.';\r
+            }\r
+            // finish url\r
+            domain += 'tv2.dk';\r
+            url = protocol + '://' + domain + uri;\r
+            \r
+            document.getElementById('url').value = url;\r
+            if (manual && action=='go-site') {\r
+                // also change url in field\r
+                document.getElementById('shorturl').value = url;\r
+            }\r
+            \r
+            // are we using the alternativ initials?\r
+            this._saveInitials = (env == 'test' && username != current_user);\r
+            \r
+            document.getElementById('tv2developer_quickbox').getButton('accept').disabled = !validState;\r
+        }\r
+       },\r
+       \r
+       /* onload */\r
+       setupQuickbox: function() {\r
+           if (window.arguments && window.arguments[0]) {\r
+               document.getElementById('shorturl').value = window.arguments[0];\r
+           }\r
+           this.updateQuickbox();\r
+           document.getElementById('php4site').addEventListener('CheckboxStateChange',\r
+               function() { TV2DeveloperQuickBox.setManuel(this); }, false);\r
+           // init saved fields\r
+               document.getElementById('testname').value = TV2Util.getPref('alternativ-initials', '');\r
+       },\r
+       \r
+       goQuickbox: function() {\r
+           // init saved fields\r
+           if (this._saveInitials) {\r
+                   TV2Util.setPref('alternativ-initials', document.getElementById('testname').value);\r
+               }\r
+        window.close();\r
+        opener.openUILink(document.getElementById('url').value, 'current', false, false, false);\r
+        /* allow ctrl, alt, but don't google */\r
+       }\r
+       \r
+};\r
diff --git a/content/tv2developer-util.js b/content/tv2developer-util.js
new file mode 100644 (file)
index 0000000..0866e76
--- /dev/null
@@ -0,0 +1,67 @@
+\r
+/* Utility class for TV2 Developer Plugin */\r
+/* @author Kristian Kræmmer Nielsen <jkkn@tv2.dk> */\r
+\r
+var TV2Util = {\r
+    /* string methods for localizations */\r
+    _strs: null,\r
+    get strs() {\r
+        if (!this._strs) {\r
+            \r
+            this._strs = document.getElementById('tv2developer_strings');\r
+        }\r
+        return this._strs;\r
+    },\r
+    \r
+    getStr: function(str) {\r
+        try {\r
+            return this.strs.getString(str);\r
+        } catch(e) {\r
+            alert('Missing string: ' + str);\r
+                       return '';\r
+        }\r
+    },\r
+    \r
+    /* preference functions */\r
+    _prefs: null,\r
+    get prefs() {\r
+        if (!this._prefs)\r
+            this._prefs =\r
+                Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch('tv2developer.');\r
+        return this._prefs;\r
+    },\r
+\r
+    getPref: function(name, defValue) {\r
+        const CI=Components.interfaces.nsIPrefBranch;\r
+        const prefs=this.prefs;\r
+        try {\r
+          switch(prefs.getPrefType(name)) {\r
+            case CI.PREF_STRING:\r
+              return prefs.getCharPref(name);\r
+            case CI.PREF_INT:\r
+              return prefs.getIntPref(name);\r
+            case CI.PREF_BOOL:\r
+              return prefs.getBoolPref(name);\r
+          }\r
+        } catch(e) {alert(e)}\r
+        return defValue;\r
+    },\r
+  \r
+    setPref: function(name, value) {\r
+        const prefs=this.prefs;\r
+        switch(typeof(value)) {\r
+          case 'string':\r
+              prefs.setCharPref(name, value);\r
+              break;\r
+          case 'boolean':\r
+            prefs.setBoolPref(name, value);\r
+            break;\r
+          case 'number':\r
+            prefs.setIntPref(name, value);\r
+            break;\r
+          default:\r
+            throw new Error('Unsupported type '+typeof(value)+' for preference '+name);\r
+        }\r
+    }\r
+    \r
+};\r
index 92f44ec00c5240abe4245e656bcef130ffd46eb1..93c0e1031e140638370ca1280cb0785a595a52ef 100755 (executable)
@@ -36,7 +36,7 @@ var TV2Developer = {
     /* method for initialize, reading properties, adding icon at firstrun, added keyshortcuts */
     init: function() {
         // init
-        this._lastAction = this.getPref('lastaction-linktype');
+        this._lastAction = TV2Util.getPref('lastaction-linktype');
         // add shortcuts depending on platform
         var shortcuts = document.getElementById('mainKeyset');
         // We take this from ui.key.chromeAccess (no other way it seems, jkkn)
@@ -58,8 +58,8 @@ var TV2Developer = {
         }
 
         // first run, add icon
-        if (this.getPref('firstRun')) {
-            this.setPref('firstRun', false);
+        if (TV2Util.getPref('firstRun')) {
+            TV2Util.setPref('firstRun', false);
             // add icon
              try {
                var firefoxnav = document.getElementById('nav-bar');
@@ -103,67 +103,6 @@ var TV2Developer = {
         parent.appendChild(newKey);
     },
             
-    /* string methods for localizations */
-    _strs: null,
-    get strs() {
-        if (!this._strs) {
-            
-            this._strs = document.getElementById('tv2developer_strings');
-        }
-        return this._strs;
-    },
-    
-    getStr: function(str) {
-        try {
-            return this.strs.getString(str);
-        } catch(e) {
-            alert('Missing string: ' + str);
-                       return '';
-        }
-    },
-    
-    /* preference functions */
-    _prefs: null,
-    get prefs() {
-        if (!this._prefs)
-            this._prefs =
-                Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch('tv2developer.');
-        return this._prefs;
-    },
-
-    getPref: function(name, defValue) {
-        const CI=Components.interfaces.nsIPrefBranch;
-        const prefs=this.prefs;
-        try {
-          switch(prefs.getPrefType(name)) {
-            case CI.PREF_STRING:
-              return prefs.getCharPref(name);
-            case CI.PREF_INT:
-              return prefs.getIntPref(name);
-            case CI.PREF_BOOL:
-              return prefs.getBoolPref(name);
-          }
-        } catch(e) {alert(e)}
-        return defValue;
-    },
-  
-    setPref: function(name, value) {
-        const prefs=this.prefs;
-        switch(typeof(value)) {
-          case 'string':
-              prefs.setCharPref(name, value);
-              break;
-          case 'boolean':
-            prefs.setBoolPref(name, value);
-            break;
-          case 'number':
-            prefs.setIntPref(name, value);
-            break;
-          default:
-            throw new Error('Unsupported type '+typeof(value)+' for preference '+name);
-        }
-    },
-    
     /* popup menu utility functions */
     emptyMenu: function(menu) {
       var children = menu.childNodes;
@@ -230,7 +169,7 @@ var TV2Developer = {
         var links = new Array();
         var currentURL = getBrowser().currentURI.spec;
         var encodedURL = encodeURIComponent(currentURL);
-        var initials = this.getPref('developer-initials');
+        var initials = TV2Util.getPref('developer-initials');
 
         // Adding links as appropiate if tv2.dk site
         var tv2 = this._reg_tv2.exec(currentURL);
@@ -271,20 +210,20 @@ var TV2Developer = {
             
             // Add the two urls we are not at
             if (!tv2_testsite) { // always add swaps to snapshot and the test site
-                links.push(new this.TV2Link('test_live_swap', testurl, tv2_uri, this.getStr('test.accesskey')));
-                links.push(new this.TV2Link('snapshot_live_swap', snapshoturl, tv2_uri, this.getStr('snapshot.accesskey')));
-                links.push(new this.TV2Link('testprompt_swap', testprompturl, tv2_uri, this.getStr('testprompt.accesskey'), 'promptInitials'));
+                links.push(new this.TV2Link('test_live_swap', testurl, tv2_uri, TV2Util.getStr('test.accesskey')));
+                links.push(new this.TV2Link('snapshot_live_swap', snapshoturl, tv2_uri, TV2Util.getStr('snapshot.accesskey')));
+                links.push(new this.TV2Link('testprompt_swap', testprompturl, tv2_uri, TV2Util.getStr('testprompt.accesskey'), 'promptInitials'));
             } else if (tv2_testtype == 'snapshot') {
-                links.push(new this.TV2Link('snapshot_live_swap', liveurl, tv2_uri, this.getStr('live.accesskey')));
-                links.push(new this.TV2Link('test_snapshot_swap', testurl, tv2_uri, this.getStr('test.accesskey')));
-                links.push(new this.TV2Link('testprompt_swap', testprompturl, tv2_uri, this.getStr('testprompt.accesskey'), 'promptInitials'));
+                links.push(new this.TV2Link('snapshot_live_swap', liveurl, tv2_uri, TV2Util.getStr('live.accesskey')));
+                links.push(new this.TV2Link('test_snapshot_swap', testurl, tv2_uri, TV2Util.getStr('test.accesskey')));
+                links.push(new this.TV2Link('testprompt_swap', testprompturl, tv2_uri, TV2Util.getStr('testprompt.accesskey'), 'promptInitials'));
             } else { // must be test
-                links.push(new this.TV2Link('test_live_swap', liveurl, tv2_uri, this.getStr('live.accesskey')));
-                links.push(new this.TV2Link('test_snapshot_swap', snapshoturl, tv2_uri, this.getStr('snapshot.accesskey')));
+                links.push(new this.TV2Link('test_live_swap', liveurl, tv2_uri, TV2Util.getStr('live.accesskey')));
+                links.push(new this.TV2Link('test_snapshot_swap', snapshoturl, tv2_uri, TV2Util.getStr('snapshot.accesskey')));
                 if (tv2_user != initials) {
-                    links.push(new this.TV2Link('test_swap', testurl, tv2_uri, this.getStr('test.accesskey')));
+                    links.push(new this.TV2Link('test_swap', testurl, tv2_uri, TV2Util.getStr('test.accesskey')));
                 }
-                links.push(new this.TV2Link('testprompt_swap', testprompturl, tv2_uri, this.getStr('testprompt.accesskey'), 'promptInitials'));
+                links.push(new this.TV2Link('testprompt_swap', testprompturl, tv2_uri, TV2Util.getStr('testprompt.accesskey'), 'promptInitials'));
             }
             
             links.push(new this.TV2LinkSplit());
@@ -298,11 +237,11 @@ var TV2Developer = {
             var normal = (tv2_testsite ? _prefix + '.' + tv2_testsite + '.tv2.dk'
                                        : live_sitename + 'tv2.dk');
             links.push(new this.TV2Link('opdatering_swap', (tv2_sitetype!='opdatering')?opdatering:normal, '/',
-                                        (tv2_sitetype!='opdatering') ? this.getStr('opdatering.accesskey') : this.getStr('webroot.accesskey')));
+                                        (tv2_sitetype!='opdatering') ? TV2Util.getStr('opdatering.accesskey') : TV2Util.getStr('webroot.accesskey')));
             /*links.push(new this.TV2Link('template_swap', (tv2_sitetype!='template')?template:normal, '/',
-                                        (tv2_sitetype!='template') ? this.getStr('template.accesskey') : this.getStr('webroot.accesskey'))); */
+                                        (tv2_sitetype!='template') ? TV2Util.getStr('template.accesskey') : TV2Util.getStr('webroot.accesskey'))); */
             links.push(new this.TV2Link('robot_swap', (tv2_sitetype!='robot')?robot:normal, '/',
-                                        (tv2_sitetype!='robot') ? this.getStr('robot.accesskey') : this.getStr('webroot.accesskey')));
+                                        (tv2_sitetype!='robot') ? TV2Util.getStr('robot.accesskey') : TV2Util.getStr('webroot.accesskey')));
             
             links.push(new this.TV2LinkSplit());
             
@@ -327,8 +266,8 @@ var TV2Developer = {
             } else {
                 viewcvs_type = 'viewcvs_test';
             }
-            links.push(new this.TV2LinkWithLabel(viewcvs_type, this.getStr('lookupInViewCVS'), viewcvs,
-                                                 this.getStr('lookupInViewCVS.accesskey')));
+            links.push(new this.TV2LinkWithLabel(viewcvs_type, TV2Util.getStr('lookupInViewCVS'), viewcvs,
+                                                 TV2Util.getStr('lookupInViewCVS.accesskey')));
 
             // Update and I2 base URL
             var updatepostfix = (tv2_user ? '.' + tv2_user : '')
@@ -353,36 +292,36 @@ var TV2Developer = {
             var docWin = getBrowser().contentWindow;
             if (docWin.wrappedJSObject && docWin.wrappedJSObject.Tango_URL) {
                 tango = encodeURIComponent(docWin.wrappedJSObject.Tango_URL);
-                links.push(new this.TV2LinkWithLabel('tango/dynamic', this.getStr('viewDynamicVersion'),
+                links.push(new this.TV2LinkWithLabel('tango/dynamic', TV2Util.getStr('viewDynamicVersion'),
                         i2link + '/tango/dynamic.php?url='+tango+'&referer='+encodedURL, 
-                        this.getStr('viewDynamicVersion.accesskey'),
+                        TV2Util.getStr('viewDynamicVersion.accesskey'),
                         'flushCache'));
             }
             if (onI2interface != 'tango/entry' && onI2interface != 'tango/requeue') {
-                links.push(new this.TV2LinkWithLabel('tango/entry', this.getStr('lookupInTango'),
-                                i2link + '/tango/entry.php?url=' + tango, this.getStr('lookupInTango.accesskey')));
-                links.push(new this.TV2LinkWithLabel('tango/requeue', this.getStr('requeueInTango'),
-                                i2link + '/tango/requeue.php?url=' + tango, this.getStr('requeueInTango.accesskey')));
+                links.push(new this.TV2LinkWithLabel('tango/entry', TV2Util.getStr('lookupInTango'),
+                                i2link + '/tango/entry.php?url=' + tango, TV2Util.getStr('lookupInTango.accesskey')));
+                links.push(new this.TV2LinkWithLabel('tango/requeue', TV2Util.getStr('requeueInTango'),
+                                i2link + '/tango/requeue.php?url=' + tango, TV2Util.getStr('requeueInTango.accesskey')));
             }
             
             // Add run pdo_log link
             if ((onI2interface != 'tool/pdo_log/frameset') &&
                 ((!tv2_testsite && php5) || // only php5 live sites
                 (tv2_testsite && tv2_testsite != 'snapshot3' && tv2_testsite != 'test3'))) { /* not supported on php4 sites */
-                links.push(new this.TV2LinkWithLabel('tool/pdo_log/frameset', this.getStr('performDbPdoLog'),
+                links.push(new this.TV2LinkWithLabel('tool/pdo_log/frameset', TV2Util.getStr('performDbPdoLog'),
                    i2link + '/tool/pdo_log/frameset.php?url='+tango+'&autostop=1&prefix='+initials,
-                   this.getStr('performDbPdoLog.accesskey'),
+                   TV2Util.getStr('performDbPdoLog.accesskey'),
                    'flushCache'));
             }
             
-//            if (this.getPref('enable-secret', false)) {
+//            if (TV2Util.getPref('enable-secret', false)) {
 //            }
 
             if (onI2interface_url) {
                 /* link entered in I2 interface */
                 links.push(new this.TV2LinkSplit());
                 /* tango/entry, tango/requeue, tango/dynamic, tool/pdo_log */
-                links.push(new this.TV2LinkWithLabel(onI2interface, onI2interface_url, onI2interface_url, this.getStr('backI2.accesskey')));
+                links.push(new this.TV2LinkWithLabel(onI2interface, onI2interface_url, onI2interface_url, TV2Util.getStr('backI2.accesskey')));
             }
          
             // Some special cases for some sites 
@@ -391,12 +330,12 @@ var TV2Developer = {
                 var ttv_page = /side=([0-9]+)/.exec(tv2_uri);
                 if (ttv_page) {
                     skip_treenodes = true;
-                    links.push(new this.TV2LinkWithLabel('ttvpage', this.getStr('lookupTTVPage') + ' ' + ttv_page[1],
+                    links.push(new this.TV2LinkWithLabel('ttvpage', TV2Util.getStr('lookupTTVPage') + ' ' + ttv_page[1],
                                 i2link + '/tool/ttv/?1=' + ttv_page[1] + '&2=0', /* hardcoded to TV 2 TTV */
-                                this.getStr('lookupTTVPage.accesskey')));
+                                TV2Util.getStr('lookupTTVPage.accesskey')));
                 }
-                /*links.push(new this.TV2Link('ttvpumpe', 'ttvpumpe'+updatepostfix, '/', this.getStr('ttvpumpe.accesskey')));*/
-                links.push(new this.TV2Link('ttvpumpe', 'ttvpumpe.opdatering.tv2.dk', '/', this.getStr('ttvpumpe.accesskey')));
+                /*links.push(new this.TV2Link('ttvpumpe', 'ttvpumpe'+updatepostfix, '/', TV2Util.getStr('ttvpumpe.accesskey')));*/
+                links.push(new this.TV2Link('ttvpumpe', 'ttvpumpe.opdatering.tv2.dk', '/', TV2Util.getStr('ttvpumpe.accesskey')));
             }
             
             // I2-Files and I2-Images
@@ -417,11 +356,11 @@ var TV2Developer = {
                         }
                     }
                     links.push(new this.TV2LinkSplit());
-                    links.push(new this.TV2LinkWithLabel('i2files', this.getStr('lookupContent') + ' ' + contentId[1] + ', ' +
-                        this.getStr('lookupContent.type') + ' ' + typeName,
+                    links.push(new this.TV2LinkWithLabel('i2files', TV2Util.getStr('lookupContent') + ' ' + contentId[1] + ', ' +
+                        TV2Util.getStr('lookupContent.type') + ' ' + typeName,
                         i2link + 
                             '/tool/query/?id=&_checkbox=1&2=&3='+typeId+'&content_id='+contentId[1]+'&4=&5=0&6=&action=Query&timeout=1',
-                            this.getStr('lookupContent.accesskey')
+                            TV2Util.getStr('lookupContent.accesskey')
                             ));
                 }
             }
@@ -436,9 +375,9 @@ var TV2Developer = {
                         links.push(new this.TV2LinkSplit());
                         first = false;
                     }
-                    links.push(new this.TV2LinkWithLabel('node', this.getStr('lookupTreeNode') + ' ' + nodeids[1],
+                    links.push(new this.TV2LinkWithLabel('node', TV2Util.getStr('lookupTreeNode') + ' ' + nodeids[1],
                                 i2node + nodeids[1],
-                                this.getStr('lookupTreeNode.accesskey')
+                                TV2Util.getStr('lookupTreeNode.accesskey')
                                 ));
                }
             }
@@ -465,26 +404,26 @@ var TV2Developer = {
                 var live_sitename = (tv2_sitetype=='webroot' && tv2_sitename=='www') ? '': (tv2_sitename+'.');
                 var type = (tv2_sitetype=='webroot')? '' : tv2_sitetype+'.';
                 
-                links.push(new this.TV2Link('viewcvs_live', live_sitename + type + 'tv2.dk', tv2_uri, this.getStr('live.accesskey')));
-                links.push(new this.TV2Link('viewcvs_test', tv2_sitename + '.' + initials + '.' + type + 'test' + testType + '.tv2.dk', tv2_uri, this.getStr('test.accesskey')));
-                links.push(new this.TV2Link('viewcvs_snapshot', tv2_sitename + '.' + type + 'snapshot' + testType + '.tv2.dk', tv2_uri, this.getStr('snapshot.accesskey')));
-                links.push(new this.TV2Link('viewcvs_testprompt', tv2_sitename + '.?.' + type + 'test' + testType + '.tv2.dk', tv2_uri, this.getStr('testprompt.accesskey'), 'promptInitials'));
+                links.push(new this.TV2Link('viewcvs_live', live_sitename + type + 'tv2.dk', tv2_uri, TV2Util.getStr('live.accesskey')));
+                links.push(new this.TV2Link('viewcvs_test', tv2_sitename + '.' + initials + '.' + type + 'test' + testType + '.tv2.dk', tv2_uri, TV2Util.getStr('test.accesskey')));
+                links.push(new this.TV2Link('viewcvs_snapshot', tv2_sitename + '.' + type + 'snapshot' + testType + '.tv2.dk', tv2_uri, TV2Util.getStr('snapshot.accesskey')));
+                links.push(new this.TV2Link('viewcvs_testprompt', tv2_sitename + '.?.' + type + 'test' + testType + '.tv2.dk', tv2_uri, TV2Util.getStr('testprompt.accesskey'), 'promptInitials'));
                 
             } else {
-                links.push(new this.TV2LinkWithLabel('disabled', this.getStr('notTV2Site'), null, '', null, true));
+                links.push(new this.TV2LinkWithLabel('disabled', TV2Util.getStr('notTV2Site'), null, '', null, true));
                 links.push(new this.TV2LinkSplit());
-                links.push(new this.TV2Link('tv2dk', 'tv2.dk', '/', this.getStr('tv2dk.accesskey')));
+                links.push(new this.TV2Link('tv2dk', 'tv2.dk', '/', TV2Util.getStr('tv2dk.accesskey')));
             }
         }
         
         // Utility links
         links.push(new this.TV2LinkSplit());
-        links.push(new this.TV2LinkWithLabel('link_tree', this.getStr('i2Tree'), 'http://i2.opdatering.tv2.dk/tree/', this.getStr('i2Tree.accesskey')));
-        links.push(new this.TV2LinkWithLabel('node', this.getStr('nodeInformationTool'), 'http://i2.opdatering.tv2.dk/tool/node/', this.getStr('nodeInformationTool.accesskey')));
-        links.push(new this.TV2LinkWithLabel('link_query', this.getStr('nodeQueryTool'), 'http://i2.opdatering.tv2.dk/tool/query/', this.getStr('nodeQueryTool.accesskey')));
-        links.push(new this.TV2LinkWithLabel('tango/entry', this.getStr('tangoInterface'), 'http://i2.opdatering.tv2.dk/tango/', this.getStr('tangoInterface.accesskey')));
-        links.push(new this.TV2LinkWithLabel('w3c', this.getStr('w3c'),
-            'http://validator.w3.org/check?uri=' + encodedURL, this.getStr('w3c.accesskey')));
+        links.push(new this.TV2LinkWithLabel('link_tree', TV2Util.getStr('i2Tree'), 'http://i2.opdatering.tv2.dk/tree/', TV2Util.getStr('i2Tree.accesskey')));
+        links.push(new this.TV2LinkWithLabel('node', TV2Util.getStr('nodeInformationTool'), 'http://i2.opdatering.tv2.dk/tool/node/', TV2Util.getStr('nodeInformationTool.accesskey')));
+        links.push(new this.TV2LinkWithLabel('link_query', TV2Util.getStr('nodeQueryTool'), 'http://i2.opdatering.tv2.dk/tool/query/', TV2Util.getStr('nodeQueryTool.accesskey')));
+        links.push(new this.TV2LinkWithLabel('tango/entry', TV2Util.getStr('tangoInterface'), 'http://i2.opdatering.tv2.dk/tango/', TV2Util.getStr('tangoInterface.accesskey')));
+        links.push(new this.TV2LinkWithLabel('w3c', TV2Util.getStr('w3c'),
+            'http://validator.w3.org/check?uri=' + encodedURL, TV2Util.getStr('w3c.accesskey')));
         return links;
         
     },
@@ -503,9 +442,9 @@ var TV2Developer = {
         // add link to quickbox
         menu.appendChild(document.createElement('menuseparator'));
         var item = document.createElement('menuitem');
-        item.setAttribute('label', this.getStr('quickbox.menuitem')); 
-        item.setAttribute('accesskey', this.getStr('quickbox.accesskey'));
-        item.setAttribute('tooltiptext', this.getStr('quickbox.menuitem'));
+        item.setAttribute('label', TV2Util.getStr('quickbox.menuitem')); 
+        item.setAttribute('accesskey', TV2Util.getStr('quickbox.accesskey'));
+        item.setAttribute('tooltiptext', TV2Util.getStr('quickbox.menuitem'));
         item.setAttribute('oncommand', 'TV2Developer.openQuickbox(event)');
         menu.appendChild(item);
     },
@@ -577,11 +516,11 @@ var TV2Developer = {
             /* handle flags */
             if (tv2flags) {
                  if (tv2flags.indexOf('promptInitials') != -1) {
-                    var initials = prompt(this._strs.getString('enterInitials'), this.getPref('alternativ-initials', ''));
+                    var initials = prompt(TV2Util.getStr('enterInitials'), TV2Util.getPref('alternativ-initials', ''));
                     if (initials == '' || initials == null) {
                         return; // cancelled
                     }
-                    this.setPref('alternativ-initials', initials);
+                    TV2Util.setPref('alternativ-initials', initials);
                     url = url.replace('?', initials);
                  }
                  if (tv2flags.indexOf('flushCache') != -1) {
@@ -592,7 +531,7 @@ var TV2Developer = {
             openUILink(url, event, false, true, false); /* allow ctrl, not alt, and don't google */
             if (tv2linktype) {
                 this._lastAction = tv2linktype;
-                this.setPref('lastaction-linktype', tv2linktype);
+                TV2Util.setPref('lastaction-linktype', tv2linktype);
             }
         }
     },
@@ -606,87 +545,20 @@ var TV2Developer = {
         } catch(ex) {}
     },
 
-       /* Below is functionality for the quick link box */
-
-       _addCheckbox: function(here, id, label, accesskey) {
-               var radio = document.createElement('radio');
-               radio.setAttribute('id', id);
-               radio.setAttribute('label', label);
-               radio.setAttribute('accesskey', accesskey);
-               here.appendChild(radio);
-       },
-
-       updateQuickbox: function() {
-               var postfix = document.getElementById('radiobox-rows');
-               var username = this.getPref('developer-initials');
-               var php4 = '';
-               // add webroot links
-               var webroot = document.createElement('row');
-               this._addCheckbox(webroot, 'postfix-live', '.tv2.dk', this.getStr('quickbox.live.accesskey'));
-               this._addCheckbox(webroot, 'postfix-test', '.'+username+'.test'+php4+'.tv2.dk', this.getStr('quickbox.test.accesskey'));
-               this._addCheckbox(webroot, 'postfix-snapshot', '.snapshot'+php4+'.tv2.dk', this.getStr('quickbox.snapshot.accesskey'));
-               postfix.appendChild(webroot);
-               // add opdatering links
-               var opdatering = document.createElement('row');
-               this._addCheckbox(opdatering, 'postfix-live-opdatering', '.opdatering.tv2.dk', this.getStr('quickbox.live-opdatering.accesskey'));
-               this._addCheckbox(opdatering, 'postfix-test-opdatering', '.'+username+'.opdatering.test'+php4+'.tv2.dk', this.getStr('quickbox.test-opdatering.accesskey'));
-               this._addCheckbox(opdatering, 'postfix-snapshot-opdatering', '.opdatering.snapshot'+php4+'.tv2.dk', this.getStr('quickbox.snapshot-opdatering.accesskey'));
-               postfix.appendChild(opdatering);
-               // add robot links
-               var robot = document.createElement('row');
-               this._addCheckbox(robot, 'postfix-live-robot', '.robot.tv2.dk', this.getStr('quickbox.live-robot.accesskey'));
-               this._addCheckbox(robot, 'postfix-test-robot', '.'+username+'.robot.test'+php4+'.tv2.dk', this.getStr('quickbox.test-robot.accesskey'));
-               this._addCheckbox(robot, 'postfix-snapshot-robot', '.robot.snapshot'+php4+'.tv2.dk', this.getStr('quickbox.snapshot-robot.accesskey'));
-               postfix.appendChild(robot);
-               // select default radio button
-               var def = document.getElementById(this.getPref('lastaction-quickbox-postfix', 'postfix-live'));
-               if (def) {
-                   document.getElementById('tv2postfix').selectedItem = def;
-               }
-               document.getElementById('tv2prefix').value = this.getPref('lastaction-quickbox-prefix', '');
-               document.getElementById('php4site').checked = this.getPref('lastaction-quickbox-php4site', false);
-       },
-       
-       goQuickbox: function() {
-           var prefix  =  document.getElementById('tv2prefix').value;
-           var postfix_obj = document.getElementById('tv2postfix').selectedItem;
-           var php4site = document.getElementById('php4site').checked;
-           var url;
-           this.setPref('lastaction-quickbox-prefix', prefix);
-           this.setPref('lastaction-quickbox-postfix', postfix_obj.id);
-           this.setPref('lastaction-quickbox-php4site', document.getElementById('php4site').checked);
-           if (postfix_obj.id.substr(0, 8)=='postfix-') {
-               if (prefix == '') {
-                   prefix = 'www';
-               }
-               var postfix = postfix_obj.label;
-               if (php4site) { /* change test to test3, snapshot to snapshot3 */
-                   postfix = postfix.replace(/(test|snapshot)(\.tv2\.dk)/, '$13$2');
-               }
-               url = prefix+postfix;
-           } else {
-               var id = encodeURIComponent(prefix);
-               if (postfix_obj.id == 'go-node') {
-                   url = 'http://i2.opdatering.tv2.dk/tool/node/?id=' + id;
-               } else if (postfix_obj.id == 'go-content-id') {
-                   url = 'http://i2.opdatering.tv2.dk/tool/query/?id=&2=&3=&_checkbox=1&content_id='+id+'&4=&5=0&6=&action=Query&timeout=1';
-               } else if (postfix_obj.id == 'go-ttv-page') {
-                   url = 'http://i2.opdatering.tv2.dk/tool/ttv/?1=' + id + '&2=0';
-               }
-           }
-        window.close();
-        opener.openUILink(url, 'current', false, false, false); /* allow ctrl, alt, but don't google */
-       },
-       
        openQuickbox: function(event) {
-           window.openDialog('chrome://tv2developer/content/quickbox.xul','tv2quickbox','modal,centerscreen,chrome,resizable=no');
+      var startUrl = '';
+      var urlbar = document.getElementById('urlbar');
+      if (urlbar) {
+          startUrl = urlbar.value;
+      }
+           window.openDialog('chrome://tv2developer/content/quickbox.xul','tv2quickbox','modal,centerscreen,chrome,resizable=no,title=no', startUrl);
        },
        
        /* Options */
        openOptionsDialog: function(event) {
       var instantApply = getBoolPref("browser.preferences.instantApply", false);
       var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal");
-      window.openDialog('chrome://tv2developer/content/options.xul','tv2options',features);
+      window.openDialog('chrome://tv2developer/content/options.xul', 'tv2options', features);
   }
 
 
index d3f94313cb7d00091b998ce33bceb0ddf1fb95d3..cc26ec9739947a95aa208f40590bc28996a5c1ab 100755 (executable)
 <!ENTITY about.accesskey "a">
 
 <!ENTITY quickbox.title "TV 2 | Quickbox">
-<!ENTITY quickbox.enterprefix "Indtast første del af tv2.dk domænet:">
+<!ENTITY quickbox.entershorturl "Indtast forkortet URL:">
+<!ENTITY quickbox.entershorturl.accesskey "u">
+
+<!ENTITY quickbox.othertestsite "Andet test site:">
+<!ENTITY quickbox.othertestsite.accesskey ".">
+
 <!ENTITY quickbox.php4site "PHP 4 site">
+<!ENTITY quickbox.php4site.accesskey "p">
 <!ENTITY quickbox.php4site.tooltiptext "Ændrér test til test3, snapshot til snapshot3.">
 
+<!ENTITY quickbox.makeurl "Konstruér URL til websiden">
+<!ENTITY quickbox.makeurl.accesskey "k">
+
 <!ENTITY quickbox.nodeid "Slå op som Node ID i I2">
 <!ENTITY quickbox.nodeid.accesskey "n">
 
index 9e77a527308256b2013496ace4af2ae1914ed51b..0b8a59878bfe74a33c9d8c8fd9b20173ba8bf44c 100755 (executable)
 <!ENTITY about.accesskey "a">
 
 <!ENTITY quickbox.title "TV 2 | Quickbox">
-<!ENTITY quickbox.enterprefix "Enter tv2.dk prefix:">
+<!ENTITY quickbox.entershorturl "Enter short URL:">
+<!ENTITY quickbox.entershorturl.accesskey "u">
+
+<!ENTITY quickbox.othertestsite "Other test site:">
+<!ENTITY quickbox.othertestsite.accesskey ".">
+
 <!ENTITY quickbox.php4site "PHP 4 site">
+<!ENTITY quickbox.php4site.accesskey "p">
 <!ENTITY quickbox.php4site.tooltiptext "Changes test to test3, snapshot to snapshot3.">
 
+<!ENTITY quickbox.makeurl "Make URL for website">
+<!ENTITY quickbox.makeurl.accesskey "m">
+
 <!ENTITY quickbox.nodeid "Lookup as Node ID">
 <!ENTITY quickbox.nodeid.accesskey "n">
 
@@ -29,4 +38,3 @@
 
 <!ENTITY quickbox.ttvpage "Lookup as TTV Page">
 <!ENTITY quickbox.ttvpage.accesskey "g">
-
diff --git a/version b/version
index 0426003ce38bba9118de7573594d74de24607373..faef31a4357c48d6e4c55e84c8be8e3bc9055e20 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-0.6.24
+0.7.0