function ExecuteFunction(functionName, executionContext /*, args */) { var args = Array.prototype.slice.call(arguments, 2); var namespaces = functionName.split("."); var func = namespaces.pop(); for (var i = 0; i < namespaces.length; i++) { executionContext = executionContext[namespaces[i]]; } return executionContext[func].apply(executionContext, args); }; String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }; String.prototype.replaceAll = function(find_string, substitute_string) { return this.replace(new RegExp(find_string, 'g'), substitute_string); }; String.prototype.ltrim = function() { return this.replace(/^\s+/, ''); }; String.prototype.rtrim = function() { var str = this, ws = /\s/, i = str.length; while (ws.test(str.charAt(--i))); return str.slice(0, i + 1); }; String.prototype.trim = function() { var str = this.replace(/^\s\s*/, ''), ws = /\s/, i = str.length; while (ws.test(str.charAt(--i))); return str.slice(0, i + 1); }; String.prototype.startsWith = function(prefix) { return this.indexOf(prefix) == 0; }; String.prototype.endsWith = function(suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; }; function ajax(url, data, success, e, ka) { $.ajax({ type: "POST", url: url, data: data, contentType: "application/json; charset=utf-8", dataType: "json", success: success, error: e }); if (ka != false) { var keepAlive = $('
'); var dt = new Date(); url = '/BIW/Framework/KeepSessionAlive.aspx?t=' + dt.getTime(); keepAlive.load(url, function() { keepAlive.remove(); }); } }; var ajaxCache = function(urlArg, dataArg, onSuccess, onError, cache) { if (cache == true) { var output = $.data(document, urlArg + dataArg); if (output != null && output.expiry > new Date()) { onSuccess(output); //should we poke the webservice? - keep the session ticking over? return; } else { $.data(document, urlArg + dataArg, null); } } $.ajax({ type: "POST", url: urlArg, data: dataArg, contentType: "application/json; charset=utf-8", dataType: "json", success: function(output) { if (cache) { var expiry = new Date(); expiry.setMinutes(expiry.getMinutes() + 15); output.expiry = expiry; $.data(document, urlArg + dataArg, output); onSuccess(output); } else { onSuccess(output); } }, error: onError }); }; (function($) { $.fn.outerHTML = function() { return $(this).clone().wrap('').parent().html(); } })(jQuery); var block = function(element) { if (element == null || element == undefined) { $.blockUI({ message: '', css: { backgroundColor: "Transparent", border: "0" } }); } else { $(element).block({ message: '', css: { backgroundColor: "Transparent", border: "0" } }); } }; var unblock = function(element) { if (element == null || element == undefined) { $.unblockUI(); } else { $(element).unblock(); } }; var getOptions = function(param, url, control, addEmpty, callBackFunc, blockControl) { if (blockControl != false) { $(control).parent().block({ message: '', css: { backgroundColor: "Transparent", border: "0" } }); } $(control).empty(); callAjax(url, param == null ? "{}" : JSON.stringify(param), function(output) { var options = makeOptions(output.d); if (addEmpty) { $(control).append(''); } if ($(control).attr('multiple') != true && $(control).attr('size') == 0) $(control).append(""); for (var i = 0; i < options.length; i++) $(control).append(options[i]); if (callBackFunc != null) { if ($.isFunction(callBackFunc)) { callBackFunc.call(this); } } $(control).parent().unblock(); }, function(jqXHR, textStatus, errorThrown) { handleError(jqXHR, textStatus, errorThrown); $(control).parent().unblock(); }); }; var makeOption = function(describableBase) { var option = $(''); $(option).attr('data-id', describableBase.ID); $(option).val(describableBase.ID); $(option).text(describableBase.Name); $(option).attr('title', describableBase.Description); return $(option); }; var makeOptions = function(describableBaseArray) { var options = new Array(); for (var i = 0; i < describableBaseArray.length; i++) { var option = makeOption(describableBaseArray[i]); options[i] = option; } return options; }; var setCookie = function(c_name, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); document.cookie = c_name + "=" + c_value; }; var getCookie = function(c_name) { var i, x, y, ARRcookies = document.cookie.split(";"); for (i = 0; i < ARRcookies.length; i++) { x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); x = x.replace(/^\s+|\s+$/g, ""); if (x == c_name) { return unescape(y); } } };