index.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. <script type="text/javascript">
  156. $(function () {
  157. let post_data = {
  158. 'token': $.cookie('access_token'),
  159. 'page': 1,
  160. 'line': 10
  161. };
  162. $.postJSON(
  163. http_ip_prot + 'langWord/query', JSON.stringify(post_data),
  164. function (data) {
  165. if (data['code'] == 0) {
  166. // console.log(data['res'])
  167. console.log(data)
  168. addTable(data['res'])
  169. let count_page = Math.ceil(data['res']['count'] / 10)
  170. $('#pagination').pagination({
  171. pages: count_page, //总页数
  172. // pages: 10000, //总页数
  173. edges: 2,
  174. cssStyle: 'pagination-sm', //按纽大小pagination-lg或写入自定义css
  175. displayedPages: 5, //显示几个
  176. onPageClick: function (pageNumber, event) {
  177. //点击时调用
  178. // alert(pageNumber);
  179. queryData(pageNumber)
  180. },
  181. onInit: function (getid) {
  182. //刷新时或初始化调用
  183. // alert(getid);
  184. }
  185. });
  186. } else {
  187. alert(data['msg'])
  188. }
  189. }
  190. );
  191. // $('#pagination').pagination({
  192. // pages: 50, //总页数
  193. // edges: 2,
  194. // cssStyle: 'pagination-sm', //按纽大小pagination-lg或写入自定义css
  195. // displayedPages: 5, //显示几个
  196. // onPageClick: function(pageNumber, event) {
  197. // //点击时调用
  198. // // alert(pageNumber);
  199. // },
  200. // onInit: function(getid) {
  201. // //刷新时或初始化调用
  202. // // alert(getid);
  203. // }
  204. // });
  205. });
  206. let la_list
  207. let checkboxInput = '<input type="checkbox" aria-label="Checkbox for following text input">'
  208. let lw_data
  209. function queryData(page) {
  210. let post_data = {
  211. 'token': $.cookie('access_token'),
  212. 'page': page,
  213. 'line': 10
  214. };
  215. $.postJSON(
  216. http_ip_prot + 'langWord/query', JSON.stringify(post_data),
  217. function (data) {
  218. if (data['code'] == 0) {
  219. // console.log(data['res'])
  220. console.log(data)
  221. addTable(data['res'])
  222. } else {
  223. alert(data['msg'])
  224. }
  225. }
  226. );
  227. }
  228. function addTable(data) {
  229. //头部多区域语言
  230. let head_data = data['la_list'];
  231. la_list = head_data
  232. // body部详细语言
  233. let body_data = data['lw_dict'];
  234. lw_data = body_data
  235. let head_html = '<tr><th>en</th>';
  236. //头部标签添加
  237. $.each(head_data, function (idx, obj) {
  238. // console.log(idx)
  239. head_html += ('<th>' + obj['lang'] + '</th>')
  240. });
  241. head_html += '<th width="180px"><a href="#" onclick="addRow()">add</a></th></tr>';
  242. let body_html = '';
  243. $.each(body_data, function (idx, obj) {
  244. // console.log(idx)
  245. // console.log(obj)
  246. let edit_btn = '<a href="#" title="Edit" onclick="editFunc(\'' + idx + '\')"><i class="fa fa-edit"></i></a>';
  247. let del_btn = '<a href="#" title="Delete" onclick="deleteFunc(\'' + idx + '\')"><i class="fa fa-ban"></i></a>';
  248. body_html += '<tr>';
  249. body_html += ('<td>' + idx + '</td>');
  250. console.log('--------');
  251. $.each(la_list, function (x, y) {
  252. if (obj[y['lang']]) {
  253. body_html += ('<td>' + obj[y['lang']] + '</td>')
  254. } else {
  255. body_html += ('<td></td>')
  256. }
  257. });
  258. body_html += '<td>' + edit_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td></tr>';
  259. });
  260. $('#langTableHead').html(head_html);
  261. $('#langTableBody').html(body_html);
  262. addDelFunc()
  263. }
  264. function addRow() {
  265. let newRow = '<tr><td><input class="form-control" type="text" langID="key" id="newRow_key"></td>'
  266. $.each(la_list, function (idx, obj) {
  267. // console.log(idx)
  268. // newRow += ('<td>' + obj['id'] + '</td>')
  269. newRow += ('<td>' +
  270. '<input class="form-control" type="text" langID="' + obj['id'] + '" id="newRow_lang_' + obj['id'] + '">' +
  271. '</td>')
  272. })
  273. let save_btn = '<a href="" title="Save" class="save_row"><i class="fa fa-check-circle-o"></i></a>';
  274. let del_btn = '<a href="" title="Delete" class="del_row"><i class="fa fa-ban"></i></a>';
  275. newRow += '<td>' + save_btn + '&nbsp;&nbsp;&nbsp;' + del_btn + '</td></tr>'
  276. $('#langTableBody').prepend(newRow)
  277. addDelFunc()
  278. addSaveFunc()
  279. }
  280. function addDelFunc() {
  281. $(".del_row").bind("click", function () {
  282. let trRow = $(this).parent().parent()
  283. trRow.remove()
  284. });
  285. }
  286. function addSaveFunc() {
  287. $(".save_row").bind("click", function () {
  288. let post_data = {
  289. 'token': $.cookie('access_token')
  290. }
  291. let post_list = []
  292. let trRow = $(this).parent().parent()
  293. trRow.find('input').each(function () {
  294. // console.log($(this).attr('id'))
  295. // console.log($(this).attr('langID'))
  296. let inputVal = $(this).val()
  297. let langID = $(this).attr('langID')
  298. if (langID === 'key') {
  299. post_data['word_key'] = inputVal
  300. } else {
  301. post_list.push({'la_id': langID, 'val': inputVal})
  302. }
  303. })
  304. post_data['word_arr'] = post_list
  305. console.log(post_data)
  306. $.postJSON(
  307. http_ip_prot + 'langWord/add', JSON.stringify(post_data),
  308. function (data) {
  309. if (data['code'] == 0) {
  310. // console.log(data['res'])
  311. window.location.reload();
  312. console.log(data)
  313. } else {
  314. alert(data['msg'])
  315. }
  316. }
  317. )
  318. })
  319. }
  320. // 编辑模态框
  321. function editFunc(langKey) {
  322. console.log(lw_data);
  323. console.log(la_list);
  324. // alert(langKey)
  325. $('#modal-container-593541').modal('show')
  326. // let post_data = {'token': $.cookie('access_token')};
  327. let html_per = '<label for="lang_key_edit">KEY</label><input class="form-control" type="text" id="lang_key_edit" oldkey="' + langKey + '" value="' + langKey + '"> '
  328. $.each(la_list, function (idx, obj) {
  329. console.log(obj);
  330. html_per += ('<label for="InputLangArea">' + obj['lang'] + ':</label>' +
  331. '<input type="text" class="form-control" lang="' + obj['lang'] + '" value="' + (lw_data[langKey][obj['lang']] ? lw_data[langKey][obj['lang']] : '') + '"/>')
  332. });
  333. // console.log(html_per)
  334. $('#edit_model_form').html(html_per)
  335. }
  336. function deleteFunc(langKey) {
  337. var r = confirm("Press a button")
  338. if (r) {
  339. let post_data = {
  340. 'token': $.cookie('access_token'),
  341. 'word_key': langKey
  342. }
  343. console.log(post_data)
  344. $.postJSON(
  345. http_ip_prot + 'langWord/delete', JSON.stringify(post_data),
  346. function (data) {
  347. if (data['code'] == 0) {
  348. // console.log(data['res'])
  349. console.log(data);
  350. alert(data['msg']);
  351. window.location.reload();
  352. } else {
  353. alert(data['msg'])
  354. }
  355. }
  356. )
  357. }
  358. }
  359. /*post_data = {
  360. word_key_id:1,
  361. word_key:xxx,
  362. word_arr:[
  363. {'lang':'','val':''},
  364. {'lang':'','val':''},
  365. {'lang':'','val':''}
  366. ]
  367. }*/
  368. function editRow() {
  369. let post_data = {}
  370. post_data['token'] = $.cookie('access_token')
  371. post_data['word_key'] = $('#lang_key_edit').val()
  372. post_data['old_word_key'] = $('#lang_key_edit').attr('oldkey')
  373. post_data['word_arr'] = {}
  374. $('#edit_model_form').find('input').each(function () {
  375. let langArea = $(this).attr('lang')
  376. if (langArea) {
  377. post_data['word_arr'][langArea] = $(this).val()
  378. }
  379. })
  380. console.log(post_data)
  381. $.postJSON(
  382. http_ip_prot + 'langWord/update', JSON.stringify(post_data),
  383. function (data) {
  384. if (data['code'] == 0) {
  385. // console.log(data['res'])
  386. console.log(data)
  387. alert(data['msg'])
  388. window.location.reload();
  389. } else {
  390. alert(data['msg'])
  391. }
  392. }
  393. )
  394. // $('.editRowSaveBtn').bind('click', function () {
  395. // console.log('adjslkfjsdalkfj')
  396. // })
  397. }
  398. function subLangAre() {
  399. let access_token = $.cookie('access_token')
  400. let langArea = $('#InputLangArea').val()
  401. let post_data = {
  402. 'token': access_token,
  403. 'lang': langArea,
  404. }
  405. console.log(post_data)
  406. $.postJSON(
  407. http_ip_prot + 'langArea/add',
  408. JSON.stringify(post_data),
  409. function (data) {
  410. if (data['code'] == 0) {
  411. alert(data['msg'])
  412. } else {
  413. alert(data['msg'])
  414. }
  415. }
  416. );
  417. }
  418. </script>
  419. </section>
  420. <section class="tab-item-2">
  421. <h1>Two</h1>
  422. </section>
  423. <section class="tab-item-3">
  424. <h1>Three</h1>
  425. </section>
  426. <section class="tab-item-4">
  427. <h1>Four</h1>
  428. </section>
  429. <section class="tab-item-5">
  430. <h1>Five</h1>
  431. </section>
  432. <section class="tab-item-6">
  433. <h1>Six</h1>
  434. </section>
  435. <section class="tab-item-7">
  436. <h1>Sever</h1>
  437. </section>
  438. <section class="tab-item-8">
  439. <h1>Eight</h1>
  440. </section>
  441. <section class="tab-item-9">
  442. <h1>Nine</h1>
  443. </section>
  444. <section class="tab-item-10">
  445. <h1>Ten</h1>
  446. </section>
  447. </div>
  448. </div>
  449. </body>
  450. </html>