-/* 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 */
+ }
+
+};