//this is a .html file instead of a .js so that FBT will serve the page with substr for all SUBS var onLoadDefaultsDone = false; var iOS = /^(iPhone|iPad|iPod)/.test(navigator.platform); if(typeof(mmUrlAddNoContext)=="undefined")mmUrlAddNoContext=""; if(typeof(mmContext)=="undefined")mmContext=""; if(typeof(mmRand)=="undefined")mmRand=""; if (!String.prototype.trim) { // no trim() prior to IE9 String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');}; } // older browsers (IE8) do not have this function // also added com/other/ddr-ecma5-1.2.1-min.js with more similar functions (if needed) if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(obj, start) { for (var i = (start || 0), j = this.length; i < j; i++) { if (this[i] === obj) { return i; } } return -1; } } var FIT_TINY = ""; var FIT_CK = ""; function checkValidRtfContent(text) { var lines = text.split("\n"); for (i=0; i<lines.length; i++) { if ((lines[i]!=FIT_TINY) && (lines[i]!=FIT_CK) && (lines[i]!="<p> </p>" )) { return true; } } return false; } function checkRtfMandatory(name) { if (typeof tinyMCE !== 'undefined') { var inst = tinyMCE.get(name); if (inst) { return checkValidRtfContent(inst.getContent()); } } return true; } function contains(a, obj) { var i = a.length; while (i--) { if (a[i] === obj) { return true; } } return false; } function mandatoryCheck() { var missingLabels = ""; var myForm = getFitForm(); var firstMissingId=""; var alreadyChecked = []; for(i=0;i<myForm.elements.length;i++) { var input = myForm.elements[i]; if (input.name.length > 0 && contains(alreadyChecked,input.name)) { continue; } alreadyChecked[alreadyChecked.length] = input.name; var pos = -1; if (input) { pos = mandFields.indexOf(input.name); if (pos>-1) { var rtfBlank = false; var multipleEmpty = false; if ((input.type == 'checkbox' || input.type == 'radio') && document.getElementsByName(input.name).length > 1) { var checkboxes = document.getElementsByName(input.name) multipleEmpty = true; //alert(input.name); for (var c=0;c<checkboxes.length;c++) { if (checkboxes[c].checked) { multipleEmpty = false; break; } } } if (input.type == 'select-multiple') { var options = input.options; multipleEmpty = true; for(d=0;d<options.length;++d) { if (options[d].selected) { multipleEmpty = false; } } } else if (rtfDefaultFields.indexOf(input.name) >= 0) { var rtfActive = false; var text = ""; if (typeof(tinyMCE) != "undefined") { var rtfObj = tinyMCE.get(input.name); if (rtfObj) { // could have been turned off text = rtfObj.getContent(); rtfActive=true; } } else if (typeof(CKEDITOR) != "undefined") { if (CKEDITOR.instances[input.name]) { text = CKEDITOR.instances[input.name].getData(); rtfActive = true; } } var div = document.createElement("div"); div.innerHTML = text; text = div.textContent || div.innerText || ""; text = text.trim(); if (rtfActive && text.length == 0) { rtfBlank = true; } } if (rtfBlank || multipleEmpty || (input.options && input.selectedIndex>=0 && input.options[input.selectedIndex].text== "") || // select now allows blanks (!input.options && input.value == "") || !checkRtfMandatory(input.name) || // RTF enabled (input.selectize && input.selectize.getValue()=="") ) // combobox { if (missingLabels.length > 0) { missingLabels += ", "; } if (firstMissingId.length==0) { firstMissingId=input.name; } missingLabels += mandFieldLabels[pos]; var obj = $("#"+input.name); if (jQuery("#"+input.name+"-selectized").length) { // combobox obj = jQuery("#"+input.name+"-selectized").parent(); } else if (!obj.is(":visible")) { obj = obj.parent(); } obj.css("border", "2px red dashed"); } else { var obj = $("#"+input.name); if (jQuery("#"+input.name+"-selectized").length) { // combobox obj = jQuery("#"+input.name+"-selectized").parent(); } else if (!obj.is(":visible")) { obj = obj.parent(); } obj.css("border", "none"); } } } } if (missingLabels.length > 0) { draggableFix(); //viewport = document.querySelector("meta[name=viewport]"); //viewport.setAttribute('content', 'width=768, initial-scale=1.0, maximum-scale=1.0, xuser-scalable=0'); //viewport.setAttribute('content', 'user-scalable=0.8'); jQuery("#"+firstMissingId ).after("
: " + missingLabels + "
"); if (iOS) { jQuery(window).scrollLeft(0); jQuery(window).scrollTop(0); } jQuery( "#dialog" ).dialog({ modal: true, open: function () { //var scrollLeft = jQuery('html, body').scrollLeft(); if (iOS) { jQuery('.ui-dialog').css("left","100px"); jQuery('.ui-dialog').css("top","200px"); } }, close: function(event, ui) { // this is the line I changed for bug 4953 if (!isElementVisible(jQuery("#"+firstMissingId)[0])) { var scrollPos = jQuery("#"+firstMissingId ).offset().top - 10; // if scrolling to field, never going to need to worry about - fixedHeaderHeight if (document.body.scrollTop==0) { scrollPos -= totalHeaderHeight; } else { scrollPos -= fixedHeaderHeight; } jQuery(window).scrollTop(scrollPos); } } }); //alert(); //jQuery("#dialog").dialog('option', 'position', 'center'); return false; } return true; } function fitSubmitCheck() { try { var ret = true; if (typeof mandFields!='undefined' && mandatoryCheck()==false) { ret = false; } //stale data check if(ret && typeof (window.ajaxCheckForStaleData) == 'function') { // ModifyBug case if (ajaxCheckForStaleData()==false) { ret = false; } } // TinyMceConfig had code checking img links if(ret && typeof (window.rtfCheckLinks) == 'function') { if (rtfCheckLinks()==false) { ret = false; } } // check for dangerous text in rtf if (rtfSubmitCheck()==false) { ret = false; } if (!otherFitSubmitChecks(ret)) { ret = false; } // check for sv_iframe windows (ie: editing relationships) var obj = jQuery("#sv_iframe"); if (obj && obj.is(":visible")) { fitDialog(window.event, {html: "You have a subwindow open and might be editing a relationship above or below.\nPlease close that window before saving!"}); ret = false; } } catch (err) { console.log(err); return confirm ("There appears to be a problem with the fitSubmitCheck code:\n" + err.message + "\nPlease have someone address this. Do you wish to submit anyways? \n\n\nTraceback Details:\n"+err.stack); } try { document.getElementById("singleSubmitCheck2").value = ""+(new Date().valueOf()); } catch (err) {} return ret; } function otherFitSubmitChecks() { //this function is overridden elsewhere return true; } function getRtfLabel(rtfname) { var obj = jQuery("[name='"+rtfname+"']"); if (obj) { var labelObj = obj.closest("td").siblings().first(); var label = labelObj.text(); label = label.replace(":","").trim(); return label; } return "fieldId:"+rtfname; } function rtfSubmitCheck() { if (typeof CKEDITOR !== 'undefined') { for (var name in CKEDITOR.instances) { var instance = CKEDITOR.instances[name]; if (instance.mode!="wysiwyg") { alert("RTF editor must be in normal mode before saving for security reasons.\nCheck if you are in source mode for ["+getRtfLabel(name)+"]?"); return false; } var data = instance.getData(); if (data.indexOf("")>=0) { alert("You have a tag in the source for rtf editor ["+getRtfLabel(name)+"].\nPlease modify as this can be dangerous to other users."); return false; } // testing for Noirlab if (data.indexOf("__LanguageMenu_popup")>0) { alert("You have __LanguageMenu_popup in your ["+getRtfLabel(name)+"] RTF editor.\nPlease check the source for that field as this has caused problems before.\nIt is possible some kind of translator plugin is altering this field?"); return false; } } } return true; } // there may be an input at the top or the bottom function synchronizeSuppress(input) { var value = input.checked; var suppress = document.getElementById("suppress"); if (suppress) { suppress.checked = value; } var bottomSuppress = document.getElementById("bottomSuppress"); if (bottomSuppress) { bottomSuppress.checked = value; } } function editorWin(name){ var win = window.open(mmUrlAddNoContext+"&CONTEXT="+mmContext+"&page=com.other.Editor","blank","toolbar=no,width=500,height=300"); //alert("win:"+win); //win.edited.value='xxx'; } // expand / collapse textareas var minsize = ; var maxsize = ; function initTA(taName) { if (minsize == -1) return; var ta; ta = getFitForm()[taName]; if (ta != null) { ta.rows = minsize; ta.scrollTop=0; } } function isdefined( variable) { return (typeof(window[variable]) == "undefined") ? false: true; } function expColTA(event,taName) { if (isdefined("tinyMCE") && tinyMCE.get(taName)) { //if (tinyMCE.getInstanceById(taName)) { // tinyMCE.get(taName).execCommand('mceFullScreen'); //} fitInfo(event,""); return; } if (minsize == -1) return; var ta; ta = getFitForm()[taName]; if (ta != null) { if (ta.rows==minsize) { ta.rows = maxsize; // maximize if minimized } else if (ta.rows > minsize) { ta.rows = minsize; // if not minimized, minimize } else { resizeTA(event,ta); // otherwise, fit existing text } } } // resize TextArea to fit text function resizeTA(event,t) { if (minsize == -1) return; a = t.value.split('\n'); b = a.length; for (i=0; i<a.length; i++) { m = parseInt(a[i].length / 80) ; if (m > 0) { b+=m; } } if (b > t.rows) { t.rows = b; } } var notifyMax = 10; var notifyMin = 4; function expColNotify(collapse,specific) { if (minsize == -1) return; var form = getFitForm(); var list = eval(form.name+'.mNotifyList'+specific); var select = eval(form.name+'.notifySelect'+specific); //if (select.length<=2 && collapse==false) return; // no need to resize if (list.rows<notifyMax) { list.rows=notifyMax; select.size=notifyMax-2; } else if (collapse==true) { list.rows=notifyMin; select.size=notifyMin; } } function sortNotify(specific){ var form = getFitForm(); if(form){ var list=eval(form.name+'.mNotifyList'+specific); if(list&&list.value){ var re=new RegExp('[,\r\n]+',"g"); if(re){ var arr=list.value.split(re); arr.sort(function(x,y){ var a=String(x).toLowerCase(); var b=String(y).toLowerCase(); if(a>b)return 1; if(a<b)return -1; return 0;}); list.value=arr.join("\n"); } } } } var tagsFirst = "<SUB TAGSFIRST>"; function addNotify(specific) { var form = getFitForm(); var append = ""; var operationObj = eval(form.name+'.notifyOperation'+specific); var operation = operationObj.selectedIndex; operationObj.selectedIndex = 0; var list = eval(form.name+'.mNotifyList'+specific); var select = eval(form.name+'.notifySelect'+specific); //clear if (operation==operationObj.options.length-1) { list.value=""; return false; } //add From notifySelect for(i=0; i<select.length; i++) { if (select[i].selected == true) { if(append.length > 0 || list.value.length > 0) { append += '\n'; } var val = select[i].value; if (tagsFirst!="1") { val = select.options[i].text; } if (operation==1&&operationObj.options.length>2) { if (tagsFirst=="1") { val += "*"; } else { var index = select[i].value.lastIndexOf("["); if (index>0) { val = val.substring(0,index-1) + " *" + val.substring(index); } else { val += "*"; } } } val = val.replace(","," "); //tagsNoComma append += val; } } list.value+=append; //sortNotify(specific); return false; } var HIGHLIGHTCLASS = "highlight"; // functions for rolling over and highlighting main menu items function rollOnAll(evt,rowId) { // check for children for(var c=1; c<10; c++) { var child = document.getElementById(rowId+"-CHILD"+c); if (!child) { break; } rollOnAll(evt,rowId+"-CHILD"+c); } var index = rowId.indexOf("-RC"); if (index<0) index = rowId.indexOf("-EL"); if (index<0) index = rowId.indexOf("-SPACER"); if (index>-1) { // in case row field, then start with parent of group of tr rollOn(evt,rowId.substr(0,index)); return; } var row = document.getElementById(rowId); if (row.className.indexOf(HIGHLIGHTCLASS)>-1) { // in case highlight is never turned off for some reason return; } if ( row.className == "" ) { row.className = HIGHLIGHTCLASS; } else { row.className = HIGHLIGHTCLASS + " " + row.className; } // possible there is a spacer var spacer = document.getElementById(rowId+"-SPACER"); if (spacer) { spacer.className = HIGHLIGHTCLASS + " " + spacer.className; } // do all row fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-RC"+c); if (child == undefined) { break; } child.className = HIGHLIGHTCLASS + " " + child.className; } // do all ExtraLine fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-EL"+c); if (child == undefined) { break; } child.className = HIGHLIGHTCLASS + " " + child.className; } } function rollOffAll(rowId) { // check for children for(var c=1; c<10; c++) { var child = document.getElementById(rowId+"-CHILD"+c); if (!child) { break; } rollOffAll(rowId+"-CHILD"+c); } var index = rowId.indexOf("-RC"); if (index<0) index = rowId.indexOf("-EL"); if (index<0) index = rowId.indexOf("-SPACER"); if (index>-1) { // in case row field, then start with parent of group of tr rollOffAll(rowId.substr(0,index)); return; } var row = document.getElementById(rowId); row.className = row.className.replace(HIGHLIGHTCLASS,""); row.className = row.className.replace(/^\s+|\s+$/g,''); // possible there is a spacer var spacer = document.getElementById(rowId+"-SPACER"); if (spacer) { spacer.className = spacer.className.replace(HIGHLIGHTCLASS,""); spacer.className = spacer.className.replace(/^\s+|\s+$/g,''); } // do all row fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-RC"+c); if (child == undefined) { break; } child.className = child.className.replace(HIGHLIGHTCLASS,""); child.className = child.className.replace(/^\s+|\s+$/g,''); } // do all ExtraLine fields for (c=1;c<10;++c) { var child = document.getElementById(rowId+"-EL"+c); if (child == undefined) { break; } child.className = child.className.replace(HIGHLIGHTCLASS,""); child.className = child.className.replace(/^\s+|\s+$/g,''); } } function rollOn(evt, rowId) { var e = (window.event) ? window.event : evt; var targ; if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; } if (targ.id.indexOf("XXidCol")!=0 && targ.id.indexOf("user")!=0) { if (quickViewType!="DISABLED") { targ.style.cursor="pointer"; } } var row = document.getElementById(rowId); row.onmouseout = new Function("rollOffAll('"+rowId+"');"); rollOnAll(evt,rowId); } var LASTSV = "-1"; var SVSTARTUP; var svVisible=false; var ie = document.all?1:0; var svid="SimpleView_DIV"; var sv="-1"; var sv_html = "
"; // allow user to press escape to close calendar window/popup function sv_escape(e) { if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event) if (e.keyCode == 27) { sv_hide(e); } } function toggle_sv(e,context,rowId) { if (svVisible==true) { sv_hide(e); } else { var link = mmUrlAddNoContext+"&CONTEXT="+context+"&page=&bugId="+rowId; sv_show(e,rowId,link); } } var updateRelationship = -1; var newButtonType=""; var quickViewType = ""; function toggle_svNew(e,bugId,fieldId,otherContext,otherFieldId) { if (checkUnsavedChanges()==true) { alert(""); } var moreVars = ""; if (typeof additionalRelationshipOverride == 'function') { moreVars = additionalRelationshipOverride(fieldId,otherContext); } if (svVisible==true) { sv_hide(e); } else { updateRelationship = fieldId; if (otherFieldId>0 && moreVars.indexOf("moreVarsSTOP")<0) { var id = bugId; if (typeof mmBugId != 'undefined') { if (id<0 ) { id = mmBugId; } moreVars += "&field"+otherFieldId+"="+id; } } var link = mmUrlAddNoContext+"&CONTEXT="+otherContext+"&page=com.other.SimpleNewBug"+moreVars+"&fromNewRelButton="+otherFieldId; var title = ""; if (link.indexOf("NewBug")>=0) { // need to destinguish new what if going to another track ?? commenting out for now //title = "" ; title = ""; } options = { url: link, title: title, otherContext: otherContext, bugId: bugId } if (e.ctrlKey || newButtonType=="inline" || quickViewType=="INLINE") { fitInlineDialog(e, options); } else if (quickViewType=="DIALOG") { fitNormalDialog(e, options); } else { sv_show(e,(new Date()).getTime(),link); } // tryOtherFrames(fieldId); newButtonType=""; } } function tryOtherFrames(fieldId) { // use load to change picker //jQuery("#relPicker"+fieldId).load(link); // add iframe to picker const iframe = document.createElement('iframe'); jQuery(iframe).css("border","none"); jQuery(iframe).css("width", "100%"); iframe.src = link; jQuery("#relPicker"+fieldId).show(); jQuery("#relPicker"+fieldId).empty().append(iframe); } function searchStringFocus() { jQuery("#searchString").focus(); } function sv_startup() { if (sv != "-1") { // close the current one sv.style.visibility = "hidden"; } sv = setupSV(); sv.innerHTML=sv_html; document.body.appendChild(sv); //sv.className='templatetitle'; //sv.style.backgroundColor='#006699'; //sv.style.padding='10px'; //these should not be modified sv.style.position="absolute"; sv.style.visibility="hidden"; sv.style.width="400px"; //sv.style.height="100000px"; // make it big so there is no second scrollbar sv.style.zIndex="1000"; sv_closer_startup(); } function setOpacityOff() { var mainMenuTable = document.getElementById("mainMenuTable"); if (mainMenuTable!=undefined) { //dashboard mainMenuTable.style.opacity = 1; mainMenuTable.style.filter = ''; var menu = document.getElementById("FBT_MENU"); if (menu!=undefined) { menu.style.opacity = 1; menu.style.filter = ''; } } } function setOpacity(value) { var mainMenuTable = document.getElementById("mainMenuTable"); if (mainMenuTable!=undefined) { mainMenuTable.style.opacity = value/10; mainMenuTable.style.filter = 'alpha(opacity=' + value*10 + ')'; var menu = document.getElementById("FBT_MENU"); if (menu!=undefined) { // older styles menu.style.opacity = value/10; menu.style.display = 'inline'; menu.style.filter = 'alpha(opacity=' + value*10 + ')'; } } } function sv_hide(e,hideId) { if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event) if (!e || !e.ctrlKey) { if (parent.frames["sv_iframe"] && typeof parent.frames["sv_iframe"].contentWindow.checkUnsavedChanges === "function" && parent.frames["sv_iframe"].contentWindow.checkUnsavedChanges()==true) { //alert(""); //return false; if (confirm("")==false) { return false; } } } if (svVisible) window.scrollTo(0,sv.offsetTop-totalHeaderHeight); // back to where we started from svVisible=false; var current_sv = document.getElementById(hideId); if (!current_sv) { current_sv = sv; } current_sv.innerHTML = "
empty
"; // stop ajax updates to FIT current_sv.style.visibility = "hidden"; setOpacityOff(); extraStepsOnQuickViewClose(); return false; } var relatedTableView = 0; function setRelatedTableView() {} function extraStepsOnQuickViewClose() {} var fixedHeaderHeight = 0; var totalHeaderHeight = 0; var VIEW = 1; var EDIT = 2; var SCROLLWIDTH = 25; // so scroll is not hidden var svOffset = 200; function sv_show(e,distinct,link) { if (link.indexOf("URIEncoded=1")<=0) { link = encodeURI(link); } if(typeof (window.sv_customshow) == 'function') { sv_customshow(distinct,link); return false; } LASTSV=distinct; if (SVSTARTUP==undefined) { sv_startup(); SVSTARTUP=1; } var myWidth; var myHeight; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } setOpacity(4); var xpos=svOffset; var xOffset=ie?document.documentElement.scrollLeft:window.pageXOffset; var yOffset=ie?document.documentElement.scrollTop:window.pageYOffset; var ypos=yOffset; ypos += totalHeaderHeight; var iPADDING = 10; // padding of table around iframe var xdiff = (myWidth<800) ? 800 : myWidth-xpos-iPADDING; if (distinct=="Trial" && xdiff<1000) xdiff = 1000; if (link.substring(0,5)=="html:") { sv_html = link.substring(5); } else { sv_html = "

