
/*---
/js/bs/blocks.js
---*/
BS.Blocks=function(){this._blocks={};};BS.Blocks._saved={};Object.extend(BS.Blocks.prototype,{blocksType:"",collapsedByDefault:true,getBlockContentElement:function(id){},onHideBlock:function(contentElement,id){},onShowBlock:function(contentElement,id){},toggleBlock:function(el,now){this._realToggle(el,now);this._saveState();},restoreSavedBlocks:function(){var blocks=BS.Blocks._saved[this.blocksType];if(!blocks)return;var savedArray=blocks.split(":");for(var i=0;i<savedArray.length;i++){if(savedArray[i]&&savedArray[i]!='null'){this.changeState(savedArray[i],true,this.collapsedByDefault);}}},_saveState:function(){var saved="";for(var i in this._blocks){saved+=i+":";}
BS.ajaxRequest(base_uri+"/ajax.html",{parameters:"blocksType="+this.blocksType+"&state="+saved});},_realToggle:function(id,now){var contentElement=this.getBlockContentElement(id);if(!contentElement)return;BS.blockRefreshTempopary();if(BS.Util.visible(contentElement)){this.changeState(id,now,false);}
else{this.changeState(id,now,true);}
contentElement=null;},isExpanded:function(id){var contentElement=this.getBlockContentElement(id);if(!contentElement)return false;return BS.Util.visible(contentElement);},changeState:function(id,now,showBlock){var contentElement=this.getBlockContentElement(id);if(!contentElement)return;if(showBlock){BS.Util.show(contentElement);if(this.collapsedByDefault){this._blocks[id]=true;}
else{delete this._blocks[id];}
this.onShowBlock(contentElement,id);}else{BS.Util.hide(contentElement);if(this.collapsedByDefault){delete this._blocks[id];}
else{this._blocks[id]=true;}
this.onHideBlock(contentElement,id);}
contentElement=null;}});
/*---
/js/bs/blockWithHandle.js
---*/
BS.BlockWithHandle=Class.create();Object.extend(BS.BlockWithHandle.prototype,BS.Blocks.prototype);Object.extend(BS.BlockWithHandle.prototype,{collapsedByDefault:false,getId:function(){return this.blockId;},initialize:function(blockTypeId,blockId){BS.Blocks.call(this);this.blocksType=blockTypeId+blockId;this.blockId=blockId;if(!this.getHandle())return;BS.Event.observe(this.getHandle(),"click",this.toggle.bindAsEventListener(this));this.changeState(this.blockId,true,!this.collapsedByDefault);this.restoreSavedBlocks();},getHandle:function(){return $('blockHandle'+this.blockId);},toggle:function(){var contentElement=this.getBlockContentElement(this.blockId);if(!contentElement)return;BS.blockRefreshTempopary();if(this.getHandle().src.indexOf("img/"+this.plusGif())<0){this.changeState(this.blockId,true,false);}
else{this.changeState(this.blockId,true,true);}
contentElement=null;this._saveState();},onHideBlock:function(contentElement,id){this.getHandle().src="img/"+this.plusGif();},onShowBlock:function(contentElement,id){this.getHandle().src="img/"+this.minusGif();},plusGif:function(){return"plus.gif";},minusGif:function(){return"minus.gif";},getBlockContentElement:function(id){return $("btb"+id);}});BS.ProjectBlock=Class.create();Object.extend(BS.ProjectBlock.prototype,BS.BlockWithHandle.prototype);Object.extend(BS.ProjectBlock.prototype,{initialize:function(blockTypeId,blockId){BS.BlockWithHandle.prototype.initialize.call(this,blockTypeId,blockId);},onShowBlock:function(contentElement,id){BS.BlockWithHandle.prototype.onShowBlock.call(this,contentElement,id);BS.Util.hide('buildAge'+this.blockId);BS.Util.hide('runningStatusTextId'+this.blockId);BS.Util.hide('runningStatusIcon'+this.blockId);},onHideBlock:function(contentElement,id){BS.BlockWithHandle.prototype.onHideBlock.call(this,contentElement,id);BS.Util.show('buildAge'+this.blockId);BS.Util.show('runningStatusTextId'+this.blockId);BS.Util.show('runningStatusIcon'+this.blockId);}});BS.OverviewBlock=Class.create();Object.extend(BS.OverviewBlock.prototype,BS.BlockWithHandle.prototype);Object.extend(BS.OverviewBlock.prototype,{minusGif:function(){return"arrowExpanded.png";},plusGif:function(){return"arrowCollapsed.png";},initialize:function(blockTypeId,blockId){BS.BlockWithHandle.prototype.initialize.call(this,blockTypeId,blockId);},onShowBlock:function(contentElement,id){BS.BlockWithHandle.prototype.onShowBlock.call(this,contentElement,id);BS.Util.hide(this.getStatusElem(id));},onHideBlock:function(contentElement,id){BS.BlockWithHandle.prototype.onHideBlock.call(this,contentElement,id);BS.Util.show(this.getStatusElem(id));},getStatusElem:function(id){return's_'+id;}});
/*---
/js/bs/forms.js
---*/
BS.AbstractWebForm={formElement:function(){return document.forms[0];},disable:function(elementsFilter){if(this._formDisabled)return;var disabledElems=BS.Util.disableFormTemp(this.formElement(),elementsFilter);this._formDisabled=true;return disabledElems;},enable:function(elementsFilter){if(this._formDisabled){BS.Util.reenableForm(this.formElement(),elementsFilter);}
var modifiedMessageForm=this._modifiedMessageForm();if(modifiedMessageForm){BS.Util.reenableForm(modifiedMessageForm);}
this._formDisabled=false;},savingIndicator:function(){return $('saving');},setSaving:function(saving){var savingElem=this.savingIndicator();if(savingElem){if(saving){BS.Util.show(savingElem);}else{BS.Util.hide(savingElem);}}},clearErrors:function(){if($("errorMessage")){$("errorMessage").innerHTML='&nbsp;';BS.Util.hide($("errorMessage"));}
var errorFields=$A(document.getElementsByClassName("errorField"));if(errorFields!=null){for(var i=0;i<errorFields.length;i++){var errorField=errorFields[i];if(errorField==null)continue;errorField.className=errorField.className.replace("errorField","");}}
var errorMessages=$A(document.getElementsByClassName("error"));if(errorMessages!=null){for(var i=0;i<errorMessages.length;i++){var msg=errorMessages[i];if(msg==null)continue;this.clearTextInsideElement(msg);}}
BS.VisibilityHandlers.updateVisibility(this.formElement());},trimSpacesInTextFields:function(){var inputs=Form.getInputs(this.formElement(),"text");for(var i=0;i<inputs.length;i++){inputs[i].value=BS.Util.trimSpaces(inputs[i].value);}},serializeParameters:function(){return BS.Util.serializeForm(this.formElement())},_modifiedMessageForm:function(){return $("modifiedMessageForm");},setModified:function(modified){if(modified){BS.Util.show($("modifiedMessage"));this.hideSuccessMessages();var modifiedMessageForm=this._modifiedMessageForm();if(modifiedMessageForm){if(this._modifiedHandlers&&this._modifiedHandlers.saveState){modifiedMessageForm.style.display='inline';}else{BS.Util.hide(modifiedMessageForm);}}}else{BS.Util.hide($("modifiedMessage"));}
this.modified=modified;},hideSuccessMessages:function(){BS.Util.hideSuccessMessages();},clearTextInsideElement:function(elem){if(!elem||!elem.firstChild)return;elem.normalize();if(!elem.firstChild||!elem.firstChild.nodeType==3)return;elem.firstChild.nodeValue='';},highlightErrorField:function(field){field.className=field.className+" errorField";if(BS.MultilineProperties){BS.MultilineProperties.updateVisible();}},focusFirstErrorField:function(){var errorFields=$A(document.getElementsByClassName("errorField"));if(errorFields&&errorFields.length>0){for(var i=0;i<errorFields[i];i++){var f=errorFields[i];if(f==null)continue;if(BS.Util.visible(f)){f.focus();}
break;}}},_clearIdleHandler:function(){if(!this._idleHandlerInfo)return;Event.stopObserving(this._idleHandlerInfo._object,'keyup',this._idleHandler,false);Event.stopObserving(this._idleHandlerInfo._object,'click',this._idleHandler,false);this._idleHandlerInfo=null;this._idleHandler=null;},_setupIdleHandler:function(handler,delay){this._clearIdleHandler();if(delay==undefined)delay=1000;var that=this;this._idleHandlerInfo={_delay:delay,_object:that.formElement(),_func:handler};this._idleHandler=function(){if(that._idleHandlerInfo._timeout){clearTimeout(that._idleHandlerInfo._timeout);}
var func=that._idleHandlerInfo._func;var arg=that._idleHandlerInfo._object;that._idleHandlerInfo._timeout=setTimeout(function(event){func()},delay);}.bindAsEventListener(this);Event.observe(this.formElement(),'keyup',this._idleHandler,false);Event.observe(this.formElement(),'click',this._idleHandler,false);},_setupExitHandler:function(){var isSafari=navigator.userAgent.toLowerCase().indexOf("safari")!=-1;if(!isSafari){this._exitHandler=function(event){if(this.modified){if(!this._shouldCheckForExit(event)){return;}
if(!confirm("Discard your changes?")){Event.stop(event);}}}.bindAsEventListener(this);Event.observe(document.body,"click",this._exitHandler,false);}},_shouldCheckForExit:function(event){var element=Event.element(event);if("true"==element.getAttribute("showdiscardchangesmessage")){return true;}
if(element.tagName!="A"){element=Event.findElement(event,"A");}
if(!element||element.nodeType!=1){return false;}
if("false"==element.getAttribute("showdiscardchangesmessage")){return false;}
return element&&element.href;},setUpdateStateHandlers:function(handlers){this._modifiedHandlers=handlers;this._setupIdleHandler(handlers.updateState);if(handlers.saveState){var form=this._modifiedMessageForm();if(form&&form.save){var origFunc=handlers.saveState;var that=this;this._modifiedHandlers.saveState=function(){BS.Util.disableFormTemp(that._modifiedMessageForm());origFunc();}
Event.observe(form.save,"click",this._modifiedHandlers.saveState,false);}}
this._setupExitHandler();},checkStateModified:function(){if(this._idleHanlder){this._idleHanlder();}},removeUpdateStateHandlers:function(){this._clearIdleHandler();if(this._modifiedHandlers&&this._modifiedHandlers.saveState){var form=this._modifiedMessageForm();if(form&&form.save){Event.stopObserving(form.save,"click",this._modifiedHandlers.saveState,false);}}
if(this._exitHandler!=null){Event.stopObserving(document.body,"click",this._exitHandler,false);}
this._modifiedHandlers=null;this._exitHandler=null;}}
BS.SimpleListener={onBeginSave:function(form){},onCompleteSave:function(form,responseXML,err,responseText){},onException:function(form,e){BS.Util.processError(e);},onFailure:function(form){alert("Error accessing server");}}
BS.ErrorsAwareListener=OO.extend(BS.SimpleListener,{onBeginSave:function(form){form.trimSpacesInTextFields();form.clearErrors();form.hideSuccessMessages();form.disable();form.setSaving(true);},onCompleteSave:function(form,responseXML,err){form.setSaving(false);if(err){form.enable();form.focusFirstErrorField();}else{this.onSuccessfulSave();}},onSuccessfulSave:function(){}});BS.StoreInSessionListener=OO.extend(BS.SimpleListener,{onCompleteSave:function(form,responseXML,errStatus){if(!errStatus){BS.XMLResponse.processModified(form,responseXML);}},onException:function(form,e){},onFailure:function(form){}});BS.AbstractPasswordForm=OO.extend(BS.AbstractWebForm,{publicKey:function(){return $F("publicKey");},serializeParameters:function(){var params=BS.AbstractWebForm.serializeParameters.bind(this)();var passwordFields=Form.getInputs(this.formElement(),"password");if(!passwordFields)return params;for(var i=0;i<passwordFields.length;i++){var name=passwordFields[i].name;var encryptedName="encrypted"+name.charAt(0).toUpperCase()+name.substring(1);params+="&"+encryptedName+"=";if(passwordFields[i].value.length==0)continue;var encryptedValue="";if(passwordFields[i].getEncryptedPassword!=null){encryptedValue=passwordFields[i].getEncryptedPassword(this.publicKey());}else{encryptedValue=BS.Encrypt.encryptData(passwordFields[i].value,this.publicKey());}
params+=encryptedValue;}
return params;}});BS.FormSaver={save:function(form,submitUrl,listener,debug){try{listener.onBeginSave(form);var params=form.serializeParameters();if(debug){alert(params);}
BS.ajaxRequest(submitUrl,{method:"post",parameters:params,onComplete:function(transport){if(debug){alert(transport.responseText);}
if(!transport.responseXML){listener.onCompleteSave(form,null,null,transport.responseText);}else{var responseXML=transport.responseXML;var err=BS.XMLResponse.processErrors(responseXML,listener);listener.onCompleteSave(form,responseXML,err,transport.responseText);}},onFailure:function(){listener.onFailure(form);},onException:function(obj,e){listener.onException(form,e);}});}
catch(e){listener.onException(form,e);}}}
BS.PasswordFormSaver=OO.extend(BS.FormSaver,{save:function(form,submitUrl,listener,debug){var that=this;if(!listener.onPublicKeyExpiredError){listener.onPublicKeyExpiredError=function(elem){$("publicKey").value=elem.firstChild.nodeValue;setTimeout(function(){that.save(form,submitUrl,listener,debug);},100);}}
BS.FormSaver.save(form,submitUrl,listener,debug);}})
/*---
/js/bs/runningBuilds.js
---*/
BS.RunningBuilds={startUpdates:function(processorCallback){new BS.PeriodicalUpdater(null,base_uri+"/ajax.html?getRunningBuilds=1",{frequency:6,evalScripts:false,onSuccess:function(transport){var root=BS.Util.documentRoot(transport);if(!root)return;var buildNodes=root.childNodes;var buildTypes2Running={};for(var i=0;i<buildNodes.length;i++){var node=buildNodes[i];var buildId=node.getAttribute("buildId");var buildTypeId=node.getAttribute("buildTypeId");if(!buildTypes2Running[buildTypeId]){buildTypes2Running[buildTypeId]=[];}
buildTypes2Running[buildTypeId].push(buildId);BS.RunningBuilds.processNode(node,buildId);}
if(processorCallback){processorCallback(buildTypes2Running);}}});},processNode:function(node,buildId){this.updateIcon(node,buildId);this.updateText(node,buildId);var elapsedTime=node.getAttribute("elapsedTime");var durationNode=$('build:'+buildId+":duration");if(durationNode){durationNode.innerHTML=elapsedTime;}
this.updateProgressNode(node,buildId,elapsedTime);this.updateArtifactsLink(node,buildId);},findNestedDiv:function(element){for(var i=0;i<element.childNodes.length;i++){var node=element.childNodes[i];if(node.nodeType==1&&node.tagName=="DIV"){return node;}}},updateIcon:function(node,buildId){var icon=$('build:'+buildId+":img");this.updateIconElement(node,icon);},updateIconElement:function(node,icon){if(icon){var successful="true"==node.getAttribute("successful");var personal=node.getAttribute("personal");var newSrc=base_uri+"/img/buildStates/"+
(personal?(successful?"personalRunning_green.gif":"personalRunning_red.gif"):(successful?"running_green_transparent.gif":"running_red_transparent.gif"));if(icon.src!=newSrc){icon.src=newSrc;}}},updateText:function(node,buildId){var txtNode=$('build:'+buildId+":text");this.updateTextElement(node,txtNode);},updateTextElement:function(node,txtNode){if(txtNode){txtNode.innerHTML=node.getAttribute("text").replace(/\./g,".<wbr>");}},updateProgressNode:function(node,buildId,elapsedTime){var progressNode=$('build:'+buildId+":progress");if(progressNode){var title="started: "+progressNode.nextSibling.innerHTML+"<br>"+elapsedTime+" passed";var nestedDiv=this.findNestedDiv(progressNode);if(nestedDiv){if('N/A'==node.getAttribute("remainingTime")){nestedDiv.style.width="100%";}
else{var remainingTime=node.getAttribute("remainingTime");if(remainingTime&&remainingTime!="< 1s"){title+="; "+remainingTime+" left";nestedDiv=this.setTextInProgress(progressNode,remainingTime+" left");}
var exceededDurationTime=node.getAttribute("exceededEstimatedDurationTime");if(exceededDurationTime&&exceededDurationTime!="< 1s"){title+="<br>"+exceededDurationTime+" overtime";nestedDiv=this.setTextInProgress(progressNode,"overtime: "+exceededDurationTime);}
var successful="true"==node.getAttribute("successful");nestedDiv.style.backgroundColor=successful?"green":"#c90a00";nestedDiv.style.width=node.getAttribute("completedPercent")+"%";}}
if($('aName:'+buildId)&&$('aName:'+buildId).innerHTML!=''){title+="<br>agent: "+$('aName:'+buildId).innerHTML;}
var progressId=progressNode.id;progressNode._title=title;if(!progressNode._eventsBound){BS.Event.observe(progressNode,"mouseover",function(){BS.Tooltip.showMessage($(progressId),{shift:{x:10,y:20}},$(progressId)._title);});BS.Event.observe(progressNode,"mouseout",BS.Tooltip.hidePopup);progressNode._eventsBound=true;}}},setTextInProgress:function(progressNode,text){var t="&nbsp;&nbsp;"+text.replace(/ /g,"&nbsp;");progressNode.innerHTML=t+"<div>"+t+"</div>"
return this.findNestedDiv(progressNode);},updateArtifactsLink:function(node,buildId){var hasArtifacts=node.getAttribute('hasArtifacts')=='true';if(hasArtifacts){var artifactsLink=$('build:'+buildId+':artifactsLink');var noArtifactsText=$('build:'+buildId+':noArtifactsText');if(artifactsLink&&noArtifactsText){artifactsLink.style.display='inline';noArtifactsText.style.display='none';}}}};
/*---
/js/bs/stopBuild.js
---*/
if(BS.AbstractModalDialog&&BS.AbstractWebForm){BS.StopBuildDialog=OO.extend(BS.AbstractWebForm,OO.extend(BS.AbstractModalDialog,{formElement:function(){return $('stopBuildForm');},getContainer:function(){return $('stopBuildFormDialog');},showStopBuildDialog:function(promoIds,defaultMessage,buildIsInQueue){if(promoIds.length==0){alert("Please select at least one build.");return;}
this.enable();this.formElement().kill.value=promoIds.join(',');var builds=promoIds.length>1?promoIds.length+' builds':'build';$('stopBuildFormTitle').innerHTML=buildIsInQueue?'Remove '+builds+' from the queue':'Stop running build';this.formElement().submit.value=buildIsInQueue?'Remove':'Stop';$('moreToStopFragment').innerHTML='';$('moreToStop').style.display='none';if(promoIds.length==1){$('moreToStop').style.display='block';$('moreToStopLoader').style.display='inline';this.disable();BS.ajaxUpdater('moreToStopFragment',base_uri+"/promotionGraph.html",{parameters:"buildPromotionId="+new String(promoIds[0])+"&jsp=moreToStop.jsp",onComplete:function(){$('moreToStop').style.display='none';BS.StopBuildDialog.enable();}});}
this.formElement().comment.value=defaultMessage!=null&&defaultMessage.length>0?defaultMessage:this.formElement().comment.defaultValue;this.showCentered();$(this.formElement().comment).activate();this.bindCtrlEnterHandler(this.killBuild.bind(this));this.setSaving(false);},killBuild:function(buildPromotionId){if(buildPromotionId){this.formElement().kill.value=buildPromotionId;}
if(this.formElement().comment.value==this.formElement().comment.defaultValue){this.formElement().comment.value="";}
if(this.isVisible()){this.setSaving(true);this.disable();}
var that=this;BS.ajaxRequest(this.formElement().action,{parameters:this.serializeParameters(),onSuccess:function(transport){if(that.isVisible()){that.setSaving(false);that.enable();that.close();}
var doc=BS.Util.documentRoot(transport);var stopped=doc.getElementsByTagName("stoppedBuild");if(stopped){for(var i=0;i<stopped.length;i++){var promoId=stopped[i].firstChild.nodeValue;that.setStopping(promoId);}}
var unqueued=doc.getElementsByTagName("unqueuedBuild");if(unqueued&&BS.Queue){for(var i=0;i<unqueued.length;i++){var itemId=unqueued[i].firstChild.nodeValue;BS.Queue.removeBuildTypeRow(itemId);}}}});this.close();if(BS.QueuedBuildsPopup&&BS.QueuedBuildsPopup.isShowing()){BS.QueuedBuildsPopup.hidePopup();}
return false;},setStopping:function(buildPromotionId){if($('stopBuild:'+buildPromotionId)){$('stopBuild:'+buildPromotionId).innerHTML='<span class="stopping">Stopping</span>';}
setTimeout(function(){if($('stopBuild:'+buildPromotionId)){$('stopBuild:'+buildPromotionId).innerHTML='<span class="stopping" title="TeamCity cannot stop this build. Please log in to the build agent and resolve the situation manually.">Cannot stop</span>';}},5*60*1000)}}));}
/*---
/js/bs/systemProblemsMonitor.js
---*/
BS.SystemProblems={_lastFailures:{},startUpdates:function(){var that=this;new BS.PeriodicalUpdater(null,base_uri+"/ajax.html?getSystemProblems=true",{frequency:30,evalScripts:false,onSuccess:function(transport){var root=BS.Util.documentRoot(transport);if(!root)return;var buildNodes=root.childNodes;var currentFailures={};for(var i=0;i<buildNodes.length;i++){var node=buildNodes[i];var buildTypeId=node.getAttribute("id");currentFailures[buildTypeId]=true;}
for(var id in that._lastFailures){if(currentFailures[id]==null){var systemProblemsDiv=$('buildType:'+id+":systemProblems");if(systemProblemsDiv){BS.Util.hide(systemProblemsDiv);}}}
that._lastFailures=currentFailures;for(id in that._lastFailures){if(currentFailures[id]!=null){systemProblemsDiv=$('buildType:'+id+":systemProblems");if(systemProblemsDiv){BS.Util.show(systemProblemsDiv);}}}}});}}
BS.SystemProblemsPopup=new BS.Popup("systemProblemDetails",{url:base_uri+"/systemProblems.html",method:"get",delay:0,hideDelay:-1})
BS.SystemProblemsPopup.showDetails=function(buildTypeId,problemType,problemSource,showHead,nearestElement){var params="buildTypeId="+buildTypeId;if(problemType!=null&&problemType!='')
params+="&problemType="+encodeURIComponent(problemType);if(problemSource!=null&&problemSource!='')
params+="&problemSource="+encodeURIComponent(problemSource);params+="&showHead="+showHead;this.options.parameters=params;this.showPopupNearElement(nearestElement);}
/*---
/js/bs/collapseExpand.js
---*/
BS.CollapsableBlocks={_allBlocks:{},registerBlock:function(block){var id=block.getId();if(this._allBlocks[id])return;this._allBlocks[id]=block;},collapseAll:function(saveState){for(var id in this._allBlocks){this._allBlocks[id].changeState(id,true,false);if(saveState){this._allBlocks[id]._saveState();}}},expandAll:function(saveState){for(var id in this._allBlocks){this._allBlocks[id].changeState(id,true,true);if(saveState){this._allBlocks[id]._saveState();}}},expandBlock:function(id,saveState){if(!this._allBlocks[id])return;this._allBlocks[id].changeState(id,true,true);if(saveState){this._allBlocks[id]._saveState();}}};
/*---
/js/bs/visibleProjects.js
---*/
BS.AbstractVisibleDialog=OO.extend(BS.AbstractModalDialog,{alwaysReload:false,show:function(){this.changed=false;var that=this;BS.ajaxUpdater(this.getDialogContainer(),this.getRequestUrl(),{method:'get',evalScripts:true,onComplete:function(){that.showCentered();that.updateButtons();}});},save:function(){if(!this.canSave()){return false;}
BS.Util.show(this.getLoadingElemId());var form=this.getFormElement();Form.disable(form);this.getObjectsOrder().value=this.getVisibleProjectsOrder();var options=this.getVisibleObjects().options;for(var i=0;i<options.length;i++){options[i].selected=true;}
var params=BS.Util.serializeForm(form);var that=this;BS.ajaxRequest(form.action,{parameters:params,onComplete:function(){Form.enable(form);BS.Util.hide(that.getLoadingElemId());that.close();if(that.alwaysReload||that.changed){BS.reload(true);}}});return false;},canSave:function(){return true;},getVisibleProjectsOrder:function(){var order="";var options=this.getVisibleObjects().options;for(var i=0;i<options.length;i++){if(order.length>0){order+=",";}
order+=options[i].getAttribute("value");}
return order;},moveToVisible:function(){this.doMoveSelectedTo(this.getHiddenObjects(),this.getVisibleObjects(),false);},moveToHidden:function(){var filterField=this.getHiddenObjectsFilter();var from=this.getVisibleObjects();var to=this.getHiddenObjects();if(filterField.value==filterField.defaultValue||filterField.value==""){this.doMoveSelectedTo(from,to,true);}else{filterField.value="";BS.InPlaceFilter.apply(this.getHiddenObjectsId(),filterField,function(){this.doMoveSelectedTo(from,to,true);filterField.value=filterField.defaultValue;});}},moveUp:function(){this.moveSelected(this.getVisibleObjects(),-1);},moveDown:function(){this.moveSelected(this.getVisibleObjects(),1);},doMoveSelectedTo:function(from,to,sort){this.changed=true;for(var k=0;k<to.options.length;k++){to.options[k].selected=false;}
var options=from.options;var toRemove=[];for(var i=0;i<options.length;i++){var option=options[i];if(option.selected){var copy=this.createCopy(option);if(sort){this.insertToSorted(copy,to);}else{to.appendChild(copy);}
toRemove.push(option);}}
for(var j=0;j<toRemove.length;j++){from.removeChild(toRemove[j]);}
this.updateButtons();to.activate();},insertToSorted:function(option,select){option.className="inplaceFiltered";var options=select.options;for(var i=0;i<options.length;i++){if(option.innerHTML.toLowerCase()<options[i].innerHTML.toLowerCase()){select.insertBefore(option,options[i]);return;}}
select.appendChild(option);},createCopy:function(option){var newOption=document.createElement("option");newOption.value=option.value;newOption.innerHTML=option.innerHTML;newOption.selected=option.selected;return newOption;},moveSelected:function(select,dir){var options=select.options;var i=dir==1?options.length-1:0;var canMove=false;for(var k=0;k<options.length;k++){var option1=options[i];if(option1.selected){if(canMove){var option2=options[i+dir];var copy1=this.createCopy(option1);var copy2=this.createCopy(option2);select.replaceChild(copy2,option1);select.replaceChild(copy1,option2);this.changed=true;}}else{canMove=true;}
i-=dir;}
this.updateButtons();},updateButtons:function(){this.getMoveToVisible().disabled=!this.hasSelection(this.getHiddenObjects());var visibleSelected=this.hasSelection(this.getVisibleObjects());this.getMoveToHidden().disabled=!visibleSelected;this.getMoveVisibleUp().disabled=!visibleSelected;this.getMoveVisibleDown().disabled=!visibleSelected;},hasSelection:function(select){var options=select.options;for(var i=0;i<options.length;i++){if(options[i].selected){return true;}}
return false;},getContainer:function(){return $(this.getPrefix()+'visibleFormDialog');},getFormElement:function(){return $(this.getPrefix()+'visibleForm');},getDialogContainer:function(){return $(this.getPrefix()+'visibleDialogContainer');},getVisibleObjects:function(){return $(this.getPrefix()+'visible');},getHiddenObjectsId:function(){return this.getPrefix()+'hidden';},getHiddenObjects:function(){return $(this.getHiddenObjectsId());},getHiddenObjectsFilter:function(){return this.getHiddenObjectsId()+'_filter';},getObjectsOrder:function(){return $(this.getPrefix()+'order');},getLoadingElemId:function(){return this.getPrefix()+'savingVisible';},getMoveToVisible:function(){return $(this.getPrefix()+'moveToVisible');},getMoveToHidden:function(){return $(this.getPrefix()+'moveToHidden');},getMoveVisibleUp:function(){return $(this.getPrefix()+'moveVisibleUp');},getMoveVisibleDown:function(){return $(this.getPrefix()+'moveVisibleDown');},getPrefix:function(){},getRequestUrl:function(){}});BS.VisibleProjectsDialog=OO.extend(BS.AbstractVisibleDialog,{getPrefix:function(){return"projects_";},getRequestUrl:function(){return base_uri+'/visibleProjects.html?init=1';}});BS.VisibleBuildTypesDialog=OO.extend(BS.AbstractVisibleDialog,{projectId:'',showForProject:function(projectId){this.projectId=projectId;this.show();},getPrefix:function(){return"bt_";},getRequestUrl:function(){return base_uri+'/visibleBuildTypes.html?projectId='+this.projectId;},canSave:function(){var s=this.getVisibleProjectsOrder();var result=s&&(s.length>0);if(!result){alert("Hiding all build configurations is not allowed");}
return result;}});
/*---
/js/bs/queueLikeSorter.js
---*/
BS.QueueLikeSorter={containerId:null,getActionUrl:function(node){},afterOrderSaving:function(){},_timoutHandle:null,scheduleUpdate:function(node){this.updateMoveTopIcons();if(this._timoutHandle){clearTimeout(this._timoutHandle);}
this._timoutHandle=setTimeout(this.saveOrder.bind(this,node.id),1000);},updateMoveTopIcons:function(){var queue=$(this.containerId);var moveTopIcons=document.getElementsByClassName("moveTopIcon",queue);if(!moveTopIcons)return;for(var i=0;i<moveTopIcons.length;i++){if(moveTopIcons[i]==null)continue;if(!moveTopIcons[i]._oldSrc){moveTopIcons[i]._oldSrc=moveTopIcons[i].src;}
if(i==0){BS.Event.stopObserving(moveTopIcons[i]);moveTopIcons[i].style.visibility='hidden';}else{moveTopIcons[i].src=moveTopIcons[i]._oldSrc;moveTopIcons[i].style.visibility='';BS.Event.observe(moveTopIcons[i],"mouseover",function(){this._oldSrc=this.src;this.src=base_uri+'/img/dragAndDrop/moveTopActive.gif';}.bind(moveTopIcons[i]));BS.Event.observe(moveTopIcons[i],"mouseout",function(){this.src=this._oldSrc;}.bind(moveTopIcons[i]));}}},saveOrder:function(nodeId){var node=$(nodeId);if(!node)return;this.setOrderSaving(true);var that=this;BS.ajaxRequest(this.getActionUrl(node),{onComplete:function(transport,object){that.setOrderSaving(false);that.afterOrderSaving();}});},setOrderSaving:function(saving){if(saving){BS.Util.hide("dataSaved");BS.Util.show('savingData');}else{window.setTimeout(function(){BS.Util.hide('savingData');BS.Util.show("dataSaved");window.setTimeout(function(){BS.Util.hide("dataSaved");},3000);},1000);}},moveToTop:function(node){var elem=$(node);var parent=elem.parentNode;if(parent.firstChild.id==elem.id)return;parent.removeChild(elem);parent.insertBefore(elem,parent.firstChild);elem.className=elem.className.replace(/draggableHover/,'');this.scheduleUpdate(parent);},computeOrder:function(node,prefix){if(node.childNodes&&node.childNodes.length>0){Element.cleanWhitespace(node);var children=node.childNodes;var order="";for(var i=0;i<children.length;i++){var id=children[i].id;if(id.indexOf(prefix)!=0)continue;order+=children[i].id.substring(prefix.length)+";";}
return order;}
return"";}}
/*---
/js/bs/buildQueue.js
---*/
if(!BS.Queue){BS.Queue=OO.extend(BS.QueueLikeSorter,{containerId:'queueTableRows',getActionUrl:function(node){return"queue.html?queueOrder="+this.computeOrder(node,"queue_");},afterOrderSaving:function(){$('buildQueueContainer').refresh();}});}
BS.Queue=OO.extend(BS.AbstractWebForm,OO.extend(BS.AbstractModalDialog,Object.extend(BS.Queue,{getContainer:function(){return $('removeFromQueueDialog');},formElement:function(){return $('removeFromQueue');},showRemoveDialog:function(buildTypeId){this.formElement().removeFromQueue.value=buildTypeId;this.formElement().comment.value=this.formElement().comment.defaultValue;this.showCentered();this.formElement().comment.focus();this.formElement().comment.select();this.bindCtrlEnterHandler(this.removeFromQueue.bind(this));},removeFromQueue:function(buildTypeId){if(buildTypeId){this.formElement().removeFromQueue.value=buildTypeId;}
if(this.formElement().comment.value==this.formElement().comment.defaultValue){this.formElement().comment.value="";}
if(this.isVisible()){this.setOrderSaving(true);this.disable();}
var that=this;BS.ajaxRequest(this.formElement().action,{parameters:this.serializeParameters(),onComplete:function(transport){if(that.isVisible()){that.setOrderSaving(false);that.enable();that.close();}
that.removeBuildTypeRow(that.formElement().removeFromQueue.value);if(BS.QueuedBuildsPopup&&BS.QueuedBuildsPopup.isShowing()){BS.QueuedBuildsPopup.hidePopup();}}});return false;},removeBuildTypeRow:function(buildTypeId){var rowId="queue_"+buildTypeId;if(!$(rowId))return;var parent=$(rowId).parentNode;parent.removeChild($(rowId));if(parent.getElementsByTagName("div").length==0){var container=$('queueTable').parentNode;container.removeChild($('queueTable'));container.innerHTML='<p>Build queue is empty.</p>';}
this.updateMoveTopIcons();BS.Queue.refreshEstimates();},refreshEstimates:function(){BS.Queue.requestNewQueueEstimates();},updateQueueEstimatesFromData:function(){for(var key in BS.QueueEstimates._estimates){var estimate=BS.QueueEstimates._estimates[key];var element=$('estimate'+key+":text");if(element){element.innerHTML=estimate!=null?estimate.getEstimate():'N/A';}}},requestNewQueueEstimates:function(){BS.ajaxRequest("queue.html?estimatesRequest=1",{onSuccess:function(transport,object){transport.responseText.evalScripts();BS.Queue.updateQueueEstimatesFromData();},method:"get"});},_updateTimer:null,initEstimatesAutoupdate:function(){var refreshRate=10;BS.Queue._updateTimer=setInterval(function(){BS.Queue.requestNewQueueEstimates();},refreshRate*1000);}})));