/* * interface_utilities.js * * Used By: * Everything :) * * Responsibilities: * Re-usable DOM feedback, logout function * * Dependencies: jQuery (1.3+) * * - - - - - - - - - - - - - - - - - - - - - */ // Array Remove - By John Resig (MIT Licensed) Array.prototype.remove = function(from, to) { var rest = this.slice((to || from) + 1 || this.length); this.length = from < 0 ? this.length + from : from; return this.push.apply(this, rest); }; Array.prototype.unique = function () { var r = new Array(); o:for(var i = 0, n = this.length; i < n; i++) { for(var x = 0, y = r.length; x < y; x++) { if(r[x]==this[i]) { continue o; } } r[r.length] = this[i]; } return r; } // function isArray(obj) { // if (undefined != obj.length) // return true // else // return false; // } function isArray(thisObj) { if (thisObj.constructor.toString().indexOf("Array") == -1) return false; else return true; } // ========================================================================== // Fuctions to mimic LTrim, RTrim, and Trim... // Author Aurélien Tisné (CS) // Date 03 avr. 2003 23:11:39 // Last Update $Date$ // Version $Revision$ // ========================================================================== // -------------------------------------------------------------------------- // Remove leading blanks from our string. // I str - the string we want to LTrim // Return the input string without any leading whitespace // Date 03 avr. 2003 23:12:13 // Author Aurélien Tisné (CS) // -------------------------------------------------------------------------- function LTrim(str) { var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(0)) != -1) { // We have a string with leading blank(s)... var j=0, i = s.length; // Iterate from the far left of string until we // do not have any more whitespace... while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++; // Get the substring from the first non-whitespace // character to the end of the string... s = s.substring(j, i); } return s; } // -------------------------------------------------------------------------- // Remove trailing blanks from our string. // I str - the string we want to RTrim // Return the input string without any trailing whitespace // Date 03 avr. 2003 23:13:50 // Author Aurélien Tisné (CS) // -------------------------------------------------------------------------- function RTrim(str) { // We do not want to trip JUST spaces, but also tabs, // line feeds, etc. Add anything else you want to // "trim" here in Whitespace var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length-1)) != -1) { // We have a string with trailing blank(s)... var i = s.length - 1; // Get length of string // Iterate from the far right of string until we // dont have any more whitespace... while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--; // Get the substring from the front of the string to // where the last non-whitespace character is... s = s.substring(0, i+1); } return s; } // -------------------------------------------------------------------------- // Remove trailing and leading blanks from our string. // I str - the string we want to Trim // Return the trimmed input string // Date 03 avr. 2003 23:15:09 // Author Aurélien Tisné (CS) // -------------------------------------------------------------------------- function Trim(str) { return RTrim(LTrim(str)); } function alphanumeric(alphane) { var numaric = alphane; for(var j=0; j 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123)) { } else { return false; } if( hh == 32 ) return false; } return true; } // -------------------------------------------------------------------------- // Custom jQuery Column Sorting. Bind this to a div, to sort a corresponding column. // Return 0 , or 1 depending on toggle. // -------------------------------------------------------------------------- function sort_column(column,direction,div,table) { //$("table .sort_icon").each(function(index){ $(this).attr("src","/style/images/bg.gif"); }); $(table).trigger("update"); $(table).trigger("refresh"); var sorting = [[column,direction]]; $(table).trigger("sorton",[sorting]); restripe() if(direction == 1) { $(div).find(".sort_icon").attr("src","/style/images/asc.gif"); return 0 } else { $(div).find(".sort_icon").attr("src","/style/images/desc.gif"); return 1 } } function impromptu_toggleError(self) { var display = $(".cleanblue").css("display"); if (display == "none") { $(".placeholder").slideDown(); $(".cleanblue").slideDown(); $(".cleanblue").css("display","block"); $(".cleanblue").css("display","block"); $(".error_expandicon").attr("src", "/style/images/icons/icon_collapse_15px.png") } else { $(".placeholder").slideUp(); $(".cleanblue").slideUp(); $(".placeholder").css("display","none"); $(".cleanblue").css("display","block"); $(".error_expandicon").attr("src", "/style/images/icons/icon_expand_15px.png") } } function catError(msg) { if (msg == "") msg = "No response from ConfigEngine. Try restarting GroupWise Mobility Services." else if (msg == 'Error: Please verify that the Connector Manager is running and that the connectors.xml is correctly configured.') msg = "Error: Please verify that the Connector Manager is running and that the connectors.xml is correctly configured." return "
Show Details"; } function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } function searchText(jQuerySelector,fieldText) { var myVal = $(jQuerySelector).val(); if (myVal == "") { $(jQuerySelector).val(fieldText) } $(jQuerySelector).focus(function() { if ($(jQuerySelector).val() == fieldText) $(jQuerySelector).val(""); }).blur(function() { if ($(jQuerySelector).val() == "") $(jQuerySelector).val(fieldText); }); } function startButtonAnimation(id,text) { $("#" + id +"_button").hide(); $("#" + id +"_text").removeClass("response"); $("#" + id +"_text").addClass("status"); $("#" + id +"_text").text(text); $("#" + id +"_text").show(); $("#" + id +"_animation").show(); } function stopButtonAnimation(id,text) { setTimeout( function(){ $("#" + id +"_animation").hide(); $("#" + id +"_text").removeClass("status"); $("#" + id +"_text").addClass("response"); $("#" + id +"_text").text(text); setTimeout( function() { $("#" + id +"_text").hide() $("#" + id +"_text").removeClass("response*"); $("#" + id +"_text").addClass("status"); $("#" + id +"_animation").hide(); $("#" + id +"_button").fadeIn("fast"); }, 2000); }, 350); } // Restripes tables, this is called on any table sort event. function restripe(){ $(".stripeMe tr").removeClass("stripe") $(".stripeMe tr:even").addClass("stripe") } function utility_isalive(){ $("img, input, a").click(function(){ $.post("/post/utility", {"func": "alive"}, function(data){ if (data == "False") { var url = "https://" + window.location.hostname + ":" + document.location.port; self.location=url } }) }); } var stick = 0; // Tooltip Utilities $(document).bind('click', function(e) { var $clicked=$(e.target); // get the element clicked if($clicked.is('.tooltip_container_R') || $clicked.is('.help_icon') || $clicked.parents().is('.tooltip_container_R')) { console.log("Clicked a tooltip"); } else { $('.tooltip_container_R').hide(); stick = 0; } }); // jQuery Global Onload $(document).ready(function(){ restripe() // logout bind $("#logout").click(function(){ $.post("/post/auth", {"func" : "logout"}, function(data) { var url = "https://" + window.location.hostname + ":" + document.location.port; self.location=url }); }); $(".error_showdetails").live("click", function(){impromptu_toggleError($(this))}); $(".help_icon").click(function(){ if (stick == 0) { showSticky(this) stick = 1; // disables the on mouse out event in the hover. } else { stick = 0 // hides, on mouse click of help icon. $(".tooltip").remove(); } }); $(".help_icon").hover(function(){ showSticky(this) }, function() { if (stick == 1) return; $(".tooltip_container_R").remove(); } ) }); function showSticky(sticky) { $(".tooltip_container_R").remove(); var content = $(sticky).position(); var leftAlign = content.left + 40; var tooltipText = $(sticky).attr("title"); if (tooltipText != "") { $(sticky).attr("helpTitle", tooltipText) $(sticky).attr("title","") }; tooltipText = $(sticky).attr("helpTitle"); var string = '
\
\
'+tooltipText+'
\
\ '+tooltipText+'\
\
\
\
'; $(sticky).parent().append(string); var divSize = $(".tooltip_top").height() / 2; var divSizeAdjust = 8; var topAlign = (content.top - divSize) + divSizeAdjust; $("#trashTip").css("top",topAlign) $(".tooltip_pointer").css("top",divSize - 8) } function validateResponse(response){ if (response == "Not Authorized") { var url = "https://" + window.location.hostname + ":" + document.location.port; self.location=url } }