aboutsummaryrefslogtreecommitdiffstats
path: root/config/snort-dev/javascript/snort_globalsend.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/snort-dev/javascript/snort_globalsend.js')
-rw-r--r--config/snort-dev/javascript/snort_globalsend.js156
1 files changed, 92 insertions, 64 deletions
diff --git a/config/snort-dev/javascript/snort_globalsend.js b/config/snort-dev/javascript/snort_globalsend.js
index b8fde968..9f721053 100644
--- a/config/snort-dev/javascript/snort_globalsend.js
+++ b/config/snort-dev/javascript/snort_globalsend.js
@@ -1,30 +1,22 @@
jQuery.noConflict();
//prepare the form when the DOM is ready
-jQuery(document).ready(function() {
-
+jQuery(document).ready(function() {
+
jQuery(".icon_click").live('mouseover', function() {
jQuery(this).css('cursor', 'pointer');
});
//-------------------START Misc-------------------------------------------
-
- /*
- * Gives you even true or false on even numbers
- */
- window.isEven = function(someNumber) {
-
- return (someNumber%2 == 0) ? true : false;
-
- };
/*! 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,
@@ -47,40 +39,94 @@ jQuery(document).ready(function() {
}
};
}
+
+ //-------------------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() {
+ jQuery('#select_all').live('click', function(){
checkAll(jQuery('.domecheck'));
});
- jQuery('#deselect_all').live('click', function() {
+ jQuery('#deselect_all').live('click', function(){
uncheckAll(jQuery('.domecheck'));
});
- function checkAll(field)
- {
- for (i = 0; i < field.length; i++)
- {
+ function checkAll(field){
+ for (i = 0; i < field.length; i++){
field[i].checked = true;
}
}
- function uncheckAll(field)
- {
- for (i = 0; i < field.length; i++)
- {
+ function uncheckAll(field){
+ for (i = 0; i < field.length; i++){
field[i].checked = false;
}
}
-
- //--------------------------- STOP select all code --------------------------
-
// -------------------------- START cancel form code -------------------------------------------
//jQuery('#cancel').click(function() {
- jQuery('#cancel').live('click', function() {
+ jQuery('#cancel').live('click', function(){
location.reload();
@@ -94,15 +140,13 @@ jQuery(document).ready(function() {
var NewRow_UUID = genUUID();
var rowNumCount = jQuery("#address").length;
- if (rowNumCount > 0)
- {
+ 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 === '')
- {
+ if (prevAddressEmpty_ck === ''){
return false;
}
}
@@ -127,12 +171,11 @@ jQuery(document).ready(function() {
// ------------------------------- START remove row element ---------------------------------------
- function removeRow()
- {
+ function removeRow(){
jQuery("#maintable_" + window.RemoveRow_UUID).remove();
}
- jQuery(".icon_x").live('click', function() {
+ jQuery(".icon_x").live('click', function(){
var elem = getBaseElement(this.id); // this.id gets id of .icon_x
@@ -142,8 +185,8 @@ jQuery(document).ready(function() {
window.RemoveRow_DB = jQuery("#maintable_" + window.RemoveRow_UUID).data("options").pagedb;
window.RemoveRow_POST = jQuery("#maintable_" + window.RemoveRow_UUID).data("options").DoPOST;
- if (window.RemoveRow_POST === 'true') // snort_interfaces_whitelist
- {
+ // snort_interfaces_whitelist
+ if (window.RemoveRow_POST === 'true'){
if(confirm('Do you really want to delete this list? (e.g. snort rules will fall back to the default list)!')) {
jQuery("#maintable_" + window.RemoveRow_UUID).fadeOut("fast");
@@ -155,8 +198,7 @@ jQuery(document).ready(function() {
}
// remove element NO post
- if (window.RemoveRow_POST === 'false')
- {
+ if (window.RemoveRow_POST === 'false'){
jQuery("#maintable_" + window.RemoveRow_UUID).fadeOut("fast");
@@ -169,15 +211,15 @@ jQuery(document).ready(function() {
});
- function RMlistDBDelCall() {
+ function RMlistDBDelCall(){
return RemoveRow_DB;
}
- function RMlistTableDelCall() {
+ function RMlistTableDelCall(){
return RemoveRow_Table;
}
- function RMlistUuidDelCall() {
+ function RMlistUuidDelCall(){
return RemoveRow_UUID;
}
@@ -193,14 +235,13 @@ jQuery(document).ready(function() {
}
// post-submit callback if snort_json_post.php returns true or false
- function showResponseRMlist(data) {
+ function showResponseRMlist(data){
//alert('test');
}
- function getBaseElement(elem)
- {
+ function getBaseElement(elem){
elem = elem + "";
var len = elem.length;
var lPos = elem.lastIndexOf("_") * 1;
@@ -229,7 +270,7 @@ jQuery(document).ready(function() {
/* general form */
//jQuery('#iform').submit(function() {
- jQuery('#iform, #iform2, #iform3').live('submit', function() {
+ jQuery('#iform, #iform2, #iform3').live('submit', function(){
jQuery(this).ajaxSubmit(options);
@@ -241,10 +282,6 @@ jQuery(document).ready(function() {
var queryString = jQuery.param(formData);
- // Please wait code
- function showLoading() {
- jQuery("#loadingWaiting").show();
- }
// call to please wait
showLoading();
@@ -254,13 +291,9 @@ jQuery(document).ready(function() {
return true;
}
- function hideLoading()
- {
- jQuery("#loadingWaiting").hide();
- }
+
- function downloadsnortlogs(data)
- {
+ function downloadsnortlogs(data){
jQuery('.hiddendownloadlink').append('<iframe width="1" height="1" frameborder="0" src="/snort/snort_json_get.php?snortlogdownload=1&snortlogfilename=' + data.downloadfilename + '" ></iframe>');
var appendElem = jQuery('<br> <span>success...<span>');
@@ -270,36 +303,31 @@ jQuery(document).ready(function() {
// After Save Calls display
var appendElem = jQuery('<br> <span>success...<span>');
- function finnish()
- {
+ function finnish(){
hideLoading();
appendElem.remove();
updatestarted = 1;
}
- function showResponse(data, responseText, statusText, xhr, $form)
- {
+ function showResponse(data, responseText, statusText, xhr, $form){
// START of fill call to user
if (responseText === 'success') {
// snort logs download success
- if (data.downloadfilename !== '' && data.snortdownload === 'success')
- {
+ if (data.downloadfilename !== '' && data.snortdownload === 'success'){
downloadsnortlogs(data);
}
// succsess display
- if (data.snortgeneralsettings === 'success' || data.snortdelete === 'success' || data.snortreset === 'success')
- {
+ if (data.snortgeneralsettings === 'success' || data.snortdelete === 'success' || data.snortreset === 'success'){
// sucsses msg
appendElem.appendTo('.loadingWaitingMessage');
// Clean up Waiting code
finnish();
- if (data.snortUnhideTabs === 'true')
- {
+ if (data.snortUnhideTabs === 'true'){
jQuery('.hide_newtabmenu').show();
}