// JavaScript Document // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function tabOver(obj) { if( obj.className != "currentTab") { obj.className = "hoverTab"; } } function tabOut(obj) { if( obj.className != "currentTab") { obj.className = "normalTab"; } } /* PURPOSE - to take the user back one screen */ function Back() { window.history.go( - 1) } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function ButtonOut(obj) { obj.style.background = document.forms[0].Buttonnorm.value; ; } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function ButtonOver(obj) { obj.style.background = document.forms[0].Buttonover.value; } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to tell the user that they must save any changes to the WO prior to changing the Property and give them a chance to get out */ function ChangePropWarn() { var tester = confirm("Please save any changes made to the Work Order before changing the Property. Click OK to continue with the Property Change or CANCEL to return to the Work Order to save your changes."); if(tester) { window.ChangeProp.PromptProp(); } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to close the current document which is in edit mode */ function Close() { // Prompt user to save changes. yesno = confirm("Do you want to save the document? \nClick OK to save\n or Cancel to Continue without saving."); if( yesno) { // if yes, call the save and close SaveandClose(); } else { if( window.opener | parent.window.name == "_new" | parent.name == "_new" | parent.name == "New") { parent.window.close(); } else { window.open("/" + document.forms[0].filepath.value + "/Web View?OpenForm&" + document.forms[0].ReturnView.value, '_top' ); } } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function Close2() { if (window.opener | parent.name == "_new") { self.close(); } else { window.history.back(); } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function Close3() { if( window.opener | parent.window.name == "_new" | parent.name == "_new" | parent.name == "New") { parent.window.close(); } else { window.open("/" + document.forms[0].filepath.value + "/Web View?OpenForm&" + document.forms[0].ReturnView.value, '_top' ) } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - Used for WO's - the WO form launches in a frameset and therefore the Close3() causes a double navigator to appear */ function Close4() { if( window.opener | parent.window.name == "_new" | parent.name == "_new" | parent.name == "New") { parent.window.close(); } else { window.open("/" + document.forms[0].filepath.value + "/Web View?OpenForm&" + document.forms[0].ReturnView.value, '_top' ) } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open a new document in a new window - includes the UNID of the parent to create a child document INPUT - the formname to open - the form using this function needs to have the RepID field defined */ function CreateChild(what, UNID) { var f = document.forms[0]; window.open('/' + f.value + '/' + what + '?OpenForm&ParentUNID=' + UNID, '_new' , 'status=yes, resizable=yes, toolbars=no, scrollbars=yes, width=750, height=600, position=absolute, left=40, top=40'); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - To open a new window to create a new document INPUT - the formname to open - the form using this function needs to have the RepID field defined */ function CreateNew(what) { var f = document.forms[0]; window.open('/' + f.RepID.value + '/' + what + '?OpenForm', '_new' , 'status=yes, resizable=yes, toolbars=no, scrollbars=yes, width=650, height=400, position=absolute, left=40, top=40'); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open the selected Crystal Report THIS IS NO LONGER USED - just scared to remove the code in case we need it later. */ function CrystalPick(RepID, Index) { var Report = document.forms[0].CrystalPick.options[Index].text if (Report == "All Databases") { window.open("/" + RepID + "/All+Reports?OpenForm" , "_rpt" , "status=yes,resizable=yes, toolbars=no, scrollbars=yes,width=650,height=400, position=absolute, left=40, top=40"); } else { document.forms[0].ViewTitleToSend.value = "ByDatabaseWeb"; document.forms[0].CategoryToSend.value = Report; document.forms[0].LabelToSend.value = "Reports for " + Report; window.open("/" + RepID + "/ViewOneCategory?OpenForm" , "_rpt" , "status=yes,resizable=yes, toolbars=no, scrollbars=yes,width=650,height=400, position=absolute, left=40, top=40"); } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function DeleteThisDoc(repid, unid) { window.open("/" + repid + "/(WebDeleteThisDoc)?OpenAgent&" + unid , "_new" , "toolbars=no, height=300, width=300"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to be used in the HREF for links where the action needs to run in the onClick (more code than can be called in the HREF. */ function doNothing() { } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to Open the current document in Edit Mode INPUT - ReplicaID of the DB used and the doc's universalid */ function Edit(RepID, UNID) { window.open("/" + RepID + "/0/" + UNID + "?EditDocument" , "_top"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function Filedropout(obj) { obj.style.color = 'black'; obj.style.background = 'EFEFEF'; } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function Filedropover(obj) { obj.style.color = 'black'; obj.style.background = '#96B877'; } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to format the number provided to include commas */ function formatNumber(nums) { comp = new String(nums) if( comp.length > 3) { backthree = comp.substring(comp.length - 3 , comp.length); front = new String(comp.substring(0 , comp.length - 3)); if( front.length > 3) { temp = front.substring(front.length - 3 , front.length); front2 = front.substring(0 , front.length - 3); front = front2 + "," + temp; } comp = front + "," + backthree; } return comp } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open the Help document in a new window INPUT - the URL to the Help document */ function Help2(page) { window.open(page, '_help' , 'scrollbars=yes, resizable=yes, width=650, height=400, position=absolute, left=50, top=50') } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to take the value sent and convert it to a money format INPUT - the value to be converted */ function isMoney(thenumber) { var newNum = "" + thenumber ; var theLength = newNum.length; var theDecLoc = newNum.lastIndexOf("."); // Used to find the decimal point neg = false; if( theDecLoc == - 1) { // no decimal var temp = new String(newNum); var temp2 = temp.split("-"); // check to see if negative number if (temp2.length > 1) { newNum = temp2[1]; neg = true; // flag as negative number } // parse to enter the commas 100, 000, 000 if( newNum.length > 3) { // work from the back backthree = newNum.substring(newNum.length - 3 , newNum.length); front = newNum.substring(0 , newNum.length - 3); if( front.length > 3) { temp = front.substring(front.length - 3 , front.length); front2 = front.substring(0 , front.length - 3); front = front2 + "," + temp; } newNum = front + "," + backthree + ".00"; } else { newNum = newNum + ".00"; } if( neg) { // negative number return "$ -" + newNum; } else { return "$ " + newNum; } } // end of no decimal if( theDecLoc != - 1) { // Is a decimal - parse into dollars and cents var theDollars = newNum.substring(0 , theDecLoc) ; var temp = new String(theDollars); var temp2 = temp.split("-"); // Check for negative if (temp2.length > 1) { theDollars = temp2[1]; neg = true; } if( theDollars.length > 3) { backthree = theDollars.substring(theDollars.length - 3 , theDollars.length); front = theDollars.substring(0 , theDollars.length - 3); if( front.length > 3) { temp = front.substring(front.length - 3 , front.length); front2 = front.substring(0 , front.length - 3); front = front2 + "," + temp; } theDollars = front + "," + backthree; } // Figuring out the cents portion and making sure it is 2 decimals var theCents = newNum.substring( theDecLoc, theLength); var theCents = "" + Math.round(theCents * 100); var newCents = (theCents.length == 1) ? "0" + theCents : theCents; newNum = theDollars + "." + newCents; if( neg) { return "$ -" + newNum; } else { return "$" + newNum; } } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - tests to see if the opener or parent.opener of the window is within same database or an external launch window if it is a launcher returns value of 1 to tell Close() function to return to previous view not close window. */ function Launcher(where) { var bingo = where.location.pathname.split("/") var dingo = document.location.pathname.split("/") if (bingo[1] == dingo[1]) { return "no" } else { return "yes" } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function Login() { var f = document.forms[0]; window.open("/" + f.filepath.value + "?Logout&redirectTo=/" + f.filepath.value + "?OpenDatabase&login" , "_top"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to take a string and convert it to a number - strip off the $ is there is one INPUT - the string to convert */ function isNumber(val) { var tester = new String(MakeNumber(val)); if(tester == "NaN") { return false; } else { return true; } } function MakeNumber(nums) { var comp = new String(nums); var comp2 = comp.split("$"); // Look for any $ in the string if( comp2.length > 1) { comp = new String(comp2[1]); } comp4 = comp.split(","); var temp4 = ""; for ( i = 0 ; i < comp4.length + 1 ; i ++ ) { temp4 = temp4 + comp4[i]; } return parseFloat(temp4); // return the number } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function MouseOut(div, obj) { if( window[div].style.display == "") { } else { obj.style.background = document.forms[0].TabNorm.value; } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function MouseOver(div, obj) { if( window[div].style.display == "") { } else { obj.style.background = document.forms[0].TabHover.value; } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function onBlurField(obj) { obj.style.background = 'white'; } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function onFocusField(obj) { obj.style.background = 'EFEFEF'; } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function OpenAbout() { window.open("/?OpenAbout", "_new" , "width=400, height=400, toolbars=no"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function OpenBrowser() { window.open("//Browser+Settings?OpenPage", "_new" , "width=400, height=400, toolbars=no, scrollbars=yes"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open a new document where it replaces the current screen - current frame INPUT - the formname to open - the form using this function needs to have the RepID field defined */ function OpenForm(what) { var f = document.forms[0]; window.open('/' + f.RepID.value + '/' + what + '?OpenForm', '_self' , 'status=yes, resizable=yes, toolbars=no, scrollbars=yes, width=650, height=400, position=absolute, left=40, top=40'); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open a new document where it replaces the current screen - all frames INPUT - the formname to open - the form using this function needs to have the RepID field defined */ function OpenFull(what) { var f = document.forms[0]; window.open('/' + f.RepID.value + '/' + what + '?OpenForm', '_top' , 'status=yes, resizable=yes, toolbars=no, scrollbars=yes, width=650, height=400, position=absolute, left=40, top=40'); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function PicOut(picname) { if(document[picname].style.borderBottom == 'black 1px solid') { document[picname].src = '/medtabgrey.jpg'; } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function PicOutSm(picname) { if(document[picname].style.borderBottom == 'black 1px solid') { document[picname].src = '/' + document.forms[0].SysPrefRepID.value + '/smtabgrey.jpg'; } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function PicOver(picname) { if(document[picname].style.borderBottom == 'black 1px solid') { document[picname].src = '/medtabgold.jpg'; } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function PicOverSm(picname) { if(document[picname].style.borderBottom == 'black 1px solid') { document[picname].src = '/' + document.forms[0].SysPrefRepID.value + '/smtabgold.jpg'; } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to remove a substring from the master */ function RemoveSubstring( master, sub) { var newone = new String var NewArray = master.split("~") if( master == sub) { newone = "" } else { var i = 0; while ( ( sub != NewArray[i] ) & ( NewArray.length > i ) ) { i ++ } if ( i == NewArray.length ) i = - 1 if ( i > - 1) { var x = 0 for (x = 0 ; x < NewArray.length ; x ++ ) { if ( x != i) if (newone == "" ) newone = NewArray[x] else newone += "~" + NewArray[x] } } else { newone = master } } return newone } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - for closing forms back to previous view user was in. Need a ReturnView field on form. */ function ReturnView() { window.open("/" + document.forms[0].filepath.value + "/Web View?OpenForm&" + document.forms[0].ReturnView.value, '_top' ); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to call a submit from the current document */ function Save() { var f = document.forms[0]; // Check to see if the user isn't logged in - if not logged in, redirect to a login screen if( document.forms[0].Username.value == "Anonymous") { alert("Your session has expired. Please log back into the OnCite system."); window.open("/" + f.filepath.value + "?Logout&redirectTo=/" + f.filepath.value+ "?OpenDatabase&login" , "_top"); } else { document.forms[0].CloseSave.value = ""; ValidateFields(); } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to call a submit for the current document and then close the document, returning to the view */ function SaveandClose() { var f = document.forms[0]; // Check to see if the user isn't logged in - if not logged in, redirect to a login screen if( document.forms[0].Username.value == "Anonymous") { alert("Your session has expired. Please log back into the OnCite system."); window.open("/" + f.filepath.value + "?Logout&redirectTo=/" + f.filepath.value+ "?OpenDatabase&login" , "_top"); } else { // Check to see if the current window is in a frame titled "_new" - this means that the window itself needs to be closed // otherwise, exit back to the last view if( window.opener | parent.name == "_new" | parent.name == "New" | parent.name == "New2" | document.forms[0].UNID.value == parent.name) { f.CloseSave.value = ""; } else { // The last view is defined in the ReturnView field. The CloseSave Field is used by the $$Return field when recalculated f.CloseSave.value = "[/" + f.filepath.value + "/Web View?OpenForm&" + f.ReturnView.value + "]"; } ValidateFields(); } } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ function ShowGuide(guidename) { window.open("//" + guidename + "?OpenPage" , "_guide", "width=800, height=600, scrollbars=yes, resizable"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to Open a Support Document in a new window. This is called from forms only, not any views. INPUT - uses the window.title, the field Formname and generates the path. This calls an agent which then creates the document in the Support DB */ function Support() { var newpath = window.location.href; var passedata = ("&view=None&win=" + window.document.title + "&form=" + document.forms[0].Formname.value + "&url=" + newpath); var newHttp = "/" + document.forms[0].filepath.value + "/(ProcessHelp)?OpenAgent&" + passedata; window.open(newHttp, 'Request', 'status=yes, resizable=yes, scrollbars=yes, width=650, height=400, position=absolute, left=50, top=50') } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to Open a Support Document in a new window. This is called from views only - not forms INPUT - uses the window.title, the field Formname and generates the path. This calls an agent which then creates the document in the Support DB */ function Support2() { var f = document.forms['View']; var newpath = window.location.href; var passedata = ("&view=" + f.ViewTitle.value + "&win=" + window.document.title + "&form=" + f.Formname.value + "&url=" + newpath); var newHttp = "/" + f.filepath.value + "/(ProcessHelp)?OpenAgent&" + passedata; window.open(newHttp, 'Request', 'status=yes, resizable=yes, scrollbars=yes, width=650, height=400, position=absolute, left=50, top=50') } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* * PURPOSE - to return a clean string - remove the extra spaces and the # character Returns a trimmed up name with no ending space */ function TrimText(master) { if( master.length > 0 ) { while(master.indexOf("#") != - 1) { master = master.replace("#" , " "); } while(master.indexOf(" ") != - 1) { master = master.replace(" " , " "); } var len = master.length; while (master.lastIndexOf(" ") == (len - 1)) { master = master.substring(0 , (len - 1)); len = master.length; } } return master } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open the related Property Profile (from current document) in a new window for viewing INPUT - the ReplicaID for the Property Profiles Module and the PropertyDocID */ function ViewPropProfile(RepID, PropID) { window.open("/" + RepID + "/(PropProfiles)/" + PropID + "?OpenDocument" , "_new" , "status=yes,resizable=yes,scrollbars=yes,width=650,height=400, position=absolute, left=40, top=40"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open a new window that displays a one category view - typically called from within a document to see related documents, such as in the Property Profile - menu option - View - Work Orders INPUT - The title to display in the new window, the category for the view, the label for the view and the DB ReplicaID needed */ function ViewWindow(Title, Category, Label, DB) { document.forms[0].ViewTitleToSend.value = Title; document.forms[0].CategoryToSend.value = Category; document.forms[0].LabelToSend.value = Label; window.open('/' + DB + '/ViewOneCategory?OpenForm' , '_new', 'toolbars=no, status=yes,resizable=yes,scrollbars=yes, width=650, height=400, position=absolute, left=40, top=40'); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* PURPOSE - to open a new window that displays a one category view - typically called from within a document to see related documents called from the $$ViewTemplateDefault - that's why the form is ['View'] The $$ViewTemplateDefault form has extra < FORM > 's which cause the forms[0]. to not work for retrieving values from specific fields INPUT - The title to display in the new window, the category for the view, the label for the view and the DB ReplicaID needed */ function ViewWindow2(Title, Category, Label, DB) { document.forms['View'].ViewTitleToSend.value = Title; document.forms['View'].CategoryToSend.value = Category; document.forms['View'].LabelToSend.value = Label; window.open('/' + DB + '/ViewOneCategory?OpenForm' , '_new', 'toolbars=no, status=yes,resizable=yes,scrollbars=yes, width=650, height=400, position=absolute, left=40, top=40'); }