--- /dev/null
+/* 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
/* 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)
}
// 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');
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;
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);
// 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());
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());
} 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 : '')
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
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
}
}
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')
));
}
}
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')
));
}
}
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;
},
// 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);
},
/* 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) {
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);
}
}
},
} 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);
}