PageSourceSearch

https://capemaycountynj.gov/Assets/Scripts/ImportModal.js

js capemaycountynj.gov collected 2026-09-24 08:53:06 UTC 2,480 bytes, 96 lines download raw bytes

1function ImportModal() {
2	this.title = "";	
3	this.getImportModalUrl = "";
4	this.performImportUrl = "";
5	this.importResultUrl = "";
6	this.modal = {};
7}
8
9ImportModal.prototype.init = function (options) {
10	var self = this;
11	var alreadyParsedAsJson = typeof (options) === "object";
12	if (!alreadyParsedAsJson)
13		options = JSON.parse(options);
14	self.title = options.title;
15	self.getImportModalUrl = options.getImportModalUrl;
16	self.performImportUrl = options.performImportUrl;
17	self.importResultUrl = options.importResultUrl;
18	self.openModal();
19};
20
21ImportModal.prototype.openModal = function () {
22	var self = this;
23	self.modal = openCpModal({
24		title: self.title,
25		className: 'modalImport modalContainerCP adminWrap',
26		url: self.getImportModalUrl,
27		autoAdjust: false,
28		isFrontEnd: false,
29		onLoadComplete: () => self.modalOpened()
30	});
31};
32
33ImportModal.prototype.modalOpened = function () {
34	var self = this;
35	//Bind Import and Cancel buttons on the modal
36	$("#lnkStartImport").on("click", function () {
37		var validated = self.validateExtensionAndExistence();
38		if (validated)
39		{
40			$('#ImportModalForm').attr("action", self.performImportUrl);
41			$('#ImportModalForm').ajaxSubmit({
42				type: 'POST',
43				dataType: 'json',
44				success: function (response) {
45					//Hide current modal
46					hideModal('modalImport');
47					//Open results modal
48					openCpModal({
49						title: "Import Results",
50						type:"POST",
51						className: 'modalImport modalContainerCP adminWrap',
52						url: self.importResultUrl,
53						data: response,
54						autoAdjust: false,
55						isFrontEnd: false,
56						onClose: hideModal('modalImport')
57					});
58					
59					return false;
60				},
61				beforeSend: function () {
62					ajaxPostBackStart('Loading');
63				},
64				complete: function () {
65					//hideModal('modalImport');
66					ajaxPostBackEnd();
67				}
68			});
69		}
70		
71	});
72
73	$("#lnkCancelImportModal").on("click", function () {
74		hideModal('modalImport');
75	});
76};
77
78ImportModal.prototype.validateExtensionAndExistence = function ()
79{
80	if (!$('#importFile').val()) {
81		alert('Please select a file');
82		return false;
83	}
84	
85	var filename = $('#importFile').val().toUpperCase();
86	var ext = '.CSV';
87
88	if (!(filename.indexOf(ext, filename.length - ext.length) != -1)) {
89		alert('Only .csv files can be uploaded.');
90		return false;
91	}
92
93	return true;
94}
95
96window.ImportModalInstance = window.ImportModalInstance || new ImportModal();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.