var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
this._keyBranch = prefs.getBranch('ui.key.');
this._prefBranch = prefs.getBranch('browser.preferences.');
- // we show the options for hacing accesskeys if user has set a preference or accesskeys are disabled
+ // we show the options for hacking accesskeys if user has set a preference or accesskeys are disabled
this._hackEnabled =
this._keyBranch.prefHasUserValue('menuAccessKey') ||
(this._keyBranch.getIntPref('menuAccessKey') == 0);
document.getElementById('mac-accesskeys').checked =
(this._keyBranch.getIntPref('menuAccessKey') != 0);
}
+ // fill in php5 sites
+ document.getElementById('php5auto').selectedIndex =
+ (TV2Util.hasPref('php5sites') ? 1 : 0);
+ this.php5sitesFillIn(TV2Util.getPref('php5sites', ''));
+ },
+
+ /* fill in list */
+ php5sitesFillIn: function(php5set) {
+ var php5sites = php5set.split(',').sort();
+ var php5list = document.getElementById('php5sites');
+ var child = php5list.childNodes;
+ for (var i=child.length-1; i>=0; --i) {
+ if (child[i].tagName == 'listitem') {
+ php5list.removeChild(child[i]);
+ }
+ }
+ for (var i=0; i<php5sites.length; i++) {
+ if (php5sites[i] == '') continue;
+ var php5item = document.createElement('listitem');
+ php5item.setAttribute('label', php5sites[i]);
+ php5list.appendChild(php5item);
+ }
+ },
+
+ php5sitesSelect: function(obj) {
+ document.getElementById('php5sites_remove').disabled = (obj.selectedItem) ? false : true;
+ },
+
+ php5sitesAdd: function(obj) {
+ var add = prompt(TV2Util.getStr('optionsDialog.enterphp5site'), '');
+ if (add && add != '') {
+ var php5sites = document.getElementById('php5sites');
+ var php5childs = php5sites.childNodes;
+ var insertBefore = null;
+ // place at right sorted place in list
+ for (var i=0; i<php5childs.length; i++) {
+ if (php5childs[i].tagName == 'listitem') {
+ var item = php5childs[i].getAttribute('label');
+ if (item > add) {
+ insertBefore = php5childs[i];
+ break;
+ }
+ }
+ }
+ var newItem = document.createElement('listitem');
+ newItem.setAttribute('label', add);
+ php5sites.insertBefore(newItem, insertBefore);
+ php5sites.selectedItem = newItem;
+ php5sites.focus();
+ }
+ },
+
+ php5sitesRemove: function(obj) {
+ var php5sites = document.getElementById('php5sites');
+ php5sites.removeChild(php5sites.selectedItem);
+ php5sites.focus();
+ },
+
+ php5sitesAuto: function(obj) {
+ var php5sites = document.getElementById('php5sites');
+ var useDefaults = (obj.selectedIndex == 0);
+ if (useDefaults && !php5sites.disabled) {
+ this.php5sitesFillIn(TV2Util.getDefaultPref('php5sites'));
+ } else {
+ php5sites.focus();
+ }
+ php5sites.disabled = useDefaults;
+ document.getElementById('php5sites_add').disabled = useDefaults;
},
save: function() {
this._keyBranch.clearUserPref('menuAccessKey');
}
}
+ // save php5 sites list
+ var php5auto = document.getElementById('php5auto');
+ if (php5auto.selectedIndex == 1) {
+ var php5childs = document.getElementById('php5sites').childNodes;
+ var php5sites = [];
+ for (var i=0; i<php5childs.length; i++) {
+ if (php5childs[i].tagName == 'listitem') {
+ php5sites.push(php5childs[i].getAttribute('label'));
+ }
+ }
+ TV2Util.setPref('php5sites', php5sites.join(','));
+ } else {
+ if (TV2Util.hasPref('php5sites')) {
+ TV2Util.clearPref('php5sites');
+ }
+ }
},
update: function() {
title="&optionsDialog.title;"
onload="TV2Options.init()"
ondialogaccept="TV2Options.save()">
-<script type="application/x-javascript" src="options.js" />
-
+
+ <script type="application/x-javascript" src="tv2developer-util.js" />
+ <script type="application/x-javascript" src="options.js" />
+
+ <stringbundleset id="stringbundleset">
+ <stringbundle id="tv2developer_strings" src="chrome://tv2developer/locale/tv2developer.properties"/>
+ </stringbundleset>
+
<prefpane id="pane1" label="&optionsDialog.options.label;">
<preferences>
<preference id="pref_developer-initials" name="tv2developer.developer-initials" type="string"/>
</preferences>
<groupbox>
- <label control="developer-initials" value="&developerInitials.description;" />
+ <caption label="&developerInitials.description;" />
<textbox id="developer-initials" preference="pref_developer-initials" />
</groupbox>
+
+ <groupbox>
+ <caption label="&optionsDialog.php5sites.label;" tooltiptext="&optionsDialog.php5sites.tooltiptext;"/>
+ <radiogroup id="php5auto" onselect="TV2Options.php5sitesAuto(this)">
+ <radio label="&optionsDialog.php5sites.defaults;"/>
+ <radio label="&optionsDialog.php5sites.custom;"/>
+ </radiogroup>
+ <listbox id="php5sites" onselect="TV2Options.php5sitesSelect(this)"/>
+ <hbox align="center">
+ <spacer flex="1"/>
+ <button label="&optionsDialog.php5sites.addsite;" accesskey="&optionsDialog.php5sites.addsite.accesskey;" id="php5sites_add" oncommand="TV2Options.php5sitesAdd()" disabled="true"/>
+ <button label="&optionsDialog.php5sites.removesite;" accesskey="&optionsDialog.php5sites.removesite.accesskey;" id="php5sites_remove" oncommand="TV2Options.php5sitesRemove()" disabled="true"/>
+ <spacer flex="1"/>
+ </hbox>
+ </groupbox>
<groupbox id="mac-hacks">
<checkbox id="mac-accesskeys" label="&optionsDialog.mac.accesskeys;"
},\r
\r
_autoChange: false,\r
- _saveInitials: false, /* safe the alternative initials field */\r
+ _saveInitials: false, /* save the alternative initials field */\r
\r
setManuel: function(target) {\r
if (target.id == 'environment') {\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
+ 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
- continue;\r
}\r
\r
// detect short sitetype (.o, .op, .opd,.. )\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
Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch('tv2developer.');\r
return this._prefs;\r
},\r
+ \r
+ /* default preference functions */\r
+ _defPrefs: null,\r
+ get defPrefs() {\r
+ if (!this._defPrefs)\r
+ this._defPrefs =\r
+ Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getDefaultBranch('tv2developer.');\r
+ return this._defPrefs;\r
+ },\r
\r
getPref: function(name, defValue) {\r
const CI=Components.interfaces.nsIPrefBranch;\r
default:\r
throw new Error('Unsupported type '+typeof(value)+' for preference '+name);\r
}\r
+ },\r
+ \r
+ hasPref: function(name) {\r
+ return this.prefs.prefHasUserValue(name);\r
+ },\r
+ \r
+ clearPref: function(name) {\r
+ this.prefs.clearUserPref(name);\r
+ },\r
+ \r
+ getDefaultPref: function(name) {\r
+ const CI=Components.interfaces.nsIPrefBranch;\r
+ const prefs=this.defPrefs;\r
+ try {\r
+ switch(prefs.getPrefType(name)) {\r
+ case CI.PREF_STRING:\r
+ return prefs.getCharPref(name);\r
+ case CI.PREF_INT:\r
+ return prefs.getIntPref(name);\r
+ case CI.PREF_BOOL:\r
+ return prefs.getBoolPref(name);\r
+ }\r
+ } catch(e) {alert(e)}\r
+ return defValue;\r
}\r
\r
+ \r
};\r
menu.appendChild(item);
return def;
},
+
+ _isPhp5: function(site) {
+ if (!site) site = 'www';
+ return ((','+TV2Util.getPref('php5sites')+',').indexOf(','+site+',') != -1);
+ },
/* Main function for adding all the links for the menu popup */
_reg_tv2: /^https?:\/\/([^/.]*)?([^/]*?)(\.(robot|opdatering|template)\.?)?(\.((test|snapshot)3?)\.)?tv2\.dk((\/[^#\?]*).*)?$/,
_reg_php: /^(.*\.php)/,
_reg_nodeid: /([0-9]{2,})/g,
_reg_i2files: /\/([0-9]+)-/,
- _reg_php5: /^(www|i2|common|ttvpumpe|1234|nyhederne|krimi)$/,
_reg_fromviewcvs: /^http:\/\/viewcvs\.tv2.dk:7467\/cgi-bin\/viewvc\.cgi\/([^/]+)\.tv2\.dk\/(webroot|robot|opdatering|template)([^#\?]+)/,
_reg_fromi2if: /^\/(tango\/(entry|requeue|dynamic)|tool\/pdo_log\/frameset)\.php.*?(\?|&)url=([^&]+)/,
getLinks: function() {
// Strip -dyn and -static
if (tv2_sitename) tv2_sitename = tv2_sitename.replace(/-(dyn|static)$/, '');
if (tv2_user) tv2_user = tv2_user.replace(/^\./, '');
-
- // php5 sites
- var php5 = ((!tv2_sitename) || (this._reg_php5.test(tv2_sitename)));
+
+ // php5 site
+ var php5 = this._isPhp5(tv2_sitename);
var testType = php5 ? '' : '3';
// Find live, test and snapshot url for current site
}
// php5 sites
- //var php5 = ((!tv2_sitename) || (this._reg_php5.test(tv2_sitename)));
- var php5 = ((tv2_sitename) && (this._reg_php5.test(tv2_sitename)));
+ var php5 = this._isPhp5(tv2_sitename);
var testType = php5 ? '' : '3';
var live_sitename = (tv2_sitetype=='webroot' && tv2_sitename=='www') ? '': (tv2_sitename+'.');
pref('tv2developer.firstRun', true);
pref('tv2developer.developer-initials', 'CHANGE-THIS');
pref('tv2developer.lastaction-linktype', 'tango/entry');
+pref('tv2developer.php5sites', 'www,i2,common,ttvpumpe,1234,nyhederne,krimi,radio');
<!ENTITY optionsDialog.mac.accesskeys "Slå genvejstaster til i Firefox på Mac">
<!ENTITY optionsDialog.mac.accesskeys.tooltiptext "Ændring af dette felt kræver genstart af Firefox">
+<!ENTITY optionsDialog.php5sites.label "PHP 5 konverterede sites">
+<!ENTITY optionsDialog.php5sites.tooltiptext "Sites i denne liste vil blive betragtet som PHP 5 sites.">
+<!ENTITY optionsDialog.php5sites.defaults "Brug standard PHP 5 sites">
+<!ENTITY optionsDialog.php5sites.custom "Vælg manuelt PHP 5 sites:">
+<!ENTITY optionsDialog.php5sites.addsite "Tilføj site">
+<!ENTITY optionsDialog.php5sites.addsite.accesskey "t">
+<!ENTITY optionsDialog.php5sites.removesite "Fjern site">
+<!ENTITY optionsDialog.php5sites.removesite.accesskey "f">
+
<!ENTITY config.label "Konfigurér">
<!ENTITY config.accesskey "c">
enterInitials=Indtast tv2.dk initialer (f.eks. jkkn):
+# Quickbox dialog
+
quickbox.menuitem=TV 2 | Quickbox dialog...
quickbox.accesskey=q
-quickbox.live.accesskey=w
-quickbox.test.accesskey=t
-quickbox.snapshot.accesskey=s
-quickbox.live-opdatering.accesskey=o
-quickbox.test-opdatering.accesskey=p
-quickbox.snapshot-opdatering.accesskey=d
-quickbox.live-robot.accesskey=r
-quickbox.test-robot.accesskey=b
-quickbox.snapshot-robot.accesskey=a
+# Options dialog
+
+optionsDialog.enterphp5site=Indtast navn på PHP 5 site:
<!ENTITY optionsDialog.mac.accesskeys "Enable accesskeys in Firefox on Mac">
<!ENTITY optionsDialog.mac.accesskeys.tooltiptext "Changing this requires restart of Firefox">
+<!ENTITY optionsDialog.php5sites.label "PHP 5 enabled sites">
+<!ENTITY optionsDialog.php5sites.tooltiptext "Sites listed here will be seen as PHP 5 sites.">
+<!ENTITY optionsDialog.php5sites.defaults "Use default PHP 5 sites">
+<!ENTITY optionsDialog.php5sites.custom "Custom PHP 5 sites:">
+<!ENTITY optionsDialog.php5sites.addsite "Add site">
+<!ENTITY optionsDialog.php5sites.addsite.accesskey "a">
+<!ENTITY optionsDialog.php5sites.removesite "Remove site">
+<!ENTITY optionsDialog.php5sites.removesite.accesskey "r">
+
<!ENTITY config.label "Configure">
<!ENTITY config.accesskey "c">
enterInitials=Enter TV 2 initials (e.x. jkkn):
+# Quickbox dialog
+
quickbox.menuitem=TV 2 | Quickbox dialog...
quickbox.accesskey=q
-quickbox.live.accesskey=w
-quickbox.test.accesskey=t
-quickbox.snapshot.accesskey=s
-quickbox.live-opdatering.accesskey=o
-quickbox.test-opdatering.accesskey=p
-quickbox.snapshot-opdatering.accesskey=d
-quickbox.live-robot.accesskey=r
-quickbox.test-robot.accesskey=b
-quickbox.snapshot-robot.accesskey=a
+# Options dialog
+
+optionsDialog.enterphp5site=Enter name of PHP 5 site: