ciyunindex.html 40 KB

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