"; } sv.innerHTML = sv_html; sv.style.left=xpos+'px'; sv.style.top=ypos+'px'; sv.style.position="absolute"; sv.style.width=xdiff+"px"; //sv.style.height="100000px"; sv.style.visibility = "visible"; svVisible=true; document.onkeypress= new Function("event","sv_escape(event);"); return false; } function sv_minimize(e) { sv.style.height="50px"; if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event) if (e) { //if (isDrag) { var mouseX=ie?event.x:e.clientX; var mouseY=ie?event.y:e.clientY; var tx = parseInt(sv.style.left+0); var ty = parseInt(sv.style.top+0); // unknown x/y ?? // sv.style.left=tx + mouseX-x; // sv.style.top=ty + mouseY-y; //} } } function setupSV() { //created the div element for the popup var divTag = document.createElement("div"); divTag.id = svid + (new Date()).getTime(); return divTag; } var sv_closer="-1"; function sv_closer_startup() { sv_closer = setupSV(); sv_closer.innerHTML = //"

" + ""; //""; //"

"; sv_closer.id = "sv_closer"; document.body.appendChild(sv_closer); //document.onmousemove=sv_minimize; //these should not be modified sv_closer.style.position="absolute"; sv_closer.style.visibility="hidden"; sv_closer.style.zIndex="2000"; } function sv_showCloser() { if (svVisible) { var top = ie?document.documentElement.scrollTop:window.pageYOffset; if ( top < sv.offsetTop) { top = sv.offsetTop; } else { top += totalHeaderHeight; } top += ie?10:15; sv_closer.style.top = top +"px"; sv_closer.style.left = sv.offsetLeft+10+"px"; sv_closer.style.visibility="visible"; window.setTimeout("sv_showCloser()", 100); } else { sv_closer.style.visibility="hidden"; window.setTimeout("sv_showCloser()", 500); } } function arrayUnique(array) { var a = array.concat(); for(var i=0; i<a.length; ++i) { for(var j=i+1; j<a.length; ++j) { if(a[i] === a[j]) a.splice(j--, 1); } } return a; }; // hierarchy functions (requires variables on template pages - fieldVal / fieldLabel) function clearField(updateSelect) { for(c=updateSelect.options.length-1;c>=0;--c) { updateSelect.options[c] = null; } } function updateField(fieldname,newVals,newLabels) { var updateSelect = getFitForm()[fieldname]; if (updateSelect == undefined || newVals == undefined || updateSelect.options == undefined) { return; } if (addedMand) { //this keeps track of dynamically mandatory fields if (addedMand[fieldname] == "1" && (newLabels.length > 1 || newLabels[0] != "") && newLabels[0] != selectStr) { log("updateField: " + fieldname + " is mand, updating"); newLabels.unshift(selectStr); newVals.unshift(""); } else if (addedMand[fieldname] == "0" && newLabels[0] == selectStr) { log("updateField: " + fieldname + " is no longer mand, updating"); newLabels.shift(); newVals.shift(); } } var currentValue = ""; var currentLabel = ""; if (updateSelect.selectedIndex >= 0) { currentValue = updateSelect.options[updateSelect.selectedIndex].value; currentLabel = updateSelect.options[updateSelect.selectedIndex].text; } for(c=updateSelect.options.length-1;c>=0;--c) { try { updateSelect.options[c] = null; } catch (err) { log ("updateField:" + err + err.description); } } currExists = false; for(c=0;c<newVals.length;++c) { val = newVals[c]; label = newLabels[c]; if (val == currentValue || val == currentLabel) { match = true; currExists = true; } else { match = false; } updateSelect.options[c] = new Option(label,val,false,match); } // in case an old value exists... if (newVals.length>0 && currExists==false && onLoadDefaultsDone==false && "" != "com.other.NewBug" && "".indexOf("com.other.FieldHierarchy")<0 ) // init fieldHierarchy examples properly { updateSelect.options[c] = new Option(currentLabel,currentValue,false,true); } //instead of using changeField we should call onchange //incase other functions have been nested //changeField(updateSelect); updateSelect.onchange(updateSelect); //resetSelectize($(updateSelect)); if ($(updateSelect).hasClass("fit-combobox")) { if (jQuery("#"+updateSelect.id+" option").length==0) { jQuery("#"+updateSelect.id).append(""); // no way to select without second option } jQuery("#"+updateSelect.id).append(""); } } var previousComboboxSelection = -1; function enableCombobox(sel) { //alert("enableCombobox"); var id = sel[0].id; if (jQuery("#"+id+" option").length==0) { jQuery("#"+id).append(""); // no way to select without second option } jQuery("#"+id).append(""); jQuery("#"+id).focus(function() { if (this.multiple) { previousComboboxSelection = jQuery(this).val(); //alert(previousComboboxSelection); } }); jQuery("#"+id).change(function() { var val = jQuery("#"+id+" option:selected").text(); if (val.endsWith("")) { if (val=="" && (previousComboboxSelection+"").length>0) { alert("This is a multiple select field. Use CTRL select if you need to keep previous values. They were : "+ previousComboboxSelection); } addDropdownOption(null,id); } }); } function resetSelectize(sel) { sel.selectize()[0].selectize.destroy(); enableSelectize(sel); } function enableSelectize(sel){ var allowEmpty = false; if (sel[0].options.length>0 && ("" == sel[0].options[0].value)) { allowEmpty = true; } //alert("enableSelectize"); sel.selectize({ create: true, //allowEmptyOption: allowEmpty, //sortField: 'text' onInitialize: function(value) { if (this.$input[0].value=="") { this.clear(); } }, onChange: function(value) { if (value=="") { this.clear(); //$(".selectize-input input[placeholder]").attr('placeholder','Select an Architecture (Optional)'); //setValue("something",false); } var obj = $(this)[0]; //alert("selectize "+obj.$input["0"].id+" changed to "+value); changeField(obj); } }); } function changeTextField(parent) { /* if (parent.value != "") { removeMandIcon(parent.name); } else { addMandIcon(parent.name); } */ } var ajaxFieldHierarchy = false; var trackInitialChangeFields = []; function changeField(parent) { var vals = []; if (parent.selectedIndex >= 0) { //var options = parent && parent.options; var opt; for (var i=0; parent.options && i<parent.options.length; i++) { opt = parent.options[i]; if (opt.selected) { vals.push(opt.value || opt.text); } } } else { if (parent.type=="hidden") { // ReadOnly vals.push(parent.value); } } if (ajaxFieldHierarchy) { updateHierarchyField(parent, vals[0]); } else { if (FieldLabel[parent.name]) { var children = FieldLabel[parent.name]; var c = 0; for(c=0;c<children.length;++c) { var valHash = []; var labelHash = []; child = children[c]; for (var s=0; s<vals.length; s++) { var val = vals[s]; valHash=arrayUnique(valHash.concat(FieldVal[parent.name + "~" + val + "~" + child])); labelHash=arrayUnique(labelHash.concat(FieldLabel[parent.name + "~" + val + "~" + child])); } updateField(child,valHash,labelHash); } } } // hiding sections based on project if (onLoadDefaultsDone == true) { if (parent.name == "mProject") { if (typeof hideSections === "function") { hideSections(val); } } } if (parent && parent.id && trackInitialChangeFields.includes(parent.id)==false) { trackInitialChangeFields.push(parent.id); initSaveReminder(); // in case no options } } //mandatory fields that were added dynamically var addedMand = new Array(); //mandatory fields that were added dynamically, then made non-mandatory var removedMand = new Array(); function addMandatory(fieldName,fieldLabel) { log("addMandatory for field: " + fieldName + " / " + fieldLabel); addedMand[fieldName] = "1"; if (removedMand[fieldName] = "1") { removedMand[fieldName] = ""; } for (var i=0;i<mandFields.length;i++) { if (mandFields[i] == fieldName) { log("addMandatory for field: " + fieldName + " / " + fieldLabel + " already MAND"); return; } } mandFields.length++; mandFieldLabels.length++; mandFields[mandFields.length-1] = fieldName; mandFieldLabels[mandFields.length-1] = fieldLabel; addMandIcon(fieldName); var field = getFitForm()[fieldName]; if (field && field.tagName == "SELECT") { //this is a dropdown, add select... option log("addMandatory for field: " + fieldName + " / " + fieldLabel + ", it's a select field..."); addMandSelect(field); } } //when a field is made mandatory dynamically, //set to true if Select... should be selected //otherwise current value will stay selected var setMandFieldToSelect = false; var selectStr = "<SUB sSelectMandatory>"; function addMandSelect(field) { //we need to go through the array and find hierarchies //where this field is a child... var parents = new Array(); var addedParents = new Array(); try { if (field != null && field.options[0] && field.options[0].value != selectStr) { log("addMandSelect for field: " + field.getAttribute('name') + ", no "+selectStr+" yet: [" + field.options[0].value +"]"); log("FieldVal.length: " + FeldVal.length); for (i in FieldVal) { var index = i.lastIndexOf("~"+field.getAttribute('name')); if (index > 0 && i.charAt(index-1) != '~') { if (FieldVal[i][0] != selectStr) { log("addMandSelect for field: " + field.getAttribute('name') + ", adding "+selectStr+" to [" + i + "]"); FieldVal[i].unshift(selectStr); FieldLabel[i].unshift(selectStr); var parentName = i.substring(0,i.indexOf("~")); var parent = getFitForm()[parentName]; if (addedParents[parentName] != 1) { parents.push(parent); addedParents[parentName] = 1; } } } } for (i=0;i<parents.length;i++) { log("addMandSelect for field: " + field.getAttribute('name') + ", changeField parent:" + parents[i].getAttribute('name')); changeField(parents[i]); } } else { log("addMandSelect for field: " + field.getAttribute('name') + ", already has Select..."); } } catch(err) { //this case is when there is no heirarchy //so we just want to add selectStr to the field itself //alert("error on adding mand select: " + err); if (field != null && field.options[0].value != selectStr) { myEle=document.createElement("option"); theText=document.createTextNode(selectStr); myEle.appendChild(theText); myEle.setAttribute("value",selectStr); field.insertBefore(myEle,field.getElementsByTagName('option')[0]); if (setMandFieldToSelect || "<SUB onPage>" == "com.other.NewBug") { field.selectedIndex = 0; } } } if (field.value == "" && field.options[0].value == selectStr) { //if a blank val is selected, highlight "Select..." instead field.selectedIndex = 0; } } function removeMandSelect(field) { //we need to go through the array and find hierarchies //where this field is a child... var parents = new Array(); var addedParents = new Array(); try { if (field != null && field.options[0] && field.options[0].value == selectStr) { log("removeMandSelect for field: " + field.getAttribute('name') + ", has "+selectStr); log("FieldVal.length: " + FeldVal.length); for (i in FieldVal) { var index = i.lastIndexOf("~"+field.getAttribute('name')); if (index > 0 && i.charAt(index-1) != '~') { if (FieldVal[i][0] == selectStr) { log("removeMandSelect for field: " + field.getAttribute('name') + ", removing "+selectStr+" from [" + i + "]"); FieldVal[i].shift(); FieldLabel[i].shift(); var parentName = i.substring(0,i.indexOf("~")); var parent = getFitForm()[parentName]; if (addedParents[parentName] != 1) { parents.push(parent); addedParents[parentName] = 1; } } } } for (i=0;i<parents.length;i++) { log("removeMandSelect for field: " + field.getAttribute('name') + ", changeField parent:" + parents[i].getAttribute('name')); changeField(parents[i]); } } else { log("removeMandSelect for field: " + field.getAttribute('name') + ", no Select... to remove"); } } catch(err) { //this case is when there is no heirarchy //so we just want to remove Select... from the field itself //alert("error on adding mand select..."); if (field != null && field.options[0].value == selectStr) { field.options[0] = null; } } } function removeMandatory(fieldName) { log("removeMandatory for field: " + fieldName); addedMand[fieldName] = "0"; var remove = false; for (var i=0;i<mandFields.length;i++) { if (!remove && mandFields[i] == fieldName) { remove = true; } if (remove && i < mandFields.length-1) { mandFields[i] = mandFields[i+1]; mandFieldLabels[i] = mandFieldLabels[i+1]; } } if (remove) { mandFields.length--; mandFieldLabels.length--; } removeMandIcon(fieldName); var field = getFitForm()[fieldName]; if (field && field.tagName == "SELECT") { //this is a dropdown, remove select... option removeMandSelect(field); } log("removeMandatory for field: " + fieldName + ", done... returning"); } function whatIsMandatory() { var ret = mandFields[0]; for (var i=1;i<mandFields.length;i++) { ret += ", " + mandFields[i]; } alert(ret); } function addMandIcon(fieldName) { var destination = document.getElementById(fieldName+"Icons"); try { if (destination.firstChild.getAttribute('name') == "dynamicMand") { //already there return; } } catch (err) {} var image = document.createElement("img"); image.src = "<SUB REVISIONPREFIX>com/other/req.gif"; image.border = "0"; image.title = "<SUB sMandatoryField>"; image.alt = "<SUB sMandatoryField>"; var image = document.createElement("img"); image.src = "<SUB REVISIONPREFIX>com/other/req.gif"; image.border = "0"; image.title = "<SUB sMandatoryField>"; image.alt = "<SUB sMandatoryField>"; image.setAttribute('name','dynamicMand'); if (destination!=null) { // not hidden destination.insertBefore(image,destination.firstChild); } } function removeMandIcon(fieldName) { var target = document.getElementById(fieldName+"Icons"); try { if (target.firstChild.getAttribute('name') == "dynamicMand") { target.removeChild(target.firstChild); } } catch (err) {} } var debug = 0; function log(message) { if (!debug || (debug==1 && message.length==0)) { console.log("log: "+message); return; } else if (debug==1) { setTimeout(function() { throw new Error(message); }, 0); return; } if (!log.window_ || log.window_.closed) { var win = window.open("", null, "width=800,height=600," + "scrollbars=yes,resizable=yes,status=no," + "location=no,menubar=no,toolbar=no"); if (!win) return; var doc = win.document; doc.write("<html>" + "<bo"+"dy></bo"+"dy>"); doc.close(); log.window_ = win; } var logLine = log.window_.document.createElement("div"); logLine.appendChild(log.window_.document.createTextNode(message)); log.window_.document.body.appendChild(logLine); } //might need this //if (document.layers) { // if (document.id.display == "none"){ function toggleInnerSection(name,onDisplay) { var inner = document.getElementById(name+"_INNER"); var display = "none"; var img = "com/other/plus_black.gif"; var skin15img = "com/other/img/skin15/white/16/chevron-circle-right.png"; var icon = "fa-chevron-right"; if (inner.style.display=='none') { display = "block"; if (onDisplay) display=onDisplay; img = "com/other/minus_black.gif"; skin15img = "com/other/img/skin15/white/16/chevron-circle-down.png"; icon = "fa-chevron-down"; } inner.style.display = display; if (document.images && document.images[name+"_IMG"]){ document.images[name+"_IMG"].src=img; } else { //new way //jQuery("#"+name+"_ICON").removeClass("fa-plus-circle"); //jQuery("#"+name+"_ICON").removeClass("fa-minus-circle"); var elem = jQuery("#"+name+"_ICON"); if (elem.prop("tagName").toUpperCase()=="SPAN") { elem = elem.children(":first"); } if (elem.prop("tagName").toUpperCase()=="I") { var classes = elem.attr("class"); if (classes.indexOf("-circle-")>0) { icon = icon.replace("fa-chevron","fa-chevron-circle"); elem.removeClass("fa-chevron-circle-right"); elem.removeClass("fa-chevron-circle-down"); } else { elem.removeClass("fa-chevron-right"); elem.removeClass("fa-chevron-down"); } elem.addClass(icon); } else { if (elem[0].src.indexOf("img/skin15")>0) { elem[0].src=skin15img; } else { elem[0].src=img; } } } for(var i=0;i<document.forms.length;i+=1){ if(!document.forms[i].toggleCommands){ var toggleCommands=document.createElement("input"); if(toggleCommands){ toggleCommands.name="toggleCommands"; toggleCommands.type="hidden"; document.forms[i].appendChild(toggleCommands); if(!document.forms[i].toggleCommands){ document.forms[i].toggleCommands=toggleCommands; } } } if(document.forms[i].toggleCommands){ var re=new RegExp("\\btoggleInnerSection\\('"+name+"'\\);\\b"); if(document.forms[i].toggleCommands.value.match(re)){ document.forms[i].toggleCommands.value.replace(re,""); }else{ document.forms[i].toggleCommands.value+="toggleInnerSection('"+name+"');"; } } } } function getElementsByClass(searchClass,node,tag) { var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } // Used to toggle the value of whether something is displayed by changing the attributes of it's CSS... function toggleInnerCSS(name,tagname) { var display = "none"; var img = "<SUB REVISIONPREFIX>com/other/plus_black.gif"; if (document.images){ if (document.images[name+"_IMG"].src.indexOf("plus") > 0) { display = ""; img = "com/other/minus_black.gif"; } } var elements = getElementsByClass(name+"_INNER",tagname); for(i=0;i<elements.length;++i) { elements[i].style.display = display; // alert("CHANGE!"); } if (document.images){ document.images[name+"_IMG"].src=img; } } function getCurrentSelections(selectName) { var sel = document.getElementsByName(selectName)[0]; var ret = "<P><U><B>Current Selections</B></U>:<P>"; for (i=0; i<sel.options.length; i++) { if (sel.options[i].selected) { ret += sel.options[i].value + "<BR>"; } } return ret; } function draggableFix() { // draggable has a bug in jquery if page is scrolled //var css = document.createElement("style"); //css.type = "text/css"; //css.innerHTML = ".ui-dialog {position: fixed;}"; //document.body.appendChild(css); jQuery( '
').appendTo('head'); } // info popup using jQuery (pass div) function fitDialog(e, options) { draggableFix(); var h = 400; var w = 400; if (options && options.big==true) { h=jQuery(window).height()*.8; w=jQuery(window).width()*.8; } if (options && options.autoSize==true) { h="auto"; w="auto"; } if (options && options.width) { w=options.width; } if (options && options.height) { w=options.height; } if (!options.html.startsWith("<div")) { options.html = "<div class='p-3'>" + options.html + "</div>"; } if (jQuery("#dashConfigDialog").length==0) { jQuery(document.body).append('
'); } var title = "Info"; if (options && options.title) { title=options.title; } jQuery("#dashConfigDialog") //.html('
') .html(options.html) .dialog({ //autoOpen: true, modal: true, draggable: true, height: h, width: w, //position: ['right', 'top'], title: title, open: function() { $(this).css('padding', '0px'); jQuery(".ui-widget-overlay").css({background: "#000", opacity: 0.4}); jQuery(".ui-widget-overlay").bind('click',function(event){ jQuery("#dashConfigDialog").dialog('close'); }); }, close: function() { jQuery(".ui-widget-overlay").css({background: '', opacity: ''}); try { var otherClose = options.close; otherClose(); } catch (err) {} } }); } function fitToast(e,html) { var options = { }; options.html = html; fitToastOps(e,options); } function fitToastOps(e, options) { if (jQuery("#fitToastDialog").length==0) { jQuery(document.body).append('
'); } if (!options.h) options.h = "auto"; if (!options.w) options.w = 300; if (!options.title) options.title = "Info"; if (!options.waitTime) options.waitTime = 2000; jQuery("#fitToastDialog") .html(options.html) .dialog({ //autoOpen: true, classes: { "ui-dialog": "alert alert-success", "ui-dialog-titlebar": "noTitle", "dialogClass": "noTitle", }, modal: false, draggable: true, height: options.h, width: options.w, position: { my: "left-200 top-150", at: "left top", of: e, //collision: "none" }, title: options.title }); setTimeout( function () { jQuery("#fitToastDialog").dialog("close"); } , options.waitTime); } // retrive Documentation from Fit Server language file // (more detailed docs that can be created separately and no quote problems) function fitDialogFromKey(e,str) { jQuery.get( "&page=GetInfo&key="+str, function( data ) { fitDialog(e,{html: data, big: true }); }); } // get dialog info from a hidden div (old method) function fitDialogDiv(e, id) { fitDialog(e,{ html: jQuery(id).html(), big: true } ); } // get html to show from a url (such as com/other/docs function fitDialogUrl(e,options) { jQuery.get( options.url, function( data ) { if (!options.big) options.big = true; options.html = data; fitDialog(e,options); }); } // info popup (override old method below) function fitInfo(e,str) { if (!e) var e = window.event; //jQuery('body').append('
'+ str.replace(/(['"])/g, "\\$1") +'
'); fitDialog(e,{html: str}); } function OLDfitInfo(e,str) { if (!e) var e = window.event; //str = str.replace(/
/i, "\r\n"); //alert(str); // open a blank window //var infoWin = window.open('', 'FitInfo', 'location=no,status=no,toolbar=no,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,width=600,height=400'); //infoWin.document.write("Fit Information" + str); // use calendar stuff instead cause of popup blockers var info = "

