You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

search.js 51 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. var token;
  2. if (isEmpty(token)) {
  3. var meta = $("meta[name=_uid]");
  4. if (!isEmpty(meta)) {
  5. token = meta.attr("content");
  6. }
  7. }
  8. var html = document.documentElement;
  9. var lang = html.attributes["lang"]
  10. var isZh = true;
  11. if (lang != null && lang.nodeValue == "en-US") {
  12. isZh = false;
  13. } else {
  14. }
  15. function isEmpty(str) {
  16. if (typeof str == "undefined" || str == null || str == "") {
  17. return true;
  18. }
  19. return false;
  20. }
  21. var itemType = {
  22. "1": "repository",
  23. "2": "issue",
  24. "3": "user",
  25. "4": "org",
  26. "5": "dataset",
  27. "6": "pr"
  28. };
  29. var sortBy = {
  30. "10": "default",
  31. "11": "updated_unix.keyword",
  32. "12": "num_watches",
  33. "13": "num_stars",
  34. "14": "num_forks",
  35. "20": "default",
  36. "21": "updated_unix.keyword",
  37. "30": "default",
  38. "31": "name.keyword",
  39. "32": "name.keyword",
  40. "33": "created_unix.keyword",
  41. "34": "created_unix.keyword",
  42. "40": "default",
  43. "41": "name.keyword",
  44. "42": "name.keyword",
  45. "43": "created_unix.keyword",
  46. "44": "created_unix.keyword",
  47. "50": "default",
  48. "51": "download_times",
  49. "60": "default",
  50. "61": "updated_unix.keyword"
  51. };
  52. var sortAscending = {
  53. "10": "false",
  54. "11": "false",
  55. "12": "false",
  56. "13": "false",
  57. "14": "false",
  58. "20": "false",
  59. "21": "false",
  60. "30": "false",
  61. "31": "true",
  62. "32": "false",
  63. "33": "false",
  64. "34": "true",
  65. "40": "false",
  66. "41": "true",
  67. "42": "false",
  68. "43": "false",
  69. "44": "true",
  70. "50": "false",
  71. "51": "false",
  72. "60": "false",
  73. "61": "false"
  74. };
  75. var currentPage = 1;
  76. var pageSize = 15;
  77. var currentSearchTableName = "repository";
  78. var currentSearchKeyword = "";
  79. var currentSearchSortBy = "";
  80. var currentSearchAscending = "false";
  81. var OnlySearchLabel = false;
  82. var startIndex = 1;
  83. var endIndex = 5;
  84. var totalPage = 1;
  85. var totalNum = 0;
  86. var privateTotal = 0;
  87. function initPageInfo() {
  88. currentPage = 1;
  89. startIndex = 1;
  90. endIndex = 5;
  91. }
  92. function searchItem(type, sortType) {
  93. if (OnlySearchLabel) {
  94. doSearchLabel(currentSearchTableName, currentSearchKeyword, sortBy[sortType], sortAscending[sortType])
  95. } else {
  96. currentSearchKeyword = document.getElementById("keyword_input").value;
  97. if (!isEmpty(currentSearchKeyword)) {
  98. initPageInfo();
  99. currentSearchTableName = itemType[type];
  100. currentSearchSortBy = sortBy[sortType];
  101. currentSearchAscending = sortAscending[sortType];
  102. OnlySearchLabel = false;
  103. page(currentPage);
  104. } else {
  105. emptySearch();
  106. }
  107. }
  108. }
  109. function search() {
  110. currentSearchKeyword = document.getElementById("keyword_input").value;
  111. if (!isEmpty(currentSearchKeyword)) {
  112. currentSearchKeyword = currentSearchKeyword.trim();
  113. }
  114. if (!isEmpty(currentSearchKeyword)) {
  115. doSpcifySearch(currentSearchTableName, currentSearchKeyword, sortBy[10], "false");
  116. } else {
  117. emptySearch();
  118. }
  119. }
  120. function emptySearch() {
  121. initDiv(false);
  122. initPageInfo();
  123. $('#searchForm').addClass("hiddenSearch");
  124. document.getElementById("find_id").innerHTML = getLabel(isZh, "search_empty");
  125. $('#find_title').html("");
  126. document.getElementById("sort_type").innerHTML = "";
  127. document.getElementById("child_search_item").innerHTML = "";
  128. document.getElementById("page_menu").innerHTML = "";
  129. $('#repo_total').text("");
  130. $('#pr_total').text("");
  131. $('#issue_total').text("");
  132. $('#dataset_total').text("");
  133. $('#user_total').text("");
  134. $('#org_total').text("");
  135. setActivate(null);
  136. }
  137. function initDiv(isSearchLabel = false) {
  138. if (isSearchLabel) {
  139. document.getElementById("search_div").style.display = "none";
  140. document.getElementById("search_label_div").style.display = "block";
  141. document.getElementById("dataset_item").style.display = "none";
  142. document.getElementById("issue_item").style.display = "none";
  143. document.getElementById("pr_item").style.display = "none";
  144. document.getElementById("user_item").style.display = "none";
  145. document.getElementById("org_item").style.display = "none";
  146. document.getElementById("find_id").innerHTML = "";
  147. } else {
  148. document.getElementById("search_div").style.display = "block";
  149. document.getElementById("search_label_div").style.display = "none";
  150. document.getElementById("dataset_item").style.display = "block";
  151. document.getElementById("issue_item").style.display = "block";
  152. document.getElementById("pr_item").style.display = "block";
  153. document.getElementById("user_item").style.display = "block";
  154. document.getElementById("org_item").style.display = "block";
  155. document.getElementById("find_id").innerHTML = getLabel(isZh, "search_finded");
  156. }
  157. }
  158. function doSpcifySearch(tableName, keyword, sortBy = "", ascending = "false") {
  159. initDiv(false);
  160. $('#searchForm').addClass("hiddenSearch");
  161. document.getElementById("find_id").innerHTML = getLabel(isZh, "search_finded");
  162. currentSearchKeyword = keyword;
  163. initPageInfo();
  164. currentSearchTableName = tableName;
  165. currentSearchSortBy = sortBy;
  166. currentSearchAscending = ascending;
  167. OnlySearchLabel = false;
  168. page(currentPage);
  169. if (currentSearchTableName != "repository") {
  170. doSearch("repository", currentSearchKeyword, 1, pageSize, true, "", false);
  171. }
  172. if (currentSearchTableName != "issue") {
  173. doSearch("issue", currentSearchKeyword, 1, pageSize, true, "", false);
  174. }
  175. if (currentSearchTableName != "user") {
  176. doSearch("user", currentSearchKeyword, 1, pageSize, true, "", false);
  177. }
  178. if (currentSearchTableName != "org") {
  179. doSearch("org", currentSearchKeyword, 1, pageSize, true, "", false);
  180. }
  181. if (currentSearchTableName != "dataset") {
  182. doSearch("dataset", currentSearchKeyword, 1, pageSize, true, "", false);
  183. }
  184. if (currentSearchTableName != "pr") {
  185. doSearch("pr", currentSearchKeyword, 1, pageSize, true, "", false);
  186. }
  187. }
  188. function doSearchLabel(tableName, keyword, sortBy = "", ascending = "false") {
  189. initDiv(true);
  190. //document.getElementById("search_div").style.display="none";
  191. //document.getElementById("search_label_div").style.display="block";
  192. document.getElementById("search_label_div").innerHTML = "<p class=\"searchlabel\">#" + keyword + "</p>";
  193. currentSearchKeyword = keyword;
  194. initPageInfo();
  195. currentSearchTableName = tableName;
  196. currentSearchSortBy = sortBy;
  197. currentSearchAscending = ascending;
  198. OnlySearchLabel = true;
  199. page(currentPage);
  200. }
  201. function searchLabel(tableName, keyword, sortBy = "", ascending = "false") {
  202. sessionStorage.setItem("keyword", keyword);
  203. sessionStorage.setItem("tableName", tableName);
  204. sessionStorage.setItem("searchLabel", true);
  205. sessionStorage.setItem("sortBy", sortBy);
  206. sessionStorage.setItem("ascending", ascending);
  207. window.open("/all/search/");
  208. }
  209. function doSearch(tableName, keyword, page, pageSize = 15, onlyReturnNum = true, sortBy = "", OnlySearchLabel = false) {
  210. var language = "zh-CN";
  211. if (!isZh) {
  212. language = "en-US";
  213. }
  214. $.ajax({
  215. type: "GET",
  216. url: "/all/dosearch/",
  217. headers: {
  218. authorization: token,
  219. },
  220. dataType: "json",
  221. data: {
  222. 'TableName': tableName,
  223. 'Key': keyword,
  224. 'Page': page,
  225. 'PageSize': pageSize,
  226. 'OnlyReturnNum': onlyReturnNum,
  227. 'SortBy': sortBy,
  228. 'OnlySearchLabel': OnlySearchLabel,
  229. 'Ascending': currentSearchAscending,
  230. 'WebTotal': totalNum,
  231. 'PrivateTotal': privateTotal,
  232. 'language': language
  233. },
  234. async: true,
  235. success: function (json) {
  236. displayResult(tableName, page, json, onlyReturnNum, keyword);
  237. },
  238. error: function (response) {
  239. }
  240. });
  241. }
  242. function displayResult(tableName, page, jsonResult, onlyReturnNum, keyword) {
  243. if (tableName == "repository") {
  244. displayRepoResult(page, jsonResult, onlyReturnNum, keyword);
  245. } else if (tableName == "issue") {
  246. displayIssueResult(page, jsonResult, onlyReturnNum, keyword);
  247. } else if (tableName == "user") {
  248. displayUserResult(page, jsonResult, onlyReturnNum, keyword);
  249. } else if (tableName == "org") {
  250. displayOrgResult(page, jsonResult, onlyReturnNum, keyword);
  251. } else if (tableName == "dataset") {
  252. displayDataSetResult(page, jsonResult, onlyReturnNum, keyword);
  253. } else if (tableName == "pr") {
  254. displayPrResult(page, jsonResult, onlyReturnNum, keyword);
  255. }
  256. if (!onlyReturnNum) {
  257. totalPage = Math.ceil(jsonResult.Total / pageSize);
  258. totalNum = jsonResult.Total;
  259. privateTotal = jsonResult.PrivateTotal;
  260. setPage(page);
  261. }
  262. }
  263. function displayPrResult(page, jsonResult, onlyReturnNum, keyword) {
  264. var data = jsonResult.Result;
  265. var total = jsonResult.Total;
  266. $('#pr_total').text(total);
  267. if (!onlyReturnNum) {
  268. setActivate("pr_item");
  269. //$('#keyword_desc').text(keyword);
  270. //$('#obj_desc').text(getLabel(isZh,"search_pr"));
  271. //$('#child_total').text(total);
  272. $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_pr")).replace('{total}', total));
  273. setIssueOrPrInnerHtml(data, "pulls");
  274. }
  275. }
  276. var categoryDesc = {
  277. "computer_vision": "计算机视觉",
  278. "natural_language_processing": "自然语言处理",
  279. "speech_processing": "语音处理",
  280. "computer_vision_natural_language_processing": "计算机视觉、自然语言处理"
  281. };
  282. var categoryENDesc = {
  283. "computer_vision": "computer vision",
  284. "natural_language_processing": "natural language processing",
  285. "speech_processing": "speech processing",
  286. "computer_vision_natural_language_processing": "computer vision and natural language processing"
  287. };
  288. var taskDesc = {
  289. "machine_translation": "机器翻译",
  290. "question_answering_system": "问答系统",
  291. "information_retrieval": "信息检索",
  292. "knowledge_graph": "知识图谱",
  293. "text_annotation": "文本标注",
  294. "text_categorization": "文本分类",
  295. "emotion_analysis": "情感分析",
  296. "language_modeling": "语言建模",
  297. "speech_recognition": "语音识别",
  298. "automatic_digest": "自动文摘",
  299. "information_extraction": "信息抽取",
  300. "description_generation": "说明生成",
  301. "image_classification": "图像分类",
  302. "face_recognition": "人脸识别",
  303. "image_search": "图像搜索",
  304. "target_detection": "目标检测",
  305. "image_description_generation": "图像描述生成",
  306. "vehicle_license_plate_recognition": "车辆车牌识别",
  307. "medical_image_analysis": "医学图像分析",
  308. "unmanned": "无人驾驶",
  309. "unmanned_security": "无人安防",
  310. "drone": "无人机",
  311. "vr_ar": "VR/AR",
  312. "2_d_vision": "2-D视觉",
  313. "2_5_d_vision": "2.5-D视觉",
  314. "3_d_reconstruction": "3D重构",
  315. "image_processing": "图像处理",
  316. "video_processing": "视频处理",
  317. "visual_input_system": "视觉输入系统",
  318. "speech_coding": "语音编码",
  319. "speech_enhancement": "语音增强",
  320. "speech_recognition": "语音识别",
  321. "speech_synthesis": "语音合成"
  322. };
  323. var taskENDesc = {
  324. "machine_translation": "machine translation",
  325. "question_answering_system": "question answering system",
  326. "information_retrieval": "information retrieval",
  327. "knowledge_graph": "knowledge graph",
  328. "text_annotation": "text annotation",
  329. "text_categorization": "text categorization",
  330. "emotion_analysis": "emotion analysis",
  331. "language_modeling": "language modeling",
  332. "speech_recognition": "speech recognition",
  333. "automatic_digest": "automatic digest",
  334. "information_extraction": "information extraction",
  335. "description_generation": "description generation",
  336. "image_classification": "image classification",
  337. "face_recognition": "face recognition",
  338. "image_search": "image search",
  339. "target_detection": "target detection",
  340. "image_description_generation": "image description generation",
  341. "vehicle_license_plate_recognition": "vehicle license plate recognition",
  342. "medical_image_analysis": "medical image analysis",
  343. "unmanned": "unmanned",
  344. "unmanned_security": "unmanned security",
  345. "drone": "drone",
  346. "vr_ar": "VR/AR",
  347. "2_d_vision": "2.D vision",
  348. "2.5_d_vision": "2.5D vision",
  349. "3_d_reconstruction": "3Dreconstruction",
  350. "image_processing": "image processing",
  351. "video_processing": "video processing",
  352. "visual_input_system": "visual input system",
  353. "speech_coding": "speech coding",
  354. "speech_enhancement": "speech enhancement",
  355. "speech_recognition": "speech recognition",
  356. "speech_synthesis": "speech synthesis"
  357. };
  358. function getCategoryDesc(isZh, key) {
  359. var re = key;
  360. if (isZh) {
  361. re = categoryDesc[key];
  362. } else {
  363. re = categoryENDesc[key];
  364. }
  365. if (isEmpty(re)) {
  366. return key;
  367. }
  368. return re;
  369. }
  370. function getTaskDesc(isZh, key) {
  371. var re = key;
  372. if (isZh) {
  373. re = taskDesc[key];
  374. } else {
  375. re = taskENDesc[key];
  376. }
  377. if (isEmpty(re)) {
  378. return key;
  379. }
  380. return re;
  381. }
  382. function getActiveItem(sort_type) {
  383. if (currentSearchSortBy == sortBy[sort_type] && currentSearchAscending == sortAscending[sort_type]) {
  384. return "active ";
  385. } else {
  386. return "";
  387. }
  388. }
  389. function displayDataSetResult(page, jsonResult, onlyReturnNum, keyword) {
  390. var data = jsonResult.Result;
  391. var total = jsonResult.Total;
  392. $('#dataset_total').text(total);
  393. if (!onlyReturnNum) {
  394. setActivate("dataset_item");
  395. //$('#keyword_desc').text(keyword);
  396. //$('#obj_desc').text(getLabel(isZh,"search_dataset"));
  397. //$('#child_total').text(total);
  398. $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_dataset")).replace('{total}', total));
  399. var sortHtml = "";
  400. sortHtml += "<a class=\"" + getActiveItem(50) + "item\" href=\"javascript:searchItem(5,50);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched") + "</a>";
  401. sortHtml += "<a class=\"" + getActiveItem(51) + "item\" href=\"javascript:searchItem(5,51);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched_download") + "</a>";
  402. document.getElementById("sort_type").innerHTML = sortHtml;
  403. var html = "";
  404. var currentTime = new Date().getTime();
  405. for (var i = 0; i < data.length; i++) {
  406. var recordMap = data[i];
  407. html += "<div class=\"item\">";
  408. html += " <div class=\"content\">";
  409. html += " <div class=\"ui right metas\">";
  410. if (!isEmpty(recordMap["category"])) {
  411. html += " <span class=\"text grey\"><svg class=\"svg octicon-tasklist\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-tasklist\" /></svg> " + getCategoryDesc(isZh, recordMap["category"]) + "</span>";
  412. }
  413. if (!isEmpty(recordMap["task"])) {
  414. html += " <span class=\"text grey\"><svg class=\"svg octicon-tag\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-tag\" /></svg>" + getTaskDesc(isZh, recordMap["task"]) + "</span>";
  415. }
  416. html += " <span class=\"text grey\"><i class=\"ri-fire-line\"></i> " + recordMap["download_times"] + "</span> ";
  417. html += " </div>";
  418. html += " <div class=\"ui header\">";
  419. html += " <a class=\"name\" href=\"/" + recordMap["repoUrl"] + "/datasets\" target=\"_blank\">" + recordMap["title"] + "</a>";
  420. html += " <span class=\"middle\"><svg class=\"svg octicon-repo-clone\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-repo-clone\"></use></svg></span>";
  421. html += " </div>";
  422. html += " <div class=\"description\">";
  423. html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
  424. if (!isEmpty(recordMap["file_name"])) {
  425. html += " <p class=\"has-emoji\"> " + recordMap["file_name"] + "</p>";
  426. }
  427. html += " <p class=\"time\">";
  428. html += " <span class=\"am-ml-10\"></span> " + getLabel(isZh, "search_lasted_update") + " " + recordMap["updated_html"];
  429. html += " </p>";
  430. html += " </div>";
  431. html += " </div>";
  432. html += "</div>";
  433. }
  434. document.getElementById("child_search_item").innerHTML = html;
  435. }
  436. }
  437. function displayOrgResult(page, jsonResult, onlyReturnNum, keyword) {
  438. var data = jsonResult.Result;
  439. var total = jsonResult.Total;
  440. $('#org_total').text(total);
  441. if (!onlyReturnNum) {
  442. setActivate("org_item");
  443. //$('#keyword_desc').text(keyword);
  444. //$('#obj_desc').text(getLabel(isZh,"search_org"));
  445. //$('#child_total').text(total);
  446. $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_org")).replace('{total}', total));
  447. var sortHtml = "";
  448. sortHtml += "<a class=\"" + getActiveItem(40) + "item\" href=\"javascript:searchItem(4,40);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched") + "</a>";
  449. sortHtml += "<a class=\"" + getActiveItem(41) + "item\" href=\"javascript:searchItem(4,41);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_letter_asc") + "</a>";
  450. sortHtml += "<a class=\"" + getActiveItem(42) + "item\" href=\"javascript:searchItem(4,42);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_2\">" + getLabel(isZh, "search_letter_desc") + "</a>";
  451. sortHtml += "<a class=\"" + getActiveItem(43) + "item\" href=\"javascript:searchItem(4,43);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_2\">" + getLabel(isZh, "search_lasted_create") + "</a>";
  452. sortHtml += "<a class=\"" + getActiveItem(44) + "item\" href=\"javascript:searchItem(4,44);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_2\">" + getLabel(isZh, "search_early_create") + "</a>";
  453. document.getElementById("sort_type").innerHTML = sortHtml;
  454. var html = "";
  455. var currentTime = new Date().getTime();
  456. for (var i = 0; i < data.length; i++) {
  457. var recordMap = data[i];
  458. html += "<div class=\"item members\">";
  459. html += "<img class=\"ui avatar image\" src=\"" + recordMap["avatar"] + "\"></img>";
  460. html += " <div class=\"content\">";
  461. html += " <div class=\"ui header\">";
  462. html += " <a class=\"name\" href=\"/" + recordMap["real_name"] + "\" target=\"_blank\">" + recordMap["name"] + "&nbsp;&nbsp;" + recordMap["full_name"] + "</a>";
  463. html += " </div>";
  464. html += " <div class=\"description\">";
  465. html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
  466. html += " <p class=\"has-emoji\">";
  467. if (!isEmpty(recordMap["location"]) && recordMap["location"] != "null") {
  468. html += " <i class=\"ri-map-pin-2-line\"></i> " + recordMap["location"];
  469. }
  470. html += " <span class=\"am-ml-10\"></span>";
  471. if (!isEmpty(recordMap["website"]) && recordMap["website"] != "null") {
  472. html += " <i class=\"ri-links-line\"></i>" + "<a href=\"" + recordMap["website"] + "\" target=\"_blank\">" + recordMap["website"] + "</a>";
  473. }
  474. html += " <i class=\"ri-time-line am-ml-10\"></i> " + getLabel(isZh, "search_add_by") + " ";
  475. html += recordMap["add_time"]
  476. html += " </p>";
  477. html += " </div>";
  478. html += " </div>";
  479. html += "</div>";
  480. }
  481. document.getElementById("child_search_item").innerHTML = html;
  482. }
  483. }
  484. var monthDisplay = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Spt", "Oct", "Nov", "Dec");
  485. function displayUserResult(page, jsonResult, onlyReturnNum, keyword) {
  486. var data = jsonResult.Result;
  487. var total = jsonResult.Total;
  488. $('#user_total').text(total);
  489. if (!onlyReturnNum) {
  490. setActivate("user_item");
  491. //$('#keyword_desc').text(keyword);
  492. //$('#obj_desc').text(getLabel(isZh,"search_user"));
  493. //$('#child_total').text(total);
  494. $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_user")).replace('{total}', total));
  495. var sortHtml = "";//equal user sort by
  496. sortHtml += "<a class=\"" + getActiveItem(30) + "item\" href=\"javascript:searchItem(3,30);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched") + "</a>";
  497. sortHtml += "<a class=\"" + getActiveItem(31) + "item\" href=\"javascript:searchItem(3,31);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_letter_asc") + "</a>";
  498. sortHtml += "<a class=\"" + getActiveItem(32) + "item\" href=\"javascript:searchItem(3,32);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_2\">" + getLabel(isZh, "search_letter_desc") + "</a>";
  499. sortHtml += "<a class=\"" + getActiveItem(33) + "item\" href=\"javascript:searchItem(3,33);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_2\">" + getLabel(isZh, "search_lasted_create") + "</a>";
  500. sortHtml += "<a class=\"" + getActiveItem(34) + "item\" href=\"javascript:searchItem(3,34);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_2\">" + getLabel(isZh, "search_early_create") + "</a>";
  501. document.getElementById("sort_type").innerHTML = sortHtml;
  502. var html = "";
  503. var currentTime = new Date().getTime();
  504. for (var i = 0; i < data.length; i++) {
  505. var recordMap = data[i];
  506. html += "<div class=\"item members\">";
  507. html += "<img class=\"ui avatar image\" src=\"" + recordMap["avatar"] + "\"></img>";
  508. html += " <div class=\"content\">";
  509. html += " <div class=\"ui header\">";
  510. html += " <a class=\"name\" href=\"/" + recordMap["real_name"] + "\" target=\"_blank\">" + recordMap["name"] + "&nbsp;&nbsp;" + recordMap["full_name"] + "</a>";
  511. html += " </div>";
  512. html += " <div class=\"description\">";
  513. html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
  514. html += " <p class=\"has-emoji\">";
  515. if (!isEmpty(recordMap["email"]) && recordMap["email"] != "null") {
  516. html += " <i class=\"ri-mail-line\"></i>&nbsp;<a href=\"mailto:" + recordMap["email"] + "\" rel=\"nofollow\">" + recordMap["email"] + "</a>";
  517. }
  518. html += " <i class=\"ri-time-line am-ml-10\"></i> " + getLabel(isZh, "search_add_by") + " ";
  519. html += recordMap["add_time"]
  520. html += " </p>";
  521. html += " </div>";
  522. html += " </div>";
  523. html += "</div>";
  524. }
  525. document.getElementById("child_search_item").innerHTML = html;
  526. }
  527. }
  528. function setIssueOrPrInnerHtml(data, path) {
  529. var sortHtml = "";
  530. if (path == "issues") {
  531. sortHtml += "<a class=\"" + getActiveItem(20) + "item\" href=\"javascript:searchItem(2,20);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched") + "</a>";
  532. sortHtml += "<a class=\"" + getActiveItem(21) + "item\" href=\"javascript:searchItem(2,21);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_lasted") + "</a>";
  533. } else {
  534. sortHtml += "<a class=\"" + getActiveItem(60) + "item\" href=\"javascript:searchItem(6,60);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched") + "</a>";
  535. sortHtml += "<a class=\"" + getActiveItem(61) + "item\" href=\"javascript:searchItem(6,61);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_lasted") + "</a>";
  536. }
  537. document.getElementById("sort_type").innerHTML = sortHtml;
  538. var html = "";
  539. var currentTime = new Date().getTime();
  540. for (var i = 0; i < data.length; i++) {
  541. var recordMap = data[i];
  542. html += "<div class=\"item\">";
  543. html += " <div class=\"content\">";
  544. html += " <div class=\"ui header\">";
  545. html += " <a class=\"name\" href=\"/" + recordMap["repoUrl"] + "/" + path + "/" + recordMap["index"] + "\" target=\"_blank\">" + recordMap["name"] + "</a>";
  546. html += " </div>";
  547. html += " <div class=\"description\">";
  548. html += " <p class=\"has-emoji\"> " + recordMap["content"] + "</p>";
  549. html += " <p class=\"time\">";
  550. html += " <i class=\"ri-code-box-line\"></i>";
  551. html += " <a class=\"am-text grey\" href=\"/" + recordMap["repoUrl"] + "/" + path + "/" + recordMap["index"] + "\" target=\"_blank\"> " + addBlank(recordMap["repoUrl"]) + " #" + recordMap["index"] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
  552. html += " <i class=\"ri-information-line am-ml-10\"></i>&nbsp;";
  553. if (recordMap["is_closed"] != null && (!(recordMap["is_closed"]) || recordMap["is_closed"] == "f")) {
  554. html += getLabel(isZh, "search_open");
  555. } else {
  556. html += getLabel(isZh, "search_closed");
  557. }
  558. html += " &nbsp;&nbsp;&nbsp;&nbsp;<i class=\"ri-message-2-line am-ml-10\"></i>&nbsp;" + recordMap["num_comments"];
  559. html += " <span class=\"am-ml-10\">&nbsp;&nbsp;</span>&nbsp;&nbsp;" + getLabel(isZh, "search_lasted_update") + " " + recordMap["updated_html"];
  560. html += " </p>";
  561. html += " </div>";
  562. html += " </div>";
  563. html += "</div>";
  564. }
  565. document.getElementById("child_search_item").innerHTML = html;
  566. }
  567. function addBlank(url) {
  568. if (url == null) {
  569. return url;
  570. }
  571. var tmps = url.split("/");
  572. if (tmps.length == 2) {
  573. return tmps[0] + " / " + tmps[1];
  574. }
  575. return url;
  576. }
  577. function displayIssueResult(page, jsonResult, onlyReturnNum, keyword) {
  578. var data = jsonResult.Result;
  579. var total = jsonResult.Total;
  580. $('#issue_total').text(total);
  581. if (!onlyReturnNum) {
  582. setActivate("issue_item");
  583. //$('#keyword_desc').text(keyword);
  584. //$('#obj_desc').text(getLabel(isZh,"search_issue"));
  585. //$('#child_total').text(total);
  586. $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_issue")).replace('{total}', total));
  587. setIssueOrPrInnerHtml(data, "issues");
  588. }
  589. }
  590. function setActivate(name) {
  591. $('#repo_item').removeClass("active");
  592. $('#user_item').removeClass("active");
  593. $('#issue_item').removeClass("active");
  594. $('#dataset_item').removeClass("active");
  595. $('#org_item').removeClass("active");
  596. $('#pr_item').removeClass("active");
  597. if (name == null) {
  598. return;
  599. }
  600. var tmp = "#" + name;
  601. $(tmp).addClass("active");
  602. }
  603. function LetterAvatar(name, size, color) {
  604. name = name || '';
  605. size = size || 60;
  606. var colours = [
  607. "#1abc9c", "#2ecc71", "#3498db", "#9b59b6", "#34495e", "#16a085", "#27ae60", "#2980b9", "#8e44ad", "#2c3e50",
  608. "#f1c40f", "#e67e22", "#e74c3c", "#00bcd4", "#95a5a6", "#f39c12", "#d35400", "#c0392b", "#bdc3c7", "#7f8c8d"
  609. ],
  610. nameSplit = String(name).split(' '),
  611. initials, charIndex, colourIndex, canvas, context, dataURI;
  612. if (nameSplit.length == 1) {
  613. initials = nameSplit[0] ? nameSplit[0].charAt(0) : '?';
  614. } else {
  615. initials = nameSplit[0].charAt(0) + nameSplit[1].charAt(0);
  616. }
  617. if (w.devicePixelRatio) {
  618. size = (size * w.devicePixelRatio);
  619. }
  620. charIndex = (initials == '?' ? 72 : initials.charCodeAt(0)) - 64;
  621. colourIndex = charIndex % 20;
  622. canvas = d.createElement('canvas');
  623. canvas.width = size;
  624. canvas.height = size;
  625. context = canvas.getContext("2d");
  626. context.fillStyle = color ? color : colours[colourIndex - 1];
  627. context.fillRect(0, 0, canvas.width, canvas.height);
  628. context.font = Math.round(canvas.width / 2) + "px 'Microsoft Yahei'";
  629. context.textAlign = "center";
  630. context.fillStyle = "#FFF";
  631. context.fillText(initials, size / 2, size / 1.5);
  632. dataURI = canvas.toDataURL();
  633. canvas = null;
  634. return dataURI;
  635. }
  636. LetterAvatar.transform = function () {
  637. Array.prototype.forEach.call(d.querySelectorAll('img[avatar]'), function (img, name, color) {
  638. name = img.getAttribute('avatar');
  639. color = img.getAttribute('color');
  640. img.src = LetterAvatar(name, img.getAttribute('width'), color);
  641. img.removeAttribute('avatar');
  642. img.setAttribute('alt', name);
  643. });
  644. };
  645. function displayRepoResult(page, jsonResult, onlyReturnNum, keyword) {
  646. var data = jsonResult.Result;
  647. var total = jsonResult.Total;
  648. $('#repo_total').text(total);
  649. if (!onlyReturnNum) {
  650. setActivate("repo_item");
  651. // $('#keyword_desc').text(keyword);
  652. //$('#obj_desc').text(getLabel(isZh,"search_repo"));
  653. //$('#child_total').text(total);
  654. $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_repo")).replace('{total}', total));
  655. var sortHtml = "";
  656. sortHtml += "<a class=\"" + getActiveItem(10) + "item\" href=\"javascript:searchItem(1,10);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_matched") + "</a>";
  657. sortHtml += "<a class=\"" + getActiveItem(11) + "item\" href=\"javascript:searchItem(1,11);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_lasted") + "</a>";
  658. sortHtml += "<a class=\"" + getActiveItem(12) + "item\" href=\"javascript:searchItem(1,12);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_watched") + "</a>";
  659. sortHtml += "<a class=\"" + getActiveItem(13) + "item\" href=\"javascript:searchItem(1,13);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_star") + "</a>";
  660. sortHtml += "<a class=\"" + getActiveItem(14) + "item\" href=\"javascript:searchItem(1,14);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">" + getLabel(isZh, "search_fork") + "</a>";
  661. document.getElementById("sort_type").innerHTML = sortHtml;
  662. var html = "";
  663. var currentTime = new Date().getTime();
  664. for (var i = 0; i < data.length; i++) {
  665. var recordMap = data[i];
  666. html += "<div class=\"item\">";
  667. if (recordMap['avatar']) {
  668. html += `<img class="ui avatar image" src="${recordMap["avatar"]}">`
  669. } else {
  670. html += `<img class="ui avatar image" avatar="${recordMap["owner_name"]}">`
  671. }
  672. html += " <div class=\"content\">";
  673. html += " <div class=\"ui header\">";
  674. html += " <a class=\"name\" href=\"/" + recordMap["owner_name"] + "/" + recordMap["real_name"] + "\" target=\"_blank\"> <span>" + recordMap["owner_name"] + "</span> <span>/</span> <strong>" + recordMap["alias"] + "</strong></a>";
  675. if (recordMap["is_private"]) {
  676. html += " <span class=\"middle text gold\"><svg class=\"svg octicon-lock\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-lock\" /></svg></span>";
  677. }
  678. html += " </div>";
  679. html += " <div class=\"description\">";
  680. html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
  681. html += " <div class=\"ui tags\">";
  682. if (!isEmpty(recordMap["topics"]) && recordMap["topics"] != "null") {
  683. for (var j = 0; j < recordMap["topics"].length; j++) {
  684. //function searchLabel(tableName,keyword,sortBy="",ascending=false)
  685. html += " <a href=\"javascript:searchLabel('repository','" + recordMap["topics"][j] + "','updated_unix.keyword',false);\" ><div class=\"ui small label topic\">" + recordMap["hightTopics"][j] + "</div></a>";
  686. }
  687. }
  688. html += " </div>";
  689. html += " <p class=\"time\">";
  690. html += " <i class=\"icon fa-eye outline\"></i>&nbsp;" + recordMap["num_watches"] + "&nbsp;&nbsp;<i class=\"icon star outline\"></i>&nbsp;" + recordMap["num_stars"] + "&nbsp;&nbsp;<i class=\"icon code branch\"></i>&nbsp;" + recordMap["num_forks"] + "&nbsp;&nbsp;";
  691. html += "&nbsp;&nbsp;&nbsp;&nbsp;" + getLabel(isZh, "search_lasted_update") + " " + recordMap["updated_html"];
  692. if (!isEmpty(recordMap["lang"])) {
  693. var lang = recordMap["lang"]
  694. var tmpLang = recordMap["lang"].split(",");
  695. if (tmpLang.length > 0) {
  696. lang = tmpLang[0]
  697. }
  698. var backColor = "#3572A5";
  699. if (LanguagesColor[lang] != null) {
  700. backColor = LanguagesColor[lang];
  701. }
  702. html += " <span class=\"text grey am-ml-10\"><i class=\"color-icon\" style=\"background-color: " + backColor + "\"></i>&nbsp;" + lang + "</span>";
  703. }
  704. html += " </p>";
  705. html += " </div>";
  706. html += " </div>";
  707. html += "</div>";
  708. }
  709. document.getElementById("child_search_item").innerHTML = html;
  710. LetterAvatar.transform()
  711. }
  712. }
  713. function getTime(UpdatedUnix, currentTime) {
  714. UpdatedUnix = UpdatedUnix;
  715. currentTime = currentTime / 1000;
  716. var timeEscSecond = currentTime - UpdatedUnix;
  717. if (timeEscSecond < 0) {
  718. timeEscSecond = 1;
  719. }
  720. var hours = Math.floor(timeEscSecond / 3600);
  721. //计算相差分钟数
  722. var leave2 = Math.floor(timeEscSecond % (3600)); //计算小时数后剩余的秒数
  723. var minutes = Math.floor(leave2 / 60);//计算相差分钟数
  724. var leave3 = Math.floor(leave2 % 60); //计算分钟数后剩余的秒数
  725. var seconds = leave3;
  726. if (hours == 0 && minutes == 0) {
  727. return seconds + getRepoOrOrg(6, isZh);
  728. } else {
  729. if (hours > 0) {
  730. if (hours >= 24) {
  731. var days = Math.ceil(hours / 24)
  732. if (days >= 30 && days < 365) {
  733. return Math.ceil(days / 30) + getRepoOrOrg(8, isZh);
  734. } else if (days >= 365) {
  735. return Math.ceil(days / 365) + getRepoOrOrg(9, isZh);
  736. }
  737. return Math.ceil(hours / 24) + getRepoOrOrg(7, isZh);
  738. } else {
  739. return hours + getRepoOrOrg(4, isZh);
  740. }
  741. } else {
  742. return minutes + getRepoOrOrg(5, isZh);
  743. }
  744. }
  745. }
  746. function getRepoOrOrg(key, isZhLang) {
  747. if (isZhLang) {
  748. return repoAndOrgZH[key];
  749. } else {
  750. return repoAndOrgEN[key];
  751. }
  752. }
  753. var repoAndOrgZH = {
  754. "1": "项目",
  755. "2": "成员",
  756. "3": "团队",
  757. "4": "小时前",
  758. "5": "分钟前",
  759. "6": "秒前",
  760. "7": "天前",
  761. "8": "个月前",
  762. "9": "年前"
  763. };
  764. var repoAndOrgEN = {
  765. "1": "repository",
  766. "2": "Members ",
  767. "3": "Teams",
  768. "4": " hours ago",
  769. "5": " minutes ago",
  770. "6": " seconds ago",
  771. "7": " day ago",
  772. "8": " month ago",
  773. "9": " year ago"
  774. };
  775. function page(current) {
  776. currentPage = current;
  777. doSearch(currentSearchTableName, currentSearchKeyword, current, pageSize, false, currentSearchSortBy, OnlySearchLabel);
  778. }
  779. function nextPage() {
  780. currentPage = currentPage + 1;
  781. page(currentPage);
  782. }
  783. function prePage() {
  784. if (currentPage > 1) {
  785. currentPage = currentPage - 1;
  786. page(currentPage);
  787. }
  788. }
  789. function getXPosition(e) {
  790. var x = e.offsetLeft;
  791. while (e = e.offsetParent) {
  792. x += e.offsetLeft;
  793. }
  794. return x + 20;//-260防止屏幕超出
  795. }
  796. //获取y坐标
  797. function getYPosition(e) {
  798. var y = e.offsetTop;
  799. while (e = e.offsetParent) {
  800. y += e.offsetTop;
  801. }
  802. return y + 20;//80为input高度
  803. }
  804. function goPage(event) {
  805. var inputpage = document.getElementById("inputpage_div")
  806. var left = getXPosition(event.target);
  807. var top = getYPosition(event.target);
  808. var goNum = $('#inputpage').val();
  809. if (goNum <= 0) {
  810. showTip(getLabel(isZh, "search_input_large_0"), "warning", left + 5, top);
  811. }
  812. else if (goNum <= totalPage) {
  813. page(parseInt(goNum, 10));
  814. }
  815. else {
  816. showTip(getLabel(isZh, "search_input_maxed"), "warning", left + 5, top);
  817. }
  818. }
  819. function showTip(tip, type, left, top) {
  820. var $tip = $('#tipmsg');
  821. var tipmsg = document.getElementById("tipmsg")
  822. var style = "z-index:10024;top:" + top + "px;left:" + left + "px;position:absolute;width:200px;height:60px;vertical-align:middle;";
  823. tipmsg.style = style;
  824. var html = "<p>" + tip + "</p>"
  825. $tip.stop(true).prop('class', 'alert alert-' + type).html(html).fadeIn(500).delay(2000).fadeOut(500);
  826. }
  827. function setPage(currentPage) {
  828. var html = "";
  829. startIndex = currentPage - 1;
  830. if (startIndex < 1) {
  831. startIndex = 1;
  832. }
  833. endIndex = currentPage + 2;
  834. if (endIndex >= totalPage) {
  835. endIndex = totalPage;
  836. }
  837. html += "<span class=\"item\">" + getLabel(isZh, "search_input_total") + " " + totalNum + " " + getLabel(isZh, "search_srtip") + "</span>"
  838. if (currentPage > 1) {
  839. html += "<a class=\"item navigation\" href=\"javascript:page(1)\"><span class=\"navigation_label\">" + getLabel(isZh, "search_home_page") + "</span></a>";
  840. html += "<a class=\"item navigation\" href=\"javascript:prePage()\"><i class=\"left arrow icon\"></i></a>";
  841. } else {
  842. html += "<a class=\"disabled item navigation\" href=\"javascript:page(1)\"><span class=\"navigation_label\">" + getLabel(isZh, "search_home_page") + "</span></a>";
  843. html += "<a class=\"disabled item navigation\" href=\"javascript:prePage()\"><i class=\"left arrow icon\"></i></a>";
  844. }
  845. for (var i = startIndex; i <= endIndex; i++) {
  846. var page_i = i;
  847. if (page_i > totalPage) {
  848. break;
  849. }
  850. if (page_i == currentPage) {
  851. html += "<a id=\"page_" + page_i + "\" class=\"active item\" href=\"javascript:page(" + page_i + ")\">" + page_i + "</a>";
  852. } else {
  853. html += "<a id=\"page_" + page_i + "\" class=\"item\" href=\"javascript:page(" + page_i + ")\">" + page_i + "</a>";
  854. }
  855. }
  856. if (endIndex < totalPage - 1) {
  857. html += "...";
  858. html += "<a id=\"page_" + totalPage + "\" class=\"item\" href=\"javascript:page(" + totalPage + ")\">" + totalPage + "</a>";
  859. }
  860. if (currentPage >= totalPage) {
  861. html += "<a class=\"disabled item navigation\" href=\"javascript:nextPage()\"><i class=\"icon right arrow\"></i></a>";
  862. html += "<a class=\"disabled item navigation\" href=\"javascript:page(" + totalPage + ")\"><span class=\"navigation_label\">" + getLabel(isZh, "search_last_page") + "</span></a>";
  863. } else {
  864. html += "<a class=\"item navigation\" href=\"javascript:nextPage()\"><i class=\"icon right arrow\"></i></a>";
  865. html += "<a class=\"item navigation\" href=\"javascript:page(" + totalPage + ")\"><span class=\"navigation_label\">" + getLabel(isZh, "search_last_page") + "</span></a>";
  866. }
  867. html += "<div class=\"item\"> " + getLabel(isZh, "search_go_to") + "<div id=\"inputpage_div\" class=\"ui input\"><input id=\"inputpage\" type=\"text\"></div>" + getLabel(isZh, "search_go_page") + "</div>";
  868. document.getElementById("page_menu").innerHTML = html;
  869. $('#inputpage').on('keypress', function (event) {
  870. if (event.keyCode == 13) {
  871. goPage(event);
  872. }
  873. });
  874. }
  875. $('#keyword_input').on('keypress', function (event) {
  876. if (event.keyCode == 13) {
  877. search();
  878. }
  879. });
  880. var LanguagesColor = {
  881. "1C Enterprise": "#814CCC",
  882. "ABAP": "#E8274B",
  883. "AGS Script": "#B9D9FF",
  884. "AMPL": "#E6EFBB",
  885. "ANTLR": "#9DC3FF",
  886. "API Blueprint": "#2ACCA8",
  887. "APL": "#5A8164",
  888. "ASP": "#6a40fd",
  889. "ATS": "#1ac620",
  890. "ActionScript": "#882B0F",
  891. "Ada": "#02f88c",
  892. "Agda": "#315665",
  893. "Alloy": "#64C800",
  894. "AngelScript": "#C7D7DC",
  895. "AppleScript": "#101F1F",
  896. "Arc": "#aa2afe",
  897. "AspectJ": "#a957b0",
  898. "Assembly": "#6E4C13",
  899. "Asymptote": "#4a0c0c",
  900. "AutoHotkey": "#6594b9",
  901. "AutoIt": "#1C3552",
  902. "Ballerina": "#FF5000",
  903. "Batchfile": "#C1F12E",
  904. "BlitzMax": "#cd6400",
  905. "Boo": "#d4bec1",
  906. "Brainfuck": "#2F2530",
  907. "C": "#555555",
  908. "C#": "#178600",
  909. "C++": "#f34b7d",
  910. "CSS": "#563d7c",
  911. "Ceylon": "#dfa535",
  912. "Chapel": "#8dc63f",
  913. "Cirru": "#ccccff",
  914. "Clarion": "#db901e",
  915. "Clean": "#3F85AF",
  916. "Click": "#E4E6F3",
  917. "Clojure": "#db5855",
  918. "CoffeeScript": "#244776",
  919. "ColdFusion": "#ed2cd6",
  920. "Common Lisp": "#3fb68b",
  921. "Common Workflow Language": "#B5314C",
  922. "Component Pascal": "#B0CE4E",
  923. "Crystal": "#000100",
  924. "Cuda": "#3A4E3A",
  925. "D": "#ba595e",
  926. "DM": "#447265",
  927. "Dart": "#00B4AB",
  928. "DataWeave": "#003a52",
  929. "Dhall": "#dfafff",
  930. "Dockerfile": "#384d54",
  931. "Dogescript": "#cca760",
  932. "Dylan": "#6c616e",
  933. "E": "#ccce35",
  934. "ECL": "#8a1267",
  935. "EQ": "#a78649",
  936. "Eiffel": "#946d57",
  937. "Elixir": "#6e4a7e",
  938. "Elm": "#60B5CC",
  939. "Emacs Lisp": "#c065db",
  940. "EmberScript": "#FFF4F3",
  941. "Erlang": "#B83998",
  942. "F#": "#b845fc",
  943. "F*": "#572e30",
  944. "FLUX": "#88ccff",
  945. "Factor": "#636746",
  946. "Fancy": "#7b9db4",
  947. "Fantom": "#14253c",
  948. "Faust": "#c37240",
  949. "Forth": "#341708",
  950. "Fortran": "#4d41b1",
  951. "FreeMarker": "#0050b2",
  952. "Frege": "#00cafe",
  953. "G-code": "#D08CF2",
  954. "GAML": "#FFC766",
  955. "GDScript": "#355570",
  956. "Game Maker Language": "#71b417",
  957. "Genie": "#fb855d",
  958. "Gherkin": "#5B2063",
  959. "Glyph": "#c1ac7f",
  960. "Gnuplot": "#f0a9f0",
  961. "Go": "#00ADD8",
  962. "Golo": "#88562A",
  963. "Gosu": "#82937f",
  964. "Grammatical Framework": "#79aa7a",
  965. "Groovy": "#e69f56",
  966. "HTML": "#e34c26",
  967. "Hack": "#878787",
  968. "Harbour": "#0e60e3",
  969. "Haskell": "#5e5086",
  970. "Haxe": "#df7900",
  971. "HiveQL": "#dce200",
  972. "HolyC": "#ffefaf",
  973. "Hy": "#7790B2",
  974. "IDL": "#a3522f",
  975. "IGOR Pro": "#0000cc",
  976. "Idris": "#b30000",
  977. "Io": "#a9188d",
  978. "Ioke": "#078193",
  979. "Isabelle": "#FEFE00",
  980. "J": "#9EEDFF",
  981. "JSONiq": "#40d47e",
  982. "Java": "#b07219",
  983. "JavaScript": "#f1e05a",
  984. "Jolie": "#843179",
  985. "Jsonnet": "#0064bd",
  986. "Julia": "#a270ba",
  987. "Jupyter Notebook": "#DA5B0B",
  988. "KRL": "#28430A",
  989. "Kotlin": "#F18E33",
  990. "LFE": "#4C3023",
  991. "LLVM": "#185619",
  992. "LOLCODE": "#cc9900",
  993. "LSL": "#3d9970",
  994. "Lasso": "#999999",
  995. "Lex": "#DBCA00",
  996. "LiveScript": "#499886",
  997. "LookML": "#652B81",
  998. "Lua": "#000080",
  999. "MATLAB": "#e16737",
  1000. "MAXScript": "#00a6a6",
  1001. "MLIR": "#5EC8DB",
  1002. "MQL4": "#62A8D6",
  1003. "MQL5": "#4A76B8",
  1004. "MTML": "#b7e1f4",
  1005. "Makefile": "#427819",
  1006. "Mask": "#f97732",
  1007. "Max": "#c4a79c",
  1008. "Mercury": "#ff2b2b",
  1009. "Meson": "#007800",
  1010. "Metal": "#8f14e9",
  1011. "Mirah": "#c7a938",
  1012. "Modula-3": "#223388",
  1013. "NCL": "#28431f",
  1014. "Nearley": "#990000",
  1015. "Nemerle": "#3d3c6e",
  1016. "NetLinx": "#0aa0ff",
  1017. "NetLinx+ERB": "#747faa",
  1018. "NetLogo": "#ff6375",
  1019. "NewLisp": "#87AED7",
  1020. "Nextflow": "#3ac486",
  1021. "Nim": "#37775b",
  1022. "Nit": "#009917",
  1023. "Nix": "#7e7eff",
  1024. "Nu": "#c9df40",
  1025. "OCaml": "#3be133",
  1026. "ObjectScript": "#424893",
  1027. "Objective-C": "#438eff",
  1028. "Objective-C++": "#6866fb",
  1029. "Objective-J": "#ff0c5a",
  1030. "Odin": "#60AFFE",
  1031. "Omgrofl": "#cabbff",
  1032. "Opal": "#f7ede0",
  1033. "OpenQASM": "#AA70FF",
  1034. "Oxygene": "#cdd0e3",
  1035. "Oz": "#fab738",
  1036. "P4": "#7055b5",
  1037. "PHP": "#4F5D95",
  1038. "PLSQL": "#dad8d8",
  1039. "Pan": "#cc0000",
  1040. "Papyrus": "#6600cc",
  1041. "Parrot": "#f3ca0a",
  1042. "Pascal": "#E3F171",
  1043. "Pawn": "#dbb284",
  1044. "Pep8": "#C76F5B",
  1045. "Perl": "#0298c3",
  1046. "PigLatin": "#fcd7de",
  1047. "Pike": "#005390",
  1048. "PogoScript": "#d80074",
  1049. "PostScript": "#da291c",
  1050. "PowerBuilder": "#8f0f8d",
  1051. "PowerShell": "#012456",
  1052. "Processing": "#0096D8",
  1053. "Prolog": "#74283c",
  1054. "Propeller Spin": "#7fa2a7",
  1055. "Puppet": "#302B6D",
  1056. "PureBasic": "#5a6986",
  1057. "PureScript": "#1D222D",
  1058. "Python": "#3572A5",
  1059. "QML": "#44a51c",
  1060. "Quake": "#882233",
  1061. "R": "#198CE7",
  1062. "RAML": "#77d9fb",
  1063. "RUNOFF": "#665a4e",
  1064. "Racket": "#3c5caa",
  1065. "Ragel": "#9d5200",
  1066. "Raku": "#0000fb",
  1067. "Rascal": "#fffaa0",
  1068. "Reason": "#ff5847",
  1069. "Rebol": "#358a5b",
  1070. "Red": "#f50000",
  1071. "Ren'Py": "#ff7f7f",
  1072. "Ring": "#2D54CB",
  1073. "Riot": "#A71E49",
  1074. "Roff": "#ecdebe",
  1075. "Rouge": "#cc0088",
  1076. "Ruby": "#701516",
  1077. "Rust": "#dea584",
  1078. "SAS": "#B34936",
  1079. "SQF": "#3F3F3F",
  1080. "SRecode Template": "#348a34",
  1081. "SaltStack": "#646464",
  1082. "Scala": "#c22d40",
  1083. "Scheme": "#1e4aec",
  1084. "Self": "#0579aa",
  1085. "Shell": "#89e051",
  1086. "Shen": "#120F14",
  1087. "Slash": "#007eff",
  1088. "Slice": "#003fa2",
  1089. "SmPL": "#c94949",
  1090. "Smalltalk": "#596706",
  1091. "Solidity": "#AA6746",
  1092. "SourcePawn": "#5c7611",
  1093. "Squirrel": "#800000",
  1094. "Stan": "#b2011d",
  1095. "Standard ML": "#dc566d",
  1096. "Starlark": "#76d275",
  1097. "SuperCollider": "#46390b",
  1098. "Swift": "#ffac45",
  1099. "SystemVerilog": "#DAE1C2",
  1100. "TI Program": "#A0AA87",
  1101. "Tcl": "#e4cc98",
  1102. "TeX": "#3D6117",
  1103. "Terra": "#00004c",
  1104. "Turing": "#cf142b",
  1105. "TypeScript": "#2b7489",
  1106. "UnrealScript": "#a54c4d",
  1107. "V": "#5d87bd",
  1108. "VBA": "#867db1",
  1109. "VBScript": "#15dcdc",
  1110. "VCL": "#148AA8",
  1111. "VHDL": "#adb2cb",
  1112. "Vala": "#fbe5cd",
  1113. "Verilog": "#b2b7f8",
  1114. "Vim script": "#199f4b",
  1115. "Visual Basic .NET": "#945db7",
  1116. "Volt": "#1F1F1F",
  1117. "Vue": "#2c3e50",
  1118. "WebAssembly": "#04133b",
  1119. "Wollok": "#a23738",
  1120. "X10": "#4B6BEF",
  1121. "XC": "#99DA07",
  1122. "XQuery": "#5232e7",
  1123. "XSLT": "#EB8CEB",
  1124. "YARA": "#220000",
  1125. "YASnippet": "#32AB90",
  1126. "Yacc": "#4B6C4B",
  1127. "ZAP": "#0d665e",
  1128. "ZIL": "#dc75e5",
  1129. "ZenScript": "#00BCD1",
  1130. "Zephir": "#118f9e",
  1131. "Zig": "#ec915c",
  1132. "eC": "#913960",
  1133. "mIRC Script": "#926059",
  1134. "mcfunction": "#E22837",
  1135. "nesC": "#94B0C7",
  1136. "ooc": "#b0b77e",
  1137. "q": "#0040cd",
  1138. "sed": "#64b970",
  1139. "wdl": "#42f1f4",
  1140. "wisp": "#7582D1",
  1141. "xBase": "#403a40",
  1142. }
  1143. function getLabel(isZh, key) {
  1144. if (isZh) {
  1145. return zhCN[key]
  1146. } else {
  1147. return esUN[key]
  1148. }
  1149. }
  1150. var zhCN = {
  1151. "search": "搜索",
  1152. "search_repo": "项目",
  1153. "search_dataset": "数据集",
  1154. "search_issue": "任务",
  1155. "search_pr": "合并请求",
  1156. "search_user": "用户",
  1157. "search_org": "组织",
  1158. "search_finded": "找到",
  1159. "search_matched": "最佳匹配",
  1160. "search_matched_download": "下载次数",
  1161. "search_lasted_update": "最后更新于",
  1162. "search_letter_asc": "字母顺序排序",
  1163. "search_letter_desc": "字母逆序排序",
  1164. "search_lasted_create": "最近创建",
  1165. "search_early_create": "最早创建",
  1166. "search_add_by": "加入于",
  1167. "search_lasted": "最近更新",
  1168. "search_open": "开启中",
  1169. "search_closed": "已关闭",
  1170. "search_watched": "关注数",
  1171. "search_star": "点赞数",
  1172. "search_fork": "Fork数",
  1173. "search_input_large_0": "请输入大于0的数值。",
  1174. "search_input_maxed": "不能超出总页数。",
  1175. "search_input_total": "共",
  1176. "search_srtip": "条",
  1177. "search_home_page": "首页",
  1178. "search_last_page": "末页",
  1179. "search_go_to": "前往",
  1180. "search_go_page": "页",
  1181. "find_title": "“<strong class=\"highlight\" id=\"keyword_desc\">{keyword}</strong>”相关{tablename}约为{total}个",
  1182. "search_empty": "<strong>请输入任意关键字开始搜索。</strong>"
  1183. }
  1184. var esUN = {
  1185. "search": "Search",
  1186. "search_repo": "Repository",
  1187. "search_dataset": "DataSet",
  1188. "search_issue": "Issue",
  1189. "search_pr": "Pull Request",
  1190. "search_user": "User",
  1191. "search_org": "Organization",
  1192. "search_finded": "Find",
  1193. "search_matched": "Best Match",
  1194. "search_matched_download": "Most downloads",
  1195. "search_lasted_update": "Updated ",
  1196. "search_letter_asc": "Alphabetically",
  1197. "search_letter_desc": "Reverse alphabetically",
  1198. "search_lasted_create": "Recently created",
  1199. "search_early_create": "First created",
  1200. "search_add_by": "Joined on",
  1201. "search_lasted": "Recently updated",
  1202. "search_open": "Open",
  1203. "search_closed": "Closed",
  1204. "search_watched": "Watches",
  1205. "search_star": "Stars",
  1206. "search_fork": "Forks",
  1207. "search_input_large_0": "Please enter a value greater than 0.",
  1208. "search_input_maxed": "Cannot exceed total pages.",
  1209. "search_input_total": "Total",
  1210. "search_srtip": "",
  1211. "search_home_page": "First",
  1212. "search_last_page": "Last",
  1213. "search_go_to": "Go",
  1214. "search_go_page": "Page",
  1215. "find_title": " {total} \"<strong class=\"highlight\" id=\"keyword_desc\">{keyword}</strong>\" related {tablename}",
  1216. "search_empty": "<strong>Please enter any keyword to start the search.</strong>"
  1217. }
  1218. initDiv(false);
  1219. document.onreadystatechange = function () {
  1220. if (document.readyState === "complete") {
  1221. var tmpSearchLabel = sessionStorage.getItem("searchLabel");
  1222. if (tmpSearchLabel) {
  1223. sessionStorage.removeItem("searchLabel");
  1224. doSearchLabel(sessionStorage.getItem("tableName"), sessionStorage.getItem("keyword"), sessionStorage.getItem("sortBy"), sessionStorage.getItem("ascending"));
  1225. } else {
  1226. var specifySearch = sessionStorage.getItem("specifySearch");
  1227. if (specifySearch) {
  1228. sessionStorage.removeItem("specifySearch");
  1229. document.getElementById("keyword_input").value = sessionStorage.getItem("keyword");
  1230. doSpcifySearch(sessionStorage.getItem("tableName"), sessionStorage.getItem("keyword"), sessionStorage.getItem("sortBy"), sessionStorage.getItem("ascending"));
  1231. } else {
  1232. search();
  1233. }
  1234. }
  1235. }
  1236. }