ciyunindex.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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: 0px;"><i class="checkbox-icon fl"></i></div>
  262. <div class="checkbox-con fl stopWordList"><span id="stop" 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. 共
  285. <span id="allwordnumber"></span> 词
  286. </p>
  287. <div class="main" id="stop_word_table">
  288. <!-- <div class="one">
  289. <div>{{ item }}</div>
  290. <div class="right">
  291. <span style="margin-right: 24px" @click="edit(item)">编辑</span>
  292. <span @click="deleteOne(item, i)">删除</span>
  293. </div>
  294. </div> -->
  295. </div>
  296. <div class="bottom">
  297. <button class="close" id="emptyWord">清空</button>
  298. <button class="add" id="addWord">添加</button>
  299. </div>
  300. </div>
  301. <div class="stop_word_table" id="addwordDom" style="display: none;">
  302. <div class="title">
  303. <span>添加</span>
  304. <img id="closeWordadd" src="./img/close.png" alt="">
  305. </div>
  306. <div class="top">
  307. <input style="width: 100%;" type="" name="" value="" id="addwordContent" />
  308. </div>
  309. <div class="bottom">
  310. <button class="close" id="canceladd">取消</button>
  311. <button class="add" id="addSubmit">确定</button>
  312. </div>
  313. </div>
  314. <div class="stop_word_table" id="editwordDom" style="display: none;">
  315. <div class="title">
  316. <span>添加</span>
  317. <img id="closeWordedit" src="./img/close.png" alt="">
  318. </div>
  319. <div class="top">
  320. <input style="width: 100%;" type="" name="" value="" id="editwordContent" />
  321. </div>
  322. <div class="bottom">
  323. <button class="close" id="canceledit">取消</button>
  324. <button class="add" id="editSubmit">确定</button>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. <script src="./js/d3.min.js"></script>
  330. <script src="./js/cloud.min.js"></script>
  331. <script type="text/javascript">
  332. var stopWordList = null;
  333. var oldstopWordList = [];
  334. $(function() {
  335. // initStopWords();
  336. jiekouData();
  337. })
  338. let query = location.href.split("?");
  339. let arr = query[1].split("&");
  340. var partitionKey = null;
  341. var searchType = null;
  342. var old_searchType = null
  343. var W_stopWordStatus = null
  344. var articleId = ''
  345. arr.forEach((item) => {
  346. if (item.split("=")[0] == "partitionKey") {
  347. partitionKey = item.split("=")[1];
  348. }
  349. if (item.split("=")[0] == "articleId") {
  350. articleId = item.split("=")[1];
  351. }
  352. if (item.split("=")[0] == "searchType") {
  353. searchType = item.split("=")[1];
  354. old_searchType = item.split("=")[1];
  355. }
  356. });
  357. // 如果是词汇 默认选中词
  358. if (old_searchType == 2) {
  359. $(".danwei div").removeClass("radio-active");
  360. $(".danwei").find("div").eq(1).addClass("radio-active")
  361. }
  362. if (old_searchType == 0) {
  363. $("#font").attr("value", "FZPY");
  364. $(".danwei div").removeClass("radio-active");
  365. searchType = 3
  366. $(".danwei").find("div").eq(1).addClass("radio-active")
  367. for (let i = 0; i < $("#fontSel").children().length; i++) {
  368. if ($("#fontSel").children().eq(i)[0].value == "FZPY") {
  369. $("#fontSel").children().eq(i)[0].selected = true;
  370. } else {
  371. $("#fontSel").children().eq(i)[0].selected = false;
  372. }
  373. }
  374. } else {
  375. $("#font").attr("value", "FZKT-GBK");
  376. for (let i = 0; i < $("#fontSel").children().length; i++) {
  377. if ($("#fontSel").children().eq(i)[0].value == "FZKT-GBK") {
  378. $("#fontSel").children().eq(i)[0].selected = true;
  379. } else {
  380. $("#fontSel").children().eq(i)[0].selected = false;
  381. }
  382. }
  383. }
  384. function getdata() {
  385. var arrStr = document.cookie.split("; ");
  386. var access_token = ''
  387. for (var i = 0; i < arrStr.length; i++) {
  388. var temp = arrStr[i].split("=");
  389. if (temp[0] == 'HM21St_User_Token') {
  390. access_token = JSON.parse(unescape(temp[1])).access_token
  391. } //解码
  392. }
  393. let data = {
  394. id: articleId,
  395. type: 0,
  396. }
  397. $.ajax({
  398. url: window.g.BASE_URL + "/PaperServer/Client/Article/CalcArtWordCloud?AccessToken=" + access_token,
  399. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  400. data: JSON.stringify(data),
  401. contentType: "application/json",
  402. dataType: "json",
  403. type: "post",
  404. headers: {
  405. 'Content-Type': "application/json"
  406. },
  407. success: function(res) {
  408. let str = ''
  409. res.data.result.forEach(item => {
  410. if (item.word.indexOf(" ") != -1) {
  411. item.word = item.word.replace(" ", "")
  412. }
  413. str += item.word + " "
  414. })
  415. ciyunData = res.data.result
  416. text = str
  417. $("#text").val(text);
  418. $("#go").trigger("click");
  419. console.log("2022-11-09 14点55分");
  420. }
  421. })
  422. }
  423. function initContent() {
  424. var dataType = $("#dataType").val();
  425. var ruleType = $("#rule").val();
  426. var fileId = "${fileId}";
  427. // $.ajax({
  428. // url: "${ctx}/bc/textKeyWords/wordCloud",
  429. // data: { "fileId": fileId, "ruleType": ruleType },
  430. // dataType: "JSON",
  431. // Type: "POST",
  432. // success: function (data) {
  433. let data = {
  434. count: 0,
  435. flag: true,
  436. jsonObject: null,
  437. listStr: [{
  438. frequency: 3,
  439. level: "L1",
  440. posStr: "[\"noun\"]",
  441. rate: "2762.15",
  442. word: "mine",
  443. }, {
  444. frequency: 2,
  445. level: "L0",
  446. posStr: "[\"adj\"]",
  447. rate: "996.51",
  448. word: "nice",
  449. }, {
  450. frequency: 3,
  451. level: "L0",
  452. posStr: "[\"noun\"]",
  453. rate: "340.09",
  454. word: "house",
  455. }, {
  456. frequency: 2,
  457. level: "L0",
  458. posStr: "[\"noun\"]",
  459. rate: "251.11",
  460. word: "friend",
  461. }],
  462. message: null,
  463. objects: null,
  464. userList: null,
  465. 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']
  466. }
  467. if (data.flag) {
  468. var $stop = $(".stop");
  469. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  470. // if (!stopFlag) {
  471. // stopWordLists = null;
  472. // }
  473. // if (ruleType == 1) {
  474. // var themeList = data.listStr;
  475. // text = themeDeal(themeList, stopWordLists);
  476. // } else {
  477. // var object = data.jsonObject;
  478. // var words = "";
  479. // if (dataType == "Word") {
  480. // words = object['wordList'];
  481. // } else {
  482. // words = object['lemmaList'];
  483. // }
  484. let str = ''
  485. data.arr.forEach(item => {
  486. str += item + " "
  487. })
  488. // text = replaceStop(words, stopWordLists);
  489. // }
  490. text = str
  491. $("#text").val(text);
  492. $("#go").trigger("click");
  493. } else {
  494. layer.alert(data.message);
  495. }
  496. // }, error: function (jqXHR, textStatus, errorThrown) {
  497. // if (jqXHR.status == 401) {
  498. // var url = jqXHR.responseText;
  499. // layer.alert('会话已过期,请重新登陆。', function (index) {
  500. // layer.close(index);
  501. // location.reload();
  502. // });
  503. // } else {
  504. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  505. // }
  506. // }
  507. // })
  508. }
  509. function initStopWords() {
  510. $.ajax({
  511. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/stop/word/list",
  512. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  513. data: JSON.stringify({}),
  514. contentType: "application/json;charset=UTF-8",
  515. dataType: "json",
  516. type: "post",
  517. success: function(res) {
  518. let arr = []
  519. res.data.result.forEach(item => {
  520. arr.push(item.word)
  521. })
  522. oldstopWordList = JSON.parse(JSON.stringify(arr))
  523. stopWordList = JSON.parse(JSON.stringify(arr))
  524. $("#allwordnumber").text(oldstopWordList.length)
  525. changeWordData()
  526. },
  527. error: function(jqXHR, textStatus, errorThrown) {
  528. if (jqXHR.status == 401) {
  529. var url = jqXHR.responseText;
  530. layer.alert('会话已过期,请重新登陆。', function(index) {
  531. layer.close(index);
  532. location.reload();
  533. });
  534. } else {
  535. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  536. }
  537. }
  538. });
  539. }
  540. $(".rule div").click(function() {
  541. $(".rule div").removeClass("radio-active");
  542. $(this).addClass("radio-active");
  543. $("#rule").attr("value", $(this).attr("value"))
  544. initContent();
  545. })
  546. $(".styleType div").click(function() {
  547. $(".styleType div").removeClass("radio-active");
  548. $(this).addClass("radio-active");
  549. $("#spiral").attr("value", $(this).attr("value"));
  550. $("#go").trigger("click");
  551. })
  552. // 切换单位
  553. $(".danwei div").click(function() {
  554. $(".danwei div").removeClass("radio-active");
  555. $(this).addClass("radio-active");
  556. var value = $(this).attr("value");
  557. let newvalue = null
  558. if (old_searchType == 0) { //拼音
  559. if (value == 'zi') {
  560. newvalue = 0
  561. } else {
  562. newvalue = 3
  563. }
  564. } else if (old_searchType == 2) {
  565. if (value == 'zi') {
  566. newvalue = 1
  567. } else {
  568. newvalue = 2
  569. }
  570. } else {
  571. if (value == 'zi') {
  572. newvalue = 1
  573. } else {
  574. newvalue = 4
  575. }
  576. }
  577. searchType = newvalue
  578. getdata()
  579. })
  580. $(".fontDriect div").click(function() {
  581. $(".fontDriect div").removeClass("radio-active");
  582. $(this).addClass("radio-active");
  583. var value = $(this).attr("value");
  584. if (value == 1) {
  585. $("#angle-from").val(0);
  586. $("#angle-to").val(0);
  587. $("#angle-count").val(1);
  588. inChange();
  589. $("#go").click();
  590. $("#angles svg").remove();
  591. } else if (value == 2) {
  592. $("#angle-from").val(90)
  593. $("#angle-to").val(90)
  594. $("#angle-count").val(1);
  595. inChange();
  596. $("#go").click();
  597. $("#angles svg").remove();
  598. } else if (value == 3) {
  599. $("#angle-from").val(0)
  600. $("#angle-to").val(90)
  601. $("#angle-count").val(2);
  602. inChange();
  603. $("#go").click();
  604. $("#angles svg").remove();
  605. }
  606. })
  607. $(".scaleSel div").click(function() {
  608. $(".scaleSel div").removeClass("radio-active");
  609. $(this).addClass("radio-active");
  610. var value = $(this).attr("value");
  611. $("#scale").attr("value", value);
  612. $("#go").trigger("click");
  613. })
  614. $("#fontSel").change(function() {
  615. var value = $(this).children('option:selected').val();
  616. $("#font").attr("value", value);
  617. $("#go").trigger("click");
  618. })
  619. $("#download-png").click(function() {
  620. var el = d3.select("#cloudDiv").node().children[0];
  621. saveSvgAsPng(el, "词云.png");
  622. })
  623. // $(".stopWordList").click(function () {
  624. // var openy = layer.open({
  625. // title: '停用词表'
  626. // , title: false
  627. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  628. // , area: ['440px', '595px']
  629. // , type: 2
  630. // , closeBtn: 0
  631. // });
  632. // initStopWords();
  633. // })
  634. $("#dataTypeSel").change(function() {
  635. var selvalue = $(this).children('option:selected').val();
  636. // var ruleVlue = $("#rule").attr("value");
  637. // $("#dataType").attr("value", selvalue);
  638. // initContent();
  639. jiekouData()
  640. });
  641. $(".stop").click(function() {
  642. var $stop = $(".stop");
  643. if ($stop.hasClass("checkbox-active")) {
  644. $stop.removeClass("checkbox-active");
  645. } else {
  646. $stop.addClass("checkbox-active");
  647. }
  648. jiekouData()
  649. })
  650. $(".biglittle").click(function() {
  651. var $stop = $(".biglittle");
  652. if ($stop.hasClass("checkbox-active")) {
  653. $stop.removeClass("checkbox-active");
  654. } else {
  655. $stop.addClass("checkbox-active");
  656. }
  657. jiekouData()
  658. })
  659. function jiekouData() {
  660. var $biglittle = $(".biglittle");
  661. var $stop = $(".stop");
  662. let isSelectCaseSensitive = false
  663. let isSelectLemma = false
  664. let stopWordStatus = false
  665. if ($biglittle.hasClass("checkbox-active")) {
  666. isSelectCaseSensitive = true
  667. } else {
  668. isSelectCaseSensitive = false
  669. }
  670. if ($stop.hasClass("checkbox-active")) {
  671. stopWordStatus = 1
  672. } else {
  673. stopWordStatus = 0
  674. }
  675. var selvalue = $("#dataTypeSel").children('option:selected').val();
  676. if (selvalue == 'Lemma') {
  677. isSelectLemma = true;
  678. } else {
  679. isSelectLemma = false;
  680. }
  681. W_stopWordStatus = stopWordStatus
  682. getdata()
  683. }
  684. function replaceStop(words, stopWordList) {
  685. var text = "";
  686. var wordListLow = new Array();
  687. if (stopWordList != null) {
  688. for (var i = 0; i < stopWordList.length; i++) {
  689. wordListLow.push(stopWordList[i].toLowerCase());
  690. }
  691. }
  692. for (var i = 0; i < words.length; i++) {
  693. var wordList = words[i];
  694. var word = wordList[0];
  695. var count = wordList[1];
  696. if (wordListLow.indexOf(word) < 0) {
  697. for (var j = 0; j < count; j++) {
  698. text += word + " ";
  699. }
  700. }
  701. }
  702. return text;
  703. }
  704. function themeDeal(theme, stopWordList) {
  705. var text = "";
  706. var wordListLow = new Array();
  707. if (stopWordList != null) {
  708. for (var i = 0; i < stopWordList.length; i++) {
  709. wordListLow.push(stopWordList[i].toLowerCase());
  710. }
  711. }
  712. for (var i = 0; i < theme.length; i++) {
  713. var themeWord = theme[i];
  714. var word = themeWord['word'];
  715. var flag = false;
  716. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  717. flag = true;
  718. }
  719. if (!flag) {
  720. var rate = Math.round(themeWord['rate']);
  721. for (var j = 0; j < rate; j++) {
  722. text += word + " ";
  723. }
  724. }
  725. }
  726. return text;
  727. }
  728. // 停用词表
  729. $("#stop").click(function() {
  730. $("#shadow").show()
  731. changeWordData()
  732. })
  733. // 处理词表数据
  734. var editOldVal = ""
  735. function changeWordData(msg, arr) {
  736. if (arr) {
  737. stopWordList = JSON.parse(JSON.stringify(arr));
  738. } else {
  739. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  740. }
  741. $("#stop_word_table").empty()
  742. for (let i = 0; i < stopWordList.length; i++) {
  743. let node = ` <div class="one">
  744. <div>${stopWordList[i]}</div>
  745. <div class="right">
  746. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  747. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  748. </div>
  749. </div>`
  750. $("#stop_word_table").append(node)
  751. $(`#edit${i}`).click(function() {
  752. $("#editwordDom").show()
  753. $("#wordTable").hide()
  754. $("#editwordContent").val(stopWordList[i])
  755. editOldVal = stopWordList[i]
  756. })
  757. $(`#delete${i}`).click(function() {
  758. oldstopWordList.forEach((item, i) => {
  759. if (stopWordList[i] == item) {
  760. oldstopWordList.splice(i, 1)
  761. }
  762. })
  763. updatawordData()
  764. })
  765. }
  766. if (msg) {
  767. layer.msg("成功")
  768. }
  769. }
  770. function updatawordData() {
  771. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  772. $.ajax({
  773. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/stop/word/save",
  774. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  775. data: JSON.stringify({
  776. tenantId: "",
  777. wordList: userStopVocab
  778. }),
  779. contentType: "application/json;charset=UTF-8",
  780. dataType: "json",
  781. type: "post",
  782. success: function(data) {
  783. let val = $("#wordContent").val()
  784. if (val != "") {
  785. $("#seekWordBtn").click()
  786. } else {
  787. changeWordData("msg")
  788. }
  789. },
  790. error: function(jqXHR, textStatus, errorThrown) {
  791. if (jqXHR.status == 401) {
  792. var url = jqXHR.responseText;
  793. layer.alert('会话已过期,请重新登陆。', function(index) {
  794. layer.close(index);
  795. location.reload();
  796. });
  797. } else {
  798. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  799. }
  800. }
  801. })
  802. }
  803. // 搜索
  804. $("#seekWordBtn").click(function() {
  805. let val = $("#wordContent").val()
  806. let arr = []
  807. if (val == "") {
  808. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  809. changeWordData("msg")
  810. } else {
  811. oldstopWordList.forEach((item, i) => {
  812. if (item.indexOf(val) != -1) {
  813. arr.push(item);
  814. }
  815. })
  816. // stopWordList = JSON.parse(JSON.stringify(arr))
  817. changeWordData("msg", arr)
  818. }
  819. })
  820. // 清空
  821. $("#emptyWord").click(function() {
  822. oldstopWordList = []
  823. updatawordData()
  824. })
  825. // 关闭
  826. $("#closeWord").click(function() {
  827. $("#shadow").hide()
  828. getdata()
  829. })
  830. // 新增 addWord
  831. $("#addWord").click(function() {
  832. $("#addwordDom").show()
  833. $("#wordTable").hide()
  834. $("#addwordContent").val("")
  835. })
  836. // 确定新增 addSubmit
  837. $("#addSubmit").click(function() {
  838. let val = $("#addwordContent").val()
  839. if (val == '') {
  840. layer.msg("请输入内容")
  841. return
  842. } else {
  843. let flag = false;
  844. oldstopWordList.forEach(item => {
  845. if (item == val) {
  846. flag = true
  847. }
  848. })
  849. if (flag) {
  850. layer.msg("该词已经存在,请勿重复添加")
  851. return
  852. }
  853. oldstopWordList.unshift(val)
  854. stopWordList.unshift(val)
  855. $("#wordTable").show()
  856. $("#addwordDom").hide()
  857. updatawordData()
  858. }
  859. })
  860. // 确定修改
  861. $('#editSubmit').click(function() {
  862. let val = $("#editwordContent").val()
  863. if (val == '') {
  864. layer.msg("请输入内容")
  865. return
  866. } else {
  867. let flag = false;
  868. oldstopWordList.forEach(item => {
  869. if (item == val) {
  870. flag = true
  871. }
  872. })
  873. if (flag) {
  874. layer.msg("该词已经存在,请勿重复添加")
  875. return
  876. }
  877. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  878. let index = null
  879. arr.forEach((item, i) => {
  880. if (item == editOldVal) {
  881. index = i
  882. }
  883. })
  884. arr[index] = val
  885. oldstopWordList = JSON.parse(JSON.stringify(arr))
  886. stopWordList = JSON.parse(JSON.stringify(arr))
  887. $("#wordTable").show()
  888. $("#editwordDom").hide()
  889. updatawordData()
  890. }
  891. })
  892. // 关闭新增词
  893. $("#closeWordadd").click(function() {
  894. $("#wordTable").show()
  895. $("#addwordDom").hide()
  896. })
  897. $("#canceladd").click(function() {
  898. $("#wordTable").show()
  899. $("#addwordDom").hide()
  900. })
  901. // 关闭编辑
  902. $("#closeWordedit").click(function() {
  903. $("#wordTable").show()
  904. $("#editwordDom").hide()
  905. })
  906. $("#canceledit").click(function() {
  907. $("#wordTable").show()
  908. $("#editwordDom").hide()
  909. })
  910. </script>
  911. </body>
  912. </html>