my.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <html>
  2. <!-----------------------------------------------------------------------------------
  3. This is only a temporary work inside XC5, there will be fully functional replacement in no time.
  4. Please do not modify, copy this file to unauthorized third parties.
  5. Copyright Xiangchi LLC 2018.
  6. The use of this software is licensed under MIT license, version 3.0 . All rights reserved.
  7. ------------------------------------------------------------------------------------->
  8. <head>
  9. <script src="jquery.min.js"></script>
  10. </head>
  11. <body>
  12. This is the result viewer !
  13. <iframe src="opencc_vul.txt" id="opencc_vul"></iframe>
  14. <script>
  15. function HashTable() {
  16. let size = 0;
  17. let entry = new Object();
  18. this.add = function (key, value) {
  19. if (!this.containsKey(key)) {
  20. size++;
  21. }
  22. entry[key] = value;
  23. };
  24. this.getValue = function (key) {
  25. return this.containsKey(key) ? entry[key] : null;
  26. };
  27. this.remove = function (key) {
  28. if (this.containsKey(key) && (delete entry[key])) {
  29. size--;
  30. }
  31. };
  32. this.containsKey = function (key) {
  33. return (key in entry);
  34. };
  35. this.containsValue = function (value) {
  36. for (var prop in entry) {
  37. if (entry[prop] == value) {
  38. return true;
  39. }
  40. }
  41. return false;
  42. };
  43. this.getValues = function () {
  44. var values = new Array();
  45. for (var prop in entry) {
  46. values.push(entry[prop]);
  47. }
  48. return values;
  49. };
  50. this.getKeys = function () {
  51. var keys = new Array();
  52. for (var prop in entry) {
  53. keys.push(prop);
  54. }
  55. return keys;
  56. };
  57. this.getSize = function () {
  58. return size;
  59. };
  60. this.clear = function () {
  61. size = 0;
  62. entry = new Object();
  63. }
  64. }
  65. let myuser;
  66. let lines;
  67. let routineTab = new HashTable();
  68. let vulTypeCount = new HashTable();
  69. let fileCount = new HashTable();
  70. $(document).ready(function () {
  71. let outhtml;
  72. try {
  73. outhtml = $(window.frames["opencc_vul"].document).html();
  74. }catch (e) {
  75. outhtml = $(window.frames["opencc_vul"].document)[0].body.innerHTML
  76. }
  77. if(outhtml === "" || outhtml == undefined || outhtml == null || outhtml.length == 0){
  78. $.ajax({url: "opencc_vul.txt"}).done(display_content);
  79. } else {
  80. display_content(outhtml);
  81. }
  82. });
  83. function display_content(s){
  84. let answer = s;
  85. let i = 0;
  86. let count = 0;
  87. let one_obj = {};
  88. let obj_list = [];
  89. let all_lines = "";
  90. lines = answer.split("\n");
  91. for(i = 0; i < lines.length ; i++){
  92. let n = lines[i].match(/[a-zA-Z\._:0-9]+/g);
  93. if(n != null) {
  94. let res = {}; // One line of result
  95. res.filename = n[0];
  96. res.vultype = n[4];
  97. res.variate = n[8];
  98. res.subroutine = n[9];
  99. res.lineno = n[1];
  100. if(!routineTab.containsKey
  101. (res.subroutine+"+"+res.variate+"+"+res.filename))
  102. {
  103. // Repetition Check Passes
  104. routineTab.add(res.subroutine+"+"+res.variate+"+"+res.filename, res.vultype);
  105. obj_list.push(res);
  106. all_lines += "L" + res.lineno + " - <span> " + res.filename + "</span> <br>";
  107. count ++;
  108. if(vulTypeCount.containsKey(res.vultype)){
  109. let vul_list = vulTypeCount.getValue(res.vultype);
  110. vul_list.push(res);
  111. }else{
  112. let vul_list = new Array();
  113. vul_list.push(res);
  114. vulTypeCount.add(res.vultype, vul_list);
  115. }
  116. if(fileCount.containsKey(res.filename)){
  117. let vul_list = fileCount.getValue(res.filename);
  118. vul_list.push(res);
  119. }else{
  120. let vul_list = new Array();
  121. vul_list.push(res);
  122. fileCount.add(res.filename, vul_list);
  123. }
  124. }
  125. }
  126. }
  127. $("body").html(all_lines);
  128. }
  129. </script>
  130. </body>
  131. </html>