// show/hide the specified element function showHideElement(id) { if ($('#' + id + 'C').is(':visible')) { $('#' + id + 'E').show(); $('#' + id + 'C').hide(); $('#' + id).hide(); } else { $('#' + id + 'E').hide(); $('#' + id + 'C').show(); $('#' + id).show(); } } // show/hide all the elements stored in the array function showHideAllElement(array) { $.each(array, function(key, value) { showHideElement(value); }); } // add/remove the specified element function addRemoveElement(id, array) { var index = $.inArray(id, array); if (index == -1) { array.push(id); } else { array.splice(index, 1); } } // cancel the parent action // this function cancel the showHideElement function when you click on a link function cancelBubble() { //parent.event.cancelBubble = true; } //this functions allows us to reference dynamically via javascript a CSS file into the page DOM. function loadCSS(css_url) { //check if the css url already exist in the page dom if ($("link[href=\"" + css_url + "\"]").length < 1) { //for some reason, using jQuery to create/insert link tag into the dom crashes IE7... therefore we do it in the classic way var head = document.getElementsByTagName('head')[0]; var css = document.createElement('link'); css.setAttribute('href', css_url); css.setAttribute('type', 'text/css'); css.setAttribute('media', 'screen, projection'); css.setAttribute('rel', 'stylesheet'); head.appendChild(css); } } (function ($) { $.fn.AmadCsp = function (options) { $.fn.Csp.settings = $.extend({}, $.fn.Csp.defaults, options); return this; }; $.fn.AmadCsp.settings = {}; $.fn.AmadCsp.defaults = { }; // LZW algorithm from http://rosettacode.org/wiki/LZW_compression $.fn.AmadCsp.compress = function (uncompressed) { // Build the dictionary. var i, dictionary = {}, c, wc, w = "", result = [], dictSize = 256; for (i = 0; i < 256; i += 1) { dictionary[String.fromCharCode(i)] = i; } var length = uncompressed.length; for (i = 0; i < length; i += 1) { c = uncompressed.charAt(i); wc = w + c; if (dictionary.hasOwnProperty(wc)) { w = wc; } else { result.push(dictionary[w]); // Add wc to the dictionary. dictionary[wc] = dictSize++; w = String(c); } } // Output the code for w. if (w !== "") { result.push(dictionary[w]); } return result; }, $.fn.AmadCsp.decompress = function (compressed) { // Build the dictionary. var i, dictionary = [], w, result, k, entry = "", dictSize = 256; for (i = 0; i < 256; i += 1) { dictionary[i] = String.fromCharCode(i); } w = String.fromCharCode(compressed[0]); result = w; for (i = 1; i < compressed.length; i += 1) { k = compressed[i]; if (dictionary[k]) { entry = dictionary[k]; } else { if (k === dictSize) { entry = w + w.charAt(0); } else { return null; } } result += entry; // Add w+entry[0] to the dictionary. dictionary[dictSize++] = w + entry.charAt(0); w = entry; } return result; }, $.fn.AmadCsp.showDialog = function (idDialog, title, message) { var divDialog = $("#" + idDialog); divDialog.remove(); divDialog = $("
"); divDialog.text(message); $("body").append(divDialog); divDialog.dialog({ width: "auto", height: "auto" }); return this; }; $.fn.AmadCsp.showOkDialog = function(idDialog, title, message) { var divDialog = $("#" + idDialog); divDialog.remove(); divDialog = $("
"); divDialog.text(message); $("body").append(divDialog); divDialog.dialog( { width: "auto", height: "auto", buttons: [ { text: "OK", click: function() { $(this).dialog("close"); } } ] }); return this; }; $.fn.AmadCsp.showConfirmationDialog = function(idDialog, title, message, buttonOkText, buttonCancelText, okCallback) { var divDialog = $("#" + idDialog); divDialog.remove(); divDialog = $("
"); divDialog.text(message); $("body").append(divDialog); divDialog.dialog( { width: "auto", height: "auto", buttons: [ { text: buttonOkText, click: function() { okCallback(); $(this).dialog("close"); } }, { text: buttonCancelText, click: function() { $(this).dialog("close"); } } ] }); return this; }; $.fn.AmadCsp.showConfirmDialog = function(idCallBackButton, title, message) { var divDialog = $("#"+idCallBackButton+"Confirm"); divDialog.remove(); divDialog = $("
"); divDialog.text(message); $("body").append(divDialog); divDialog.dialog( { width: "auto", height: "auto", buttons: [{ text: "Yes", click: function() { var callBackButton = document.getElementById(idCallBackButton); $(callBackButton).after(''); $(callBackButton).click(); $( this ).dialog( "close" ); } }, { text: "No", click: function() { $( this ).dialog( "close" ); } }] }); return this; }; $.fn.AmadCsp.loadCSS = function (url) { if ($('link[href="' + url + '"]').length < 1) { //for some reason, using jQuery to create/insert link tag into the dom crashes IE7... therefore we do it in the classic way var head = document.getElementsByTagName('head')[0]; var css = document.createElement('link'); css.setAttribute('href', url); css.setAttribute('type', 'text/css'); css.setAttribute('media', 'screen, projection'); css.setAttribute('rel', 'stylesheet'); head.appendChild(css); } return this; }; })(jQuery); if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();