/* $Id$ */ /* part of pfSense All rights reserved. Pfsense snort GUI Copyright (C) 2008-2012 Robert Zelaya. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the pfSense nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ jQuery.noConflict(); //prepare the form when the DOM is ready jQuery(document).ready(function() { jQuery(".icon_click").live('mouseover', function() { jQuery(this).css('cursor', 'pointer'); }); //-------------------START Misc------------------------------------------- /*! Needs to be watched not my code <- IMPORTANT * JavaScript UUID Generator, v0.0.1 * * Copyright (c) 2009 Massimo Lombardo. * Dual licensed under the MIT and the GNU GPL licenses. */ function genUUID() { var uuid = (function () { var i, c = "89ab", u = []; for (i = 0; i < 36; i += 1) { u[i] = (Math.random() * 16 | 0).toString(16); } u[8] = u[13] = u[18] = u[23] = ""; u[14] = "4"; u[19] = c.charAt(Math.random() * 4 | 0); return u.join(""); })(); return { toString: function () { return uuid; }, valueOf: function () { return uuid; } }; } //-------------------START Misc GLOBAL WINDOW------------------------------------------- // NOTE: try not to add to manny of thses /* * Gives you even true or false on even numbers */ window.isEven = function(someNumber) { return (someNumber%2 == 0) ? true : false; }; /* * Loop through object with timeout. * NOTE: IE9 still has issues. Example : deleted rules (6000+ sigs). * Break up heavy javascript intensive processing into smaller parts. Used to stop "browser Stop responding" warnings. */ /* function processLoop( actionFunc, numTimes, numWait, doneFunc ) { var i = 0; var f = function () { if (i < numTimes) { actionFunc( i++ ); // closure on i setTimeout( f, numWait ); } else if (doneFunc) { doneFunc(); } }; f(); } */ window.incrementallyProcess = function(workerCallback, data, chunkSize, timeout, completionCallback) { var i = 0; (function() { var remainingDataLength = (data.length - i); var currentChunkSize = (remainingDataLength >= chunkSize) ? chunkSize : remainingDataLength; if(i < data.length) { while(currentChunkSize--) { workerCallback(i++); } setTimeout(arguments.callee, timeout); } else if(completionCallback) { completionCallback(); } })(); }; // Please wait code window.hideLoading = function(thisLocation){ jQuery(thisLocation).hide(); }; // Please wait code window.showLoading = function(thisLocation){ jQuery(thisLocation).show(); }; //--------------------------- START select all code --------------------------- jQuery('#select_all').live('click', function(){ checkAll(jQuery('.domecheck')); }); jQuery('#deselect_all').live('click', function(){ uncheckAll(jQuery('.domecheck')); }); function checkAll(field){ for (i = 0; i < field.length; i++){ field[i].checked = true; } } function uncheckAll(field){ for (i = 0; i < field.length; i++){ field[i].checked = false; } } // -------------------------- START cancel form code ------------------------------------------- //jQuery('#cancel').click(function() { jQuery('#cancel').live('click', function(){ location.reload(); }); // ------------------------------- START add row element ------------------------------------------ jQuery(".icon_plus").live('click', function() { var NewRow_UUID = genUUID(); var rowNumCount = jQuery("#address").length; if (rowNumCount > 0){ // stop empty var prevAddressAll_ck = jQuery('tr[id^=maintable_]'); var prevAddress_ck = prevAddressAll_ck[prevAddressAll_ck.length-1].id; var prevAddressEmpty_ck = jQuery.trim(jQuery('#' + prevAddress_ck + ' #address').val()); if (prevAddressEmpty_ck === ''){ return false; } } jQuery('#listloopblock').append( "\n" + '