" + "
com/other/info.gif\"> Info | com/other/close_black.gif\">
" + str + "

"; cal_show(e, "", info); } /// Calendar stuff var tipVisible=false var ie = document.all?1:0; var id="calendar" var calendar="-1"; var currentStatus = "Click to Drag"; var calendar_bgcolor = "lightgrey"; var cell_bgcolor = "lightgrey"; var cell_highlight = "#eeeeee"; var button_color = "#eeeeee"; var button_highlight = "#b0b0ff"; var today_bgcolor = "#b0b0ff"; var today_highlight = "#e0e0ff"; var close_bgcolor = "lightgrey"; var close_highlight = "#eeeeee"; var STARTUP; //for testing //var errors = window.open(); /***** * Following are variables for the * tooltip which can be customized *****/ var offsetX = -120; //horizontal offset of the tooltip //-120 var offsetY = -100; //vertical offset of the tooltip var tipWidth = 400; //width of the tooltip var tipHeight = 90; //approximate height of the tooltip months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var calendarhtml="

"; calendarhtml+="
Default
"; calendarhtml+="

" var x,y; var isDrag=false; function getPosition(e) { e = e || window.event; var cursor = {x:0, y:0}; if (e.pageX || e.pageY) { cursor.x = e.pageX; cursor.y = e.pageY; } else { var de = document.documentElement; var b = document.body; cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0); cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0); } return cursor; } function cal_escape(evt) { var e = (window.event) ? window.event : evt; if (e.keyCode == 27) { cal_hide(); } } var desiredX = -1; var desiredY = -1; var clickToDrag = ''; //drag not working now 'Click to drag'; function cal_show(e, target, format) { if (STARTUP==undefined) { calendar_startup(); STARTUP==1; } var screenX= document.body.clientWidth; var screenY= document.body.clientHeight; var mouseX=0; //ie?event.x:e.clientX; var mouseY=0; //ie?event.y:e.clientY; var xpos=0; var ypos=0; if (ie) { var cursor = getPosition(event); // had problems with IE 7/8 with/without DOCTYPE mouseX=cursor.x; mouseY=cursor.y; xpos=cursor.x+offsetX; ypos=cursor.y+offsetY; } else { mouseX=e.clientX; mouseY=e.clientY; xpos=e.pageX+offsetX; ypos=e.pageY+offsetY; } //old way //var xpos=ie?event.x+offsetX+document.body.scrollLeft:e.pageX+offsetX; //var ypos=ie?event.y+offsetY+document.body.scrollTop:e.pageY+offsetY; if (!ie) { //IE dragging not working right now, //this is causing it to pop up in the //wrong spot if (offsetY < 0) { //check if hitting top of the screen if (mouseY < (-offsetY)) { //move the tip under the mouse ypos -= offsetY - 10; } } else { //check if hitting the bottom if (mouseY+offsetY+tipHeight > screenY) { //move the tip over the mouse ypos -= tipHeight + 20; } } if (mouseX + offsetX < 4) { //check the left side of the screen xpos += -(mouseX+offsetX) + 4 } else if (mouseX+offsetX+tipWidth > (screenX)) { //check the right side xpos += (screenX) - (mouseX+offsetX+tipWidth); } } //alert("T: " + target + " F: " + format + " E: " + e); if (target=="") { calendar.innerHTML = format; // simple info box. } else { getCalendar(target,format); } if (desiredX>0) { xpos = desiredX; desiredX=-1; } if (desiredY>0) { ypos = desiredY; desiredY=-1; } calendar.style.left=xpos+'px'; calendar.style.top=ypos+'px'; calendar.style.visibility = "visible"; calendar.style.width = "200px"; tipVisible=true; hideSelectBoxes(xpos,ypos); document.onkeypress= new Function("event","cal_escape(event);"); } function cal_hide() { tipVisible=false; if (calendar!="-1") { calendar.innerHTML = "
empty
"; // stop ajax updates to FIT calendar.style.visibility = "hidden"; } hideSelectBoxes(0,0); setOpacityOff(); } function cal_changeStatus(stat) { currentStatus = stat; var statusBar = document.getElementById("calendar_statusBar"); statusBar.innerHTML = currentStatus; } function cal_move(e) { if (calendar == "-1") { return true; } if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event) if (e) { if (isDrag) { var mouseX=ie?event.x:e.clientX; var mouseY=ie?event.y:e.clientY; var tx = parseInt(calendar.style.left+0); var ty = parseInt(calendar.style.top+0); calendar.style.left=tx + mouseX-x; calendar.style.top=ty + mouseY-y; x=mouseX; y=mouseY; hideSelectBoxes(tx + mouseX-x,ty + mouseY-y); return false; } } return true; } function cal_select(e) { var mouseX=ie?event.x:e.clientX; var mouseY=ie?event.y:e.clientY; isDrag=true; x=mouseX; y=mouseY; return false; } function cal_deselect() { isDrag=false; return false; } function populateCalendar(month, year, target, format) { var now = new Date(); var currentDate = -1; var firstDay = new Date(); firstDay.setDate(1); firstDay.setMonth(month); firstDay.setFullYear(year); var prevY = year - 1; var nextY = year + 1; var prevM = month - 1; var nextM = month + 1; var prevMY = year; var nextMY = year; if (prevM == -1) { prevM = 11; prevMY= prevY; } else if (nextM == 12) { nextM = 0; nextMY = nextY; } var todayAction = "populateCalendar("+now.getMonth()+","+now.getFullYear()+",'"+target+"','"+format+"');"; var todayText = "Jump to current date"; var targetOnChange = "if (document."+target+".onchange!=undefined) { document." + target + ".onchange(); }"; if (month == now.getMonth() && year == now.getFullYear()) { currentDate = now.getDate(); var fullYear = new String(now.getFullYear()); var fullDate = getDateFormat(currentDate,month,fullYear,year,format); todayAction = "document." + target + ".value='" + fullDate + "';cal_hide();"+targetOnChange+"return true;"; todayText = "Set date to today"; } var ret="

