main.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977
  1. //这里的代码是最早写的,很乱,以后整合优化
  2. var editors = [];
  3. var editors_index = [];
  4. var tables = [];
  5. var select = '';
  6. var submitButton = '';
  7. var editorWidth = 0;
  8. var admingroup = false;
  9. String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
  10. if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
  11. return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
  12. } else {
  13. return this.replace(reallyDo, replaceWith);
  14. }
  15. }
  16. Array.prototype.remove = function(val) {
  17. var index = -1;
  18. for(var i = 0; i < this.length; i++)
  19. {
  20. if(this[i] == val)
  21. {
  22. index = i;
  23. }
  24. }
  25. if (index > -1) {
  26. this.splice(index, 1);
  27. }
  28. };
  29. Array.prototype.replaceOne = function(old, val) {
  30. var index = -1;
  31. for(var i = 0; i < this.length; i++)
  32. {
  33. if(this[i] == old)
  34. {
  35. index = i;
  36. }
  37. }
  38. if (index > -1) {
  39. this.splice(index, 1, val);
  40. }
  41. };
  42. $(document).ready(function()
  43. {
  44. //init();
  45. });
  46. function init(ew)
  47. {
  48. if (ew) {
  49. editorWidth = ew;
  50. } else {
  51. editorWidth = 0;
  52. }
  53. editors = [];
  54. editors_index = [];
  55. initEditor();
  56. select = '';
  57. edit();
  58. del();
  59. checkbox();
  60. image();
  61. change();
  62. autocomplete();
  63. template();
  64. submit();
  65. loadShow();
  66. initPic();
  67. initDate();
  68. initLayui();
  69. initColor();
  70. initUpdate();
  71. initClipboard();
  72. initEmoji();
  73. //更新页面一些功能,上边的一些功能等找时间再优化吧
  74. dever_update.init();
  75. hljs.initHighlightingOnLoad();
  76. table();
  77. }
  78. function initEmoji()
  79. {
  80. if ($('.dever-emoji').length) {
  81. $('.dever-emoji').each(function()
  82. {
  83. emoji($(this), $(this).html());
  84. })
  85. }
  86. }
  87. function emoji(e, content)
  88. {
  89. var handle = function()
  90. {
  91. e.html(twemoji.parse(content)).show(200);
  92. };
  93. if (typeof jEmoji != 'object') {
  94. $.getScript('//twemoji.maxcdn.com/2/twemoji.min.js?11.4', function() {
  95. /*
  96. $("head").append("<link>");
  97. var css = $("head").children(":last");
  98. css.attr({
  99. rel: "stylesheet",
  100. type: "text/css",
  101. href: config.script + '/lib/emoji/emoji.css'
  102. });
  103. */
  104. return handle();
  105. });
  106. } else {
  107. return handle();
  108. }
  109. }
  110. function checkClick(e)
  111. {
  112. var objEvt = $._data(e[0], "events");
  113. if (objEvt && !objEvt["click"]) {
  114. return false;
  115. }
  116. return true;
  117. }
  118. function initClipboard()
  119. {
  120. var clipboard = new ClipboardJS('.clipboard');
  121. clipboard.on('success', function(e) {
  122. notify('复制成功', e.trigger);
  123. e.clearSelection();
  124. });
  125. clipboard.on('error', function(e) {
  126. notify('复制失败', e.trigger);
  127. });
  128. }
  129. function initUpdate()
  130. {
  131. if ($('.update_show_editor').length) {
  132. $('.update_show_editor').each(function() {
  133. $(this).bind('click', function()
  134. {
  135. var url = $(this).attr('key');
  136. var value = $(this).attr('editor_id');
  137. var title = $(this).attr('value');
  138. var send = '';
  139. if ($(this).attr('data-value')) {
  140. send = $(this).attr('data-value');
  141. }
  142. $.post(url, {value:send}, function(t)
  143. {
  144. var func = function() {
  145. var url = $('#editor_applet_pic').val();
  146. var appid = $('#editor_applet_id').val();
  147. var path = $('#editor_applet_path').val();
  148. var link = $('#editor_applet_link').val();
  149. if (!appid) {
  150. //alert('请选择小程序');
  151. //return;
  152. }
  153. if (!path) {
  154. alert('请填写路径');
  155. return;
  156. }
  157. if (!url) {
  158. alert('请上传封面');
  159. return;
  160. }
  161. var w = 750/2;
  162. KindEditor.insertHtml('#' + value, '<img src="'+url+'" style="width:'+w+'px;" data-applet="'+url+'||'+appid+'||'+path+'||'+link+'"/>');
  163. layer.closeAll();
  164. };
  165. showAlert(t, func, title);
  166. image();
  167. })
  168. })
  169. });
  170. }
  171. }
  172. function initLayui()
  173. {
  174. layui.use('layer', function() {
  175. var layer = layui.layer;
  176. layer.ready(function() {
  177. $(".dever-img").each(function()
  178. {
  179. layer.photos({
  180. photos: '#' + $(this).attr('id'),
  181. shade : 0.5
  182. });
  183. });
  184. });
  185. });
  186. }
  187. function initColor()
  188. {
  189. if ($('.dever-color').length) {
  190. $('.dever-color').each(function()
  191. {
  192. var self = $(this);
  193. var val = self.val();
  194. if (!val) {
  195. val = '#000000';
  196. }
  197. self.css('border-right', '40px solid '+val);
  198. self.colpick({
  199. layout:'hex',
  200. submit:0,
  201. colorScheme:'dark',
  202. color: val,
  203. onChange : function (hsb,hex,rgb,el,bySetColor) {
  204. $(el).css('border-color','#'+hex);
  205. if(!bySetColor) $(el).val('#' + hex);
  206. }
  207. }).keyup(function(){
  208. $(this).colpickSetColor(this.value);
  209. });
  210. })
  211. }
  212. }
  213. function formData(form)
  214. {
  215. var d = {};
  216. var t = $(form).serializeArray();
  217. var u = '';
  218. $.each(t, function() {
  219. if (this.name.indexOf('search_') != -1) {
  220. d[this.name] = this.value;
  221. u += '&' + this.name + '=' + this.value;
  222. }
  223. });
  224. return [d,u];
  225. }
  226. function initMenu()
  227. {
  228. if(typeof(config.layout) != "undefined")
  229. {
  230. $('.list-unstyled li').each(function(j)
  231. {
  232. $(this).unbind('click').bind('click', function()
  233. {
  234. if ($(this).index() == i) {
  235. //return;
  236. }
  237. $('.list-unstyled .active').each(function()
  238. {
  239. $(this).attr('class', '');
  240. $(this).find('a').attr('class', '');
  241. })
  242. $(this).attr('class', 'active');
  243. var a = $(this).find('a');
  244. a.attr('class', 'subdrop');
  245. //alert($(this).attr('class'));
  246. })
  247. });
  248. /*
  249. $('.project-list').each(function(i)
  250. {
  251. $(this).unbind('click').bind('click', function()
  252. {
  253. if ($(this).index() == i) {
  254. return;
  255. }
  256. $('.project-list').each(function()
  257. {
  258. $(this).find('i').parent().attr('class', '');
  259. $(this).find('ul').attr('class', 'list-unstyled upload-menu');
  260. })
  261. $(this).find('i').parent().attr('class', 'active');
  262. $(this).find('ul').attr('class', 'list-unstyled upload-menu in');
  263. })
  264. });
  265. */
  266. }
  267. }
  268. function setOption(e, id)
  269. {
  270. var s = $("select[name="+id+"]");
  271. var v = s.val();
  272. if (!select) {
  273. select = s.clone();
  274. }
  275. s.find('option[parent]').remove();
  276. //查找出需要显示的option并复制
  277. var options = select.find("option[parent="+e.val()+"]").clone();
  278. //将需要显示的option添加到select中
  279. s.append(options);
  280. //因为option.remove()不会刷新控件,需要将新的option切换上去
  281. //这里排除了options.size() == 0的情况
  282. var state = 2;
  283. s.find('option').each(function()
  284. {
  285. var val = $(this).val();
  286. if (v == val) {
  287. state = 1;
  288. }
  289. });
  290. if (state == 1) {
  291. s.val(v);
  292. } else {
  293. s.val(0);
  294. }
  295. }
  296. function table()
  297. {
  298. if ($('.table-responsive').length) {
  299. $('.table-responsive[data-pattern]').each(function()
  300. {
  301. $(this).responsiveTable('update');
  302. });
  303. }
  304. }
  305. function pjax(param)
  306. {
  307. param.timeout = 8000;
  308. $.pjax(param);
  309. }
  310. function initDate()
  311. {
  312. $.datetimepicker.setLocale('ch');
  313. if($(".manage_date").length)
  314. {
  315. $(".manage_date").each(function()
  316. {
  317. $(this).datetimepicker(
  318. {
  319. //datepicker:false,
  320. format:'Y-m-d H:i:s',
  321. lang:'ch'
  322. });
  323. });
  324. }
  325. if($(".manage_day").length)
  326. {
  327. $(".manage_day").each(function()
  328. {
  329. $(this).datetimepicker(
  330. {
  331. //inline:true,
  332. timepicker:false,
  333. format:'Y-m-d',
  334. lang:'ch'
  335. });
  336. });
  337. }
  338. if($(".manage_sday").length)
  339. {
  340. $(".manage_sday").each(function()
  341. {
  342. $(this).datetimepicker(
  343. {
  344. //inline:true,
  345. timepicker:false,
  346. format:'Y-m-d',
  347. lang:'ch'
  348. });
  349. });
  350. }
  351. if($(".manage_sdate").length)
  352. {
  353. $(".manage_sdate").each(function()
  354. {
  355. $(this).datetimepicker(
  356. {
  357. //datepicker:false,
  358. format:'Y-m-d H:i:s',
  359. lang:'ch'
  360. });
  361. });
  362. }
  363. layui.use('laydate', function() {
  364. var laydate = layui.laydate;
  365. if ($('.manage_year').length) {
  366. laydate.render({
  367. elem: '.manage_year',
  368. type: 'year',
  369. });
  370. }
  371. if ($('.manage_month').length) {
  372. laydate.render({
  373. elem: '.manage_month',
  374. type: 'month',
  375. });
  376. }
  377. });
  378. }
  379. function initPic()
  380. {
  381. $('a[rel]').fancybox();
  382. }
  383. function initEditor(e)
  384. {
  385. if (!e) {
  386. e = $('.editor');
  387. }
  388. if(e.length)
  389. {
  390. var param = false;
  391. var editor = [];
  392. e.each(function()
  393. {
  394. var parent = $(this).parent().parent();
  395. //alert(parent.attr('id'));
  396. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  397. {
  398. return;
  399. }
  400. if (!param) {
  401. param = loadEditorParam($(this));
  402. }
  403. editor.push($(this).attr('id'));
  404. });
  405. if (editor) {
  406. for (var i in editor) {
  407. var id = editor[i];
  408. if (typeof(id) == 'string' && !editors[id]) {
  409. param.index = editors_index.length;
  410. editors[id] = KindEditor.create('#' + id, param);
  411. editors_index.push(id);
  412. }
  413. }
  414. }
  415. }
  416. if ($('.editor_tool').length) {
  417. $('.editor_tool').each(function()
  418. {
  419. $(this).click(function()
  420. {
  421. var tool = $(this).attr('tool');
  422. var id = $(this).attr('editor_id');
  423. editors[id].clickToolbar(tool);
  424. })
  425. });
  426. }
  427. }
  428. function loadEditorParam(e)
  429. {
  430. if(!e.length)
  431. {
  432. return;
  433. }
  434. var key = e.attr('key');
  435. var media = e.attr('media');
  436. var token = e.attr('token');
  437. var host = e.attr('host');
  438. var domain = e.attr('domain');
  439. var path = e.attr('path');
  440. var upload_search = e.attr('upload_search');
  441. var upload_search_value = e.attr('upload_search_value');
  442. var yun = {};
  443. if (token && host) {
  444. yun.token = token;
  445. yun.host = host;
  446. yun.domain = domain;
  447. yun.path = path;
  448. }
  449. if (!media) {
  450. media = key;
  451. }
  452. var view = config.upload.replace('save', 'view');
  453. var param = {
  454. height : "400px",
  455. allowImageUpload: true, //上传图片框本地上传的功能,false为隐藏,默认为true
  456. allowImageRemote : true, //上传图片框网络图片的功能,false为隐藏,默认为true
  457. allowFileManager : true, //浏览图片空间
  458. allowMediaUpload : true,
  459. filterMode : true, //HTML特殊代码过滤
  460. themeType : 'default',
  461. filePostName : 'file',
  462. dialogOffset : 0, //对话框距离页面顶部的位置,默认为0居中,
  463. uploadJson : config.upload + '.kindeditor?key=' + key + '&search=' + upload_search_value,
  464. uploadResJson : config.uploadRes + '.kindeditor?key=' + key + '&search=' + upload_search_value,
  465. uploadMediaJson : config.upload + '.kindeditor?key=' + media + '&search=' + upload_search_value,
  466. uploadYunJson : yun,
  467. fileManagerJson : view + '.files?key=' + media + '&upload_search=' + upload_search,
  468. htmlTags : {
  469. section : ['id', 'class', 'color', 'size', 'face', '.background-color'],
  470. font : ['id', 'class', 'color', 'size', 'face', '.background-color'],
  471. span : [
  472. 'id', 'class', '.color', '.background-color', '.font-size','.letter-spacing', '.background',
  473. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height'
  474. ],
  475. div : [
  476. 'id', 'class', 'data-applet', 'data-file', 'data-id', 'data-key','.dever-video', 'align', '.border', '.margin', '.padding', '.text-align', '.color',
  477. '.background-color', '.font-size','.letter-spacing', '.font-weight', '.background',
  478. '.font-style', '.text-decoration', '.vertical-align', '.margin-left'
  479. ],
  480. table: [
  481. 'id', 'class', 'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
  482. '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
  483. '.font-size', '.font-weight', '.font-style', '.text-decoration', '.background',
  484. '.width', '.height', '.border-collapse'
  485. ],
  486. 'td,th': [
  487. 'id', 'class', 'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
  488. '.text-align', '.color', '.background-color', '.font-size','.letter-spacing', '.font-weight',
  489. '.font-style', '.text-decoration', '.vertical-align', '.background', '.border'
  490. ],
  491. a : ['id', 'class', 'href', 'target', 'name'],
  492. embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess', 'wmode'],
  493. img : ['id', 'class', 'data-applet', 'data-file', 'data-id', 'data-key', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
  494. 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
  495. 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size','.letter-spacing', '.background',
  496. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
  497. ],
  498. pre : ['id', 'class'],
  499. hr : ['id', 'class', '.page-break-after'],
  500. 'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : ['id', 'class'],
  501. iframe : ['id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height']
  502. },
  503. items : [
  504. 'preview', 'undo', 'redo', '|', 'cut', 'copy', 'paste',
  505. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  506. 'justifyfull', 'indent', 'outdent', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', 'source', '/',
  507. 'formatblock', 'fontsize', 'fontheight', '|', 'forecolor', 'hilitecolor', 'bold',
  508. 'italic', 'underline', 'lineheight', 'removeformat', 'insertorderedlist','|', 'image','table', 'hr', 'pagebreak','link', 'unlink'
  509. ]
  510. /*
  511. items : [
  512. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  513. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  514. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  515. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  516. 'formatblock', 'fontsize', 'fontheight', '|', 'forecolor', 'hilitecolor', 'bold',
  517. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  518. 'anchor', 'link', 'unlink'
  519. ]
  520. */
  521. //media
  522. /*
  523. items : [
  524. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  525. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  526. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  527. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  528. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  529. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
  530. 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  531. 'anchor', 'link', 'unlink', '|', 'about'
  532. ]
  533. */
  534. }
  535. if (editorWidth > 0) {
  536. param.width = editorWidth + 'px';
  537. param.minWidth = editorWidth + 'px';
  538. }
  539. return param;
  540. }
  541. //更新页面的提交按钮
  542. function submit()
  543. {
  544. if($(".save-data").length)
  545. {
  546. if (submitButton) {
  547. $(".save-data").each(function()
  548. {
  549. $(this).html(submitButton);
  550. })
  551. }
  552. $(".save-data").unbind('click').bind('click', function()
  553. {
  554. if (editors) {
  555. for (var i in editors) {
  556. if (i.indexOf('update_') != -1) {
  557. editors[i].sync();
  558. }
  559. }
  560. }
  561. //return;
  562. submitButton = $(this).html();
  563. $(this).html('loading...');
  564. $(this).unbind('click');
  565. submit_action();
  566. })
  567. }
  568. }
  569. //直接提交更新页的数据
  570. function submit_action()
  571. {
  572. $(".form1").submit();
  573. }
  574. //设置某一个input的值
  575. function set_update(id, value)
  576. {
  577. if($(id).length)
  578. {
  579. $(id).val(value);
  580. }
  581. }
  582. /**
  583. * 批量复制数据
  584. */
  585. function copy_data(e)
  586. {
  587. var html = '<div>';
  588. html += '<div><span>请输入要复制的数量:</span><input type="text" class="form-control form_margin" id="temp_copy_num" /></div>';
  589. html += '</div>';
  590. $('#dever_modal_body').html(html);
  591. $('#dever_modal_title').html('复制数据');
  592. $("#dever_modal_yes").unbind('click').bind('click', function()
  593. {
  594. set_update('#copy_num', $("#temp_copy_num").val());
  595. set_update('#update_where_id', 0);
  596. submit_action();
  597. });
  598. }
  599. //头部菜单
  600. function topMenu(e)
  601. {
  602. var p = e.parent().parent().parent().find('span');
  603. p.html(e.html());
  604. //更新当前的精细权限
  605. var url = config.host + 'top.update_action?json=1';
  606. var id = e.attr('data-id');
  607. $.post(url, {id:id}, function(t)
  608. {
  609. var href = location.href;
  610. if(location.href.indexOf('where_id') != -1)
  611. {
  612. var temp = location.href.split('where_id');
  613. href = temp[0] + 'where_id=' + t;
  614. }
  615. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  616. {
  617. pjax({url: href, container: config.layout})
  618. }
  619. else
  620. {
  621. location.href = href;
  622. }
  623. })
  624. }
  625. //链接跳转
  626. function go(key, value)
  627. {
  628. var href = location.href;
  629. if(location.href.indexOf(key) != -1)
  630. {
  631. var temp = location.href.split(key + '=');
  632. href = temp[0] + key + '=' + value + '&' + temp[1];
  633. } else {
  634. href = href + '&' + key + '=' + value;
  635. }
  636. location.href = href;
  637. }
  638. //更新页面的批量载入选择
  639. function loadShow()
  640. {
  641. if($(".show_input").length)
  642. {
  643. $(".show_input input").each(function()
  644. {
  645. if($(this).attr('checked'))
  646. {
  647. inputShow($(this), $(this).attr('show_id'), 'input');
  648. }
  649. })
  650. $(".show_input select").each(function()
  651. {
  652. if($(this).find('option:selected').text())
  653. {
  654. inputShow($(this), $(this).attr('show_id'));
  655. }
  656. })
  657. }
  658. }
  659. function menuGroup(id, e)
  660. {
  661. if (typeof(layer) != 'undefined' && admingroup) {
  662. layer.close(admingroup);
  663. }
  664. $('.menu_group').hide();
  665. $('.menu_group_' + id).show();
  666. $('.menu_group_' + id).eq(0).addClass('layui-nav-itemed');
  667. }
  668. function inputShow(e,n,t)
  669. {
  670. $(".show_" + n).hide();
  671. var array = ['input', 'textarea'];
  672. for(var a in array)
  673. {
  674. if ($(".show_" + n).find(array[a]).length) {
  675. var c = $(".show_" + n).find(array[a]).attr('class');
  676. if (c.indexOf('validate[required]') > -1) {
  677. $(".show_" + n).find(array[a]).removeClass('validate[required]').addClass('validates');
  678. }
  679. if (c.indexOf('validates') > -1) {
  680. $(".show_" + n).find(array[a]).removeClass('validates').addClass('validate[required]');
  681. }
  682. }
  683. }
  684. if (t == 'input') {
  685. var item = e.parent().find('input');
  686. item.each(function()
  687. {
  688. if($(this).get(0).checked == true)
  689. {
  690. inputShowOne($(this),n);
  691. }
  692. });
  693. } else {
  694. var item = e.parent().find('select');
  695. item.each(function()
  696. {
  697. if($(this).find('option:selected').text())
  698. {
  699. inputShowOne($(this),n);
  700. }
  701. });
  702. }
  703. }
  704. function inputShowOne(e,n)
  705. {
  706. var value = e.val();
  707. var ele = '.show_' + n + '_ajax';
  708. if ($(ele).length) {
  709. $(ele).each(function()
  710. {
  711. var self = $(this);
  712. var url = self.attr('dever-ajax');
  713. $.getJSON(url + value + '&callback=?', function(t) {
  714. self.find('.margin-top').html(t.data);
  715. inputShowOneValiDate(self);
  716. checkbox();
  717. })
  718. })
  719. } else {
  720. ele = '.show_' + n + '_' + value;
  721. inputShowOneValiDate($(ele));
  722. }
  723. }
  724. function inputShowOneValiDate(e)
  725. {
  726. e.show();
  727. var array = ['input', 'textarea'];
  728. for(var a in array)
  729. {
  730. if(e.length && e.attr('class').indexOf('show_no') == -1)
  731. {
  732. e.find(array[a]).each(function()
  733. {
  734. var parent = $(this).parent();
  735. if($(this).attr('class') != 'editor' && $(this).attr('class').indexOf('validates') > -1 && parent.find('label').length && parent.find('label').html().indexOf('选填') == -1)
  736. {
  737. $(this).addClass('validate[required]');
  738. }
  739. })
  740. }
  741. }
  742. }
  743. //批量更新
  744. function list_mul(e)
  745. {
  746. var type = parseInt($("#mul_type").val());
  747. if(type != 1 && type != 2)
  748. {
  749. alert('您还没有选择数据更新方式');
  750. return;
  751. }
  752. var index = layer.confirm('确定进行此项操作吗?', function()
  753. {
  754. $('#method').val('mul');
  755. $('#function').val('msg');
  756. layer.close(index);
  757. $('#form1').attr('target', 'f1').submit();
  758. })
  759. }
  760. //搜索
  761. function list_search(e)
  762. {
  763. $('#method').val('search');
  764. $('#function').val('');
  765. $('#form1').attr('target', '').submit();
  766. }
  767. //更新数据
  768. function update(e, id, project, table, notice, menu_id)
  769. {
  770. var call = function()
  771. {
  772. var col = e.attr('name').replace('up_col_', '');
  773. var value = e.val();
  774. var old = e.attr('data-old');
  775. var url = config.host + 'database.update_action?json=1';
  776. $.post(url, {where_id:id,col:col,value:value,project:project,table:table,menu_id:menu_id}, function(t)
  777. {
  778. var t = eval('('+t+')');
  779. if (t.status == 1) {
  780. e.attr('data-old', value);
  781. notify('操作已成功!您的操作已修改当前选项!', e);
  782. preview();
  783. } else {
  784. msg(t);
  785. e.val(old);
  786. }
  787. })
  788. }
  789. if(notice)
  790. {
  791. var index = layer.confirm(notice, function(i, l)
  792. {
  793. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  794. layer.close(index);
  795. call();
  796. });
  797. }
  798. else
  799. {
  800. call();
  801. }
  802. }
  803. function notify(msg, e)
  804. {
  805. if (!e) {
  806. layer.msg(msg);
  807. return;
  808. }
  809. layer.tips(msg, e, {
  810. tips: [1, '#3595CC']
  811. });
  812. /*
  813. var notice = new PNotify({
  814. title: '提示信息',
  815. text: msg,
  816. buttons: {
  817. closer: false,
  818. sticker: false
  819. }
  820. });
  821. notice.get().click(function() {
  822. notice.remove();
  823. });
  824. */
  825. }
  826. //模板选择
  827. function template()
  828. {
  829. if(config.template)
  830. {
  831. $('body').attr('class', 'theme-' + config.template);
  832. }
  833. if($(".selector").length)
  834. {
  835. $(".selector").each(function()
  836. {
  837. if($(this).data('check') == 'checked')
  838. {
  839. selector($(this));
  840. }
  841. })
  842. }
  843. }
  844. //选择器
  845. function selector(e)
  846. {
  847. var value = e.data('value');
  848. var name = e.data('name');
  849. $('#'+name+'_value').val(value);
  850. $('.'+name+'_selector').children().css({'border':'1px solid #ccc'});
  851. e.children().css({'border':'1px solid black'});
  852. if(name == 'update_template')
  853. {
  854. $('body').attr('class', 'theme-' + value);
  855. }
  856. }
  857. //根据e的值,来载入其他数据
  858. function loading(e, data)
  859. {
  860. var value = e.val();
  861. if(e.attr('id') && e.attr('id').indexOf('_temp') != -1)
  862. {
  863. var id = e.attr('id').replace('_temp', '');
  864. if($('#' + id).length)
  865. {
  866. var value = $('#' + id).val();
  867. }
  868. }
  869. if(data.element)
  870. {
  871. if(data.url)
  872. {
  873. data.value = value;
  874. $.getJSON(data.url, data, function(t)
  875. {
  876. $('#update_'+data.element+'_value').val(t.data);
  877. });
  878. }
  879. else
  880. {
  881. $('#update_'+data.element+'_value').val(value);
  882. }
  883. }
  884. else if(data.url)
  885. {
  886. data.value = value;
  887. data.where_id = $('#update_where_id').val();
  888. data.table = $('#table').val();
  889. data.project = $('#project').val();
  890. $.getJSON(data.url + '&json=1', data, function(s)
  891. {
  892. t = s.data;
  893. if(t.indexOf('onblur') != -1)
  894. {
  895. eval(t);
  896. }
  897. else
  898. {
  899. var parent = e.parent().parent();
  900. if(t.indexOf('status') == -1)
  901. {
  902. if(data.type == 1)
  903. {
  904. $('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
  905. {
  906. $(this).remove();
  907. });
  908. }
  909. else
  910. {
  911. $('.checking_-1,.checking_3,.checking_4').each(function()
  912. {
  913. $(this).remove();
  914. });
  915. }
  916. if (!parent.parent().find('.bind_show').length) {
  917. parent.after('<div class="bind_show">' + t + '</div>');
  918. } else if (parent.parent().find('.bind_show').html() != t) {
  919. parent.parent().find('.bind_show').html(t);
  920. }
  921. checkbox();
  922. }
  923. }
  924. });
  925. }
  926. }
  927. //根据e的值,来载入其他数据,先检测是否选中
  928. function checking(name, e, data)
  929. {
  930. var value = [];
  931. $('.' + name).each(function()
  932. {
  933. if($(this).get(0).checked == true)
  934. {
  935. value.push($(this).val());
  936. }
  937. });
  938. if(data.url)
  939. {
  940. data.value = value.join(',');
  941. data.where_id = $('#update_where_id').val();
  942. data.table = $('#table').val();
  943. data.project = $('#project').val();
  944. if(data.check)
  945. {
  946. data.check_value = false;
  947. $(data.check).each(function()
  948. {
  949. if($(this).get(0).checked == true)
  950. {
  951. data.check_value = $(this).val();
  952. }
  953. });
  954. }
  955. $.getJSON(data.url, data, function(s)
  956. {
  957. t = s.data;
  958. var parent = e.parent().parent().parent();
  959. if(t.indexOf('status') == -1)
  960. {
  961. if(data.type == 1)
  962. {
  963. $('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
  964. {
  965. $(this).remove();
  966. });
  967. }
  968. else
  969. {
  970. $('.checking_-1,.checking_3,.checking_4').each(function()
  971. {
  972. $(this).remove();
  973. });
  974. }
  975. parent.after(t);
  976. checkbox();
  977. }
  978. });
  979. }
  980. }
  981. function autocomplete()
  982. {
  983. if ($("input").length) {
  984. $("input").each(function()
  985. {
  986. $(this).attr('autocomplete', 'off');
  987. });
  988. }
  989. if($("input[complete]").length)
  990. {
  991. $("input[complete]").each(function()
  992. {
  993. var cache = {};
  994. var self = $(this);
  995. self.autocomplete(
  996. {
  997. minLength: 2,
  998. source: function( request, response )
  999. {
  1000. var term = request.term.split( /,\s*/ );
  1001. request.term = term.pop();
  1002. if ( request.term in cache ) {
  1003. response( cache[ request.term ] );
  1004. return;
  1005. }
  1006. var cate = self.attr('complete_cate');
  1007. if (cate) {
  1008. request[cate] = $('update_' + cate + '_value').val();
  1009. }
  1010. $.getJSON(self.attr('complete') + '&callback=?', request, function( data, status, xhr ) {
  1011. data = data.data
  1012. cache[ term ] = data;
  1013. var state = true;
  1014. for(var i in data)
  1015. {
  1016. if(data[i].id <=0)
  1017. {
  1018. state = false;
  1019. }
  1020. }
  1021. if(state)
  1022. {
  1023. response( data );
  1024. }
  1025. });
  1026. },
  1027. focus: function() {
  1028. // prevent value inserted on focus
  1029. return false;
  1030. },
  1031. select: function( event, ui )
  1032. {
  1033. //log( "Selected: " + ui.item.value + " aka " + ui.item.id );
  1034. var value = self.attr('complete_callback');
  1035. var id = self.attr('id').replace('_temp', '');
  1036. var name = self.attr('name').replace('_temp', '');
  1037. //var e = $("#" + id);
  1038. var e = self;
  1039. var html = '<div style="margin-top: 10px;width: 60%; overflow: auto;max-height: 500px;"><table id="'+id+'_show" class="table table-small-font table-bordered"></table></div>';
  1040. if (!$("#" + id + '_show').length) {
  1041. e.parent().append(html);
  1042. }
  1043. if ($("#" + id + '_show').html().indexOf(ui.item.value) == -1)
  1044. {
  1045. var link = '';
  1046. var attr = '';
  1047. var pic = '';
  1048. if (ui.item['pic']) {
  1049. pic = '<a href="javascript:;"><img src="'+ui.item['pic']+'" width="100"></a>';
  1050. }
  1051. if (ui.item['link']) {
  1052. link = ui.item['link'];
  1053. attr = ' target="_blank"';
  1054. }
  1055. var html = '<tr><td width="90%"><input type="checkbox" checked name="'+name+'[]" value="'+ui.item[value]+'"/>&nbsp;&nbsp;'+pic+'<a href="'+link+'" '+attr+' title="'+ui.item.value+'">'+ui.item.value+'</td><td width="10%"><a href="javascript:;" onclick="autocomplete_del($(this), \''+id+'\', \''+ui.item[value]+'\', \''+name+'\')">[删除]</a></td></tr>';
  1056. $("#" + id + '_show').append(html);
  1057. if (!autocomplete_value[id]) {
  1058. autocomplete_value[id] = [];
  1059. }
  1060. autocomplete_value[id].push(ui.item[value]);
  1061. }
  1062. ui.item.value = '';
  1063. }
  1064. });
  1065. })
  1066. }
  1067. }
  1068. function autocomplete_del(e, id, value, name)
  1069. {
  1070. e.parent().parent().remove();
  1071. autocomplete_value[id].remove(value);
  1072. var len = autocomplete_value[id].length;
  1073. if (len < 1 && !($('#del_' + name).length)) {
  1074. $("#" + id + '_show').append('<input type="hidden" name="'+name+'[]" id="del_'+name+'" value="-1" />');
  1075. }
  1076. }
  1077. function searchbox(id, e)
  1078. {
  1079. var self = e.parent().find("input");
  1080. var v = self.val();
  1081. var key = self.attr('id').replace('_temp', '');
  1082. var request = {};
  1083. request.term = v;
  1084. var cate = self.attr('searchbox_cate');
  1085. if (cate) {
  1086. var c = cate.split(',');
  1087. for (var i in c) {
  1088. if (typeof(c[i]) == 'string' && $('#'+c[i]).length) {
  1089. request[c[i]] = $('#'+c[i]).val();
  1090. }
  1091. }
  1092. }
  1093. var index = layer.msg('加载中...');
  1094. $.getJSON(self.attr('searchbox') + '&callback=?', request, function( data, status, xhr ) {
  1095. layer.close(index);
  1096. var data = data.data;
  1097. if (!data) {
  1098. showAlert('没有搜索到数据');
  1099. return;
  1100. }
  1101. var html = '<div class="layui-tab layui-tab-brief"" overflow><ul class="layui-tab-title" style="height: 60px; overflow: auto;">{cate}</ul><div class="layui-tab-content" style="padding-top: 0px;">{content}</div><div style="margin-left:10px"><input type="checkbox" onclick="searchbox_checkall($(this), \'searchbox_'+id+'\')"/>&nbsp;全选<button type="button" onclick="searchbox_yes(\''+self.attr('id')+'\', \'.searchbox_'+id+'\', true)" class="btn btn-primary layui-btn layuiadmin-btn-list" style="margin-left:10px;margin-top: -2px;"><i class="fa fa-save"></i> 确定</button></div></div>';
  1102. if (data) {
  1103. var j = 0;
  1104. var c = '';
  1105. var s = '';
  1106. var cateHtml = '';
  1107. var content = '';
  1108. for (var i in data) {
  1109. if (j == 0) {
  1110. c = 'class="layui-this"';
  1111. s = 'layui-show';
  1112. } else {
  1113. c = '';
  1114. s = '';
  1115. }
  1116. cateHtml += '<li '+c+'>'+data[i].name+'</li>';
  1117. j++;
  1118. var item = '<div class="layui-tab-item '+s+'"><div style="margin-top: 10px;overflow: auto;max-height: 500px;"><table class="table table-small-font table-bordered">{head}';
  1119. var p = false;
  1120. for (var k in data[i].child) {
  1121. if (data[i].child[k].name) {
  1122. var pic = '';
  1123. if (data[i].child[k].pic) {
  1124. pic = '<td><img src="'+data[i].child[k].pic+'" width="100"></td>';
  1125. p = true;
  1126. }
  1127. var check = '';
  1128. if (searchbox_value[key].indexOf(data[i].child[k].id) != -1) {
  1129. check = 'checked';
  1130. }
  1131. item += '<tr><td width="10%"><input '+check+' type="checkbox" onclick="searchbox_checkone($(this), \''+self.attr('id')+'\', \''+key+'\', '+data[i].child[k].id+', \''+key+'\')" class="searchbox_'+id+' searchbox_'+id+'_'+data[i].id+'" data-class="searchbox_'+id+'_'+data[i].id+'" data-pic="'+data[i].child[k].pic+'" data-name="'+data[i].child[k].name+'" data-value="'+data[i].child[k].id+'" data-link="'+data[i].child[k].link+'" value="'+data[i].child[k].id+'"/></td>'+pic+'<td><a href="" >'+data[i].child[k].name+'</td></tr>';
  1132. }
  1133. }
  1134. item += '</table></div></div>';
  1135. var head = '<tr><td width="10%"><input type="checkbox" class="searchbox_'+id+'" onclick="searchbox_checkall($(this), \'searchbox_'+id+'_'+data[i].id+'\')"/></td><td>标题</td></tr>';
  1136. if (p) {
  1137. head = head.replace('</td><td>', '</td><td>图片</td><td>');
  1138. }
  1139. item = item.replace('{head}', head);
  1140. content += item;
  1141. }
  1142. if (cateHtml) {
  1143. html = html.replace('{cate}', cateHtml);
  1144. }
  1145. if (content) {
  1146. html = html.replace('{content}', content);
  1147. }
  1148. }
  1149. var config = {
  1150. type: 1,
  1151. shade: 0.3,
  1152. title : false,
  1153. shadeClose : true,
  1154. area : ['800px', '600px'],
  1155. content: html
  1156. };
  1157. layer.open(config);
  1158. layui.use('element', function(){
  1159. var element = layui.element;
  1160. });
  1161. });
  1162. }
  1163. function searchbox_checkall(e, id)
  1164. {
  1165. $('.' + id).each(function()
  1166. {
  1167. $(this).get(0).checked = e.get(0).checked;
  1168. //$(this).click();
  1169. })
  1170. }
  1171. function searchbox_checkone(e, id, key, value)
  1172. {
  1173. if (!e.get(0).checked) {
  1174. $('#searchbox_check_' + key + '_' + value).remove();
  1175. searchbox_value.remove(value);
  1176. var len = searchbox_value.length;
  1177. var name = key.replace('_value', '');
  1178. if (len < 1 && !($('#del_' + name).length)) {
  1179. $("#" + key + '_show').append('<input type="hidden" name="'+name+'[]" id="del_'+name+'" value="-1" />');
  1180. }
  1181. } else {
  1182. var c = '.' + e.attr('data-class');
  1183. searchbox_yes(id, c, false);
  1184. }
  1185. }
  1186. function searchbox_yes(e, c, state)
  1187. {
  1188. var self = $("#" +e);
  1189. $(c).each(function()
  1190. {
  1191. if ($(this).get(0).checked && $(this).val() && $(this).attr('data-value')) {
  1192. var value = self.attr('searchbox_callback');
  1193. var id = self.attr('id').replace('_temp', '');
  1194. var name = self.attr('name').replace('_temp', '');
  1195. var html = '<div style="margin-top: 10px;width: 60%; overflow: auto;max-height: 500px;"><table id="'+id+'_show" class="table table-small-font table-bordered"></table></div>';
  1196. if (!$("#" + id + '_show').length) {
  1197. self.parent().append(html);
  1198. }
  1199. if (!$("#" + id + '_show').find('#searchbox_check_'+id+'_'+$(this).attr('data-value')).length)
  1200. {
  1201. var link = '';
  1202. var attr = '';
  1203. var pic = '';
  1204. if ($(this).attr('data-pic') && $(this).attr('data-pic') != 'undefined') {
  1205. pic = '<a href="javascript:;"><img src="'+$(this).attr('data-pic')+'" width="100"></a>';
  1206. }
  1207. if ($(this).attr('data-link')) {
  1208. link = $(this).attr('data-link');
  1209. attr = ' target="_blank"';
  1210. }
  1211. var html = '<tr id="searchbox_check_'+id+'_'+$(this).attr('data-value')+'"><td width="90%"><input type="checkbox" checked name="'+name+'[]" value="'+$(this).attr('data-value')+'"/>&nbsp;&nbsp;'+pic+'<a href="'+link+'" '+attr+' title="'+$(this).attr('data-name')+'">'+$(this).attr('data-name')+'</td><td width="10%"><a href="javascript:;" onclick="searchbox_del($(this), \''+id+'\', \''+$(this).attr('data-value')+'\', \''+name+'\')">[删除]</a></td></tr>';
  1212. $("#" + id + '_show').append(html);
  1213. if (!searchbox_value[id]) {
  1214. searchbox_value[id] = [];
  1215. }
  1216. searchbox_value[id].push($(this).attr('data-value'));
  1217. }
  1218. }
  1219. })
  1220. if (state == true) {
  1221. layer.closeAll();
  1222. }
  1223. }
  1224. function searchbox_del(e, id, value, name)
  1225. {
  1226. e.parent().parent().remove();
  1227. searchbox_value.remove(value);
  1228. var len = searchbox_value.length;
  1229. if (len < 1 && !($('#del_' + name).length)) {
  1230. $("#" + id + '_show').append('<input type="hidden" name="'+name+'[]" id="del_'+name+'" value="-1" />');
  1231. }
  1232. }
  1233. //后台通用的提示
  1234. function msg(value)
  1235. {
  1236. $("#dever_modal_no").click();
  1237. if(!value.data)
  1238. {
  1239. value.data = value.msg;
  1240. }
  1241. if(value == 1)
  1242. {
  1243. location.reload();
  1244. return;
  1245. }
  1246. submit();
  1247. var url = '';
  1248. if(value.data != 'reload' && value.status == 2)
  1249. {
  1250. showAlert(value.msg, false, '错误提示');
  1251. //alert(value.data);
  1252. //location.reload();
  1253. return;
  1254. }
  1255. else if(value.data == 'reload')
  1256. {
  1257. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  1258. {
  1259. pjax({url: location.href, container: config.layout})
  1260. }
  1261. else
  1262. {
  1263. location.reload();
  1264. }
  1265. return;
  1266. }
  1267. else
  1268. {
  1269. if(value.data.indexOf('http') != -1)
  1270. {
  1271. url = value.data;
  1272. }
  1273. else if($("#url").length)
  1274. {
  1275. url = $("#url").val();
  1276. }
  1277. else
  1278. {
  1279. notify(value.data)
  1280. return;
  1281. }
  1282. if(url)
  1283. {
  1284. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  1285. {
  1286. pjax({url: url, container: config.layout});
  1287. }
  1288. else
  1289. {
  1290. location.href = url;
  1291. }
  1292. }
  1293. else
  1294. {
  1295. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  1296. {
  1297. pjax({url: location.href, container: config.layout});
  1298. }
  1299. else
  1300. {
  1301. location.reload();
  1302. }
  1303. }
  1304. }
  1305. return;
  1306. }
  1307. /**
  1308. * 处理多选问题,处理全选按钮
  1309. */
  1310. function checkbox()
  1311. {
  1312. if($(".autoload").length)
  1313. {
  1314. $(".autoload").each(function()
  1315. {
  1316. if($(this).get(0).checked == true)
  1317. {
  1318. $(this).removeClass('autoload');
  1319. $(this).load();
  1320. }
  1321. });
  1322. }
  1323. if($(".autoload_text").length)
  1324. {
  1325. $(".autoload_text").each(function()
  1326. {
  1327. if($(this).val())
  1328. {
  1329. $(this).removeClass('autoload_text');
  1330. $(this).load();
  1331. }
  1332. });
  1333. }
  1334. var name = 'checkbox-checkall';
  1335. var checkbox = $("." + name);
  1336. if(checkbox.length)
  1337. {
  1338. checkbox.unbind('click').bind('click', function()
  1339. {
  1340. var self = $(this);
  1341. $("." + name + "-" + self.val()).each(function()
  1342. {
  1343. $(this).get(0).checked = self.get(0).checked;
  1344. var next = $(this).next();
  1345. if($(this).get(0).checked == true)
  1346. {
  1347. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1348. {
  1349. next.attr('disabled', false);
  1350. }
  1351. if($("#mul_type").length)
  1352. {
  1353. $("#mul_type").val(1);
  1354. }
  1355. }
  1356. else
  1357. {
  1358. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1359. {
  1360. next.attr('disabled', true);
  1361. }
  1362. if($("#mul_type").length)
  1363. {
  1364. $("#mul_type").val(0);
  1365. }
  1366. }
  1367. if ($(this).attr('onclick') && $(this).attr('onclick').indexOf('show') > 0) {
  1368. inputShow($(this), 'col');
  1369. }
  1370. })
  1371. });
  1372. checkbox.each(function()
  1373. {
  1374. var self = $(this);
  1375. var len = $("." + name + "-" + self.val()).length;
  1376. $("." + name + "-" + self.val()).each(function()
  1377. {
  1378. $(this).unbind('click').bind('click', function()
  1379. {
  1380. var next = $(this).next();
  1381. var state = $(this).attr('data-state');
  1382. if($(this).get(0).checked == true)
  1383. {
  1384. if (state == 2) {
  1385. self.get(0).checked = true;
  1386. } else {
  1387. if ($("." + name + "-" + self.val()+":checked").length >= len) {
  1388. self.get(0).checked = true;
  1389. }
  1390. }
  1391. if(self.attr('type') == 'radio')
  1392. {
  1393. //如果父选项是radio类型,做下限制
  1394. //alert(1);
  1395. }
  1396. if($("#mul_type").length)
  1397. {
  1398. $("#mul_type").val(1);
  1399. }
  1400. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1401. {
  1402. next.attr('disabled', false);
  1403. }
  1404. }
  1405. else
  1406. {
  1407. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1408. {
  1409. next.attr('disabled', true);
  1410. }
  1411. }
  1412. var num = 0;
  1413. $("." + name + "-" + self.val()).each(function()
  1414. {
  1415. if($(this).get(0).checked == true)
  1416. {
  1417. num = 1;
  1418. }
  1419. });
  1420. var id = $(this).attr('name');
  1421. var hidden = id;
  1422. id = id.replace('[]', '');
  1423. if(num == 0)
  1424. {
  1425. self.get(0).checked = false;
  1426. if($("#mul_type").length)
  1427. {
  1428. $("#mul_type").val(0);
  1429. }
  1430. if (state == 2) {
  1431. } else if (!$('#' + id).length) {
  1432. self.parent().append('<input type="hidden" value="0" id="'+id+'" name="'+hidden+'" />');
  1433. }
  1434. } else {
  1435. if ($('#' + id).length) {
  1436. $('#' + id).remove();
  1437. }
  1438. }
  1439. })
  1440. if($(this).get(0).checked == true)
  1441. {
  1442. self.get(0).checked = true;
  1443. if ($(this).attr('onclick') && $(this).attr('onclick').indexOf('show') > 0) {
  1444. inputShow($(this), 'col');
  1445. }
  1446. }
  1447. });
  1448. })
  1449. }
  1450. }
  1451. /**
  1452. * 处理双击编辑
  1453. */
  1454. function edit()
  1455. {
  1456. if($(".edit").length)
  1457. {
  1458. $(".edit").each(function()
  1459. {
  1460. $(this).bind('dblclick', function()
  1461. {
  1462. var col = $(this).attr('data-col');
  1463. var project = $(this).attr('data-project');
  1464. var table = $(this).attr('data-table');
  1465. var url = $(this).attr('data-url');
  1466. var id = $(this).attr('data-id');
  1467. var html = $(this).attr('data-content');
  1468. var type = $(this).attr('data-type');
  1469. if($(this).find(".edit-content").length)
  1470. {
  1471. html = $(this).find(".edit-content").html();
  1472. html = html.replace('<!--', '<');
  1473. html = html.replace('-->', '>');
  1474. }
  1475. if (html == '点此编辑') {
  1476. html = '';
  1477. }
  1478. if(html.indexOf('input') == -1)
  1479. {
  1480. if(type && type == 'textarea')
  1481. {
  1482. $(this).html('<textarea type="text" name="edit" id="edit" rows="10" cols="60" class="layui-input">'+html+'</textarea>');
  1483. }
  1484. else
  1485. {
  1486. $(this).html('<input type="text" name="edit" id="edit" value="'+html+'" class="layui-input">');
  1487. }
  1488. var self = $(this);
  1489. self.find("#edit").focus();
  1490. self.find("#edit").blur(function()
  1491. {
  1492. var value = self.find("#edit").val();
  1493. if(!value)
  1494. {
  1495. alert('不能为空');
  1496. return;
  1497. }
  1498. if($(this).find(".edit-content").length)
  1499. {
  1500. $(this).find(".edit-content").html(value);
  1501. }
  1502. else
  1503. {
  1504. self.attr('data-content', value);
  1505. }
  1506. self.html(value);
  1507. $.post(url, {project:project,table:table,value:value,where_id:id,col:col}, function(t)
  1508. {
  1509. notify('修改成功', self);
  1510. preview();
  1511. /*
  1512. if(type && type == 'textarea')
  1513. {
  1514. self.html(t);
  1515. }
  1516. */
  1517. })
  1518. })
  1519. }
  1520. });
  1521. })
  1522. }
  1523. }
  1524. function preview()
  1525. {
  1526. if($("#preview").length)
  1527. {
  1528. var time = Date.parse(new Date());
  1529. var src = $('#preview').attr('src').split('#');
  1530. $('#preview').attr('src', src[0] + '&' + time + '#' + src[1]);
  1531. }
  1532. }
  1533. function del()
  1534. {
  1535. if($(".oper_delete").length)
  1536. {
  1537. $(".oper_delete").each(function()
  1538. {
  1539. var href = $(this).attr('href');
  1540. $(this).attr('href', '#');
  1541. $(this).unbind('click');
  1542. $(this).bind('click', function()
  1543. {
  1544. del_act(href);
  1545. });
  1546. })
  1547. }
  1548. }
  1549. /**
  1550. * 处理删除
  1551. */
  1552. function del_act(href)
  1553. {
  1554. var index = layer.confirm('确定进行此项操作吗?', function(i, l)
  1555. {
  1556. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  1557. $.getJSON(href + '&json=1&callback=?', {}, function(t)
  1558. {
  1559. msg(t);
  1560. layer.close(index);
  1561. })
  1562. });
  1563. }
  1564. /**
  1565. * 处理特殊加载的按钮
  1566. */
  1567. function load(href, content, title)
  1568. {
  1569. if (!content) {
  1570. content = '确定进行此项操作吗?';
  1571. }
  1572. if (!title) {
  1573. title = '温馨提示';
  1574. }
  1575. var send = {title:title}
  1576. var index = layer.confirm(content, send, function(i, l)
  1577. {
  1578. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  1579. if(href.indexOf('&') == -1)
  1580. {
  1581. href += '?json=1&callback=?';
  1582. }
  1583. else
  1584. {
  1585. href += '&json=1&callback=?';
  1586. }
  1587. $.getJSON(href, {}, function(t)
  1588. {
  1589. msg(t);
  1590. layer.close(index);
  1591. //location.reload();
  1592. })
  1593. })
  1594. /*
  1595. showAlert('确定进行此项操作吗?', function()
  1596. {
  1597. $("#dever_modal_no").click();
  1598. $.getJSON(href + '&json=1', {}, function(t)
  1599. {
  1600. msg(t);
  1601. })
  1602. });
  1603. */
  1604. }
  1605. /**
  1606. * 处理特殊页面
  1607. */
  1608. function loadPage(href, title, submit)
  1609. {
  1610. if(href.indexOf('&') == -1)
  1611. {
  1612. href += '?json=1&callback=?';
  1613. }
  1614. else
  1615. {
  1616. href += '&json=1&callback=?';
  1617. }
  1618. $.getJSON(href, {}, function(t)
  1619. {
  1620. var func = false;
  1621. if (submit) {
  1622. }
  1623. showAlert(t.data, func, title);
  1624. })
  1625. }
  1626. /**
  1627. * 处理特殊加载的按钮
  1628. */
  1629. function jump(href, form)
  1630. {
  1631. if (form) {
  1632. var param = formData(form);
  1633. href += param[1];
  1634. }
  1635. if (href.indexOf('list_excel') != -1) {
  1636. Excel.export(href);
  1637. } else {
  1638. location.href = href;
  1639. }
  1640. }
  1641. /**
  1642. * 处理change
  1643. */
  1644. function change()
  1645. {
  1646. if($(".change").length)
  1647. {
  1648. $(".change").each(function()
  1649. {
  1650. var key = $(this).attr('data-child');
  1651. /*
  1652. $('.' + key).each(function()
  1653. {
  1654. if($(this).find('select option:selected').val())
  1655. {
  1656. $(this).show();
  1657. $('#set_cate_id_child').get(0).value = $(this).attr('parent');
  1658. }
  1659. });
  1660. */
  1661. $(this).change(function()
  1662. {
  1663. $('.' + key).hide();
  1664. var v = $('.' + key + '_' + $(this).val());
  1665. var s = v.find('select');
  1666. s.change(function()
  1667. {
  1668. $('.' + key + '_value').val($(this).val());
  1669. })
  1670. if(v.length)
  1671. {
  1672. $('.' + key + '_value').val(s.val());
  1673. v.show();
  1674. }
  1675. else
  1676. {
  1677. $('.' + key + '_value').val(-1);
  1678. }
  1679. });
  1680. if($(this).val() > 0)
  1681. {
  1682. $(this).change();
  1683. }
  1684. });
  1685. }
  1686. }
  1687. /**
  1688. * 处理图库系统
  1689. */
  1690. function image()
  1691. {
  1692. if($(".dever-note").length)
  1693. {
  1694. $(".dever-note").each(function()
  1695. {
  1696. var key = $(this).attr('key');
  1697. $(this).inlineattachment(
  1698. {
  1699. uploadUrl: config.upload + '.drag?key='+ key
  1700. });
  1701. });
  1702. }
  1703. if($(".image_upload").length)
  1704. {
  1705. $(".image_upload").each(function(i)
  1706. {
  1707. //如果是大文件
  1708. if ($(this).attr('l')) {
  1709. loadUploadL(i,$(this),$(this).attr('key'),config.upload + '.start', config.lib + 'upload/');
  1710. } else {
  1711. var parent = $(this).parent().parent();
  1712. //alert(parent.attr('id'));
  1713. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1714. {
  1715. return;
  1716. }
  1717. loadUpload(i,$(this),$(this).attr('key'),config.upload + '.start', config.lib + 'upload/');//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1718. }
  1719. })
  1720. }
  1721. if($(".upload_show").length)
  1722. {
  1723. $(".upload_show").each(function(i)
  1724. {
  1725. var parent = $(this).parent().parent();
  1726. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1727. {
  1728. return;
  1729. }
  1730. showUpload(i,$(this),$(this).attr('key'),config.upload + '.files', config.lib + 'upload/', 1);//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1731. })
  1732. }
  1733. if($(".upload_cover").length)
  1734. {
  1735. $(".upload_cover").each(function(i)
  1736. {
  1737. var parent = $(this).parent().parent();
  1738. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1739. {
  1740. return;
  1741. }
  1742. showUploadCover(i,$(this),$(this).attr('key'),config.upload + '.videoCover', config.lib + 'upload/', 1);//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1743. })
  1744. }
  1745. if($(".upload_show_editor").length)
  1746. {
  1747. $(".upload_show_editor").each(function(i)
  1748. {
  1749. var parent = $(this).parent().parent();
  1750. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1751. {
  1752. return;
  1753. }
  1754. showUpload(i,$(this),$(this).attr('key'),config.upload + '.files', config.lib + 'upload/', 3);//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1755. })
  1756. }
  1757. }
  1758. /**
  1759. * 修改密码
  1760. */
  1761. function pass(e)
  1762. {
  1763. var html = '<style>.password_edit div{margin:10px;}.password_edit input{width:200px;}</style><div class="password_edit">';
  1764. html += '<div><label class="layui-form-label">旧密码:</label><input type="password" class="form-control form_margin layui-input" id="edit_old_password" /></div>';
  1765. html += '<div><label class="layui-form-label">新密码:</label><input type="password" class="form-control form_margin layui-input" id="edit_new_password" /></div>';
  1766. html += '</div>';
  1767. var edit = function()
  1768. {
  1769. var old_password = $("#edit_old_password").val();
  1770. var new_password = $("#edit_new_password").val();
  1771. if(!old_password || !new_password)
  1772. {
  1773. alert('请输入密码');
  1774. return;
  1775. }
  1776. if(old_password == new_password)
  1777. {
  1778. alert('旧密码和新密码相同');
  1779. return;
  1780. }
  1781. $.post(config.host + 'auth.password', {old:old_password,new:new_password}, function(t)
  1782. {
  1783. alert(t);
  1784. })
  1785. };
  1786. showAlert(html, edit, '修改密码');
  1787. /*
  1788. $('#dever_modal_body').html(html);
  1789. $('#dever_modal_title').html('修改密码');
  1790. */
  1791. }
  1792. var MSG = [];
  1793. /**
  1794. * 打开弹窗
  1795. */
  1796. //function showMsg(title, e, id, func)
  1797. function showMsg(title, e, id, func, param)
  1798. {
  1799. if(id.indexOf('http://') == -1)
  1800. {
  1801. if($(id).length)
  1802. {
  1803. var html = $(id).html();
  1804. if($(id).html())
  1805. {
  1806. var html = $(id).html();
  1807. MSG[id] = html;
  1808. $(id).html('');
  1809. }
  1810. else
  1811. {
  1812. var html = MSG[id];
  1813. }
  1814. }
  1815. else
  1816. {
  1817. var html = id;
  1818. }
  1819. showAlert(html, func, title);
  1820. /*
  1821. $('#dever_modal_body').html(html);
  1822. $('#dever_modal_title').html(title);
  1823. if (func) {
  1824. $("#dever_modal_yes").unbind('click').bind('click', func);
  1825. } else {
  1826. $("#dever_modal_yes").unbind('click').bind('click', function(){$("#dever_modal_no").click()});
  1827. }
  1828. */
  1829. }
  1830. else
  1831. {
  1832. var url = id;
  1833. var send = {};
  1834. if (param) {
  1835. send = param;
  1836. }
  1837. if (e && e.attr('msg-send')) {
  1838. send.data = e.attr('msg-send');
  1839. }
  1840. if (url.indexOf('?') != -1) {
  1841. url = url + '&';
  1842. } else {
  1843. url = url + '?';
  1844. }
  1845. $.getJSON(url+'json=1&callback=?',send,function(t)
  1846. {
  1847. t = t.data;
  1848. showAlert(t, func, t);
  1849. /*
  1850. $('#dever_modal_body').html(t);
  1851. $('#dever_modal_title').html(title);
  1852. if(func)
  1853. {
  1854. $("#dever_modal_yes").unbind('click').bind('click', func);
  1855. }
  1856. */
  1857. });
  1858. }
  1859. }
  1860. function updateMsg(id)
  1861. {
  1862. $("#"+id).submit();
  1863. }
  1864. function showAlert(msg, func, title, index, t)
  1865. {
  1866. if (!title) {
  1867. title = '温馨提示';
  1868. }
  1869. var type = 0;
  1870. if (msg.indexOf('<') != -1) {
  1871. type = 1;
  1872. }
  1873. if (t) {
  1874. type = t;
  1875. }
  1876. var config = {
  1877. type: 0,
  1878. title: title,
  1879. shade: 0.1,
  1880. shadeClose : true,
  1881. content: msg
  1882. };
  1883. if (index) {
  1884. config.zIndex = index;
  1885. }
  1886. config.scrollbar = false;
  1887. if (type == 1) {
  1888. config.type = 1;
  1889. config.btn = ['保存', '关闭'];
  1890. if (func) {
  1891. config.area = ['800px', '500px'];
  1892. config.btn = ['保存', '关闭'];
  1893. } else {
  1894. config.area = ['500px', '550px'];
  1895. config.btn = ['关闭'];
  1896. }
  1897. } else if (type == 2) {
  1898. config.type = 1;
  1899. config.btn = [];
  1900. config.area = ['800px', '550px'];
  1901. }
  1902. config.cancel = config.btn2 = function(index)
  1903. {
  1904. layer.close(index);
  1905. };
  1906. if (func) {
  1907. config.yes = function(index)
  1908. {
  1909. func(index);
  1910. };
  1911. } else {
  1912. config.yes = config.cancel;
  1913. }
  1914. config.success = function() {
  1915. //$('.layui-layer-content').css('padding', '10px');
  1916. }
  1917. config.end = function() {
  1918. $('.layui-layer-content').css('overflow-x', 'auto');
  1919. $('#update_button').show();
  1920. }
  1921. var index = layer.open(config);
  1922. }
  1923. function fastEdit(e, url, title, col, index, type)
  1924. {
  1925. var func = function()
  1926. {
  1927. $(".fast").submit();
  1928. };
  1929. var send = {};
  1930. if (col) {
  1931. send.col = col;
  1932. }
  1933. $.get(url + '&fast=1',send,function(t)
  1934. {
  1935. var html = '';
  1936. var valid = '';
  1937. var action = '';
  1938. if ($(t).find('form').length) {
  1939. if ($(t).find('form').length > 1) {
  1940. var form = $(t).find('form').eq(1);
  1941. form.addClass('layui-card-body');
  1942. } else {
  1943. var form = $(t).find('form').eq(0);
  1944. }
  1945. action = form.attr('action');
  1946. form.addClass('fast');
  1947. form.find('#function').eq(0).val('showYes');
  1948. var html = form.prop("outerHTML");
  1949. if ($(t).find('#valid').length) {
  1950. var valid = $(t).find('#valid').prop("outerHTML");
  1951. html = html + valid;
  1952. }
  1953. if (html.indexOf('left: 740px') != -1) {
  1954. html = html.replace('left: 740px', 'left:583px;')
  1955. }
  1956. } else {
  1957. html = t;
  1958. func = false;
  1959. }
  1960. /*
  1961. if ($(html).find('.layui-card-body').length > 0) {
  1962. html = html.replace('class="layui-card-body"', 'class="layui-card-body" style="display:none"');
  1963. html = html.replaceAll('class="layui-btn layuiadmin-btn-list"', 'class="layui-btn layuiadmin-btn-list" style="display:none"');
  1964. }
  1965. */
  1966. if (!action) {
  1967. type = 2;
  1968. func = false;
  1969. }
  1970. if (index == 1) {
  1971. showAlert(html, func, title, 19850422, type);
  1972. } else {
  1973. showAlert(html, func, title, false, type);
  1974. }
  1975. $('.layui-layer-content').css('overflow-x', 'hidden');
  1976. $('#update_button').hide();
  1977. layui.use(['formSelects', 'form'], function(){
  1978. var form = layui.form;
  1979. form.render();
  1980. $("select").each(function()
  1981. {
  1982. if ($(this).attr('xm-select')) {
  1983. layui.formSelects.render($(this).attr('xm-select'));
  1984. }
  1985. })
  1986. });
  1987. init(560);
  1988. });
  1989. }
  1990. /*
  1991. var test =
  1992. {
  1993. refreshPage: false,
  1994. addAjaxFlag: true,
  1995. //添加收藏
  1996. add: function(cfg)
  1997. {
  1998. }
  1999. }
  2000. */
  2001. function showToggle(e)
  2002. {
  2003. var id = e.attr('toggle');
  2004. var child = e.attr('toggle_child');
  2005. var parent = e.parent();
  2006. parent.parent().find('li').removeClass('active');
  2007. parent.addClass('active');
  2008. $(child).fadeOut(100);
  2009. $(id).fadeIn(500);
  2010. initEditor($(id).find('.editor'));
  2011. }
  2012. var select_api = {};
  2013. var select_api_name = [];
  2014. var select_api_title = '';
  2015. var select_api_open = '';
  2016. function select_linkage(level, id, url, name, value, valid, w, total, search, level_param, col, api, type, title, open)
  2017. {
  2018. var e = '#' + id;
  2019. var parent = value.split(',');
  2020. var cur = parent[0];
  2021. parent.remove(cur);
  2022. value = parent.join(',');
  2023. var html = '';
  2024. var old = level;
  2025. var level_name = '';
  2026. if (!total) {
  2027. level_id = 0;
  2028. } else {
  2029. if (level >= total) {
  2030. //$(e).show();
  2031. return;
  2032. }
  2033. level_id = $(e + '_' + level).val();
  2034. if (level_id.indexOf('|') != -1) {
  2035. var temp = level_id.split('|');
  2036. if (level == 1) {
  2037. select_api_name = [];
  2038. }
  2039. level_id = temp[0];
  2040. level_name = temp[1];
  2041. select_api_name[level-1] = level_name;
  2042. }
  2043. level = parseInt(level) + 1;
  2044. }
  2045. var api_name = '';
  2046. if (col && api) {
  2047. select_api_title = title;
  2048. select_api_open = open;
  2049. if (name.indexOf('_no') == -1) {
  2050. api_name = name;
  2051. } else {
  2052. var t = name.split('_no');
  2053. api_name = t[0];
  2054. }
  2055. name += '_no';
  2056. }
  2057. $.getJSON(url + '&json=1&callback=?', {level_search:search, level_id:level_id, level_num:level,level_param:level_param}, function(t) {
  2058. var check = '';
  2059. if (t.status == 1) {
  2060. var total = t.data.level_total;
  2061. var data = t.data.list;
  2062. if(!$(e + '_' + level).length) {
  2063. html = '<select lay-ignore style="display:inline;margin-top:10px;'+w+'" class="layui-input layui-select update_value form-control '+valid+'" id="'+id+'_'+level+'" name="'+name+'[]" onchange="select_linkage(\''+level+'\', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+total+', \''+search+'\', \''+level_param+'\', \''+col+'\', \''+api+'\', \''+type+'\', \''+title+'\', \''+open+'\');">';
  2064. }
  2065. for (a in data) {
  2066. if (data[a].value) {
  2067. check = '';
  2068. if (cur == data[a].value) {
  2069. check = ' selected';
  2070. }
  2071. var v = data[a].value;
  2072. if (col && api) {
  2073. v = data[a].value + '|' + data[a].name;
  2074. }
  2075. html += '<option value="'+v+'" '+check+'>'+data[a].name+'</option>';
  2076. }
  2077. }
  2078. if(!$(e + '_' + level).length) {
  2079. html += '</select><span>&nbsp;&nbsp;</span>';
  2080. $(e).append(html);
  2081. $(e + '_' + level).change();
  2082. } else {
  2083. $(e + '_' + level).html(html);
  2084. $(e + '_' + level).change();
  2085. }
  2086. } else {
  2087. $(e + '_' + old).nextAll('select').remove();
  2088. $(e + '_' + old).next('span').nextAll('span').remove();
  2089. }
  2090. if (col && api && level_id > 0) {
  2091. var send = {};
  2092. send[col] = level_id;
  2093. $.getJSON(api + '&json=1&callback=?', send, function(r) {
  2094. var h = '<ul style="list-style:none;margin-top: 20px;display:;" class="">';
  2095. if (type == 'checkbox') {
  2096. h += '<li style="display:inline;margin-left:15px;"><input class="update_value" type="checkbox" onclick="select_linkage_check_all($(this), \'check_level_'+level_id+'\', \''+level_id+'\', \''+select_api_name.join('->')+'\', \''+e+'\', \''+api_name+'\')" value=""/>&nbsp;&nbsp;全选</li>';
  2097. }
  2098. for (var i in r.data) {
  2099. if (r.data[i]['name']) {
  2100. var checked = false;
  2101. if (select_api['level_' + level_id] && select_api['level_' + level_id]['value'] && select_api['level_' + level_id]['value']['id_' + r.data[i]['id']] && select_api['level_' + level_id]['value']['id_' + r.data[i]['id']]['state'] == 1) {
  2102. checked = true;
  2103. }
  2104. h += '<li style="display:inline;margin-left:15px;"><input onclick="select_linkage_check($(this), \''+level_id+'\', \''+select_api_name.join('->')+'\', \''+e+'\', \''+api_name+'\')" '+(checked ? 'checked' : '')+' class="update_value check_level_'+level_id+'" type="' + type + '" id="'+id+'_'+r.data[i]['id']+'" value="'+r.data[i]['id']+'|' + r.data[i]['name'] + '"/>&nbsp;&nbsp;' + r.data[i]['name'] + '</li>';
  2105. }
  2106. }
  2107. h += '</ul>';
  2108. $(e + '_content').html(h);
  2109. });
  2110. }
  2111. /*
  2112. if ($('#' + name + '_level_value').length) {
  2113. var total = $(id).find('select').length;
  2114. $('#' + name + '_level_value').val(total);
  2115. }
  2116. if ($('#' + name + '_up_value').length) {
  2117. $('#' + name + '_up_value').val($(id + '_-2').val());
  2118. }
  2119. */
  2120. });
  2121. if (col && api) {
  2122. select_linkage_check_show(e, api_name);
  2123. }
  2124. }
  2125. function select_linkage_check_all(e, cur, level_id, level_name, id, api_name)
  2126. {
  2127. var checked = e.prop('checked');
  2128. $('.' + cur).each(function() {
  2129. $(this).prop('checked', checked);
  2130. select_linkage_check($(this), level_id, level_name, id, api_name);
  2131. })
  2132. }
  2133. function select_linkage_check(e, level_id, level_name, id, api_name, cid)
  2134. {
  2135. var level_key = 'level_' + level_id;
  2136. if (!select_api[level_key]) {
  2137. select_api[level_key] = {};
  2138. select_api[level_key]['id'] = level_id;
  2139. select_api[level_key]['name'] = level_name;
  2140. select_api[level_key]['value'] = {};
  2141. }
  2142. var value = e.val();
  2143. var temp = value.split('|');
  2144. var key = 'id_' + temp[0];
  2145. if (e.prop('checked')) {
  2146. select_api[level_key]['value'][key] = {};
  2147. select_api[level_key]['value'][key]['id'] = temp[0];
  2148. select_api[level_key]['value'][key]['name'] = temp[1];
  2149. select_api[level_key]['value'][key]['state'] = 1;
  2150. } else {
  2151. if (select_api[level_key] && select_api[level_key]['value'] && select_api[level_key]['value'][key]) {
  2152. select_api[level_key]['value'][key]['state'] = 2;
  2153. }
  2154. if (cid) {
  2155. $(cid).prop('checked', false);
  2156. }
  2157. }
  2158. select_linkage_check_show(id, api_name);
  2159. }
  2160. function select_linkage_check_show(id, api_name)
  2161. {
  2162. if (select_api) {
  2163. var select_api_json = JSON.stringify(select_api);
  2164. var html = '<div style="margin-top: 20px;display:;border: 1px solid #5050b1;padding: 10px;">';
  2165. for (var i in select_api) {
  2166. if (select_api[i]['value']) {
  2167. html += '[' + select_api[i]['name'] + ']:<ul style="list-style:none;" class="">';
  2168. for (var j in select_api[i]['value']) {
  2169. var n = '&nbsp;&nbsp;' + select_api[i]['value'][j]['name'];
  2170. if (select_api_open) {
  2171. var o = select_api_open.replace('{id}', select_api[i]['value'][j]['id']);
  2172. n = '<a href="javascript:;" onclick="fastEdit($(this), \''+o+'\', \''+select_api_title+'\', \'\', 1,1)">'+n+'</a>';
  2173. }
  2174. if (select_api[i]['value'][j]['state'] == 2) {
  2175. n += '[已删除]';
  2176. var checked = false;
  2177. } else {
  2178. var checked = true;
  2179. }
  2180. html += '<li style="display:inline;margin-left:15px;"><input onclick="select_linkage_check($(this), \''+select_api[i]['id']+'\', \''+select_api[i]['name']+'\', \''+id+'\', \''+api_name+'\', \''+id+'_'+select_api[i]['value'][j]['id']+'\')" '+(checked ? 'checked' : '')+' class="update_value" type="checkbox" id="s_'+select_api[i]['value'][j]['id']+'_test" name="s_'+select_api[i]['value'][j]['id']+'_test" value="'+select_api[i]['value'][j]['id']+'|' + select_api[i]['value'][j]['name'] + '"/>'+n+'</li>';
  2181. }
  2182. html += '</ul>';
  2183. }
  2184. }
  2185. html += '</div>';
  2186. html += '<textarea name="'+api_name+'" style="display:none">'+select_api_json+'</textarea>';
  2187. $(id + '_data').html(html);
  2188. }
  2189. }
  2190. /*
  2191. function select_mul(level, id, url, name, value, valid, w, num)
  2192. {
  2193. if(level == 0)
  2194. {
  2195. $(id).find('select').remove();
  2196. $(id).find('span').remove();
  2197. return;
  2198. }
  2199. var parent = value.split(',');
  2200. var cur = parent[0];
  2201. parent.remove(cur);
  2202. value = parent.join(',');
  2203. var html = '';
  2204. var old = level;
  2205. if(level != -1)
  2206. {
  2207. if($(id + '_' + level).length)
  2208. {
  2209. level = $(id + '_' + level).val();
  2210. }
  2211. alert(level);
  2212. if(level == 0)
  2213. {
  2214. $(id + '_' + old).nextAll('select').remove();
  2215. $(id + '_' + old).next('span').nextAll('span').remove();
  2216. if($('#' + name + '_level_value').length)
  2217. {
  2218. var total = $(id).find('select').length;
  2219. $('#' + name + '_level_value').val(total);
  2220. }
  2221. if(old == -2 && $('#' + name + '_value_value').length)
  2222. {
  2223. $('#' + name + '_value_value').val(level);
  2224. }
  2225. return;
  2226. }
  2227. if(old == -2)
  2228. {
  2229. $(id + '_' + old).nextAll('select').remove();
  2230. $(id + '_' + old).next('span').nextAll('span').remove();
  2231. }
  2232. if($('#' + name + '_value_value').length)
  2233. {
  2234. $('#' + name + '_value_value').val(level);
  2235. }
  2236. }
  2237. var total = $(id).find('select').length;
  2238. if(num > 0 && total >= num)
  2239. {
  2240. return;
  2241. }
  2242. var get = url.replace('{level}', level);
  2243. if(level == -1)
  2244. {
  2245. level = -2;
  2246. }
  2247. if(!$(id + '_' + level).length)
  2248. {
  2249. $.getJSON(get + '&json=1', {total:total,level:level}, function(t)
  2250. {
  2251. var check = '';
  2252. if(t.status == 1)
  2253. {
  2254. html = '<select style="'+w+'display:inline;margin-top:10px;" class="update_value form-control '+valid+' dever-mul-'+name+'_'+level+'" name="'+name+'[]" onchange="select_mul(\''+level+'\', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+num+');">';
  2255. console.log(t.data);
  2256. for(a in t.data)
  2257. {
  2258. if(t.data[a].value)
  2259. {
  2260. check = '';
  2261. if(cur == t.data[a].value)
  2262. {
  2263. check = ' selected';
  2264. }
  2265. html += '<option value="'+t.data[a].value+'" '+check+'>'+t.data[a].name+'</option>';
  2266. }
  2267. }
  2268. html += '</select><span>&nbsp;&nbsp;</span>';
  2269. $(id).append(html);
  2270. $(id + '_' + level).change();
  2271. }
  2272. else
  2273. {
  2274. $(id + '_' + old).nextAll('select').remove();
  2275. $(id + '_' + old).next('span').nextAll('span').remove();
  2276. }
  2277. if($('#' + name + '_level_value').length)
  2278. {
  2279. var total = $(id).find('select').length;
  2280. $('#' + name + '_level_value').val(total);
  2281. }
  2282. if($('#' + name + '_up_value').length)
  2283. {
  2284. $('#' + name + '_up_value').val($(id + '_-2').val());
  2285. }
  2286. });
  2287. }
  2288. }
  2289. */
  2290. //处理更新页面的一些功能,写到一起吧
  2291. var dever_update =
  2292. {
  2293. addIndex : 2,
  2294. index : [],
  2295. auto : false,
  2296. save_key : '',
  2297. init : function()
  2298. {
  2299. var self = this;
  2300. self.index = [];
  2301. // 增加整个更新的表单
  2302. if($(".dever_update_add").length)
  2303. {
  2304. $('.dever_update_add').unbind('click').bind('click', function()
  2305. {
  2306. self.add($(this));
  2307. })
  2308. }
  2309. /* 以后再增加 同时更新另外一个表
  2310. if($(".form-add-content").length)
  2311. {
  2312. var url = config.host + 'auth.password';
  2313. var url = 'http://localhost/dever/manage/?database.update?project=weixin&table=message&menu=weixin&menu_id=39&ajax=1';
  2314. $.get(url, function(t)
  2315. {
  2316. $(".form-add-content").html(t);
  2317. init();
  2318. })
  2319. }
  2320. */
  2321. //增加某一部分表单
  2322. if($(".dever_form_add").length)
  2323. {
  2324. $('.dever_form_add').each(function()
  2325. {
  2326. var key = $.attr('toggle_key');
  2327. if(typeof(self.index[key]) == "undefined")
  2328. {
  2329. self.index[key] = 0;
  2330. }
  2331. $(this).unbind('click').bind('click', function()
  2332. {
  2333. self.append($(this));
  2334. })
  2335. })
  2336. self.del();
  2337. }
  2338. // 开启自动保存
  2339. if($("#struct").length)
  2340. {
  2341. var save = $("#struct").attr('save');
  2342. if(save == 'yes')
  2343. {
  2344. //检测
  2345. self.save_key = location.href + 'test';
  2346. self.check();
  2347. }
  2348. }
  2349. if($('.dever-note').length)
  2350. {
  2351. $('.dever-note').each(function()
  2352. {
  2353. var mditor = new Mditor($(this),{
  2354. fixedHeight:true
  2355. });
  2356. mditor.openPreview();
  2357. })
  2358. }
  2359. },
  2360. save : function()
  2361. {
  2362. //var data = $("#data-1").html();
  2363. var data = [];
  2364. $(".update_value").each(function(i)
  2365. {
  2366. if($(this).attr("update_type") == 'checked')
  2367. {
  2368. data[i] = $(this).get(0).checked;
  2369. }
  2370. else if($(this).attr("update_type") == 'html')
  2371. {
  2372. data[i] = $(this).html();
  2373. }
  2374. else if($(this).attr("update_type") == 'src')
  2375. {
  2376. data[i] = $(this).attr('src');
  2377. }
  2378. else
  2379. {
  2380. data[i] = $(this).val();
  2381. }
  2382. });
  2383. store.set(this.save_key, data.join('|||'));
  2384. //console.info(data);
  2385. },
  2386. recover : function()
  2387. {
  2388. var index = layer.confirm('确定恢复上次保存的数据吗?', function(i, l)
  2389. {
  2390. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  2391. var data = store.get(this.save_key).split('|||');
  2392. if(data)
  2393. {
  2394. var value = $(".update_value");
  2395. for(var k in data)
  2396. {
  2397. var e = value.eq(k);
  2398. if(e.attr('update_type') == 'checked')
  2399. {
  2400. if(data[k] == 'true')
  2401. {
  2402. e.get(0).checked = true;
  2403. }
  2404. else
  2405. {
  2406. e.get(0).checked = false;
  2407. }
  2408. }
  2409. else if(e.attr('update_type') == 'html')
  2410. {
  2411. e.html(data[k]);
  2412. }
  2413. else if(e.attr('update_type') == 'src')
  2414. {
  2415. e.attr('src', data[k]);
  2416. }
  2417. else
  2418. {
  2419. if(e.attr('id'))
  2420. {
  2421. var id = e.attr('id');
  2422. if(typeof(editors[id]) != "undefined")
  2423. {
  2424. editors[id].html(data[k]);
  2425. }
  2426. }
  2427. e.val(data[k]);
  2428. }
  2429. }
  2430. store.set(this.save_key, '');
  2431. this.check();
  2432. }
  2433. })
  2434. },
  2435. check : function()
  2436. {
  2437. var data = store.get(this.save_key);
  2438. var self = this;
  2439. if(data)
  2440. {
  2441. $(".dever_save").unbind('click').bind('click', function()
  2442. {
  2443. self.recover();
  2444. }).show();
  2445. }
  2446. else
  2447. {
  2448. $(".dever_save").hide();
  2449. self.auto = setInterval(function(){self.save()}, 3000);
  2450. }
  2451. },
  2452. del : function()
  2453. {
  2454. var self = this;
  2455. if($(".dever_form_delete").length)
  2456. {
  2457. $('.dever_form_delete').each(function()
  2458. {
  2459. $(this).unbind('click').bind('click', function()
  2460. {
  2461. var parent = $(this).parent();
  2462. var id = parent.attr('id');
  2463. var index = parseInt($('#tab-' + id).attr('toggle_id'));
  2464. var key = $('#tab-' + id).attr('toggle_key');
  2465. if(index <= 1 && self.index[key] <= index)
  2466. {
  2467. }
  2468. else if(index <= 1 && self.index[key] > index)
  2469. {
  2470. index = index+1;
  2471. $("#tab-"+key+"-child-" + index).click();
  2472. }
  2473. else
  2474. {
  2475. index = index-1;
  2476. $("#tab-"+key+"-child-" + index).click();
  2477. };
  2478. $('#tab-' + id).parent().remove();
  2479. parent.remove();
  2480. self.index[key]--;
  2481. })
  2482. })
  2483. }
  2484. },
  2485. append : function(e)
  2486. {
  2487. var self = this;
  2488. var key = e.attr('toggle_key');
  2489. var child = '.dever_'+key+'_child';
  2490. if(typeof(self.index[key]) == "undefined")
  2491. {
  2492. self.index[key] = 0;
  2493. }
  2494. if (isNaN(self.index[key])) {
  2495. self.index[key] = 0;
  2496. }
  2497. if(self.index[key] <= 0)
  2498. {
  2499. self.index[key] = $(child).length;
  2500. }
  2501. if(self.index[key] > 30)
  2502. {
  2503. layer.showAlert('最多只能增加30条');
  2504. return;
  2505. }
  2506. var p = e.parent();
  2507. var id = key + '-child-' + self.index[key];
  2508. var name = '第' + (self.index[key]) + '条';
  2509. p.before('<li><a href="javascript:;" id="tab-'+id+'" toggle_key="'+key+'" toggle_id="'+self.index[key]+'" toggle_child="'+child+'" toggle="#'+id+'" onclick="showToggle($(this))">'+name+'</a></li>');
  2510. var e = e.parent().parent();
  2511. var n = e.next();
  2512. var p = e.parent();
  2513. var content = n.html();
  2514. content = content.replaceAll('_c_', '_c_' + (self.index[key]-1) + '_i_');
  2515. content = '<div id="'+id+'" style="display:none;margin:10px" class="'+n.attr('class')+' dever_form_add_child">' + content + '</div>';
  2516. p.append(content);
  2517. if ($("#" + id).find('.ke-container').length >= 1) {
  2518. $("#" + id).find('.ke-container').eq(0).remove();
  2519. }
  2520. $('#update_' + key +'_c_' + (self.index[key]-1) + '_i_' + 'order_value').val(parseInt($('#update_' + key +'_c_' + (self.index[key]-2) + '_i_' + 'order_value').val())+1);
  2521. self.del();
  2522. //$("html,body").animate({scrollTop:$('.dever_form_add_child').eq(this.appendIndex).offset().top},500);
  2523. self.index[key]++;
  2524. image();
  2525. loadShow();
  2526. autocomplete();
  2527. change();
  2528. layui.use(['formSelects'], function(){
  2529. $('#' + id + " select").each(function()
  2530. {
  2531. if ($(this).attr('xm-select')) {
  2532. layui.formSelects.render($(this).attr('xm-select'));
  2533. }
  2534. })
  2535. });
  2536. },
  2537. add : function(e)
  2538. {
  2539. var self = this;
  2540. var p = e.parent();
  2541. var id = 'data-' + this.addIndex;
  2542. var name = '新增数据-' + (this.addIndex-1);
  2543. p.before('<li><a href="#'+id+'" data-toggle="tab">'+name+'</a></li>');
  2544. var content = $("#content").find('.tab-pane').eq(0).html();
  2545. content = content.replaceAll('update_', 'update_' + this.addIndex + '__');
  2546. content = '<div class="tab-pane fade" id="'+id+'">' + content + '</div>';
  2547. $("#content").append(content);
  2548. $('#update_' + this.addIndex + '__where_id').val('-1');
  2549. this.addIndex++;
  2550. }
  2551. }
  2552. $.fn.pasteEvents = function( delay ) {
  2553. if (delay == undefined) delay = 20;
  2554. return $(this).each(function() {
  2555. var $el = $(this);
  2556. $el.on("paste", function() {
  2557. $el.trigger("prepaste");
  2558. setTimeout(function() { $el.trigger("postpaste"); }, delay);
  2559. });
  2560. });
  2561. };
  2562. $("textarea").on("postpaste", function()
  2563. {
  2564. if($(this).val().indexOf('<') != -1)
  2565. {
  2566. $(this).val(toMarkdown($(this).val()));
  2567. }
  2568. }).pasteEvents();
  2569. function showYes(msg)
  2570. {
  2571. if (msg.status == 2) {
  2572. layer.alert(msg.msg);
  2573. } else {
  2574. showAlert('保存成功', function() {
  2575. if (select_api_open) {
  2576. $('.layui-layer-content').css('overflow-x', 'auto');
  2577. $('#update_button').show();
  2578. layer.closeAll();
  2579. } else {
  2580. if(msg.data.indexOf('http') != -1) {
  2581. location.href = msg.data;
  2582. } else {
  2583. location.reload()
  2584. }
  2585. }
  2586. });
  2587. }
  2588. }
  2589. function setDay(e, d)
  2590. {
  2591. $('#search_option_sday').val(d);
  2592. $('.sday_button').removeClass('sday_button_border');
  2593. e.addClass('sday_button_border');
  2594. var date = new Date();
  2595. var year = date.getFullYear();
  2596. var month = date.getMonth()+1;
  2597. var day = date.getDate();
  2598. var nowDate = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
  2599. //获取30天前得日期
  2600. var lastDate = new Date(date - 1000 * 60 * 60 * 24 * d);
  2601. var lastY = lastDate.getFullYear();
  2602. var lastM = lastDate.getMonth()+1;
  2603. var lastD = lastDate.getDate();
  2604. var LDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD);
  2605. $('.manage_sday').eq(0).val(LDate);
  2606. $('.manage_sday').eq(1).val(nowDate);
  2607. }
  2608. function setDate(e, d)
  2609. {
  2610. $('#search_option_sdate').val(d);
  2611. $('.sdate_button').removeClass('sdate_button_border');
  2612. e.addClass('sdate_button_border');
  2613. var date = new Date();
  2614. var year = date.getFullYear();
  2615. var month = date.getMonth()+1;
  2616. var day = date.getDate();
  2617. var nowDate = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
  2618. //获取30天前得日期
  2619. var lastDate = new Date(date - 1000 * 60 * 60 * 24 * d);
  2620. var lastY = lastDate.getFullYear();
  2621. var lastM = lastDate.getMonth()+1;
  2622. var lastD = lastDate.getDate();
  2623. var LDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD);
  2624. $('.manage_sdate').eq(0).val(LDate + ' 00:00:00');
  2625. $('.manage_sdate').eq(1).val(nowDate + ' 23:59:59');
  2626. }
  2627. function showVideo(video)
  2628. {
  2629. var html = '<meta name="referrer" content="no-referrer"><video width="400" height="300" controls autoplay="autoplay"><source src="'+video+'" type="video/mp4">您的浏览器不支持Video标签。</video>';
  2630. showAlert(html);
  2631. }