PageSourceSearch

https://correlation-machine.com/CHIELD/js/db.js

js correlation-machine.com collected 2026-09-25 15:12:41 UTC 4,462 bytes, 175 lines download raw bytes

1var tableId;
2var php_link;
3var dtableConfig;
4var dtable;
5
6
7function preparePage(tableIdX,php_linkX){
8	tableId = tableIdX;
9	if(php_link!=""){
10		php_link = php_linkX;
11	}
12	setupColumnSearching(tableId);
13
14}
15
16function setupColumnSearching(tableIdX){
17	if(true){
18		$('#'+tableIdX+' tfoot th').each( function () {
19	        var title = $(this).text();
20	        //$(this).attr("id","Search_"+title);
21	        if(title=="Cor" || title=="Relation" || title=="Confirmed"){
22	        	$(this).html( '<input type="text" placeholder="Search" style="width:50px"/>' );
23	        } else{
24	        	if(title=="Notes"){
25	        		$(this).html( '<input type="text" placeholder="Search" style="width:100%"/>' );
26	        	} else{
27	        		$(this).html( '<input type="text" placeholder="Search" style="width:100%"/>' );
28	        		//$(this).html( '<input type="text" placeholder="Search" />' );
29	        	}
30	        }
31	    } );
32	}
33}
34
35function editData(data){
36	// Hook to edit data
37	return(data);	
38}
39
40function ObjectToArrayOfArrays(obj){
41	var objectArray = [];
42	for(i in obj){
43		var obj_item = [];
44		for(key in obj[i]) {
45    		if(obj[i].hasOwnProperty(key)) {
46        		obj_item.push(obj[i][key]);
47        	}
48    	}
49		objectArray.push(obj_item);
50	}
51	return(objectArray)
52}
53
54
55
56function updateLinksTable(text){
57
58	var links = JSON.parse(text);
59	// DataTable wants an array of arrays, so convert:
60	var links2 = ObjectToArrayOfArrays(links);
61
62	//console.log(links2.slice(0,4));
63
64	links2 = editData(links2);
65
66	//console.log("post edit");
67	//console.log(links2);	
68	
69	dtable_config = $.extend({data:links2},dtableConfig);
70	
71	dtable = $('#'+tableId).DataTable(dtable_config);
72	
73	// Add column searching
74    dtable.columns().every( function () {
75        var that = this;
76 		if(that.visible()){
77	        $( 'input', this.footer() ).on( 'keyup change', function () {
78	            if ( that.search() !== this.value.trim() ) {
79	                that
80	                    .search( this.value.trim() )
81	                    .draw();
82	            }
83	        } );
84    	}
85    } );
86    $('#'+tableId+' tfoot tr').appendTo('#'+tableId+' thead');
87    document.getElementById(tableId+'_filter').style.display = "none";
88}
89
90function requestVariablesFromServer(php_link){
91	var xhttp = new XMLHttpRequest();
92	xhttp.onreadystatechange = function() {
93		if (this.readyState == 4 && this.status == 200) {
94		   // Typical action to be performed when the document is ready:
95		   recieveVariablesFromServer(xhttp.responseText);
96	      // addSearchHeaders();
97		}
98	};
99	xhttp.open("GET", php_link, true);
100	xhttp.send();
101}
102
103function recieveVariablesFromServer(response){
104	console.log("Override me");
105}
106
107function requestLinks(php_link, tableId){
108	var xhttp = new XMLHttpRequest();
109	xhttp.onreadystatechange = function() {
110		if (this.readyState == 4 && this.status == 200) {
111		   // Typical action to be performed when the document is ready:
112		   updateLinksTable(xhttp.responseText);
113	      // addSearchHeaders();
114		}
115	};
116	xhttp.open("GET", php_link, true);
117	xhttp.send();
118}
119
120function updateRecord(response, type){
121	// override this
122}
123
124function recieveVersion(response){
125	// override this
126}
127
128function getVersion(){
129	var xhttp = new XMLHttpRequest();
130	xhttp.onreadystatechange = function() {
131		if (this.readyState == 4 && this.status == 200) {
132		   // Typical action to be performed when the document is ready:
133		   recieveVersion(xhttp.responseText);
134	      // addSearchHeaders();
135		}
136	};
137	xhttp.open("GET", "php/getVersion.php", true);
138	xhttp.send();
139}
140
141
142function requestRecord(php_link,params, type){
143	
144	var http = new XMLHttpRequest();
145//	var params = "lorem=ipsum&name=binny";
146	console.log(php_link);
147	http.open("POST", php_link, true);
148
149	//Send the proper header information along with the request
150	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
151	http.type = type;
152
153	http.onreadystatechange = function() {
154	//Call a function when the state changes.
155		if(http.readyState == 4 && http.status == 200) {
156			updateRecord(http.responseText,  http.type);
157		}
158	}
159	http.send(params);
160}
161
162
163function pageCounter(ignoreParameters=true){
164	var http = new XMLHttpRequest();
165	http.open("POST", "php/pageCounter.php", true);
166	//Send the proper header information along with the request
167	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
168
169	var pageLocation = window.location.href;
170	if(ignoreParameters){
171		pageLocation= pageLocation.split('?')[0];
172	}
173
174	http.send("page="+pageLocation);
175}

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.