ciyunindex.html 38 KB

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