" + "
" + "
" + months[firstDay.getMonth()] + " " + firstDay.getFullYear() + " | X
" + "
" + "
" + "
" +"
" +"
<< | < | Today | > | >>
" + "
" + "
" + "
" + "
" + "
" + "
" + "
Sun | Mon | Tue | Wed | Thu | Fri | Sat
" + getDayGrid(firstDay,currentDate,target,format) + "
" + currentStatus + "
" + "

"; calendar.innerHTML = ret; } function getDayGrid(now,today,target,format) { var ret="
"; var fullDate; var currentDate=1; var month = now.getMonth(); var fullYear = new String(now.getFullYear()); var year = new String(fullYear.substr(2,2)); var lastDay = getLastDay(now.getMonth(),now.getFullYear()); var atLastDay=0; for(i=0;i<now.getDay();i++) { //add blank cells to beginning ret+="<td width=14% style='border:1px solid #aaa'> </td>"; } for(i=now.getDay();i<7;i++) { //rest of first week fullDate = getDateFormat(currentDate,month,fullYear,year,format); ret+=getDay(currentDate,today,fullDate,target); currentDate++; } ret+="</tr>"; for (j=1;j<6;j++) { //remaining weeks ret+="<tr>"; for(i=j*7;i<(j+1)*7;i++) { if (currentDate>lastDay) { atLastDay=1; break; } fullDate = getDateFormat(currentDate,month,fullYear,year,format); ret+=getDay(currentDate,today,fullDate,target); currentDate++; } ret+="
"; if (atLastDay) { break; } } return ret; } function getDay(currentDate,today,fullDate,target) { var background = cell_bgcolor; var highlight = cell_highlight; if (currentDate == today) { background = today_bgcolor;"#b0b0ff"; highlight = today_highlight; } var targetnodes = target.split('.'); // IE8 does not see target and causes errors here ?? var targetOnChange = "if (document."+targetnodes[0]+" && document."+target+".onchange!=undefined) { document." + target + ".onchange(); }"; return "" + "
" + currentDate +"
"; } function getCalendar(target,format) { var now = new Date(); populateCalendar(now.getMonth(),now.getFullYear(),target,format); } function getLastDay(month,year) { if (month == 1) { //Feb if ((year % 4) == 0) { if ((year % 100) == 0 && (year % 400) != 0) { return 28; } return 29; } return 28; } else if (month==0||month==2||month==4||month==6||month==7||month==9||month==11) { return 31; } return 30; } function getDateFormat(d,mon,fullYear,year,format) { var date; mon++; var day = "" + d; var month = "" + mon; if (day.length==1) { day = "0" + day; } if (month.length==1) { month = "0" + month; } switch (format) { case "MM\/dd\/yyyy" : date = month + "\/" + day + "\/" + fullYear; break; case "MM\/dd\/yy" : date = month + "\/" + day + "\/" + year; break; case "yyyy\/MM\/dd" : date = fullYear + "\/" + month + "\/" + day; break; case "dd\/MM\/yy" : date = day + "\/" + month + "\/" + year; break; case "dd\/MM\/yyyy" : date = day + "\/" + month + "\/" + fullYear; break; case "dd.MM.yyyy" : date = day + "." + month + "." + fullYear; break; case "dd-MM-yyyy" : date = day + "-" + month + "-" + fullYear; break; case "MM-dd-yyyy" : date = month + "-" + day + "-" + fullYear; break; default : date = fullYear + "\/" + month + "\/" + day; } return date; } function getAbsolute(obj) { var position = {x: obj.offsetLeft,y: obj.offsetTop}; if (obj.offsetParent) { var parent = getAbsolute(obj.offsetParent); position.x += parent.x; position.y += parent.y; } return position; }; function hideSelectBoxes(xpos,ypos) { if (!ie) return; var cal_x1 = xpos; var cal_y1 = ypos; var cal_x2 = cal_x1 + calendar.offsetWidth; var cal_y2 = cal_y1 + calendar.offsetHeight; genericHideSelectBoxes(cal_x1,cal_y1,cal_x2,cal_y2,tipVisible); } function genericHideSelectBoxes(cal_x1,cal_y1,cal_x2,cal_y2, isVisible) { if (!ie) return; var omitTags = calendar.getElementsByTagName("select"); var selectTags = document.getElementsByTagName("select"); var current = null; for (var i = 0; i < selectTags.length; i++) { current = selectTags[i]; var omit=false; for(var j=0;j<omitTags.length;j+=1){ if(current==omitTags[j]){ omit=true; break; } } if(omit){continue;} var position = getAbsolute(current); var sel_x1 = position.x; var sel_y1 = position.y; var sel_x2 = current.offsetWidth + sel_x1; var sel_y2 = current.offsetHeight + sel_y1; //errors.document.writeln("cy1:"+cal_y1+",cy2:"+cal_y2+"<br>sy1:"+sel_y1+",sy2:"+sel_y2+"
-----------
"); if (!isVisible || (cal_x1 > sel_x2) || (cal_x2 < sel_x1) || (cal_y1 > sel_y2) || (cal_y2 < sel_y1)) { //no overlap if (!current.visibility_record) { current.visibility_record = current.currentStyle.visibility; } current.style.visibility = current.visibility_record; } else { //need to hide if (!current.visibility_record) { current.visibility_record = current.currentStyle.visibility; } current.style.visibility = "hidden"; } } }; document.onmousemove=cal_move; function calendar_startup() { if (calendar != "-1") { // close the current one calendar.style.visibility = "hidden"; } calendar = setupCalendar(); calendar.innerHTML=calendarhtml; document.body.appendChild(calendar); //these should not be modified calendar.style.position="absolute"; calendar.style.visibility="hidden"; calendar.style.zIndex="1000"; } function setupCalendar() { //created the div element for the popup var divTag = document.createElement("div"); divTag.id = id; divTag.onmousedown = function (evt) { cal_select(evt || window.event); }; divTag.onmouseup = function () { cal_deselect(); }; return divTag; } //Object.extend(String.prototype, { //strip: function() { // return this.replace(/^\s+/, '').replace(/\s+$/, ''); //} //} function checkDate(e, target) { var format = ""; var dateVal = target.value; var relativeDate = false; dateVal = dateVal.trim(); if (dateVal.length!=0) { var lower = dateVal.toLowerCase(); if (lower.indexOf("+")>=0 || lower.indexOf("-")>=0 || // +/- 1 day lower.indexOf("y")>=0 || //year / yesterday lower.indexOf("m")>=0 || //month lower.indexOf("w")>=0 || //week lower.indexOf("d")>=0 || //day lower.indexOf("h")>=0 || //hour lower.indexOf("m")>=0 || //minute lower.indexOf("s")>=0 || //second lower.indexOf("t")>=0 || //tomorrow lower.indexOf("n")>=0 ) //now { // relative dates allow : Year / Month / Week / Day / Hour / MINute / Second / now / today / yesterday return true; } } if (dateVal.length!=0 && dateVal.length != format.length) { alert("Incorrect date format : " + dateVal + " ["+format+"]"); } else { // check slashes/dots/dashes are in same spots for (var i=0;i<dateVal.length;i++) { var c = dateVal.charAt(i); if (c=='/'||c=="."||c=="-") { if (format.charAt(i)!=c) { alert("Incorrect date format : " + dateVal + " ["+format+"]"); } } } } } // these functions are for updating selects on the fly function copyMenuToHelperArray(menu,helperArray){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ helperArray.length=0; for(var i=0;i<menu.options.length;i+=1){ helperArray[i]=menu.options[i]; if(helperArray[i].value==""){ helperArray[i].value=helperArray[i].text; } } } } // this function is used by the DropItemMenu in Passit // it was also copied to the Notify List code to look after selections when using search option, to reduce options // make sure options stay selected user shrinks and expands the selection list function copyMenuSelectedToHelperArray(menu,helperArray){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ // speed up page load. Most of the time people will not be searching .... if (menu.options.length == helperArray.length) return; var selectedHash = {}; var unselectedHash = {}; for(var i=0;i<menu.options.length;i+=1){ if (menu.options[i].selected==true) { selectedHash[menu.options[i].text]=1; } else { unselectedHash[menu.options[i].text]=1; } } for(var j=0;j<helperArray.length;j+=1){ if (selectedHash[helperArray[j].text]) { if (helperArray[j].selected==false) { helperArray[j].selected = true; } } else if (unselectedHash[helperArray[j].text]) { if (helperArray[j].selected==true) { helperArray[j].selected = false; } } } } } function copyHelperArraySelectedToMenu(helperArray,menu){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ for(var i=0;i<helperArray.length;i+=1){ //if(helperArray[i].selected){ // need to do unselect too for(var j=0;j<menu.options.length;j+=1){ if(helperArray[i].text==menu.options[j].text){ if (menu.options[j].selected != helperArray[j].selected) { menu.options[j].selected=helperArray[j].selected; } break; } } //} } } } function copyHelperArrayToMenu(menu,helperArray){ if(menu&&menu.options&&typeof(helperArray)!="undefined"){ menu.innerText = null; // updating source control for(var i=0;i<helperArray.length;i+=1){ var optn=document.createElement("option"); optn.selected=helperArray[i].selected; optn.text=helperArray[i].text; optn.value=helperArray[i].value; optn.style.fontFamily = helperArray[i].style.fontFamily; //"monospace"; // titles for pickers optn.disabled=helperArray[i].disabled; optn.style.fontWeight = helperArray[i].style.fontWeight; // "bold"; optn.style.textDecoration = helperArray[i].style.textDecoration; // "underline"; menu.options.add(optn); } } } var helperArray=[]; var notifyGroupArray=[]; function updateMenu(specific,menu,helperArray,menuHelper,emptyMessage,startsWith){ if(menu&&menu.options&&typeof(helperArray)!="undefined"&&menuHelper){ if(helperArray.length==0&&menu.options.length>0){ copyMenuToHelperArray(menu,helperArray); } copyMenuSelectedToHelperArray(menu,helperArray); menu.options.length=0; var j=0; var help; if(startsWith===true){ help=new RegExp("^"+menuHelper.value,"i"); }else{ help=new RegExp(menuHelper.value,"i"); } for(var i=0;i<helperArray.length;i+=1){ if(helperArray[i].disabled==true || (helperArray[i].text.match(help)&&(extraCheck(specific,menu,helperArray[i].text)))) { var optn=document.createElement("option"); optn.selected=helperArray[i].selected; optn.text=helperArray[i].text; if(helperArray[i].value!=""){ optn.value=helperArray[i].value; }else{ optn.value=helperArray[i].text; } optn.style.fontFamily = helperArray[i].style.fontFamily; //"monospace"; // titles for pickers optn.disabled = helperArray[i].disabled; optn.style.fontWeight = helperArray[i].style.fontWeight; // "bold"; optn.style.textDecoration = helperArray[i].style.textDecoration; // "underline"; // these did not work : // optn.style = helperArray[i].style; // optn.css("font-family","monospace"); menu.options.add(optn); } } if(menu.options.length==0&&emptyMessage&&emptyMessage.style){ menu.style.display="none"; emptyMessage.style.display=""; }else{ menu.style.display=""; if(emptyMessage&&emptyMessage.style)emptyMessage.style.display="none"; } } } function extraCheck(specific,menu,option) { if (menu.name=='notifySelect'+specific) { var filter = eval('menu.form.notifyFilter'+specific); var groupArray = eval('notifyGroupArray'+specific); if (filter.selectedIndex==0) { // show all return true; } else { var group = false; for (i=0; i<groupArray.length; i++) { if (option==groupArray[i]) { group=true; } } if (filter.selectedIndex==1) { // show groups return group; } else { return !group; } } } else { return true; } } function submitFormOnEnter(textfield,e,button){ var keycode; if(window.event)keycode=window.event.keyCode; else if(e)keycode=e.which; else return true; if(keycode==13){ if(button&&button.click){ button.click(); return false; }else{ if(textfield&&textfield.form&&textfield.form.submit){ textfield.form.submit(); return false; }else{ return true; } } }else{ return true; } } //this function can be called from anonymous pages //to update a select field with the current list options // accepts childId in id form (custom+=100) or domName form (mArea/fieldX) function getFieldJsVars(trackNum, childId, options) { var mmContext = trackNum; var mand = false; if (options && options.includeMandatory==true) mand=true; jQuery.ajax({ type: 'GET', url: '<SUB URLADDWITHOUTCONTEXT>' + '?CONTEXT=' + trackNum + '&page=com.other.AnonAjaxUtil' + '&makeUniqueUrl=' + (new Date().valueOf()) + '&getFieldJsVars=1' + '&includeMandatory=' + mand + '&childId=' + childId, success: function(t) { try { eval(t); } catch (e) { alert("Problem retrieving jsVars for field "+childId+". Check Exception Log. " + e); } }, error: function(xhr, error) { alert("Problem retrieving jsVars for field "+childId+". Check Exception Log. " + error); } }); } //this function can be called from anonymous pages //to update a select field with the current list options // accepts fieldId in id form (custom+=100) or domName form (mArea/fieldX) function getFieldListOptions(trackNum, fieldId, options) { var mmContext = trackNum; var mand = false; if (options && options.includeMandatory==true) mand=true; jQuery.ajax({ type: 'GET', url: '' + '?CONTEXT=' + trackNum + '&page=com.other.AnonAjaxUtil' + '&makeUniqueUrl=' + (new Date().valueOf()) + '&includeMandatory=' + mand + '&getFieldListOptions=' + fieldId, success: function(t) { try { eval(t); } catch (e) { alert("Problem retrieving list options for field "+fieldId+". Check Exception Log. " + e); } }, error: function(xhr, error) { alert("Problem retrieving list options for field "+fieldId+". Check Exception Log. " + error); } }); } function checkUniqueField(id, bugid) { var ret = true; var success = false; var fieldValue = ""; try { fieldValue = document.getElementById("field"+id).value; } catch (err) { return true; } jQuery.ajax({ type: 'GET', url: mmUrlAddNoContext + '&CONTEXT=' + mmContext + '&page=com.other.AjaxUtil' + '&checkUniqueField=' + id + '&checkUniqueFieldValue=' + fieldValue + '&checkUniqueFieldBug=' + bugid + '&makeUniqueUrl=' + (new Date().valueOf())+ '', async: false, success: function(t) { if (!success && t.length > 5) { alert(t); success = true; ret = false; } }, failure: function(t) { alert("Unique value check failed: "+t); } }); return ret; } // hello there function addRelationshipWarning() { if (""=="com.other.NewBug") { alert(""); return false; } else if (""=="com.other.ModifyBug") { return confirm(""); } return true; } function changeChart(obj,chartId) { var summaryChartImage = document.getElementById('summaryChartImage'); var link = "&page=com.other.JFreeReportChart&chartId="+chartId+"&chartType="+type; if (summaryChartImage) { var type = obj.options[obj.selectedIndex].value; summaryChartImage.src = link; } else { sv_show(e,"Trial",link); } return true; } function showSummaryChart(e, obj) { var link = "&page=com.other.MainMenuSummary"; sv_show(e,"Trial",link); return true; } var checkedHistory = new Array(); function toggleHistoryCheckbox(boxId) { if (checkedHistory[boxId]) { checkedHistory[boxId] = false; } else { checkedHistory[boxId] = true; } submitHistoryCheckboxes(); } function submitHistoryCheckboxes() { var checkedBoxes = ""; for (var i=0;i<checkedHistory.length;i++) { if (checkedHistory[i]) { checkedBoxes += " " + i; } } document.getElementById("checkedHistoryCheckboxes").value = checkedBoxes; return true; } function showHistoryCheckboxes(show) { var c = 0; var check = document.getElementById("historyCheck"+c); while (check) { if (show) { check.style.display = ""; } else { check.style.display = "none"; } c++; check = document.getElementById("historyCheck"+c); } } function showOptionsMenu(event,baseName) { //var ret = ""; var baseDiv=document.getElementById(baseName); if (baseDiv) { //log(baseName+ " : ["+ event.clientX + "," + event.clientY+"] ["+ // event.offsetLeft+ "," + event.offsetTop+"]" ); //log("target : ["+ event.target.clientX + "," + event.target.clientY+"] ["+ // event.target.offsetLeft+ "," + event.target.offsetTop+"]" ); //log("baseDiv.hideEvent: "+baseDiv.hideEvent); if(baseDiv.hideEvent!=null){ clearTimeout(baseDiv.hideEvent); } baseDiv.hideEvent=null; var e=event.target||event.srcElement; //var x=0; //var y=0; while(e!=null) { //log("showOptionsMenu " + baseDiv.id +":" +e.id||0); if (e.id) { //ret += "["+e.id+"]"; if (baseDiv.id == e.id) { //alert("returning : "+ret); return; } //log("add: "+e.id +" - "+e.offsetTop); //x+=e.offsetLeft; //y+=e.offsetTop; } e=e.offsetParent; } var scrollX = (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0); var scrollY = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); baseDiv.style.left=(event.clientX+scrollX+5)+'px'; baseDiv.style.top=(event.clientY+scrollY+5)+'px'; //baseDiv.style.left=x+'px'; //baseDiv.style.top=y+'px'; baseDiv.style.display=""; } //alert(ret); } function hideOptionsMenu(evt, baseName, when) { var baseDiv=document.getElementById(baseName); if(baseDiv){ if (when!=0 && baseDiv.hideEvent==null) { var str = "hideOptionsMenu(window.event,'"+baseName+"',1000);"; baseDiv.hideEvent=setTimeout(str,when); } else { baseDiv.style.display="none"; } } } ////// quickHeaderMenu stuff var QHmenu=-1; var lastQHClickTime=0; function quickHeaderMenu(event,context,fieldId) { if (QHmenu==-1) { QHmenu = new QuickHeaderMenu(event); } QHmenu.setContext(context); QHmenu.setFieldId(fieldId); //log(event.timeStamp-lastClickTime); if (event.type=="click" && event.timeStamp-lastQHClickTime<500) { QHmenu.quickView(event); hideOptionsMenu(event,"hOptionsMenu",0); } else { showOptionsMenu(event,"hOptionsMenu"); } if (event.timeStamp) { lastQHClickTime=event.timeStamp; } //log(lastClickTime + " : " + event.type); hideOptionsMenu(event,"hOptionsMenu",2000); // so it does not stay up forever return QHmenu; } function QuickHeaderMenu(event) { var context = -1; var fieldId = -1; this.setContext=function(id){this.context=id}; this.getContext=function(){return this.context}; this.setFieldId=function(id){this.fieldId=id}; this.getFieldId=function(){return this.fieldId}; var html="\ <div id=hOptionsMenu style=\"display:none;position:absolute;background:white;\" onmouseout=\"hideOptionsMenu(event,'hOptionsMenu',500);\">"; html += "\

