Added lots of new functionalities to Quickbox, lookup in CVS, lookup in Tango, back...
authorKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Sat, 29 Dec 2007 01:24:51 +0000 (02:24 +0100)
committerKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Sat, 29 Dec 2007 01:24:51 +0000 (02:24 +0100)
content/quickbox.xul
content/tv2developer-quickbox.js
content/tv2developer.js
locale/da-DK/tv2developer.dtd
locale/en-US/tv2developer.dtd
version
webroot/index.html

index 6874288b4761e439544de88b069b6b6ba886e41c..146bb3f8c0867cb0e0bd6d8cedb2c67ddaaea68f 100755 (executable)
@@ -20,7 +20,7 @@
 <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"/>
+    <label id="url" style="width:20em" value="" crop="end"/>
 </vbox>
 
     <hbox>
       </groupbox>
     </hbox>
 
-    <groupbox>
-      <caption label="&quickbox.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>
+    <radiogroup id="action" onselect="TV2DeveloperQuickBox.setManuel(this)">
+     <hbox>
+      <groupbox flex="1">
+        <caption label="&quickbox.action;"/>
+        <hbox>
+          <radio id="go-site" label="&quickbox.makeurl;" accesskey="&quickbox.makeurl.accesskey;" selected="true"/>
+          <checkbox id="php4site" label="&quickbox.php4site;" accesskey="&quickbox.php4site.accesskey;" tooltiptext="&quickbox.php4site.tooltiptext;"/>
+        </hbox>
+        <hbox>
+          <vbox flex="1">
+            <radio id="go-tango-page" label="&quickbox.tangolookup;" accesskey="&quickbox.tangolookup.accesskey;"/>
+            <radio id="go-tango-requeue" label="&quickbox.tangorequeue;" accesskey="&quickbox.tangorequeue.accesskey;"/>
+            <radio id="go-dynamic" label="&quickbox.dynamic;" accesskey="&quickbox.dynamic.accesskey;"/>
+          </vbox>
+        </hbox>
+        <hbox>
+          <radio id="go-viewcvs" label="&quickbox.openinviewcvs;" accesskey="&quickbox.openinviewcvs.accesskey;"/>
+          <checkbox id="php5branch" label="&quickbox.php5branch;" accesskey="&quickbox.php5branch.accesskey;"/>
+        </hbox>
+        <radio id="go-pdolog" label="&quickbox.examinedbqueries;" accesskey="&quickbox.examinedbqueries.accesskey;"/>
+      </groupbox>
+      <groupbox flex="1">
+        <caption label="&quickbox.otheractions;"/>
+          <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;"/>
+      </groupbox>
+     </hbox>
+    </radiogroup>
 
 </dialog>
