ciyunindex.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Access-Control-Allow-Origin" content="*">
  5. <meta charset="utf-8" />
  6. <title>词云</title>
  7. <link rel="stylesheet" href="./layui/css/layui.css">
  8. <script src="./js/jquery-1.11.3.js"></script>
  9. <script type="text/javascript" src="./js/saveSvgAsPng.js"></script>
  10. <script type="text/javascript" src="./layer/layer.js"></script>
  11. <script type="text/javascript" src="./layui/layui.js"></script>
  12. <link rel="stylesheet" href="./css/common.css">
  13. <link rel="stylesheet" href="./css/jiaocai.css">
  14. <link rel="stylesheet" href="./css/font/font.css">
  15. <script src="../config.js"></script>
  16. <style type="text/css">
  17. #stop:hover {
  18. text-decoration: underline;
  19. color: #FF0000;
  20. }
  21. .shadow {
  22. position: absolute;
  23. width: 100%;
  24. height: 100%;
  25. left: 0;
  26. top: 0;
  27. background: rgba(0, 0, 0, 0.3);
  28. }
  29. .stop_word_table {
  30. width: 413px;
  31. position: fixed;
  32. top: 5%;
  33. left: 37%;
  34. background: #FFFFFF;
  35. border: 1px solid rgba(0, 0, 0, 0.1);
  36. padding: 24px;
  37. }
  38. .stop_word_table .title {
  39. display: flex;
  40. justify-content: space-between;
  41. align-items: center;
  42. font-weight: bold;
  43. font-size: 16px;
  44. color: #000000;
  45. padding-bottom: 16px;
  46. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  47. }
  48. .stop_word_table .title img {
  49. width: 24px;
  50. height: 24px;
  51. cursor: pointer;
  52. }
  53. .stop_word_table .top {
  54. display: flex;
  55. align-items: center;
  56. margin-top: 16px;
  57. }
  58. .stop_word_table .top input {
  59. width: 278px;
  60. height: 40px;
  61. border: 1px solid #000000;
  62. outline: none;
  63. }
  64. .stop_word_table .top button {
  65. width: 87px;
  66. height: 40px;
  67. background: #000000;
  68. text-align: center;
  69. font-weight: bold;
  70. font-size: 16px;
  71. line-height: 40px;
  72. color: #ffffff;
  73. cursor: pointer;
  74. border: none;
  75. }
  76. .stop_word_table .main {
  77. margin-top: 16px;
  78. max-height: 340px;
  79. overflow: hidden;
  80. overflow-y: scroll;
  81. }
  82. .stop_word_table .one {
  83. display: flex;
  84. justify-content: space-between;
  85. font-size: 16px;
  86. color: #000000;
  87. height: 34px;
  88. line-height: 34px;
  89. padding: 0 8px;
  90. }
  91. .stop_word_table .right span {
  92. cursor: pointer;
  93. }
  94. .stop_word_table .main> :nth-child(2n) {
  95. background: #ffffff;
  96. }
  97. .stop_word_table .main> :nth-child(2n-1) {
  98. background: #f8f8f8;
  99. }
  100. .stop_word_table .bottom {
  101. display: flex;
  102. justify-content: space-between;
  103. margin-top: 16px;
  104. }
  105. .stop_word_table .bottom button {
  106. width: 173.5px;
  107. height: 48px;
  108. font-weight: bold;
  109. font-size: 16px;
  110. border: none;
  111. cursor: pointer;
  112. }
  113. .stop_word_table .bottom .close {
  114. background: #ebebeb;
  115. color: #000000;
  116. }
  117. .stop_word_table .bottom .add {
  118. background: #000000;
  119. color: #ffffff;
  120. }
  121. </style>
  122. </head>
  123. <body>
  124. <div class="wrap">
  125. <div class="content">
  126. <div class="content-inner" style="padding: 0;">
  127. <div class="cloudDiv">
  128. <div class="cloud-copyright">Copyright © Jason Davies</div>
  129. <div class="cloud-con-div" id="cloudDiv"></div>
  130. </div>
  131. <form id="form">
  132. <div class="cloud-box">
  133. <!-- <div class="cloud-rule clear">
  134. <div class="rule-item fl">
  135. <p class="fl">规则:</p>
  136. <input type="text" hidden="" id="rule" value="1">
  137. <div class="rule-radio rule fl">
  138. <div name="radio" class="radio-con fl ruleType radio-active" value='1'><i
  139. class="radio-icon fl"></i>主题性
  140. </div>
  141. <div name="radio" class="radio-con fl ruleType" value='2'><i
  142. class="radio-icon fl"></i>频次</div>
  143. </div>
  144. </div>
  145. <div class="rule-item fl">
  146. <p class="fl">数据类型:</p>
  147. <input type="text" hidden="" id="dataType" value="Word">
  148. <select name="selectDataType" class="selectOp fl" id="dataTypeSel">
  149. <option value="Word">Word</option>
  150. <option value="Lemma">Lemma</option>
  151. </select>
  152. </div>
  153. <div class="rule-item fl">
  154. <div class="checkbox-con fl biglittle" style="margin-right: 0px;"><i
  155. class="checkbox-icon fl"></i></div>
  156. <div class="checkbox-con fl stopWordList"><span id="biglittle"
  157. style="color: #0079FF;">区分大小写</span></div>
  158. </div>
  159. </div> -->
  160. <div class="cloud-rule clear" style="border:0;">
  161. <div class="rule-item fl">
  162. <p class="fl">样式:</p>
  163. <input type="text" hidden="" id="spiral" value="archimedean">
  164. <div class="rule-radio styleType fl">
  165. <div name="radio" class="radio-con radio-active fl" value='archimedean'><i class="radio-icon fl"></i>螺线
  166. </div>
  167. <div name="radio" class="radio-con fl" value='rectangular'><i class="radio-icon fl"></i>矩形</div>
  168. </div>
  169. </div>
  170. <div class="rule-item fl">
  171. <p class="fl">字体:</p>
  172. <!-- 方正书宋 FZSS
  173. 兰亭黑 FZLTH
  174. 方正楷体 FZKT-GBK
  175. 方正拼音 FZPY
  176. -->
  177. <input type="radio" hidden="" id="font" value="">
  178. <select name="selectFont" class="selectOp fl" id="fontSel">
  179. <option value="Impact">Impact</option>
  180. <option value="Georgia">Georgia</option>
  181. <option value="Arial">Arial</option>
  182. <option value="Constantia">Constantia</option>
  183. <option value="Century">Century</option>
  184. <option value="Berlin Sans FB">Berlin Sans FB</option>
  185. <option value="Cooper Black">Cooper Black</option>
  186. <option value="Elephant">Elephant</option>
  187. <option value="FZSS">方正书宋</option>
  188. <option value="FZLTH">方正兰亭黑</option>
  189. <option value="FZKT-GBK;楷体">方正楷体</option>
  190. <option value="FZPY">方正拼音</option>
  191. </select>
  192. </div>
  193. <div class="rule-item fl">
  194. <p class="fl">文字方向:</p>
  195. <input type="text" hidden="" id="fontdir" value="1">
  196. <div class="rule-radio fontDriect fl">
  197. <div name="orientations" class="radio-con radio-active fl" value='1'><i class="radio-icon fl"></i>水平
  198. </div>
  199. <div name="orientations" class="radio-con fl" value='2'><i class="radio-icon fl"></i>垂直</div>
  200. <div name="orientations" class="radio-con fl" value='3'><i class="radio-icon fl"></i>垂直和水平</div>
  201. </div>
  202. </div>
  203. <div class="rule-item fl">
  204. <p class="fl">单位:</p>
  205. <input type="text" hidden="" id="danwei" value="zi">
  206. <div class="rule-radio danwei fl">
  207. <div name="danwei" class="radio-con radio-active fl" value='zi'><i class="radio-icon fl"></i>字
  208. </div>
  209. <div name="danwei" class="radio-con fl" value='ci'><i class="radio-icon fl"></i>词
  210. </div>
  211. </div>
  212. </div>
  213. <div id="angles" style="float: left" hidden="">
  214. <p>
  215. <input type="number" id="angle-count" value="5" min="1"><label for="angle-count">
  216. <font style="vertical-align: inherit;"></font>
  217. </label>
  218. <font style="vertical-align: inherit;"><label for="angle-from">
  219. <font style="vertical-align: inherit;">来自的</font>
  220. </label><label for="angle-count">
  221. <font style="vertical-align: inherit;">方向</font>
  222. </label></font><label for="angle-from">
  223. <font style="vertical-align: inherit;"></font>
  224. </label><input type="number" id="angle-from" value="0" min="-90" max="90">
  225. <font style="vertical-align: inherit;">
  226. <font style="vertical-align: inherit;">°
  227. </font>
  228. </font><label for="angle-to">
  229. <font style="vertical-align: inherit;">
  230. <font style="vertical-align: inherit;">到</font>
  231. </font>
  232. </label><input type="number" id="angle-to" value="0" min="-90" max="90">
  233. <font style="vertical-align: inherit;">
  234. <font style="vertical-align: inherit;"> °
  235. </font>
  236. </font>
  237. </p>
  238. </div>
  239. <div class="rule-item fl">
  240. <p class="fl">缩放:</p>
  241. <input type="text" hidden="" id="scale" value="sqrt">
  242. <div class="rule-radio scaleSel fl">
  243. <div name="radio" class="radio-con fl" value="log"><i class="radio-icon fl"></i>log n
  244. </div>
  245. <div name="radio" class="radio-con radio-active fl" value="sqrt"><i class="radio-icon fl"></i>✓n</div>
  246. <div name="radio" class="radio-con fl" value="linear"><i class="radio-icon fl"></i>n
  247. </div>
  248. </div>
  249. </div>
  250. <div class="rule-item fl">
  251. <p class="fl">下载:</p>
  252. <div class="download-type fl">
  253. <span class="dType" id="download-svg">SVG</span>
  254. <span class="line2">|</span>
  255. <span class="dType" id="download-png">PNG</span>
  256. </div>
  257. </div>
  258. <div class="rule-item fl">
  259. <!-- <div class="checkbox-con checkbox-active fl hide"><i class="checkbox-icon fl"></i>区分大小写 -->
  260. <!-- </div> -->
  261. <div class="checkbox-con fl stop" style="margin-right: 8px;"><i class="checkbox-icon fl"></i><span style="color: #0079FF;">停用词表</span></div>
  262. <div class="checkbox-con fl stopWordList" id="stop"><img src="./img/settings-fill.png" style="width: 16px;" /><span style="color: #0079FF;">配置</span></div>
  263. </div>
  264. </div>
  265. <textarea rows="" cols="" id="text" name="text" hidden=""></textarea>
  266. </div>
  267. <div class="cloud-footer">
  268. <button class="produce" type="submit" id="go">生成</button>
  269. </div>
  270. </form>
  271. </div>
  272. </div>
  273. <div class="shadow" id="shadow" style="display: none;">
  274. <div class="stop_word_table" id="wordTable">
  275. <div class="title">
  276. <span>停用词表</span>
  277. <img id="closeWord" src="./img/close.png" alt="">
  278. </div>
  279. <div class="top">
  280. <input type="" name="" value="" id="wordContent" />
  281. <button id="seekWordBtn">检索</button>
  282. </div>
  283. <p style="text-align: right; margin-top: 16px; font-size: 16px; color: #000000">
  284. <span id="allwordnumber"></span> 词
  285. </p>
  286. <div class="main" id="stop_word_table">
  287. <!-- <div class="one">
  288. <div>{{ item }}</div>
  289. <div class="right">
  290. <span style="margin-right: 24px" @click="edit(item)">编辑</span>
  291. <span @click="deleteOne(item, i)">删除</span>
  292. </div>
  293. </div> -->
  294. </div>
  295. <div class="bottom">
  296. <button class="close" id="emptyWord">清空</button>
  297. <button class="add" id="addWord">添加</button>
  298. </div>
  299. </div>
  300. <div class="stop_word_table" id="addwordDom" style="display: none;">
  301. <div class="title">
  302. <span>添加</span>
  303. <img id="closeWordadd" src="./img/close.png" alt="">
  304. </div>
  305. <div class="top">
  306. <input style="width: 100%;" type="" name="" value="" id="addwordContent" />
  307. </div>
  308. <div class="bottom">
  309. <button class="close" id="canceladd">取消</button>
  310. <button class="add" id="addSubmit">确定</button>
  311. </div>
  312. </div>
  313. <div class="stop_word_table" id="editwordDom" style="display: none;">
  314. <div class="title">
  315. <span>添加</span>
  316. <img id="closeWordedit" src="./img/close.png" alt="">
  317. </div>
  318. <div class="top">
  319. <input style="width: 100%;" type="" name="" value="" id="editwordContent" />
  320. </div>
  321. <div class="bottom">
  322. <button class="close" id="canceledit">取消</button>
  323. <button class="add" id="editSubmit">确定</button>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. <script src="./js/d3.min.js"></script>
  329. <script src="./js/cloud.min.js"></script>
  330. <script type="text/javascript">
  331. var stopWordList = null;
  332. var oldstopWordList = [];
  333. $(function() {
  334. initStopWords();
  335. jiekouData();
  336. })
  337. let query = location.href.split("?");
  338. let arr = query[1].split("&");
  339. var partitionKey = null;
  340. var searchType = null;
  341. var old_searchType = null
  342. var W_stopWordStatus = null
  343. var prefix = 'GCLS_Token='
  344. var start = document.cookie.indexOf(prefix)
  345. var end = document.cookie.indexOf(";", start + prefix.length)
  346. if (end == -1) {
  347. end = document.cookie.length;
  348. }
  349. var AccessToken = JSON.parse(unescape(document.cookie.substring(start + prefix.length, end))).access_token
  350. arr.forEach((item) => {
  351. if (item.split("=")[0] == "partitionKey") {
  352. partitionKey = item.split("=")[1];
  353. }
  354. if (item.split("=")[0] == "searchType") {
  355. searchType = item.split("=")[1];
  356. old_searchType = item.split("=")[1];
  357. }
  358. });
  359. // 如果是词汇 默认选中词
  360. if (old_searchType == 2) {
  361. $(".danwei div").removeClass("radio-active");
  362. $(".danwei").find("div").eq(1).addClass("radio-active")
  363. }
  364. if (old_searchType == 0) {
  365. $("#font").attr("value", "FZPY");
  366. $(".danwei div").removeClass("radio-active");
  367. searchType = 3
  368. $(".danwei").find("div").eq(1).addClass("radio-active")
  369. for (let i = 0; i < $("#fontSel").children().length; i++) {
  370. if ($("#fontSel").children().eq(i)[0].value == "FZPY") {
  371. $("#fontSel").children().eq(i)[0].selected = true;
  372. } else {
  373. $("#fontSel").children().eq(i)[0].selected = false;
  374. }
  375. }
  376. } else {
  377. $("#font").attr("value", "FZKT-GBK");
  378. for (let i = 0; i < $("#fontSel").children().length; i++) {
  379. if ($("#fontSel").children().eq(i)[0].value == "FZKT-GBK") {
  380. $("#fontSel").children().eq(i)[0].selected = true;
  381. } else {
  382. $("#fontSel").children().eq(i)[0].selected = false;
  383. }
  384. }
  385. }
  386. function getdata() {
  387. let data = {
  388. type: searchType * 1,
  389. analyse_record_id: partitionKey,
  390. is_contain_stop_word: W_stopWordStatus ? 'false' : 'true',
  391. }
  392. $.ajax({
  393. url: window.location.origin + "/TeachingServer/TextAnalyser/GetWordCloudData?AccessToken=" + AccessToken,
  394. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  395. data: JSON.stringify(data),
  396. contentType: "application/json",
  397. dataType: "json",
  398. type: "post",
  399. success: function(res) {
  400. let str = ''
  401. res.data_list.forEach(item => {
  402. if (item.word.indexOf(" ") != -1) {
  403. item.word = item.word.replace(" ", "")
  404. }
  405. str += item.word + " "
  406. })
  407. ciyunData = res.data_list
  408. text = str
  409. $("#text").val(text);
  410. $("#go").trigger("click");
  411. console.log("2022-11-09 14点55分");
  412. }
  413. })
  414. }
  415. function initContent() {
  416. var dataType = $("#dataType").val();
  417. var ruleType = $("#rule").val();
  418. var fileId = "${fileId}";
  419. // $.ajax({
  420. // url: "${ctx}/bc/textKeyWords/wordCloud",
  421. // data: { "fileId": fileId, "ruleType": ruleType },
  422. // dataType: "JSON",
  423. // Type: "POST",
  424. // success: function (data) {
  425. let data = {
  426. count: 0,
  427. flag: true,
  428. jsonObject: null,
  429. listStr: [{
  430. frequency: 3,
  431. level: "L1",
  432. posStr: "[\"noun\"]",
  433. rate: "2762.15",
  434. word: "mine",
  435. }, {
  436. frequency: 2,
  437. level: "L0",
  438. posStr: "[\"adj\"]",
  439. rate: "996.51",
  440. word: "nice",
  441. }, {
  442. frequency: 3,
  443. level: "L0",
  444. posStr: "[\"noun\"]",
  445. rate: "340.09",
  446. word: "house",
  447. }, {
  448. frequency: 2,
  449. level: "L0",
  450. posStr: "[\"noun\"]",
  451. rate: "251.11",
  452. word: "friend",
  453. }],
  454. message: null,
  455. objects: null,
  456. userList: null,
  457. arr: ['5', '6', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'a', 'Hi', 'Is', 'It', 'My', 'am', 'is', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'my', 'my', 'my', 'my', 'my', 'my', 'Are', 'She', 'are', 'big', 'you', 'you', 'you', 'you', 'you', 'They', 'This', 'mine', 'mine', 'mine', 'name', 'nice', 'tall', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'very', 'very', 'very', 'very', 'you', 'you', 'you', 'you', 'you', 'Giant', 'Kendo', 'These', 'funny', 'house', 'house', 'house', 'nicer', 'think', 'think', 'three', 'yours', 'yours', 'yours', 'bigger', 'meters', 'school', 'school', 'taller', 'friends', 'funnier', 'teacher', 'teacher', 'younger', 'friendly', 'nineteen', 'friendlier', 'qinpeng']
  458. }
  459. if (data.flag) {
  460. var $stop = $(".stop");
  461. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  462. // if (!stopFlag) {
  463. // stopWordLists = null;
  464. // }
  465. // if (ruleType == 1) {
  466. // var themeList = data.listStr;
  467. // text = themeDeal(themeList, stopWordLists);
  468. // } else {
  469. // var object = data.jsonObject;
  470. // var words = "";
  471. // if (dataType == "Word") {
  472. // words = object['wordList'];
  473. // } else {
  474. // words = object['lemmaList'];
  475. // }
  476. let str = ''
  477. data.arr.forEach(item => {
  478. str += item + " "
  479. })
  480. // text = replaceStop(words, stopWordLists);
  481. // }
  482. text = str
  483. $("#text").val(text);
  484. $("#go").trigger("click");
  485. } else {
  486. layer.alert(data.message);
  487. }
  488. // }, error: function (jqXHR, textStatus, errorThrown) {
  489. // if (jqXHR.status == 401) {
  490. // var url = jqXHR.responseText;
  491. // layer.alert('会话已过期,请重新登陆。', function (index) {
  492. // layer.close(index);
  493. // location.reload();
  494. // });
  495. // } else {
  496. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  497. // }
  498. // }
  499. // })
  500. }
  501. function initStopWords() {
  502. $.ajax({
  503. url: window.location.origin + "/TeachingServer/TextAnalyser/GetMyStopWordList?AccessToken=" + AccessToken,
  504. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  505. data: JSON.stringify({}),
  506. contentType: "application/json;charset=UTF-8",
  507. dataType: "json",
  508. type: "post",
  509. success: function(res) {
  510. let arr = []
  511. if (res.word_list) {
  512. res.word_list.forEach(item => {
  513. arr.push(item)
  514. })
  515. }
  516. oldstopWordList = JSON.parse(JSON.stringify(arr))
  517. stopWordList = JSON.parse(JSON.stringify(arr))
  518. $("#allwordnumber").text(oldstopWordList.length)
  519. changeWordData()
  520. },
  521. error: function(jqXHR, textStatus, errorThrown) {
  522. if (jqXHR.status == 401) {
  523. var url = jqXHR.responseText;
  524. layer.alert('会话已过期,请重新登陆。', function(index) {
  525. layer.close(index);
  526. location.reload();
  527. });
  528. } else {
  529. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  530. }
  531. }
  532. });
  533. }
  534. $(".rule div").click(function() {
  535. $(".rule div").removeClass("radio-active");
  536. $(this).addClass("radio-active");
  537. $("#rule").attr("value", $(this).attr("value"))
  538. initContent();
  539. })
  540. $(".styleType div").click(function() {
  541. $(".styleType div").removeClass("radio-active");
  542. $(this).addClass("radio-active");
  543. $("#spiral").attr("value", $(this).attr("value"));
  544. $("#go").trigger("click");
  545. })
  546. // 切换单位
  547. $(".danwei div").click(function() {
  548. $(".danwei div").removeClass("radio-active");
  549. $(this).addClass("radio-active");
  550. var value = $(this).attr("value");
  551. let newvalue = null
  552. if (old_searchType == 0) { //拼音
  553. if (value == 'zi') {
  554. newvalue = 0
  555. } else {
  556. newvalue = 3
  557. }
  558. } else if (old_searchType == 2) {
  559. if (value == 'zi') {
  560. newvalue = 1
  561. } else {
  562. newvalue = 2
  563. }
  564. } else {
  565. if (value == 'zi') {
  566. newvalue = 1
  567. } else {
  568. newvalue = 2
  569. }
  570. }
  571. searchType = newvalue
  572. getdata()
  573. })
  574. $(".fontDriect div").click(function() {
  575. $(".fontDriect div").removeClass("radio-active");
  576. $(this).addClass("radio-active");
  577. var value = $(this).attr("value");
  578. if (value == 1) {
  579. $("#angle-from").val(0);
  580. $("#angle-to").val(0);
  581. $("#angle-count").val(1);
  582. inChange();
  583. $("#go").click();
  584. $("#angles svg").remove();
  585. } else if (value == 2) {
  586. $("#angle-from").val(90)
  587. $("#angle-to").val(90)
  588. $("#angle-count").val(1);
  589. inChange();
  590. $("#go").click();
  591. $("#angles svg").remove();
  592. } else if (value == 3) {
  593. $("#angle-from").val(0)
  594. $("#angle-to").val(90)
  595. $("#angle-count").val(2);
  596. inChange();
  597. $("#go").click();
  598. $("#angles svg").remove();
  599. }
  600. })
  601. $(".scaleSel div").click(function() {
  602. $(".scaleSel div").removeClass("radio-active");
  603. $(this).addClass("radio-active");
  604. var value = $(this).attr("value");
  605. $("#scale").attr("value", value);
  606. $("#go").trigger("click");
  607. })
  608. $("#fontSel").change(function() {
  609. var value = $(this).children('option:selected').val();
  610. $("#font").attr("value", value);
  611. $("#go").trigger("click");
  612. })
  613. $("#download-png").click(function() {
  614. var el = d3.select("#cloudDiv").node().children[0];
  615. saveSvgAsPng(el, "词云.png");
  616. })
  617. // $(".stopWordList").click(function () {
  618. // var openy = layer.open({
  619. // title: '停用词表'
  620. // , title: false
  621. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  622. // , area: ['440px', '595px']
  623. // , type: 2
  624. // , closeBtn: 0
  625. // });
  626. // initStopWords();
  627. // })
  628. $("#dataTypeSel").change(function() {
  629. var selvalue = $(this).children('option:selected').val();
  630. // var ruleVlue = $("#rule").attr("value");
  631. // $("#dataType").attr("value", selvalue);
  632. // initContent();
  633. jiekouData()
  634. });
  635. $(".stop").click(function() {
  636. var $stop = $(".stop");
  637. if ($stop.hasClass("checkbox-active")) {
  638. $stop.removeClass("checkbox-active");
  639. } else {
  640. $stop.addClass("checkbox-active");
  641. }
  642. jiekouData()
  643. })
  644. $(".biglittle").click(function() {
  645. var $stop = $(".biglittle");
  646. if ($stop.hasClass("checkbox-active")) {
  647. $stop.removeClass("checkbox-active");
  648. } else {
  649. $stop.addClass("checkbox-active");
  650. }
  651. jiekouData()
  652. })
  653. function jiekouData() {
  654. var $biglittle = $(".biglittle");
  655. var $stop = $(".stop");
  656. let isSelectCaseSensitive = false
  657. let isSelectLemma = false
  658. let stopWordStatus = false
  659. if ($biglittle.hasClass("checkbox-active")) {
  660. isSelectCaseSensitive = true
  661. } else {
  662. isSelectCaseSensitive = false
  663. }
  664. if ($stop.hasClass("checkbox-active")) {
  665. stopWordStatus = 1
  666. } else {
  667. stopWordStatus = 0
  668. }
  669. var selvalue = $("#dataTypeSel").children('option:selected').val();
  670. if (selvalue == 'Lemma') {
  671. isSelectLemma = true;
  672. } else {
  673. isSelectLemma = false;
  674. }
  675. W_stopWordStatus = stopWordStatus
  676. getdata()
  677. }
  678. function replaceStop(words, stopWordList) {
  679. var text = "";
  680. var wordListLow = new Array();
  681. if (stopWordList != null) {
  682. for (var i = 0; i < stopWordList.length; i++) {
  683. wordListLow.push(stopWordList[i].toLowerCase());
  684. }
  685. }
  686. for (var i = 0; i < words.length; i++) {
  687. var wordList = words[i];
  688. var word = wordList[0];
  689. var count = wordList[1];
  690. if (wordListLow.indexOf(word) < 0) {
  691. for (var j = 0; j < count; j++) {
  692. text += word + " ";
  693. }
  694. }
  695. }
  696. return text;
  697. }
  698. function themeDeal(theme, stopWordList) {
  699. var text = "";
  700. var wordListLow = new Array();
  701. if (stopWordList != null) {
  702. for (var i = 0; i < stopWordList.length; i++) {
  703. wordListLow.push(stopWordList[i].toLowerCase());
  704. }
  705. }
  706. for (var i = 0; i < theme.length; i++) {
  707. var themeWord = theme[i];
  708. var word = themeWord['word'];
  709. var flag = false;
  710. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  711. flag = true;
  712. }
  713. if (!flag) {
  714. var rate = Math.round(themeWord['rate']);
  715. for (var j = 0; j < rate; j++) {
  716. text += word + " ";
  717. }
  718. }
  719. }
  720. return text;
  721. }
  722. // 停用词表
  723. $("#stop").click(function() {
  724. $("#shadow").show()
  725. changeWordData()
  726. })
  727. // 处理词表数据
  728. var editOldVal = ""
  729. function changeWordData(msg, arr) {
  730. if (arr) {
  731. stopWordList = JSON.parse(JSON.stringify(arr));
  732. } else {
  733. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  734. }
  735. $("#stop_word_table").empty()
  736. for (let i = 0; i < stopWordList.length; i++) {
  737. let node = ` <div class="one">
  738. <div>${stopWordList[i]}</div>
  739. <div class="right">
  740. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  741. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  742. </div>
  743. </div>`
  744. $("#stop_word_table").append(node)
  745. $(`#edit${i}`).click(function() {
  746. $("#editwordDom").show()
  747. $("#wordTable").hide()
  748. $("#editwordContent").val(stopWordList[i])
  749. editOldVal = stopWordList[i]
  750. })
  751. $(`#delete${i}`).click(function() {
  752. oldstopWordList.forEach((item, i) => {
  753. if (stopWordList[i] == item) {
  754. oldstopWordList.splice(i, 1)
  755. }
  756. })
  757. updatawordData()
  758. })
  759. }
  760. if (msg) {
  761. layer.msg("成功")
  762. }
  763. }
  764. function updatawordData() {
  765. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  766. $.ajax({
  767. url: window.location.origin + "/TeachingServer/TextAnalyser/AddMyStopWord?AccessToken=" + AccessToken,
  768. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  769. data: JSON.stringify({
  770. word_list: userStopVocab
  771. }),
  772. contentType: "application/json;charset=UTF-8",
  773. dataType: "json",
  774. type: "post",
  775. success: function(data) {
  776. let val = $("#wordContent").val()
  777. if (val != "") {
  778. $("#seekWordBtn").click()
  779. } else {
  780. changeWordData("msg")
  781. }
  782. },
  783. error: function(jqXHR, textStatus, errorThrown) {
  784. if (jqXHR.status == 401) {
  785. var url = jqXHR.responseText;
  786. layer.alert('会话已过期,请重新登陆。', function(index) {
  787. layer.close(index);
  788. location.reload();
  789. });
  790. } else {
  791. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  792. }
  793. }
  794. })
  795. }
  796. // 搜索
  797. $("#seekWordBtn").click(function() {
  798. let val = $("#wordContent").val()
  799. let arr = []
  800. if (val == "") {
  801. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  802. changeWordData("msg")
  803. } else {
  804. oldstopWordList.forEach((item, i) => {
  805. if (item.indexOf(val) != -1) {
  806. arr.push(item);
  807. }
  808. })
  809. // stopWordList = JSON.parse(JSON.stringify(arr))
  810. changeWordData("msg", arr)
  811. }
  812. })
  813. // 清空
  814. $("#emptyWord").click(function() {
  815. oldstopWordList = []
  816. updatawordData()
  817. })
  818. // 关闭
  819. $("#closeWord").click(function() {
  820. $("#shadow").hide()
  821. getdata()
  822. })
  823. // 新增 addWord
  824. $("#addWord").click(function() {
  825. $("#addwordDom").show()
  826. $("#wordTable").hide()
  827. $("#addwordContent").val("")
  828. })
  829. // 确定新增 addSubmit
  830. $("#addSubmit").click(function() {
  831. let val = $("#addwordContent").val()
  832. if (val == '') {
  833. layer.msg("请输入内容")
  834. return
  835. } else {
  836. let flag = false;
  837. oldstopWordList.forEach(item => {
  838. if (item == val) {
  839. flag = true
  840. }
  841. })
  842. if (flag) {
  843. layer.msg("该词已经存在,请勿重复添加")
  844. return
  845. }
  846. oldstopWordList.unshift(val)
  847. stopWordList.unshift(val)
  848. $("#wordTable").show()
  849. $("#addwordDom").hide()
  850. updatawordData()
  851. }
  852. })
  853. // 确定修改
  854. $('#editSubmit').click(function() {
  855. let val = $("#editwordContent").val()
  856. if (val == '') {
  857. layer.msg("请输入内容")
  858. return
  859. } else {
  860. let flag = false;
  861. oldstopWordList.forEach(item => {
  862. if (item == val) {
  863. flag = true
  864. }
  865. })
  866. if (flag) {
  867. layer.msg("该词已经存在,请勿重复添加")
  868. return
  869. }
  870. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  871. let index = null
  872. arr.forEach((item, i) => {
  873. if (item == editOldVal) {
  874. index = i
  875. }
  876. })
  877. arr[index] = val
  878. oldstopWordList = JSON.parse(JSON.stringify(arr))
  879. stopWordList = JSON.parse(JSON.stringify(arr))
  880. $("#wordTable").show()
  881. $("#editwordDom").hide()
  882. updatawordData()
  883. }
  884. })
  885. // 关闭新增词
  886. $("#closeWordadd").click(function() {
  887. $("#wordTable").show()
  888. $("#addwordDom").hide()
  889. })
  890. $("#canceladd").click(function() {
  891. $("#wordTable").show()
  892. $("#addwordDom").hide()
  893. })
  894. // 关闭编辑
  895. $("#closeWordedit").click(function() {
  896. $("#wordTable").show()
  897. $("#editwordDom").hide()
  898. })
  899. $("#canceledit").click(function() {
  900. $("#wordTable").show()
  901. $("#editwordDom").hide()
  902. })
  903. </script>
  904. </body>
  905. </html>