/******************************************************* * JavaScript Name = js_global * $Description: used in all pages * $CreatedBy: Jake Howlett * $CreatedOn: 18/09/2001 * $UpdatedBy: * $UpdatedOn: *******************************************************/ function doLogin() { s = document.location.search; //Check '&Login' not already in URL! if (s.toLowerCase().indexOf("&login") == -1 ) { //Check that there is a '?Open' part to append to a = (s=="") ? "?Open&Login" : "&Login"; document.location.href += a; } } /**** doDelete is used to delete a document from the server The user is first asked to confirm that this is what they want to do. Giving them the chance to cancel the action. This works SIMPLY by changing the end of the URL from "?OpenDocument" to "?DeleteDocument" Arguments____ navTo - Where to redirect the browser [Optional, null if none] msg - The prompt to include in the message box [Optional] ****/ function doDelete(navTo, msg) { //has the confirm box message been passed in? msg = (msg == null || msg == '') ? 'Are you sure you want to delete this document?' : msg; //do they want go somewhere afterward navTo = (navTo == null || navTo == '') ? '' : '&NavTo=' + navTo; if ( confirm( msg ) ){ location.search = "?DeleteDocument" + navTo; } } /**** openDBRelativeURL is used to open relative URLs Given the string of the URL that needs opening, this function will open it relative to the directory and file name of the database. Arguments____ url - Database design element you want to open [Required] target - The object reference to the frame to use [Optional] ****/ function openDBRelativeURL( url, target ){ //Check we have a target window; target = (target == null ) ? window : target; //Work out the path of the database; var p = location.pathname; path = p.slice( 1, p.toLowerCase().lastIndexOf('.nsf')+4) + '/'; target.location.href = path + url; } /**** trim & fullTrim Simple functions to remove leading/trailing spaces Arguments____ aStr - Any string object [Required] ****/ function trim(aStr) { return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "") } function fullTrim(aStr) { return trim(aStr.replace(/\s{2,}/g, " ")) } /*doSearch is called from the button below simple query box on all forms */ function doSearch ( s ) { var regExp1 = /\bfield\b/i; //used to test for reserved word field in query string var regExp2 = /[(,),<,>,\[,\]]/; //used to test for reserved char(s) in the query string var str = s.value; if ( str == "" ){ alert("Please be sure to enter something to search for."); s.focus(); return false; } else { if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing if ( regExp1.test( str ) || regExp2.test( str ) ){ var alrt = "Please note that you can not include:"; alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >"; alrt += "\n\nin your search query!\n\nIf you are confident that you know"; alrt += "\nwhat you are doing, then you can\nmanually produce the URL required." alert( alrt ); s.focus(); return false; } //path = location.pathname.slice( 1, location.pathname.toLowerCase().lastIndexOf('.nsf')+4) + '/'; //location.href = "/" + path + "vwSCH?SearchView&Query=" + escape( str ) + "&start=1&count=10"; window.location="/index.nsf/vwSCH?SearchView&Query=" + escape(str) + "&start=1&count=10"; } }