Add To Filter
</table</div>\

Remove From Filter
</table</div>\ \

"; var div = document.createElement('div'); div.innerHTML = html; document.body.appendChild(div) this.quickFilterAddField=function(e) { //quickView(e,this.getContext(),this.getFieldId(),"IFRAME","com.other.QuickFilterAddField&fieldId="+this.getFieldId()); fitDialogUrl(e,{url: "?page=com.other.QuickFilterAddField&fieldId="+this.getFieldId(), title: ""}); } this.quickFilterRemoveField=function(e) { var ret = confirm("Are you sure you want to remove this field [id:"+this.getFieldId()+"] from the current filter?"); if (ret==true) { document.location = "?page=com.other.QuickFilterRemoveField&fieldId="+this.getFieldId(); } } return(html); } ///// quickMenu stuff var qmenu=-1; var lastClickTime=0; function quickMenu(event,context,bsId) { //chanes on the fly now for rowFieldDisplay // if (qmenu==-1) { qmenu = new QuickMenu(event); //} qmenu.setContext(context); qmenu.setBsId(bsId); //log(event.timeStamp-lastClickTime); if (event.type=="click" && event.timeStamp-lastClickTime<500) { qmenu.quickView(event); hideOptionsMenu(event,"rowOptionsMenu",0); } else { showOptionsMenu(event,"rowOptionsMenu"); } if (event.timeStamp) { lastClickTime=event.timeStamp; } //log(lastClickTime + " : " + event.type); hideOptionsMenu(event,"rowOptionsMenu",2000); // so it does not stay up forever return qmenu; } var quickWin="-1"; function QuickMenu(event) { var context = -1; var bsId = -1; this.setContext=function(id){this.context=id}; this.getContext=function(){return this.context}; this.setBsId=function(id){this.bsId=id}; this.getBsId=function(){return this.bsId}; try { initialColId = jQuery(event.target).closest("td").attr("id"); } catch (error) { alert("QuickMenu exception: "+error); } var borderTopStyle=""; var html="\
\ \

