function HashTable() { let size = 0; let entry = new Object(); this.add = function (key, value) { if (!this.containsKey(key)) { size++; } entry[key] = value; }; this.getValue = function (key) { return this.containsKey(key) ? entry[key] : null; }; this.remove = function (key) { if (this.containsKey(key) && (delete entry[key])) { size--; } }; this.containsKey = function (key) { return (key in entry); }; this.containsValue = function (value) { for (var prop in entry) { if (entry[prop] == value) { return true; } } return false; }; this.getValues = function () { var values = new Array(); for (var prop in entry) { values.push(entry[prop]); } return values; }; this.getKeys = function () { var keys = new Array(); for (var prop in entry) { keys.push(prop); } return keys; }; this.getSize = function () { return size; }; this.clear = function () { size = 0; entry = new Object(); } } let myuser; let lines; let routineTab = new HashTable(); let vulTypeCount = new HashTable(); let fileCount = new HashTable(); $(document).ready(function () { let outhtml; try { outhtml = $(window.frames["opencc_vul"].document).html(); }catch (e) { outhtml = $(window.frames["opencc_vul"].document)[0].body.innerHTML } if(outhtml === "" || outhtml == undefined || outhtml == null || outhtml.length == 0){ $.ajax({url: "opencc_vul.txt"}).done(display_content); } else { display_content(outhtml); } }); function display_content(s){ let answer = s; let i = 0; let count = 0; let one_obj = {}; let obj_list = []; let all_lines = ""; lines = answer.split("\n"); for(i = 0; i < lines.length ; i++){ let n = lines[i].match(/[a-zA-Z\._:0-9]+/g); if(n != null) { let res = {}; // One line of result res.filename = n[0]; res.vultype = n[4]; res.variate = n[8]; res.subroutine = n[9]; res.lineno = n[1]; if(!routineTab.containsKey (res.subroutine+"+"+res.variate+"+"+res.filename)) { // Repetition Check Passes routineTab.add(res.subroutine+"+"+res.variate+"+"+res.filename, res.vultype); obj_list.push(res); all_lines += "L" + res.lineno + " - " + res.filename + "
"; count ++; if(vulTypeCount.containsKey(res.vultype)){ let vul_list = vulTypeCount.getValue(res.vultype); vul_list.push(res); }else{ let vul_list = new Array(); vul_list.push(res); vulTypeCount.add(res.vultype, vul_list); } if(fileCount.containsKey(res.filename)){ let vul_list = fileCount.getValue(res.filename); vul_list.push(res); }else{ let vul_list = new Array(); vul_list.push(res); fileCount.add(res.filename, vul_list); } } } } }