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.js175
1 files changed, 124 insertions, 51 deletions
diff --git a/config/snort-dev/javascript/snort_globalsend.js b/config/snort-dev/javascript/snort_globalsend.js
index 60968670..a23f78c9 100644
--- a/config/snort-dev/javascript/snort_globalsend.js
+++ b/config/snort-dev/javascript/snort_globalsend.js
@@ -15,79 +15,127 @@ jQuery(document).ready(function() {
});
+
+// ------------------------------- 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('#' + prevAddress_ck + ' #address').val();
+ var prevAddressEmpty_ck = jQuery.trim(prevAddressEmpty_ck);
+
+ if (prevAddressEmpty_ck == '')
+ {
+ return false;
+ }
+
+ }
+ jQuery('#listloopblock').append(
+ "\n" + '<tr id="maintable_' + NewRow_UUID + '" ' + 'data-options=\'{"pagetable":"SnortWhitelist", "pagedb":"snortDB", "DoPOST":"false"}\' >' +
+ '<td>' +
+ '<input class="formfld2" name="list[' + NewRow_UUID + '][ip]" type="text" id="address" size="30" value="" />' +
+ '</td>' +
+ '<td>' +
+ '<input class="formfld2" name="list[' + NewRow_UUID + '][description]" type="text" id="detail" size="50" value="" />' +
+ '</td>' +
+ '<td>' +
+ '<img id="icon_x_' + NewRow_UUID + '" class="icon_click icon_x" src="/themes/nervecenter/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete list" >' +
+ '</td>' +
+ '<input name="list[' + NewRow_UUID + '][uuid]" value="EmptyUUID" type="hidden">' +
+ '</tr>' + "\n"
+ );
-// ------------------------------- START remove row element ------------------------------------------
+ });
+
+
+// ------------------------------- START remove row element ---------------------------------------
jQuery(".icon_x").live('click', function() {
var elem = getBaseElement(this.id); // this.id gets id of .icon_x
- window.RemoveRow_UUID = jQuery("#rowlist_" + elem.index).data("options").rowuuid;
- window.RemoveRow_Table = jQuery("#maintable").data("options").pagetable;
- window.RemoveRow_POST = jQuery("#maintable").data("options").DoPOST;
+ // window.RemoveRow_UUID = jQuery("#rowlist_" + elem.index).data("options").rowuuid;
+ window.RemoveRow_UUID = elem.index;
+ window.RemoveRow_Table = jQuery("#maintable_" + window.RemoveRow_UUID).data("options").pagetable;
+ window.RemoveRow_DB = jQuery("#maintable_" + window.RemoveRow_UUID).data("options").pagedb;
+ window.RemoveRow_POST = jQuery("#maintable_" + window.RemoveRow_UUID).data("options").DoPOST;
- if (RemoveRow_Table == 'SnortWhitelist') // snort_interfaces_whitelist
+ if (window.RemoveRow_POST == 'true') // snort_interfaces_whitelist
{
- if(confirm('Do you really want to delete this whitelist? (e.g. snort rules will fall back to the default whitelist)!')) {
-
- jQuery("#rowlist_" + elem.index).fadeOut("fast");
+ 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");
function removeRow()
{
- jQuery("#rowlist_" + elem.index).remove();
+ jQuery("#maintable_" + window.RemoveRow_UUID).remove();
}
setTimeout(removeRow, 600);
- jQuery(this).ajaxSubmit(optionsWhitelist); // call POST
+ jQuery(this).ajaxSubmit(optionsRMlist); // call POST
return false;
}
}
- if (RemoveRow_Table == 'SnortWhitelistips')
- { // editing snort_interfaces_whitelist_edit
+ // remove element NO post
+ if (window.RemoveRow_POST == 'false')
+ {
- jQuery("#rowlist_" + elem.index).fadeOut("fast");
+ jQuery("#maintable_" + window.RemoveRow_UUID).fadeOut("fast");
function removeRow()
{
- jQuery("#rowlist_" + elem.index).remove();
- }
+ jQuery("#maintable_" + window.RemoveRow_UUID).remove();
+ }
+ setTimeout(removeRow, 600);
+
+ return false;
- setTimeout(removeRow, 600);
- return false;
}
});
// declare variable for whitelist delete
- var optionsWhitelist = {
- beforeSubmit: showRequestWhitelist,
+ var optionsRMlist = {
+ beforeSubmit: showRequestRMlist,
dataType: 'json',
- success: showResponseWhitelist,
- type: 'POST',
- data: { WhitelistDelRow: '1', WhitelistTable: WhitelistTableDelCall, WhitelistUuid: WhitelistUuidDelCall },
- url: './snort_json_post.php'
+ success: showResponseRMlist,
+ type: 'POST',
+ data: { RMlistDelRow: '1', RMlistDB: RMlistDBDelCall, RMlistTable: RMlistTableDelCall, RMlistUuid: RMlistUuidDelCall },
+ url: './snort_json_post.php'
};
-
- function WhitelistTableDelCall() {
+
+ function RMlistDBDelCall() {
+ return RemoveRow_DB;
+ }
+
+ function RMlistTableDelCall() {
return RemoveRow_Table;
}
- function WhitelistUuidDelCall() {
+ function RMlistUuidDelCall() {
return RemoveRow_UUID;
}
// pre-submit callback
- function showRequestWhitelist(formData, jqForm, optionsWhitelist) {
+ function showRequestRMlist(formData, jqForm, optionsWhitelist) {
var queryString = jQuery.param(formData);
- alert('About to submit: \n\n' + queryString);
+ //alert('About to submit: \n\n' + queryString);
- // call false to prevent the form
+ // call false to prevent form reload
return true;
}
- // pre-submit callback
- function showResponseWhitelist(data) {
+ // post-submit callback if snort_json_post.php returns true or false
+ function showResponseRMlist(data) {
+ //alert('test');
}
@@ -99,31 +147,16 @@ jQuery(document).ready(function() {
var baseElem = elem.substr(0, lPos);
var index = elem.substr(lPos+1, len);
- //alert(index);
+ return {"base": baseElem, "index": index};
- if (checkNumeric(index))
- {
- return {"base": baseElem, "index": index};
- }else{
- return {"base": null, "index": null};
- };
-
- function checkNumeric(value)
- {
- if(isNaN(value)) {
- return false;
- }else{
- return true;
- };
- };
-
- };
+ }
// STOP remove row element
// ------------------- START iform Submit/RETURN code ---------------------------------------------
/* general form */
- jQuery('#iform').submit(function() {
+ //jQuery('#iform').submit(function() {
+ jQuery('#iform').live('submit', function() {
jQuery(this).ajaxSubmit(options);
@@ -150,7 +183,9 @@ jQuery(document).ready(function() {
var options = {
beforeSubmit: showRequest,
dataType: 'json',
- success: showResponse
+ success: showResponse,
+ type: 'POST',
+ url: './snort_json_post.php'
};
});
@@ -221,6 +256,44 @@ function showResponse(data, responseText, statusText, xhr, $form) {
+//-------------------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;
+ }
+ };
+}
+
+//-----------------STOP Misc----------------------------------------------
+
+
+
+
+
+