\ \ \ '; var fld = jQuery("#"+fieldTag); var parentRow = fld.closest('tr'); jQuery(parentRow).after(htmlAdd); //setTimeout("initializeMap('"+fieldTag+"');",1000); } // quick canvas on main menu function mmQuickToggle(){ var obj = jQuery("#mmQuickReport"); if (obj.length==0) { // refresh page with mmQuickReport data document.location = "?page=&canvasType=click"; } else { if (obj.is(":visible")) { obj.hide(); } else { obj.show(); runCanvasReports(); } } } function ajaxContextInfo() { var extras = ""; var showContext=mmContext; if (jQuery("#showContextId").length>0) { jQuery("#showContextId").val(); } //var radioObj = document.forms['entry_form'].elements['type']; //var showContext = document.forms['entry_form'].elements['parentTrack'].value; if (document.getElementById('parentTypeOption')) { var showDisplay = document.forms['entry_form'].elements['parentFieldDisplay'].value; var showFormat = document.forms['entry_form'].elements['parentFieldFormat'].value; var showAttributes = document.forms['entry_form'].elements['parentFieldAttributes'].value; if (document.getElementById('childTypeOption').checked) { //showContext = document.forms['entry_form'].elements['childTrack'].value; showDisplay = document.forms['entry_form'].elements['childFieldDisplay'].value; showFormat = document.forms['entry_form'].elements['childFieldFormat'].value; showAttributes = document.forms['entry_form'].elements['childFieldAttributes'].value; } extras += '&showDisplay=' + encodeURIComponent(showDisplay)+ '&showFormat=' + encodeURIComponent(showFormat) + '&showAttributes=' + encodeURIComponent(showAttributes); } jQuery.ajax({ type: 'GET', url: mmUrlAddNoContext + '&CONTEXT=' + mmContext + '&page=com.other.AjaxUtil' + '&mmRand=' + mmRand + '&makeUniqueUrl=' + (new Date().valueOf()) + '&ajaxContextInfo=1' + '&showContextId=' + showContext + extras, success: function(t) { try { eval(t); } catch (e) { // Occurs when bug has been closed, user no longer sees that bug // and another user exits that bug... showErrorMessage("Exception: "+t+" - " +e.message); } }, error: function(xhr, error) { showErrorMessage("Failure: "+xhr+" - " +error); } }); } function ajaxContextFieldNames() { jQuery.ajax({ type: 'GET', url: mmUrlAddNoContext + '&CONTEXT=' + mmContext + '&page=com.other.AjaxUtil' + '&mmRand=' + mmRand + '&makeUniqueUrl=' + (new Date().valueOf()) + '&ajaxContextFieldNames=1', success: function(t) { try { eval(t); } catch (e) { // Occurs when bug has been closed, user no longer sees that bug // and another user exits that bug... showErrorMessage("Exception: "+t+" - " +e.message); } }, error: function(xhr, error) { showErrorMessage("Failure: "+xhr+" - " +error); } }); } // inline edit function updateFieldInTable(contextId,bsId,fieldId) { var pickPage = '&page=com.other.AjaxUtil'; jQuery.ajax({ type: 'get', url: mmUrlAddNoContext + '&CONTEXT=' + contextId + pickPage + '&tableCellEdit='+fieldId+'&tableCellVal=' + document.getElementById(fieldId).value + '&ajaxModifyBug=' + bsId + '&makeUniqueUrl=' + (new Date().valueOf()), success: function(t) { try { eval(t); } catch (e) { // Occurs when bug has been closed, user no longer sees that bug // and another user exits that bug... alert("Error: " + e); showErrorMessage("Exception: "+t+" - " +e.message); } }, error: function(xhr, error) { showErrorMessage("Failure: "+xhr+" - " +error); alert("error: " + error); } }); } function appendScript(filepath) { if (jQuery('head script[src="' + filepath + '"]').length > 0) return; var ele = document.createElement('script'); ele.setAttribute("type", "text/javascript"); ele.setAttribute("src", filepath); jQuery('head').append(ele); } function appendStyle(filepath) { if (jQuery('head link[href="' + filepath + '"]').length > 0) return; var ele = document.createElement('link'); ele.setAttribute("type", "text/css"); ele.setAttribute("rel", "Stylesheet"); ele.setAttribute("href", filepath); jQuery('head').append(ele); } function displayGaugeChart(containerId, score, total) { appendScript(''); var complexities = [ "Sustaining", "Tactical", "Evolutionary", "Transformational" ]; var colors = [ "#00cc00", "#e6e600", "#ff8000", "#ff3333" ]; // green/yellow/orange/red var index = 0; var percent = score/total*100; if (percent>45) index = 1; if (percent>63) index = 2; if (percent>82) index = 3; var gauge = { title:{ text: complexities[index] }, data : { y: score }, //gauge value change it color : colors[index], maximum : total }; var chart = new CanvasJS.Chart(containerId); createGauge(chart); //Function for gauge function createGauge(chart){ //Caluculation of remaining parameters to render gauge with the help of doughnut gauge.unoccupied = { y: gauge.maximum - gauge.data.y , color: "#DEDEDE", toolTipContent: null, highlightEnabled: false, click : function (){ gauge.unoccupied.exploded = true; } } gauge.data.click = function (){ gauge.data.exploded = true; }; if(!gauge.data.color) gauge.data.color = gauge.color; //"#69C434"; gauge.valueText = {text: gauge.data.y.toString() + " / " + gauge.maximum , verticalAlign :"center"}; //gauge.complexityText = { text: complexities[index] , verticalAlign :"center"}; var data = { type: "doughnut", dataPoints: [ { y: gauge.maximum , color: "transparent", toolTipContent: null }, gauge.data, gauge.unoccupied ], }; if(!chart.options.data) chart.options.data = []; chart.options.data.push(data); if(gauge.title){ chart.options.title = gauge.title; } //For showing value if(!chart.options.subtitles) chart.options.subtitles = []; chart.options.subtitles.push(gauge.valueText); chart.render(); } } // inline edit -- id variable : "b"+bs.mId+"c"+bs.mContextId+"uf"+uf.mId; var inlineEditCancelValues={}; function showInlineEdit(id) { var val = jQuery("#ieSpan-"+id).attr("value"); inlineEditCancelValues[id]=val; var form = ""; jQuery("#ieSpan-"+id).html(form); //setInlineEditEvents(); } function resetInlineEdit(id) { var html = inlineEditCancelValues[id] + " "; jQuery("#ieSpan-"+id).html(html); delete inlineEditCancelValues[id]; //setInlineEditEvents(); } jQuery(document).ready(function($) { setInlineEditEvents(); }); function setInlineEditEvents() { //jQuery( "span.inlineEditSpan" ).click(function(event) { $(document).on('click', 'span.inlineEditSpan', function(event){ var id = $(this)[0].id; id = id.replace("ieSpan-",""); event.stopPropagation(); if (typeof(inlineEditCancelValues[id])=="undefined") { showInlineEdit(id); } }); //jQuery( "span.inlineEditSpan" ).mouseover(function(event) { $(document).on('mouseover', 'span.inlineEditSpan', function(event){ $(this).children().show(); }); //jQuery( "span.inlineEditSpan" ).mouseout(function(event) { $(document).on('mouseout', 'span.inlineEditSpan', function(event){ var id = $(this)[0].id; id = id.replace("ieSpan-",""); if (typeof(inlineEditCancelValues[id])=="undefined") { $(this).children().hide(); } }); //jQuery( "i.inlineEditStart" ).click(function(event) { $(document).on('click', 'i.inlineEditStart', function(event){ var id = $(this).parent()[0].id; id = id.replace("ieSpan-",""); event.stopPropagation(); showInlineEdit(id); }); //jQuery( "i.inlineEditSave" ).click(function(event) { $(document).on('click', 'i.inlineEditSave', function(event){ var id = $(this).parent()[0].id; id = id.replace("ieSpan-",""); var numberPattern = /\d+/g; var arr = id.match( numberPattern ); if (arr.length<3) { alert("invalid inlineId: "+id); return; } if (inlineEditCancelValues[id] != $("#ie-"+id).val()) { // update if different updateFieldInTable(arr[1],arr[0],"ie-"+id); var parentRelDiv = $(this).closest("[id^='display']"); var relId = parentRelDiv.attr("id").replace("display",""); refreshRel('relPicker' + relId, 'display' + relId,'field' + relId); // refresh full line in case calculated fields //$("#ieSpan-"+id).attr("value",$("#ie-"+id).val()); //} else { // alert("nothing changed"); } inlineEditCancelValues[id] = $("#ie-"+id).val(); event.stopPropagation(); resetInlineEdit(id); }); //jQuery( "i.inlineEditCancel" ).click(function(event) { $(document).on('click', 'i.inlineEditCancel', function(event){ var id = $(this).parent()[0].id; id = id.replace("ieSpan-",""); event.stopPropagation(); resetInlineEdit(id); }); } var peterColorSet = [ // my extras //"#4661EE", // close to google //"#EC5657", // close to google "#1BCDD1", "#8FAABB", "#B08BEB", "#3EA0DD", "#F5A52A", "#23BFAA", "#FAA586", "#EB8CC6" ]; var currentColorSet = [ //https://docs.appian.com/suite/help/21.3/Chart_Color_Scheme.html "#619ED6", "#6BA547", "#F7D027", "#E48F1B", "#B77EA3", "#E64345", "#60CEED", "#9CF168", "#F7EA4A", "#FBC543", "#FFC9ED", "#E6696E", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#e6f598", "#abdda4", "#66c2a5", "#3288bd", "#5e4fa2" ]; var googleColorSet = [ // google colors "#3366CC", "#DC3912", "#FF9900", "#109618", "#990099", "#3B3EAC", "#0099C6", "#DD4477", "#66AA00", "#B82E2E", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#8B0707", "#329262", "#5574A6", "#3B3EAC", "#b77322", "#16d620", "#b91383", "#f4359e", "#9c5935", "#a9c413", "#2a778d", "#668d1c", "#bea413", "#0c5922", "#743411", ]; function setupColorSets() { //https://canvasjs.com/docs/charts/chart-options/colorset/ CanvasJS.addColorSet("greenShades", [//colorSet Array "#2F4F4F", "#008080", "#2E8B57", "#3CB371", "#90EE90" ]); var arr = googleColorSet.concat(peterColorSet); //arr.push(arr.shift()); //move first to last , just to change colors up (add option later) //arr.splice(5,0,arr.shift()); //move first to 5th spot , just to change //arr.sort(() => Math.random() - 0.5); // quick shuffle routine - to change color layout CanvasJS.addColorSet("customColorSet1", arr ); CanvasJS.addColorSet("currentColorSet1", currentColorSet ); //https://www.w3schools.com/w3css/w3css_color_ios.asp CanvasJS.addColorSet("priorityColorSet", [//colorSet Array "#ff3b30", //red "#ff9500", //orange "#ffcc00", //yellow "#8e8e93", //gray "#ceced2", //lightgray "#34AADC", //medblue "#4cd964", //green "#5856d6", //purple "#007AFF", //blue "#5AC8FA", //lightblue "#FAA586", //beige-pink "#EB8CC6", //lightpurple "#ff2d55", // pink ]); } function enableCanvasFitOptions( canvasChart ) { //// export options //var toolBar = document.getElementsByClassName("canvasjs-chart-toolbar")[0]; var toolBar = canvasChart._toolBar; if(canvasChart.get("exportEnabled")){ // button for adding to dashboard var addToDash = document.createElement('div'); var addText = document.createTextNode("Add To Dash"); addToDash.setAttribute("style", "padding: 12px 8px; background-color: white; color: black") addToDash.appendChild(addText); addToDash.addEventListener("click", function(){ //var type = canvasChart.options.fitInfo.componentName; //alert("add "+type+" to dashboard"); var queryStr = $.param(canvasChart.options.fitInfo); document.location="&mainMenuFunctionSelect=dashboardCanvasComp&page=com.other.MenuRedirect&"+queryStr; //alert("&mainMenuFunctionSelect=dashboardCanvasComp&page=com.other.MenuRedirect&"+queryStr); }); addToDash.addEventListener("mouseover", function(){ addToDash.setAttribute("style", "padding: 12px 8px; background-color: #2196F3; color: white") }); addToDash.addEventListener("mouseout", function(){ addToDash.setAttribute("style", "padding: 12px 8px; background-color: white; color: black") }); toolBar.lastChild.appendChild(addToDash); // button for exporting chart data to CSV var exportCSV = document.createElement('div'); var text = document.createTextNode("Save as CSV"); exportCSV.setAttribute("style", "padding: 12px 8px; background-color: white; color: black") exportCSV.appendChild(text); exportCSV.addEventListener("mouseover", function(){ exportCSV.setAttribute("style", "padding: 12px 8px; background-color: #2196F3; color: white") }); exportCSV.addEventListener("mouseout", function(){ exportCSV.setAttribute("style", "padding: 12px 8px; background-color: white; color: black") }); exportCSV.addEventListener("click", function(){ downloadCSV({ filename: "chart-data.csv", chart: canvasChart }) }); //toolBar.lastChild.appendChild(exportCSV); } else { var exportCSV = document.createElement('button'); var text = document.createTextNode("Save as CSV"); exportCSV.appendChild(text); exportCSV.addEventListener("click", function(){ downloadCSV({ filename: "chart-data.csv", chart: canvasChart }) }); //document.body.appendChild(exportCSV) } function convertChartDataToCSV(args) { var result, ctr, keys, columnDelimiter, lineDelimiter, data; data = args.data || null; if (data == null || !data.length) { return null; } columnDelimiter = args.columnDelimiter || ','; lineDelimiter = args.lineDelimiter || '\n'; keys = Object.keys(data[0]); result = ''; result += keys.join(columnDelimiter); result += lineDelimiter; data.forEach(function(item) { ctr = 0; keys.forEach(function(key) { if (ctr > 0) result += columnDelimiter; result += item[key]; ctr++; }); result += lineDelimiter; }); return result; } function downloadCSV(args) { var data, filename, link; var csv = ""; for(var i = 0; i < args.chart.options.data.length; i++){ csv += convertChartDataToCSV({ data: args.chart.options.data[i].dataPoints }); } if (csv == null) return; filename = args.filename || 'chart-data.csv'; if (!csv.match(/^data:text\/csv/i)) { csv = 'data:text/csv;charset=utf-8,' + csv; } data = encodeURI(csv); link = document.createElement('a'); link.setAttribute('href', data); link.setAttribute('download', filename); document.body.appendChild(link); // Required for FF link.click(); document.body.removeChild(link); } } function showDocusignEnvelope(event) { var eid = jQuery("#mSubject").text(); var url = "?page=com.other.docusign.DocusignGetEnvelope&envelopeId="+eid; open(url, "_blank"); } //function populateDocusignIframe(iframe, url, headers) { function populateDocusignIframe() { var iframe = jQuery("#docusignIframe"); if (iframe.length) { return; } var xhr = new XMLHttpRequest(); xhr.open('GET', "?page=com.other.docusign.DocusignEmbedUi"); xhr.onreadystatechange = handler; xhr.responseType = 'text'; //headers.forEach(function(header) { // xhr.setRequestHeader(header[0], header[1]); //}); xhr.send(); function handler() { if (this.readyState === this.DONE) { if (this.status === 200) { // this.response is a Blob, because we set responseType above var url = "https://www.youtube.com/embed/zoMYU_nOGNg?rel=0&showinfo=0&enablejsapi=1"; //var url = this.response; jQuery('

').insertAfter(jQuery("#mainMenuHeaderDiv")); console.log(this.response); jQuery("#docusignIframe").attr("src",url); //document.location = url; } else { console.error('XHR failed', this); } } } //https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/embedding/#docusign-js }