index 5aa50675a44ed3c5e65a16fc547e2ffec634e392..4943653df093b753739c307d685abc5b4110da69 100644 (file)
-/* 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, /* save 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, part.length-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 (!auto_username) {\r
-                    if (part.length == 5 && part.substr(part.length-1, 1) == '3') {\r
-                        part = part.substr(0, part.length-1); // handle 'jkkn3' as short for php4 site, ...\r
-                        auto_php4 = true;\r
-                        // will also continue into next if-statement since we cut off one character\r
-                    }\r
-                    if (part.length == 4) {\r
-                        auto_username = part;\r
-                        if (auto_env == 'live') {\r
-                            auto_env = 'test';\r
-                        }\r
-                        continue;\r
-                    }\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
-                // handle other kinds of usernames\r
-                if (!auto_username) {\r
-                    if (part.substr(part.length-1, 1) == '3') {\r
-                        part = part.substr(0, part.length-1); // handle 'certus3' as short for php4 site, ...\r
-                        auto_php4 = true;\r
-                    }\r
-                    auto_username = part;\r
-                }\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 (env == 'test' && 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
-        // auto go (ALT+4)\r
-           if (window.arguments && window.arguments[1]) {\r
-               this.goQuickbox();\r
-           }\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
+/* Functionality for the quick link box */
+/* @author Kristian Kræmmer Nielsen <jkkn@tv2.dk> */
+
+var TV2DeveloperQuickBox = {
+       
+       _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);
+       },
+       
+       _autoChange: false,
+       _saveInitials: false, /* save the alternative initials field */
+       
+       /* assemble a final url */
+       _makeUrl: function(protocol, env, sitetype, php4, username, site, uri, dynsite) {
+         var domain;
+      // Assemble domain
+      // Always remove -dyn on test and -static on live
+      if (env != 'live' && site.substr(-4) == '-dyn') {
+           site = site.substr(0, site.length-4);
+      }
+      if (env == 'live' && site.substr(-7) == '-static') {
+           site = site.substr(0, site.length-7);
+      }
+      // Remove -static or add dyn
+      if (dynsite) {
+          if (site.substr(-7) == '-static') {
+              site = site.substr(0, site.length-7);
+          }
+          if (env == 'live' && sitetype == 'webroot') {
+              if (site == '') site = 'www';
+              if (site.substr(-4) != '-dyn') {
+                  site += '-dyn';
+              }
+          }
+      }
+      // handle www.tv2.dk
+      if (env == 'live' && sitetype == 'webroot') {
+          if (site == '' || site == 'www') {
+              domain = '';
+          } else {
+              domain = site + '.';
+          }
+      } else {
+          if (site == '') {
+              domain = 'www.';
+          } else {
+              domain = site + '.';
+          }
+      }
+      // handle environment
+      if (env == 'test') {
+          domain += username + '.';
+      }
+      // handle site type
+      if (sitetype != 'webroot') domain += sitetype + '.';
+      if (env != 'live') {
+          domain += env;
+          if (php4) domain += '3';
+          domain += '.';
+      }
+      // finish url
+      domain += 'tv2.dk';
+      
+      return protocol + '://' + domain + uri;
+    },
+       
+       /* determind if action requires us to create a site URL */ 
+       _shouldMakeURL: function(action) {
+           switch (action) {
+              case 'go-site':
+              case 'go-tango-page':
+              case 'go-tango-requeue':
+              case 'go-dynamic':
+              case 'go-viewcvs':
+              case 'go-pdolog':
+              return true;
+              default:
+              return false;
+           }
+       },
+       
+       /* Change action manually */
+       setManuel: function(target) {
+        var action = document.getElementById('action').selectedItem.id;
+           var makeSiteURL = this._shouldMakeURL(action);
+        var environment = document.getElementById('environment').selectedItem;
+        if (target.id == 'environment') {
+            document.getElementById('testname').disabled = (target.selectedItem.id != 'othertest');
+            if (!this._autoChange) {
+                document.getElementById('testname').select();
+                document.getElementById('testname').focus();
+            }
+        }
+        if (target.id == 'action') {
+            document.getElementById('sitetype').disabled = !makeSiteURL;
+            document.getElementById('php5branch').disabled = (action != 'go-viewcvs');
+            document.getElementById('environment').disabled = (action == 'go-viewcvs');
+        }
+        document.getElementById('php4site').disabled = (!makeSiteURL || action == 'go-pdolog' || action == 'go-viewcvs')
+                                                      || (environment && environment.id == 'live');
+           if (!this._autoChange) { /* avoid updating if this was triggered by updateQuickbox() */
+               if (target.id == 'testname' &&
+                   document.getElementById('environment').selectedItem.id != 'othertest') {
+                       document.getElementById('environment').selectedItem =
+                           document.getElementById('othertest');
+               }
+               this.updateQuickbox(true);
+           }
+       },
+
+    _reg_nodeid: /^(?!1234$)[0-9]+$/,
+    _reg_ttv: /^[0-9]{3}$/,
+    _reg_extract_nums: /([0-9]+)/g,
+    _reg_shortlink: /^((https?):\/?\/?)?([^/]*?)(tv2\.dk)?((\/[^#\?]*).*)?$/,
+    _reg_classname: /^[A-Z][a-zA-Z0-9_/]*(\.(p(hp?)?)?)?$/,
+    _sitetypes: ['opdatering', 'robot', 'template'],
+    _envs:      ['test', 'snapshot'],
+       updateQuickbox: function(manual) {
+           if (!manual) manual = false;
+           var current_user = TV2Util.getPref('developer-initials');
+               var username = current_user;
+               var shorturl = document.getElementById('shorturl').value;
+               var auto_action;
+               
+        var tv2 = this._reg_shortlink.exec(shorturl);
+        if (tv2) {
+            var protocol = tv2[2];
+            var domain   = tv2[3];
+            var uri      = tv2[5];
+            var uriOnly  = tv2[6];
+            var url      = '';
+            
+            var site = null;
+            var auto_sitetype = 'webroot';
+            var auto_env      = 'live';
+            var auto_username = null;
+            var auto_php4     = false;
+            var validState    = true;
+            
+            var parts = domain.split('.');
+            for (var i=0; i<parts.length; i++) {
+                var part = parts[i];
+                if (part.length == 0) continue;
+
+                // first take site name
+                if (!site) {
+                    site = part;
+                    continue;
+                }
+                
+                // detect short env (.t, .s, .dk,.. )
+                var used = false;
+                var env_part = part;
+                var env_php4 = false;
+                if (part.substr(part.length-1, 1) == '3') {
+                    env_part = part.substr(0, part.length-1); // handle t3, te3, test3, snapshot3
+                    env_php4 = true;
+                }
+                for (var j=0; j<this._envs.length; j++) {
+                    if (this._envs[j].substr(0, env_part.length) == env_part) {
+                        auto_env = this._envs[j];
+                        used = true; break;
+                    }
+                }
+                if (used) {
+                    auto_php4 = env_php4;
+                    continue;
+                }
+
+                // optional username
+                if (!auto_username) {
+                    if (part.length == 5 && part.substr(part.length-1, 1) == '3') {
+                        part = part.substr(0, part.length-1); // handle 'jkkn3' as short for php4 site, ...
+                        auto_php4 = true;
+                        // will also continue into next if-statement since we cut off one character
+                    }
+                    if (part.length == 4) {
+                        auto_username = part;
+                        if (auto_env == 'live') {
+                            auto_env = 'test';
+                        }
+                        continue;
+                    }
+                }
+
+                // detect short sitetype (.o, .op, .opd,.. )
+                var used = false;
+                for (var j=0; j<this._sitetypes.length; j++) {
+                    if (this._sitetypes[j].substr(0, part.length) == part) {
+                        auto_sitetype = this._sitetypes[j];
+                        used = true; break;
+                    }
+                }
+                if (used) continue;
+
+                // handle other kinds of usernames
+                if (!auto_username) {
+                    if (part.substr(part.length-1, 1) == '3') {
+                        part = part.substr(0, part.length-1); // handle 'certus3' as short for php4 site, ...
+                        auto_php4 = true;
+                    }
+                    auto_username = part;
+                }
+          
+            }
+            
+            // defaults
+            if (!protocol) protocol = 'http';
+            if (!uri) uri = '/';
+            if (!site) site = '';
+            
+            // determind action and options set
+            var env;
+            var sitetype;
+            var php4;
+            var action;
+            if (manual) {
+                // read options
+                env = document.getElementById('environment').selectedItem.id;
+                sitetype = document.getElementById('sitetype').selectedItem.id;
+                action = document.getElementById('action').selectedItem.id;
+                php4 = document.getElementById('php4site').checked;
+                if (env == 'othertest') {
+                    env = 'test';
+                    username = document.getElementById('testname').value;
+                }
+            } else {
+                // determind action
+               var cur_action = document.getElementById('action').selectedItem;
+                       if (this._reg_ttv.exec(site)) {
+                       auto_action = 'go-ttv-page';
+                       } else if (this._reg_nodeid.exec(site)) {
+                       auto_action = 'go-node';
+                   } else if (this._reg_classname.exec(shorturl)) {
+                       auto_action = 'go-viewcvs';
+                   } else {
+                       // if we are using the user input as an url we keep an eventually already selected action
+                       if (!this._shouldMakeURL(cur_action.id)) {
+                           auto_action = 'go-site';
+                       } else {
+                           auto_action = cur_action.id;
+                       }
+                }
+                // set options
+                env = auto_env;
+                /* sitetype and php5 is only relevant if we are creating a link for a site */
+                if (this._shouldMakeURL(cur_action.id)) {
+                    sitetype = auto_sitetype;
+                    php4 = (cur_action.id != 'go-pdolog' && auto_php4); // no support for pdo in php 4
+                } else {
+                    sitetype = 'opdatering';
+                    php4 = false;
+                }
+                action = auto_action;
+                
+                this._autoChange = true;
+                if (env == 'test' && auto_username && auto_username != username) {
+                    username = auto_username;
+                    document.getElementById('environment').selectedItem=document.getElementById('othertest');
+                    document.getElementById('testname').value=username;
+                } else {
+                    document.getElementById('environment').selectedItem=document.getElementById(env);
+                }
+                document.getElementById('sitetype').selectedItem=document.getElementById(sitetype);
+                document.getElementById('action').selectedItem=document.getElementById(action);
+                document.getElementById('php4site').checked = php4;
+                this._autoChange = false;
+            }
+
+            // Store constructed url before action
+            var entered_url;
+            if (this._shouldMakeURL(action)) {
+                entered_url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false);
+            }
+
+            // Handle actions - part one set host
+            var longest_id = null;
+            var action_uses_i2_opdatering = false;
+            var action_on_url_encoded;
+            switch (action) {
+            case 'go-node':
+            case 'go-content-id':
+            case 'go-ttv-page':
+                // find longest id in entered url
+                var max_len = 0;
+                var cur_id;
+                while ((cur_id = this._reg_extract_nums.exec(shorturl)) != null) {
+                    if (cur_id[1].length > max_len) {
+                        max_len = cur_id[1].length;
+                        longest_id = cur_id[1];
+                    }
+                }
+                if (!longest_id) {
+                    validState = false;
+                    longest_id = '?';
+                }
+                action_uses_i2_opdatering = true;
+                break;
+            case 'go-pdolog':
+                php4 = false; // not allowed
+            case 'go-tango-page':
+            case 'go-tango-requeue':
+            case 'go-dynamic':
+                action_on_url_encoded = encodeURIComponent(this._makeUrl(protocol, env, sitetype, php4, username, site, uri, true));
+                action_uses_i2_opdatering = true;
+                break;
+            case 'go-viewcvs':
+                break;
+            }
+            if (action_uses_i2_opdatering) {
+                protocol='http';
+                site = 'i2';
+                sitetype = 'opdatering';
+                php4 = false;
+            }                
+            // Handle actions - part two set uri
+            switch (action) {
+            case 'go-node':
+                uri = '/tool/node/?id=' + longest_id;
+                break;
+            case 'go-content-id':
+                uri = '/tool/query/?id=&2=&3=&_checkbox=1&content_id='+longest_id+'&4=&5=0&6=&action=Query&timeout=1';
+                break;
+            case 'go-ttv-page':
+                uri = '/tool/ttv/?1=' + longest_id + '&2=0';
+                break;
+            case 'go-tango-page':
+                uri = '/tango/entry.php?url='+action_on_url_encoded;
+                break;
+            case 'go-tango-requeue':
+                uri = '/tango/requeue.php?url='+action_on_url_encoded;
+                break;
+            case 'go-dynamic':
+                uri = '/tango/dynamic.php?url='+action_on_url_encoded;
+                break;
+            case 'go-viewcvs':
+                // Magically handle classnames (Enter as e.x. Tree_Node)
+                var classname = this._reg_classname.exec(shorturl);
+                if (classname) { // way want to move this section up a bit due to entered_url already set
+                    var clsname = classname[0];
+                    // remove ".php" :
+                    if (classname[1]) {
+                        clsname = clsname.substring(0, clsname.length-classname[1].length);
+                    }
+                    clsname = clsname.replace(/_/,'/');
+                    // add php if not entering on a slash:
+                    if (clsname.substr(-1) != '/') clsname += '.php';
+                    uri = uriOnly = '/' + clsname;
+                    site = 'globals';
+                    // must update entered url manually since it was stored before these changes
+                    entered_url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false);
+                    php5branch = true; // may want this auto default
+                }
+                var cvs_sitename = (!site) ? 'www' : site.replace(/-(static|dyn)/, '');
+                var php5branch = document.getElementById('php5branch').checked;
+                url = 'http://viewcvs.tv2.dk:7467/cgi-bin/viewvc.cgi/';
+                if (cvs_sitename == 'globals') {
+                    // special support for globals
+                    url += 'globals/php/TV2';
+                } else {
+                    url += cvs_sitename + '.tv2.dk/' + sitetype;
+                }
+                if (uriOnly) {
+                    var php = /^(.*\.php)/.exec(uriOnly);
+                    if (php) {
+                        url += php[1] + '?view=log';
+                    } else if(uriOnly.substr(-1) == '/') {
+                        // we show the directory listing :-)
+                        url += uriOnly;
+                    } else {
+                        url += uriOnly + '?view=log';
+                    }
+                } else {
+                    url += '/';
+                }
+                if (php5branch) {
+                    url += (url.indexOf('?')!=-1?'&':'?') + 'pathrev=PHP5';
+                }
+                break;
+            case 'go-pdolog':
+                uri = '/tool/pdo_log/frameset.php?url='+action_on_url_encoded+'&autostop=1&prefix='+current_user;
+                break;
+            }
+
+            // assmble url
+            if (env == 'test' && username == '') {
+               validState = false;
+               username = '?';
+            }
+            
+            if (url=='') {
+                url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false);
+            }
+            
+            document.getElementById('url').setAttribute('tooltiptext',
+            document.getElementById('url').value = url);
+            if (manual && this._shouldMakeURL(action)) {
+                // also change url in field
+                document.getElementById('shorturl').value = entered_url;
+            }
+            
+            // are we using the alternativ initials?
+            this._saveInitials = (env == 'test' && username != current_user);
+            
+            document.getElementById('tv2developer_quickbox').getButton('accept').disabled = !validState;
+        }
+       },
+       
+       /* method to extract short url */
+    _reg_fromviewcvs: /^http:\/\/viewcvs\.tv2.dk:7467\/cgi-bin\/viewvc\.cgi\/(([^/]+)\.tv2\.dk\/(webroot|robot|opdatering|template)|globals\/php\/TV2)([^#?]+)(.*)?/,
+    _reg_viewcvsbranch: /^\?(?:.*&)?pathrev=PHP5(?:&|$)/,
+    _reg_fromi2if: /^http:\/\/i2\.(?:[^.]+\.)?opdatering\.(?:(?:test|snapshot)\.)?tv2\.dk\/(tango\/(entry|requeue|dynamic)|tool\/pdo_log\/frameset)\.php.*?(\?|&)url=([^&]+)/,
+    _extractURL: function(url) {
+        var action = 'go-site';
+        
+        // Check if we are on an Tango or I2 interface, then we can extract the URL again
+        var tangoif = this._reg_fromi2if.exec(url);
+        if (tangoif) {
+            switch (tangoif[1]) {
+                case 'tango/entry':
+                action = 'go-tango-page';
+                break;
+                case 'tango/requeue':
+                action = 'go-tango-requeue';
+                break;
+                case 'tango/dynamic':
+                action = 'go-dynamic';
+                break;
+                case 'tool/pdo_log/frameset':
+                action = 'go-pdolog';
+                break;
+            }
+            url = decodeURIComponent(tangoif[4]);
+        }
+        /* Extract link from ViewCVS site */
+        var fromviewcvs = this._reg_fromviewcvs.exec(url);
+        if (fromviewcvs) {
+            var tv2_cvspath  = fromviewcvs[1];
+            var tv2_sitename = fromviewcvs[2];
+            var tv2_sitetype = fromviewcvs[3];
+            var tv2_uri      = fromviewcvs[4];
+            var tv2_php5branch = fromviewcvs[5];
+            
+            action = 'go-viewcvs';
+            if (tv2_sitename && tv2_sitetype) {
+                url = tv2_sitename + (tv2_sitetype == 'webroot' ? '' : '.'+tv2_sitetype) + tv2_uri;
+            } else { // must be globals match
+                url = 'globals' + tv2_uri;
+            }
+            if (this._reg_viewcvsbranch.exec(tv2_php5branch)) {
+                document.getElementById('php5branch').checked = true;
+            }
+        }
+        
+        this._autoChange = true;
+        document.getElementById('action').selectedItem = document.getElementById(action);
+        document.getElementById('shorturl').value = url;
+        this._autoChange = false;
+
+    },
+    
+    /* onload */
+       setupQuickbox: function() {
+           if (window.arguments && window.arguments[0]) {
+               this._extractURL(window.arguments[0]);
+           }
+           this.updateQuickbox();
+           document.getElementById('php4site').addEventListener('CheckboxStateChange',
+               function() { TV2DeveloperQuickBox.setManuel(this); }, false);
+           document.getElementById('php5branch').addEventListener('CheckboxStateChange',
+               function() { TV2DeveloperQuickBox.setManuel(this); }, false);
+           // init saved fields
+               document.getElementById('testname').value = TV2Util.getPref('alternativ-initials', '');
+        // auto go (ALT+4)
+           if (window.arguments && window.arguments[1]) {
+               this.goQuickbox();
+           }
+       },
+       
+       goQuickbox: function() {
+           // init saved fields
+           if (this._saveInitials) {
+                   TV2Util.setPref('alternativ-initials', document.getElementById('testname').value);
+               }
+        window.close();
+        opener.openUILink(document.getElementById('url').value, 'current', false, false, false);
+        /* allow ctrl, alt, but don't google */
+       }
+       
+};
index 72c1df37de053f3493595f07f724131684584bed..020d5615d012a273614663c81bbf45977338829a 100755 (executable)
@@ -255,13 +255,14 @@ var TV2Developer = {
                         + cvs_sitename + '.tv2.dk/' + (tv2_sitetype?tv2_sitetype:'webroot');
             var php = this._reg_php.exec(tv2_uriOnly);
             if (php) {
-                viewcvs += php[1] + '?view=log';
+                viewcvs += php[1];
             } else if(tv2_uriOnly.substr(-1) == '/') {
                 // we add 'index.php' and say that's it! :-)
-                viewcvs += tv2_uriOnly + 'index.php' + '?view=log';
+                viewcvs += tv2_uriOnly + 'index.php';
             } else {
                 viewcvs += tv2_uriOnly;
             }
+            viewcvs += '?view=log';
             // we set a nice type so we can swap between using the button (test<>viewcvs, live<>viewcvs,...)
             var viewcvs_type;
             if (!tv2_testsite) {
index 09b994257a5788742ab0ae554cfc785152e22501..00c4c8983447fd47d9896cc8610dad1efd5f3888 100755 (executable)
 <!ENTITY quickbox.makeurl "Konstruér URL til websiden">
 <!ENTITY quickbox.makeurl.accesskey "k">
 
+<!ENTITY quickbox.action "Funktion">
+<!ENTITY quickbox.environment "Miljø">
+<!ENTITY quickbox.sitetype "Site type">
+
+<!ENTITY quickbox.tangolookup "Tango: Vis information om siden">
+<!ENTITY quickbox.tangolookup.accesskey "g">
+
+<!ENTITY quickbox.tangorequeue "Tango: Sæt i kø">
+<!ENTITY quickbox.tangorequeue.accesskey "q">
+
+<!ENTITY quickbox.dynamic "Vis den dynamiske version af siden">
+<!ENTITY quickbox.dynamic.accesskey "d">
+
+<!ENTITY quickbox.openinviewcvs "Slå op i ViewCVS">
+<!ENTITY quickbox.openinviewcvs.accesskey "c">
+
+<!ENTITY quickbox.php5branch "PHP 5 branch">
+<!ENTITY quickbox.php5branch.accesskey "b">
+
+<!ENTITY quickbox.examinedbqueries "Undersøg database forespørgsler på siden">
+<!ENTITY quickbox.examinedbqueries.accesskey "x">
+
+<!ENTITY quickbox.otheractions "Andre funktioner">
+
 <!ENTITY quickbox.nodeid "Slå op som Node ID i I2">
 <!ENTITY quickbox.nodeid.accesskey "n">
 
 <!ENTITY quickbox.contentid "Slå op som Content ID i I2">
-<!ENTITY quickbox.contentid.accesskey "c">
+<!ENTITY quickbox.contentid.accesskey "i">
 
 <!ENTITY quickbox.ttvpage "Slå op som TTV side i I2">
-<!ENTITY quickbox.ttvpage.accesskey "g">
-
-<!ENTITY quickbox.action "Funktion">
-<!ENTITY quickbox.environment "Miljø">
-<!ENTITY quickbox.sitetype "Site type">
+<!ENTITY quickbox.ttvpage.accesskey "a">
index c8d5ad73c00c93675e7c852d0fa0a64b1d8439b0..7af883d88da9595a1923da9af1c2c3948334bbdb 100755 (executable)
 <!ENTITY quickbox.makeurl "Make URL for website">
 <!ENTITY quickbox.makeurl.accesskey "m">
 
+<!ENTITY quickbox.action "Action">
+<!ENTITY quickbox.environment "Environment">
+<!ENTITY quickbox.sitetype "Site type">
+
+<!ENTITY quickbox.tangolookup "Tango: Lookup">
+<!ENTITY quickbox.tangolookup.accesskey "g">
+
+<!ENTITY quickbox.tangorequeue "Tango: Open in requeue">
+<!ENTITY quickbox.tangorequeue.accesskey "q">
+
+<!ENTITY quickbox.dynamic "View dynamic version">
+<!ENTITY quickbox.dynamic.accesskey "d">
+
+<!ENTITY quickbox.openinviewcvs "Open in ViewCVS">
+<!ENTITY quickbox.openinviewcvs.accesskey "c">
+
+<!ENTITY quickbox.php5branch "PHP 5 branch">
+<!ENTITY quickbox.php5branch.accesskey "b">
+
+<!ENTITY quickbox.examinedbqueries "Examine database queries">
+<!ENTITY quickbox.examinedbqueries.accesskey "x">
+
+<!ENTITY quickbox.otheractions "Other actions">
+
 <!ENTITY quickbox.nodeid "Lookup as Node ID">
 <!ENTITY quickbox.nodeid.accesskey "n">
 
 <!ENTITY quickbox.contentid "Lookup as Content ID">
-<!ENTITY quickbox.contentid.accesskey "c">
+<!ENTITY quickbox.contentid.accesskey "i">
 
 <!ENTITY quickbox.ttvpage "Lookup as TTV Page">
-<!ENTITY quickbox.ttvpage.accesskey "g">
-
-<!ENTITY quickbox.action "Action">
-<!ENTITY quickbox.environment "Environment">
-<!ENTITY quickbox.sitetype "Site type">
+<!ENTITY quickbox.ttvpage.accesskey "a">
diff --git a/version b/version
index 100435be135a32ae8974fe4dd281c4d3a9d62e02..ac39a106c48515b621e90c028ed94c6f71bc03fa 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-0.8.2
+0.9.0
index 729a1a9c7c72225230f29115b7d00e84eaf48795..a858e5c392505b262aa893dfad1bac4719155a7f 100644 (file)
                 <li>Links opfører sig som normale links, således <code>CTRL</code> kan bruges til at åbne i ny tab, <code>CTRL+SHIFT</code> i en ny tab i baggrunden, <code>SHIFT</code> i ny vindue, osv..</li>
                 <li>(Bemærk at på mac er det nødvendigt at slå accesskeys til - dette kan gøres under indstillingerne i pluginen).</li>
             </ul>
+            <h3>Quick box features</h3>
+            <ul>
+                <li>Indtast korte url'er i adresselinjen så som: <code>nyhederne.o.t/nyheder/</code></li>
+                <li>Slå en TTV-side op blot ved at skrive sidenumret</li>
+                <li>Slå en node-id op blot ved at skrive numret</li>
+                <li>Skift mellem test, snapshot ved at bruge forkortelser så som: <code>t</code>, <code>s</code>, <code>t3</code> eller <code>s</code></li>
+                <li>Skift mellem opdatering, robot, template ved at bruge forkortelser så som: <code>o</code>, <code>r</code> eller <code>tem</code></li>
+                <li>Genkender andres test webs hvis der indtastes initialer på 4 bogstaver, eller der angives <code>.t.</code></li>
+                <li>Slå sider op i Tango, vis den dynamiske version eller slå op i CVS direkte fra en forkortet URL</li>
+                <li>Genkender klasse-navne (start med stort bogstav) og slår dem op i CVS i globals, indtast f.eks.: <code>ORM</code></li>
+                <li>Navigér videre rundt i ViewCVS let ved hjælp af korte url'er, prøv <code>ALT+3</code> i ViewCVS</li>
+                <li>Genkender URL angivet som parameter i fleste i2-interfaces</li>
+            </ul>
             <div class="center">
                 <a href="tv2developer.xpi">Install now</a>
             </div>