index.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>afaa</title>
  8. <link rel="stylesheet" type="text/css" href="css/normalize.css"/>
  9. <link rel="stylesheet" type="text/css" href="css/default.css">
  10. <link rel="stylesheet" href="css/style.css">
  11. <link href="http://cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="css/bootstrap.min.css" rel="stylesheet">
  13. <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
  14. <script src="js/jquery.min.js"></script>
  15. <script src="js/bootstrap.min.js"></script>
  16. <script src="js/jquery_cookie_min.js"></script>
  17. <script src="js/scripts.js"></script>
  18. <script src="js/jqhttpsdk.js"></script>
  19. <script src="js/jkcor.js"></script>
  20. <script src="js/pages.js"></script>
  21. </head>
  22. <body>
  23. <div class="clear-backend">
  24. <div class="avatar">
  25. <div>
  26. <a href="#" target="_blank">
  27. <img src="img/admin.png" alt="">
  28. </a>
  29. </div>
  30. </div>
  31. <!-- tab-menu -->
  32. <input type="radio" class="tab-1" name="tab" checked="checked">
  33. <span>Home</span><i class="fa fa-home"></i>
  34. <input type="radio" class="tab-2" name="tab">
  35. <span>Lang</span><i class="fa fa-medium"></i>
  36. <input type="radio" class="tab-3" name="tab">
  37. <span>Users</span><i class="fa fa-user"></i>
  38. <input type="radio" class="tab-4" name="tab">
  39. <span>Comments</span><i class="fa fa-comment"></i>
  40. <input type="radio" class="tab-5" name="tab">
  41. <span>Upload</span><i class="fa fa-cloud-upload"></i>
  42. <input type="radio" class="tab-6" name="tab">
  43. <span>Favorite</span><i class="fa fa-star"></i>
  44. <input type="radio" class="tab-7" name="tab">
  45. <span>Photos</span><i class="fa fa-photo"></i>
  46. <input type="radio" class="tab-8" name="tab">
  47. <span>Analysis</span><i class="fa fa-line-chart"></i>
  48. <input type="radio" class="tab-9" name="tab">
  49. <span>Links</span><i class="fa fa-link"></i>
  50. <input type="radio" class="tab-10" name="tab">
  51. <span>Settings</span><i class="fa fa-cog"></i>
  52. <!-- tab-top-bar -->
  53. <div class="top-bar">
  54. <ul>
  55. <li>
  56. <a href="" title="Log Out">
  57. <i class="fa fa-sign-out"></i>
  58. </a>
  59. </li>
  60. <li>
  61. <a href="" title="Messages">
  62. <i class="fa fa-envelope"></i>
  63. </a>
  64. </li>
  65. <li>
  66. <a href="" title="Edit">
  67. <i class="fa fa-edit"></i>
  68. </a>
  69. </li>
  70. </ul>
  71. </div>
  72. <!-- tab-content -->
  73. <div class="tab-content">
  74. <section class="tab-item-1">
  75. <!--<header></header>-->
  76. <div class="container-fluid">
  77. <div class="row">
  78. <div class="col-md-12">
  79. <form role="form">
  80. <div class="form-group">
  81. <label for="InputLangArea">
  82. langArea
  83. </label>
  84. <input type="text" class="form-control" id="InputLangArea"/>
  85. </div>
  86. <button type="submit" class="btn btn-primary" onclick="subLangAre();return false;">
  87. Submit
  88. </button>
  89. </form>
  90. </div>
  91. </div>
  92. </div>
  93. <!--add area-->
  94. <!--table-->
  95. <div class="container-fluid">
  96. <div class="row">
  97. <div class="col-md-12">
  98. <div class="input-group">
  99. <div class="input-group-prepend">
  100. <div class="input-group-text">
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <!--add-->
  106. <div class="col-md-12">
  107. <table class="table table-bordered table-hover">
  108. <thead id="langTableHead"></thead>
  109. <tbody id="langTableBody"></tbody>
  110. </table>
  111. </div>
  112. </div>
  113. <div id="pagination"></div>
  114. </div>
  115. <!---->
  116. <div class="container-fluid">
  117. <div class="row">
  118. <div class="col-md-12">
  119. <div class="modal fade" id="modal-container-593541" role="dialog" aria-labelledby="myModalLabel"
  120. aria-hidden="true">
  121. <div class="modal-dialog" role="document">
  122. <div class="modal-content">
  123. <div class="modal-header">
  124. <h5 class="modal-title" id="myModalLabel">
  125. EDIT
  126. </h5>
  127. <button type="button" class="close" data-dismiss="modal">
  128. <span aria-hidden="true">×</span>
  129. </button>
  130. </div>
  131. <div class="modal-body">
  132. <div class="form-group" id="edit_model_form">
  133. <!--<label for="InputLangArea">-->
  134. <!--langArea-->
  135. <!--</label>-->
  136. <!--<input type="text" class="form-control" id="InputLangArea"/>-->
  137. </div>
  138. </div>
  139. <div class="modal-footer">
  140. <button type="button" class="btn btn-primary editRowSaveBtn"
  141. onclick="editRow(this);return false;">
  142. Save changes
  143. </button>
  144. <button type="button" class="btn btn-secondary" data-dismiss="modal">
  145. Close
  146. </button>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <!---->
  155. </section>
  156. <section class="tab-item-2">
  157. <h1>Two</h1>
  158. </section>
  159. <section class="tab-item-3">
  160. <h1>Three</h1>
  161. </section>
  162. <section class="tab-item-4">
  163. <h1>Four</h1>
  164. </section>
  165. <section class="tab-item-5">
  166. <h1>Five</h1>
  167. </section>
  168. <section class="tab-item-6">
  169. <h1>Six</h1>
  170. </section>
  171. <section class="tab-item-7">
  172. <h1>Sever</h1>
  173. </section>
  174. <section class="tab-item-8">
  175. <h1>Eight</h1>
  176. </section>
  177. <section class="tab-item-9">
  178. <h1>Nine</h1>
  179. </section>
  180. <section class="tab-item-10">
  181. <h1>Ten</h1>
  182. </section>
  183. </div>
  184. </div>
  185. <script type="text/javascript">
  186. $(function () {
  187. let post_data = {
  188. 'token': $.cookie('access_token'),
  189. 'page': 1,
  190. 'line': 10
  191. };
  192. $.postJSON(
  193. http_ip_prot + 'langWord/query', JSON.stringify(post_data),
  194. function (data) {
  195. if (data['code'] == 0) {
  196. // console.log(data['res'])
  197. console.log(data)
  198. addTable(data['res'])
  199. let count_page = Math.ceil(data['res']['count'] / 10)
  200. $('#pagination').pagination({
  201. pages: count_page, //总页数
  202. // pages: 10000, //总页数
  203. edges: 2,
  204. cssStyle: 'pagination-sm', //按纽大小pagination-lg或写入自定义css
  205. displayedPages: 5, //显示几个
  206. onPageClick: function (pageNumber, event) {
  207. //点击时调用
  208. // alert(pageNumber);
  209. queryData(pageNumber)
  210. },
  211. onInit: function (getid) {
  212. //刷新时或初始化调用
  213. // alert(getid);
  214. }
  215. });
  216. } else {
  217. alert(data['msg'])
  218. }
  219. }
  220. );
  221. // $('#pagination').pagination({
  222. // pages: 50, //总页数
  223. // edges: 2,
  224. // cssStyle: 'pagination-sm', //按纽大小pagination-lg或写入自定义css
  225. // displayedPages: 5, //显示几个
  226. // onPageClick: function(pageNumber, event) {
  227. // //点击时调用
  228. // // alert(pageNumber);
  229. // },
  230. // onInit: function(getid) {
  231. // //刷新时或初始化调用
  232. // // alert(getid);
  233. // }
  234. // });
  235. });
  236. let la_list
  237. let checkboxInput = '<input type="checkbox" aria-label="Checkbox for following text input">'
  238. let lw_data
  239. function queryData(page) {
  240. let post_data = {
  241. 'token': $.cookie('access_token'),
  242. 'page': page,
  243. 'line': 10
  244. };
  245. $.postJSON(
  246. http_ip_prot + 'langWord/query', JSON.stringify(post_data),
  247. function (data) {
  248. if (data['code'] == 0) {
  249. // console.log(data['res'])
  250. console.log(data)
  251. addTable(data['res'])
  252. } else {
  253. alert(data['msg'])
  254. }
  255. }
  256. );
  257. }
  258. function addTable(data) {
  259. //头部多区域语言
  260. let head_data = data['la_list'];
  261. la_list = head_data
  262. // body部详细语言
  263. let body_data = data['lw_dict'];
  264. lw_data = body_data
  265. let head_html = '<tr><th>en</th>';
  266. //头部标签添加
  267. $.each(head_data, function (idx, obj) {
  268. // console.log(idx)
  269. head_html += ('<th>' + obj['lang'] + '</th>')
  270. });
  271. head_html += '<th width="180px"><a href="#" onclick="addRow()">add</a></th></tr>';
  272. let body_html = '';
  273. $.each(body_data, function (idx, obj) {
  274. // console.log(idx)
  275. // console.log(obj)
  276. let edit_btn = '<a href="#" title="Edit" onclick="editFunc(\'' + idx + '\')"><i class="fa fa-edit"></i></a>';
  277. let del_btn = '<a href="#" title="Delete" onclick="deleteFunc(\'' + idx + '\')"><i class="fa fa-ban"></i></a>';
  278. body_html += '<tr>';
  279. body_html += ('<td>' + idx + '</td>');
  280. console.log('--------');
  281. $.each(la_list, function (x, y) {
  282. if (obj[y['lang']]) {
  283. body_html += ('<td>' + obj[y['lang']] + '</td>')
  284. } else {
  285. body_html += ('<td></td>')
  286. }
  287. });
  288. body_html += '<td>' + edit_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td></tr>';
  289. });
  290. $('#langTableHead').html(head_html);
  291. $('#langTableBody').html(body_html);
  292. addDelFunc()
  293. }
  294. function addRow() {
  295. let newRow = '<tr><td><input class="form-control" type="text" langID="key" id="newRow_key"></td>'
  296. $.each(la_list, function (idx, obj) {
  297. // console.log(idx)
  298. // newRow += ('<td>' + obj['id'] + '</td>')
  299. newRow += ('<td>' +
  300. '<input class="form-control" type="text" langID="' + obj['id'] + '" id="newRow_lang_' + obj['id'] + '">' +
  301. '</td>')
  302. })
  303. let save_btn = '<a href="" title="Save" class="save_row"><i class="fa fa-check-circle-o"></i></a>';
  304. let del_btn = '<a href="" title="Delete" class="del_row"><i class="fa fa-ban"></i></a>';
  305. newRow += '<td>' + save_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td></tr>'
  306. $('#langTableBody').prepend(newRow)
  307. addDelFunc()
  308. addSaveFunc()
  309. }
  310. function addDelFunc() {
  311. $(".del_row").bind("click", function () {
  312. let trRow = $(this).parent().parent()
  313. trRow.remove()
  314. });
  315. }
  316. function addSaveFunc() {
  317. $(".save_row").bind("click", function () {
  318. let post_data = {
  319. 'token': $.cookie('access_token')
  320. }
  321. let post_list = []
  322. let trRow = $(this).parent().parent()
  323. trRow.find('input').each(function () {
  324. // console.log($(this).attr('id'))
  325. // console.log($(this).attr('langID'))
  326. let inputVal = $(this).val()
  327. let langID = $(this).attr('langID')
  328. if (langID === 'key') {
  329. post_data['word_key'] = inputVal
  330. } else {
  331. post_list.push({'la_id': langID, 'val': inputVal})
  332. }
  333. })
  334. post_data['word_arr'] = post_list
  335. console.log(post_data)
  336. $.postJSON(
  337. http_ip_prot + 'langWord/add', JSON.stringify(post_data),
  338. function (data) {
  339. if (data['code'] == 0) {
  340. // console.log(data['res'])
  341. window.location.reload();
  342. console.log(data)
  343. } else {
  344. alert(data['msg'])
  345. }
  346. }
  347. )
  348. })
  349. }
  350. // 编辑模态框
  351. function editFunc(langKey) {
  352. console.log(lw_data);
  353. console.log(la_list);
  354. // alert(langKey)
  355. $('#modal-container-593541').modal('show')
  356. // let post_data = {'token': $.cookie('access_token')};
  357. let html_per = '<label for="lang_key_edit">KEY</label><input class="form-control" type="text" id="lang_key_edit" oldkey="' + langKey + '" value="' + langKey + '"> '
  358. $.each(la_list, function (idx, obj) {
  359. console.log(obj);
  360. html_per += ('<label for="InputLangArea">' + obj['lang'] + ':</label>' +
  361. '<input type="text" class="form-control" lang="' + obj['lang'] + '" value="' + (lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '') + '"/>')
  362. });
  363. // console.log(html_per)
  364. $('#edit_model_form').html(html_per)
  365. }
  366. function deleteFunc(langKey) {
  367. var r = confirm("Press a button")
  368. if (r) {
  369. let post_data = {
  370. 'token': $.cookie('access_token'),
  371. 'word_key': langKey
  372. }
  373. console.log(post_data)
  374. $.postJSON(
  375. http_ip_prot + 'langWord/delete', JSON.stringify(post_data),
  376. function (data) {
  377. if (data['code'] == 0) {
  378. // console.log(data['res'])
  379. console.log(data);
  380. alert(data['msg']);
  381. window.location.reload();
  382. } else {
  383. alert(data['msg'])
  384. }
  385. }
  386. )
  387. }
  388. }
  389. /*post_data = {
  390. word_key_id:1,
  391. word_key:xxx,
  392. word_arr:[
  393. {'lang':'','val':''},
  394. {'lang':'','val':''},
  395. {'lang':'','val':''}
  396. ]
  397. }*/
  398. function editRow() {
  399. let post_data = {}
  400. post_data['token'] = $.cookie('access_token')
  401. post_data['word_key'] = $('#lang_key_edit').val()
  402. post_data['old_word_key'] = $('#lang_key_edit').attr('oldkey')
  403. post_data['word_arr'] = {}
  404. $('#edit_model_form').find('input').each(function () {
  405. let langArea = $(this).attr('lang')
  406. if (langArea) {
  407. post_data['word_arr'][langArea] = $(this).val()
  408. }
  409. })
  410. console.log(post_data)
  411. $.postJSON(
  412. http_ip_prot + 'langWord/update', JSON.stringify(post_data),
  413. function (data) {
  414. if (data['code'] == 0) {
  415. // console.log(data['res'])
  416. console.log(data)
  417. alert(data['msg'])
  418. window.location.reload();
  419. } else {
  420. alert(data['msg'])
  421. }
  422. }
  423. )
  424. // $('.editRowSaveBtn').bind('click', function () {
  425. // console.log('adjslkfjsdalkfj')
  426. // })
  427. }
  428. function subLangAre() {
  429. let access_token = $.cookie('access_token')
  430. let langArea = $('#InputLangArea').val()
  431. let post_data = {
  432. 'token': access_token,
  433. 'lang': langArea,
  434. }
  435. console.log(post_data)
  436. $.postJSON(
  437. http_ip_prot + 'langArea/add',
  438. JSON.stringify(post_data),
  439. function (data) {
  440. if (data['code'] == 0) {
  441. alert(data['msg'])
  442. window.location.reload();
  443. } else {
  444. alert(data['msg'])
  445. }
  446. }
  447. );
  448. }
  449. </script>
  450. </body>
  451. </html>