_saveInitials: false, /* save the alternative initials field */
/* assemble a final url */
- _makeUrl: function(protocol, env, sitetype, php4, username, site, uri, dynsite) {
+ _makeUrl: function(protocol, env, sitetype, branch, php4, username, site, uri, dynsite) {
var domain;
// Assemble domain
// Always remove -dyn on test and -static on live
domain = site + '.';
}
}
+ // handle branch
+ if (env != 'live' && branch) {
+ domain += branch + '.';
+ }
// handle environment
if (env == 'test') {
domain += username + '.';
document.getElementById('sitetype').disabled = !makeSiteURL;
document.getElementById('php4branch').disabled = (action != 'go-gitweb');
document.getElementById('viewcontent').disabled = (action != 'go-gitweb');
- document.getElementById('environment').disabled = (action == 'go-gitweb');
+ document.getElementById('environment').disabled = (action == 'go-gitweb' || action == 'go-bugzilla');
}
document.getElementById('php4site').disabled = (!makeSiteURL || action == 'go-pdolog' || action == 'go-gitweb')
|| (environment && environment.id == 'live');
+ document.getElementById('subdomain.label').disabled =
+ document.getElementById('subdomain').disabled = ((action == 'go-gitweb' || action == 'go-bugzilla')
+ || (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') {
var auto_sitetype = 'webroot';
var auto_env = 'live';
var auto_username = null;
+ var auto_branch = '';
var auto_php4 = false;
var validState = true;
// optional username
if (!auto_username) {
- if (part.length == 5) {
- var lastChar = part.substr(part.length-1, 1);
- if (lastChar == '4' || lastChar == '5') {
- part = part.substr(0, part.length-1); // handle 'jkkn4' as short for php4 site, ...
- auto_php4 = (lastChar == '4');
- }
- // will also continue into next if-statement since we cut off one character
- }
if (part.length == 4) {
auto_username = part;
if (auto_env == 'live') {
continue;
}
}
-
+
// detect short sitetype (.o, .op, .opd,.. )
var used = false;
for (var j=0; j<this._sitetypes.length; j++) {
}
if (used) continue;
+ // optional subdomain (for branches)
+ if (!auto_branch) {
+ if (auto_username && part.length == 4) {
+ // if both set, we expect user to have written them in the right order
+ auto_branch = auto_username;
+ auto_username = part;
+ } else {
+ auto_branch = part;
+ }
+ if (auto_env == 'live') {
+ auto_env = 'test';
+ }
+ continue;
+ }
+
// handle other kinds of usernames
if (!auto_username) {
if (part.substr(part.length-1, 1) == '4') {
var sitetype;
var php4;
var action;
+ var branch;
if (manual) {
// read options
env = document.getElementById('environment').selectedItem.id;
env = 'test';
username = document.getElementById('testname').value;
}
+ if (env != 'live') {
+ branch = document.getElementById('subdomain').value;
+ }
} else {
// determind action
var cur_action = document.getElementById('action').selectedItem;
} else {
document.getElementById('environment').selectedItem=document.getElementById(env);
}
+ branch = auto_branch;
+ document.getElementById('subdomain').value=branch;
document.getElementById('sitetype').selectedItem=document.getElementById(sitetype);
document.getElementById('action').selectedItem=document.getElementById(action);
document.getElementById('php4site').checked = php4;
// Store constructed url before action
var entered_url;
if (this._shouldMakeURL(action)) {
- entered_url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false);
+ entered_url = this._makeUrl(protocol, env, sitetype, branch, php4, username, site, uri, false);
}
// Handle actions - part one set host
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_on_url_encoded = encodeURIComponent(this._makeUrl(protocol, env, sitetype, branch, php4, username, site, uri, true));
action_uses_opdatering = true;
site = 'i2';
break;
if (action_uses_opdatering) {
protocol='http';
sitetype = 'opdatering';
+ branch = '';
php4 = false;
}
// Handle actions - part two set uri
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);
+ entered_url = this._makeUrl(protocol, env, sitetype, branch, php4, username, site, uri, false);
}
var git_sitename = (!site) ? 'www' : site.replace(/-(static|dyn)/, '');
url = 'http://flimmer.tv2.dk/git/?p=';
}
if (url=='') {
- url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false);
+ url = this._makeUrl(protocol, env, sitetype, branch, php4, username, site, uri, false);
}
document.getElementById('url').setAttribute('tooltiptext',
},
/* Main function for adding all the links for the menu popup */
- _reg_tv2: /^https?:\/\/([^/.]*)?([^/]*?)(\.(robot|opdatering|template)\.?)?(\.(php4|php5)\.?)?(\.((test3?|snapshot3?|stage))\.)?tv2\.dk((\/[^#\?]*).*)?$/,
+ _reg_tv2: /^https?:\/\/([^/.]*)?(\.([^/]*?))?(\.(robot|opdatering|template)\.?)?(\.(php4|php5)\.?)?(\.((test3?|snapshot3?|stage))\.)?tv2\.dk((\/[^#\?]*).*)?$/,
+ _reg_branchuser: /(([^.]*?)\.)?([^.]*)/,
_reg_php: /^(.*\.php)/,
_reg_nodeid: /([0-9]{2,})/g,
_reg_i2files: /\/([0-9]+)-/,
if (tv2 && !fromgitweb) {
var skip_treenodes = false;
var tv2_sitename = tv2[1];
- var tv2_user = tv2[2];
- var tv2_sitetype = tv2[4];
- var tv2_apptype = tv2[6]; // php4 or php5
- var tv2_testsite = tv2[8];
- var tv2_testtype = tv2[9]; /* no 3 */
- var tv2_uri = tv2[10];
- var tv2_uriOnly = tv2[11]; // no parameters, anchers
+ var tv2_branchuser = tv2[3];
+ var tv2_sitetype = tv2[5];
+ var tv2_apptype = tv2[7]; // php4 or php5
+ var tv2_testsite = tv2[9];
+ var tv2_testtype = tv2[10]; /* no 3 */
+ var tv2_uri = tv2[11];
+ var tv2_uriOnly = tv2[12]; // no parameters, anchers
// Strip -dyn and -static
if (tv2_sitename) tv2_sitename = tv2_sitename.replace(/-(dyn|static)$/, '');
- if (tv2_user) tv2_user = tv2_user.replace(/^\./, '');
-
+
// convert old URLs (.test3 / .snapshot3)
if (tv2_testsite == 'test3') {
tv2_testsite = 'test';
tv2_testsite = 'snapshot';
tv2_apptype = 'php4';
}
+
+ var tv2_user;
+ var tv2_branch;
+ // In stage and snapshot and test - split username and branch
+ if (tv2_testsite == 'snapshot' || tv2_testsite == 'stage' || tv2_testsite == 'test' && tv2_branchuser) {
+ if (tv2_testsite == 'test') { // if only one - this is the username
+ var bc = this._reg_branchuser.exec(tv2_branchuser);
+ if (bc) {
+ tv2_branch = bc[2];
+ tv2_user = bc[3];
+ }
+ } else { // we do not have usernames on snapshot/stage, so this is the branch
+ tv2_branch = tv2_branchuser;
+ }
+ }
// php4 site
var php4 = this._isPhp4(tv2_sitename);
}
}
- var testprompturl = git_sitename+'.'+'?'+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.test'+'.tv2.dk';
- var testurl = git_sitename+'.'+initials+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.test'+'.tv2.dk';
- var snapshoturl = git_sitename+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.snapshot'+'.tv2.dk';
- var stageurl = git_sitename+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.stage'+'.tv2.dk';
+ var testprompturl = git_sitename+(tv2_branch?'.'+tv2_branch:'')+'.?'+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.test'+'.tv2.dk';
+ var testurl = git_sitename+(tv2_branch?'.'+tv2_branch:'')+'.'+initials+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.test'+'.tv2.dk';
+ var snapshoturl = git_sitename+(tv2_branch?'.'+tv2_branch:'')+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.snapshot'+'.tv2.dk';
+ var stageurl = git_sitename+(tv2_branch?'.'+tv2_branch:'')+(tv2_sitetype?'.'+tv2_sitetype:'')+'.'+tv2_apptype+'.stage'+'.tv2.dk';
// Add the two urls we are not at
if (!tv2_testsite) { // always add swaps to stage, snapshot and the test site
links.push(new this.TV2LinkSplit());
// Add link to .opdatering, .template, .robot
- var _prefix = (tv2_testsite ? git_sitename : live_sitename) + (tv2_user ? '.' + tv2_user : '');
+ var _prefix = (tv2_testsite ? git_sitename : live_sitename) + (tv2_branch?'.'+tv2_branch:'') + (tv2_user ? '.' + tv2_user : '');
var _postfix = (tv2_testsite ? '.'+tv2_apptype+'.'+tv2_testsite : '') + '.tv2.dk';
var opdatering = _prefix + '.opdatering' + _postfix;
//var template = _prefix + '.template' + _postfix;