setting.util.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. define(
  2. "/js/setting.util",
  3. [
  4. "js/lib/handlebars",
  5. /*"js/handlebars.helper",*/ "js/lib/jquery-lib",
  6. "js/common.tools",
  7. "js/util",
  8. "js/jquery.pager",
  9. "js/lib/ztree/js/ztree",
  10. "js/lib/artDialog/jquery-artDialog",
  11. "setting/core",
  12. /*"tpl/copyright.html", "tpl/search.html", "tpl/search_list.html", "tpl/upload.html",*/ "setting/setting",
  13. /*"menu",*/ "site",
  14. "role",
  15. "setting/system",
  16. ],
  17. function (e) {
  18. ;(template = Handlebars),
  19. (core = e("setting/core")),
  20. (Setting = e("setting/setting")),
  21. // Menu = e("menu"),
  22. (Role = e("role")),
  23. // User = e("user"),
  24. (System = e("setting/system")),
  25. (Site = e("site")),
  26. Setting.init(),
  27. // Menu.bindEvent(),
  28. // User.bindEvent(),
  29. Role.bindEvent(),
  30. Site.bindEvent(),
  31. (RULES = {
  32. query: "查询",
  33. add: "新增",
  34. edit: "编辑",
  35. remove: "删除",
  36. upload: "上传",
  37. download: "下载",
  38. import: "导入",
  39. export: "导出",
  40. })
  41. }
  42. ),
  43. define("setting/core", [], function (require, exports) {
  44. var t = template.compile($("#setting-template").html())
  45. $("#setting-box").html(t({ G: G, LNG: LNG, AUTH: AUTH, data: {} }))
  46. if (!G.is_root) {
  47. $("#system,#code,#area,#user,#role,#custom,#proxy,#resident,#menu,#site", "#setting-box").remove()
  48. }
  49. return {
  50. filetype: {
  51. image: ["jpg", "jpeg", "png", "bmp", "gif", "ico"],
  52. music: ["mp3", "wma", "wav", "mid", "m4a", "aac", "midi"],
  53. movie: ["avi", "flv", "f4v", "wmv", "3gp", "mp4", "wmv", "asf", "m4v", "mov", "mpg"],
  54. doc: ["doc", "docx", "docm", "xls", "xlsx", "xlsb", "xlsm", "ppt", "pptx", "pptm"],
  55. text: ["oexe", "inc", "inf", "csv", "log", "asc", "tsv"],
  56. code: [
  57. "abap",
  58. "abc",
  59. "as",
  60. "ada",
  61. "adb",
  62. "htgroups",
  63. "htpasswd",
  64. "conf",
  65. "htaccess",
  66. "htgroups",
  67. "htpasswd",
  68. "asciidoc",
  69. "asm",
  70. "ahk",
  71. "bat",
  72. "cmd",
  73. "c9search_results",
  74. "cpp",
  75. "c",
  76. "cc",
  77. "cxx",
  78. "h",
  79. "hh",
  80. "hpp",
  81. "cirru",
  82. "cr",
  83. "clj",
  84. "cljs",
  85. "CBL",
  86. "COB",
  87. "coffee",
  88. "cf",
  89. "cson",
  90. "Cakefile",
  91. "cfm",
  92. "cs",
  93. "css",
  94. "curly",
  95. "d",
  96. "di",
  97. "dart",
  98. "diff",
  99. "patch",
  100. "Dockerfile",
  101. "dot",
  102. "dummy",
  103. "dummy",
  104. "e",
  105. "ejs",
  106. "ex",
  107. "exs",
  108. "elm",
  109. "erl",
  110. "hrl",
  111. "frt",
  112. "fs",
  113. "ldr",
  114. "ftl",
  115. "gcode",
  116. "feature",
  117. ".gitignore",
  118. "glsl",
  119. "frag",
  120. "vert",
  121. "go",
  122. "groovy",
  123. "haml",
  124. "hbs",
  125. "handlebars",
  126. "tpl",
  127. "mustache",
  128. "hs",
  129. "hx",
  130. "html",
  131. "htm",
  132. "xhtml",
  133. "erb",
  134. "rhtml",
  135. "ini",
  136. "cfg",
  137. "prefs",
  138. "io",
  139. "jack",
  140. "jade",
  141. "java",
  142. "js",
  143. "jsm",
  144. "json",
  145. "jq",
  146. "jsp",
  147. "jsx",
  148. "jl",
  149. "tex",
  150. "latex",
  151. "ltx",
  152. "bib",
  153. "lean",
  154. "hlean",
  155. "less",
  156. "liquid",
  157. "lisp",
  158. "ls",
  159. "logic",
  160. "lql",
  161. "lsl",
  162. "lua",
  163. "lp",
  164. "lucene",
  165. "Makefile",
  166. "GNUmakefile",
  167. "makefile",
  168. "OCamlMakefile",
  169. "make",
  170. "md",
  171. "markdown",
  172. "mask",
  173. "matlab",
  174. "mel",
  175. "mc",
  176. "mush",
  177. "mysql",
  178. "nix",
  179. "m",
  180. "mm",
  181. "ml",
  182. "mli",
  183. "pas",
  184. "p",
  185. "pl",
  186. "pm",
  187. "pgsql",
  188. "php",
  189. "phtml",
  190. "ps1",
  191. "praat",
  192. "praatscript",
  193. "psc",
  194. "proc",
  195. "plg",
  196. "prolog",
  197. "properties",
  198. "proto",
  199. "py",
  200. "r",
  201. "Rd",
  202. "Rhtml",
  203. "rb",
  204. "ru",
  205. "gemspec",
  206. "rake",
  207. "Guardfile",
  208. "Rakefile",
  209. "Gemfile",
  210. "rs",
  211. "sass",
  212. "scad",
  213. "scala",
  214. "scm",
  215. "rkt",
  216. "scss",
  217. "sh",
  218. "bash",
  219. ".bashrc",
  220. "sjs",
  221. "smarty",
  222. "tpl",
  223. "snippets",
  224. "soy",
  225. "space",
  226. "sql",
  227. "styl",
  228. "stylus",
  229. "svg",
  230. "tcl",
  231. "tex",
  232. "txt",
  233. "textile",
  234. "toml",
  235. "twig",
  236. "ts",
  237. "typescript",
  238. "str",
  239. "vala",
  240. "vbs",
  241. "vb",
  242. "vm",
  243. "v",
  244. "vh",
  245. "sv",
  246. "svh",
  247. "vhd",
  248. "vhdl",
  249. "xml",
  250. "rdf",
  251. "rss",
  252. "wsdl",
  253. "xslt",
  254. "atom",
  255. "mathml",
  256. "mml",
  257. "xul",
  258. "xbl",
  259. "xaml",
  260. "xq",
  261. "yaml",
  262. "yml",
  263. "htm",
  264. "xib",
  265. "storyboard",
  266. "plist",
  267. "csproj",
  268. ],
  269. bindary: ["pdf", "bin", "zip", "swf", "gzip", "rar", "arj", "tar", "gz", "cab", "tbz", "tbz2", "lzh", "uue", "bz2", "ace", "exe", "so", "dll", "chm", "rtf", "odp", "odt", "pages", "class", "psd", "ttf", "fla", "7z", "dmg", "iso", "dat", "ipa"],
  270. },
  271. ico: function (e) {
  272. var t = "/" + "images/file_16/",
  273. a = ["folder", "file", "edit", "search", "up", "setting", "appStore", "error", "info", "mp3", "flv", "pdf", "doc", "xls", "ppt", "html", "swf"],
  274. i = $.inArray(e, a)
  275. return -1 == i ? t + "file.png" : t + e + ".png"
  276. },
  277. contextmenu: function (e) {
  278. try {
  279. rightMenu.hidden()
  280. } catch (t) {}
  281. var t = e || window.event
  282. return t ? ((t && $(t.target).is("textarea")) || $(t.target).is("input") || 0 != $(t.target).parents(".topbar").length || 0 != $(t.target).parents(".edit_body").length || 0 != $(t.target).parents(".aui_state_focus").length ? !0 : !1) : !0
  283. },
  284. pathThis: function (e) {
  285. e = e.replace(/\\/g, "/")
  286. var t = e.split("/"),
  287. a = t[t.length - 1]
  288. if (("" == a && (a = t[t.length - 2]), 0 == a.search("fileProxy"))) {
  289. a = urlDecode(a.substr(a.search("&path=")))
  290. var t = a.split("/")
  291. ;(a = t[t.length - 1]), "" == a && (a = t[t.length - 2])
  292. }
  293. return a
  294. },
  295. pathFather: function (e) {
  296. e = e.replace(/\\/g, "/")
  297. var t = e.lastIndexOf("/")
  298. return e.substr(0, t + 1)
  299. },
  300. pathExt: function (e) {
  301. ;(e = e.replace(/\\/g, "/")), (e = e.replace(/\/+/g, "/"))
  302. var t = e.lastIndexOf(".")
  303. return (e = e.substr(t + 1)), e.toLowerCase()
  304. },
  305. path2url: function (e) {
  306. if ("http" == e.substr(0, 4)) return e
  307. if (((e = e.replace(/\\/g, "/")), (e = e.replace(/\/+/g, "/")), (e = e.replace(/\/\.*\//g, "/")), G.is_root && e.substring(0, G.web_root.length) == G.web_root)) return G.web_host + e.replace(G.web_root, "")
  308. var t = G.app_host + "/index.html?explorer/fileProxy&path=" + urlEncode(e)
  309. return G.share_page !== void 0 && (t = G.app_host + "/index.html?share/fileProxy&user=" + G.user + "&sid=" + G.sid + "&path=" + urlEncode(e)), t
  310. },
  311. authCheck: function (e, t) {
  312. return G.is_root ? !0 : AUTH.hasOwnProperty(e) ? (AUTH[e] ? !0 : (void 0 == t && (t = LNG.no_permission), core.tips.tips(t, !1), !1)) : !0
  313. },
  314. ajaxError: function (e) {
  315. core.tips.close(LNG.system_error, !1)
  316. var t = e.responseText,
  317. a = '<div class="ajaxError">' + t + "</div>",
  318. i = $.dialog.list.ajaxErrorDialog
  319. return "<!--user login-->" == t.substr(0, 17)
  320. ? (FrameCall.goRefresh(), void 0)
  321. : (i
  322. ? i.content(a)
  323. : $.dialog({
  324. id: "ajaxErrorDialog",
  325. padding: 0,
  326. fixed: !0,
  327. resize: !0,
  328. ico: core.ico("error"),
  329. title: "ajax error",
  330. content: a,
  331. }),
  332. void 0)
  333. },
  334. file_get: function (e, t) {
  335. var a = "setting/index.html?editor/fileGet&filename=" + urlEncode2(e)
  336. G.share_page !== void 0 && (a = "setting/index.html?share/fileGet&user=" + G.user + "&sid=" + G.sid + "&filename=" + urlEncode2(e)),
  337. ajax({
  338. url: a,
  339. dataType: "json",
  340. beforeSend: function () {
  341. core.tips.loading(LNG.loading)
  342. },
  343. error: core.ajaxError,
  344. success: function (e) {
  345. core.tips.close(LNG.success), "function" == typeof t && t(e.data.content)
  346. },
  347. })
  348. },
  349. setting: function (e) {
  350. void 0 == e && (e = G.is_root ? "system" : "user"),
  351. void 0 == window.top.frames.Opensetting_mode
  352. ? $.dialog.open("setting/index.html?setting#" + e, {
  353. id: "setting_mode",
  354. fixed: !0,
  355. ico: core.ico("setting"),
  356. resize: !0,
  357. title: LNG.setting,
  358. width: 960,
  359. height: 580,
  360. })
  361. : ($.dialog.list.setting_mode.display(!0), FrameCall.top("Opensetting_mode", "Setting.setGoto", '"' + e + '"'))
  362. },
  363. openIE: function (e) {
  364. $.dialog.open(e, {
  365. fixed: !0,
  366. resize: !0,
  367. title: LNG.app_store,
  368. width: "80%",
  369. height: "70%",
  370. })
  371. },
  372. openApp: function (app) {
  373. if ("url" == app.type) {
  374. var icon = app.icon
  375. ;-1 == app.icon.search(G.static_path) && "http" != app.icon.substring(0, 4) && (icon = "/" + "images/app/" + app.icon),
  376. "number" != typeof app.width && -1 == app.width.search("%") && (app.width = parseInt(app.width)),
  377. "number" != typeof app.height && -1 == app.height.search("%") && (app.height = parseInt(app.height)),
  378. $.dialog.open(app.content, {
  379. title: app.name,
  380. fixed: !0,
  381. ico: icon,
  382. resize: app.resize,
  383. simple: app.simple,
  384. title: app.name.replace(".oexe", ""),
  385. width: app.width,
  386. height: app.height,
  387. })
  388. } else {
  389. var exec = app.content
  390. eval("{" + exec + "}")
  391. }
  392. },
  393. setSkin_finished: function () {
  394. var e = $(".setSkin_finished").attr("src")
  395. e && ($("#link_css_list").attr("href", e), $(".setSkin_finished").remove())
  396. },
  397. setSkin: function (e, t) {
  398. var a = "/" + "css/skin/" + e + t
  399. $("body").append('<img src="' + a + '" onload="core.setSkin_finished();" onerror="core.setSkin_finished();" class="setSkin_finished">')
  400. },
  401. editorFull: function () {
  402. var e = $("iframe[name=OpenopenEditor]")
  403. e.toggleClass("frame_fullscreen")
  404. },
  405. language: function (e) {
  406. Cookie.set("sys_user_language", e, 8760), window.location.reload()
  407. },
  408. tips: {
  409. topHeight: function () {
  410. return "undefined" != typeof Global && Global.topbar_height ? Global.topbar_height : 0
  411. },
  412. loading: function (e) {
  413. Tips.loading(e, "info", core.tips.topHeight())
  414. },
  415. close: function (e, t) {
  416. "object" == typeof e ? Tips.close(e.data, e.code, core.tips.topHeight()) : Tips.close(e, t, core.tips.topHeight())
  417. },
  418. tips: function (e, t) {
  419. "object" == typeof e ? Tips.tips(e.data, e.code, core.tips.topHeight()) : Tips.tips(e, t, core.tips.topHeight())
  420. },
  421. },
  422. fullScreen: function () {
  423. "true" == $("body").attr("fullScreen") && core.exitfullScreen(), $("body").attr("fullScreen", "true")
  424. var e = document.documentElement
  425. e.requestFullscreen ? e.requestFullscreen() : e.mozRequestFullScreen ? e.mozRequestFullScreen() : e.webkitRequestFullScreen && e.webkitRequestFullScreen()
  426. },
  427. exitfullScreen: function () {
  428. $("body").attr("fullScreen", "false"), document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitCancelFullScreen && document.webkitCancelFullScreen()
  429. },
  430. }
  431. }),
  432. define("setting/setting", [], function () {
  433. var e,
  434. t = function (e) {
  435. core.setSkin(e, "setting.css"), FrameCall.father("ui.setTheme", '"' + e + '"')
  436. },
  437. a = function (e) {
  438. core.setSkin(e, "setting.css")
  439. },
  440. setGoto = function (t) {
  441. ;("" == t || void 0 == t) && (t = "basic")
  442. core.tips.loading("正在载入,请稍候...")
  443. ;(e = t), "menu&" == t.substring(0, 4) && (t = "menu"), $(".selected").removeClass("selected"), $("ul.setting li#" + t).addClass("selected"), (window.location.href = "#" + t)
  444. // if(window.timer){ clearInterval(window.timer); }
  445. if (t == "custom" || t == "area" || t == "code" || t == "proxy" || t == "resident" || t == "menu" || t == "user") {
  446. var m = {
  447. custom: { url: "setting_custom.html", title: "客户管理" },
  448. area: { url: "setting_area.html", title: "区域管理" },
  449. code: { url: "setting_code.html", title: "代码管理" },
  450. menu: { url: "setting_menu.html", title: "菜单管理" },
  451. user: { url: "setting_user.html", title: "用户管理" },
  452. resident: { url: "setting_resident.html", title: "居民信息管理" },
  453. proxy: { url: "setting_proxy.html", title: "服务机构管理" },
  454. }
  455. var title = "" //'<div class="h1"><i class="fa fa-group"></i>' + m[t].title + '</div>';
  456. var iframe = $('<iframe src="' + m[t].url + '" style="height:100%;width:100%;border:0px;"></iframe>')
  457. // var autoHeight = function(){
  458. // var win = iframe[0].contentWindow,doc = win.document,html = doc.documentElement,body = doc.body,
  459. // h = Math.max(body.scrollHeight, body.offsetHeight,html.clientHeight, html.scrollHeight, html.offsetHeight);
  460. // iframe.css({height:h});
  461. // };
  462. iframe.load(function () {
  463. window.loadtimer = setInterval(function () {
  464. core.tips.close("载入成功")
  465. clearInterval(window.loadtimer)
  466. window.loadtimer = undefined
  467. }, 2000)
  468. })
  469. // window.timer = setInterval(autoHeight, 800);
  470. $(".main").css({ margin: "0px", position: "fixed", height: "100%" }).empty().append(title).append(iframe)
  471. return
  472. } else {
  473. $(".main").css({ margin: "30px 0 0 20px", position: "none", height: "auto" })
  474. }
  475. ajax({
  476. url: "setting_" + t + ".html?slider=" + t,
  477. beforeSend: function () {
  478. $(".main").html("<img src='" + "/" + "images/loading.gif'/>")
  479. },
  480. success: function (a) {
  481. core.tips.close("载入成功")
  482. $(".main").css("display", "none")
  483. if (t == "basic") {
  484. var firstMsg = "您是首次登录"
  485. var data = eval("(" + JSON.stringify(AUTH.user) + ")")
  486. data.currLoginTime = new Date(data.currLoginTime).format("yyyy年MM月dd日 HH:mm:ss")
  487. if (data.lastLoginTime) {
  488. data.lastLoginTime = new Date(data.lastLoginTime).format("yyyy年MM月dd日 HH:mm:ss")
  489. } else {
  490. data.lastLoginTime = firstMsg
  491. }
  492. if (data.lastLoginIp == null || data.lastLoginIp == "" || data.lastLoginIp == undefined) {
  493. data.lastLoginIp = firstMsg
  494. }
  495. data.lastLoginIp = data.lastLoginIp ? data.lastLoginIp.split(",")[0] : ""
  496. data.currLoginIp = data.currLoginIp ? data.currLoginIp.split(",")[0] : ""
  497. $(".main").html(template.compile(a)({ G: G, LNG: LNG, data: data }))
  498. $.get("/queryIp?type=1&ip=" + data.currLoginIp, function (s) {
  499. var msg = "载入中..."
  500. if (s.code == 0) {
  501. msg = s.address
  502. } else {
  503. msg = "获取失败"
  504. }
  505. $("#currLoginAddr").text(msg)
  506. })
  507. if (firstMsg == data.lastLoginIp) {
  508. $("#lastLoginAddr").text(firstMsg)
  509. } else {
  510. //https://www.ip.cn/api/index?type=1&ip= Nignx代理到此地址,否则会出现跨域错误
  511. $.get("/queryIp?type=1&ip=" + data.lastLoginIp, function (s) {
  512. var msg = "载入中..."
  513. if (s && s.code == 0) {
  514. msg = s.address
  515. } else {
  516. msg = "获取失败"
  517. }
  518. $("#lastLoginAddr").text(msg)
  519. })
  520. }
  521. } else {
  522. $(".main").html(template.compile(a)({ G: G, LNG: LNG, AUTH: AUTH, data: {} }))
  523. }
  524. $(".main").fadeIn("fast")
  525. // "menu" == t && Menu.init(e),
  526. "role" == t && Role.init(), "site" == t && Site.init(), "system" == t && System.init(), (e = t)
  527. },
  528. })
  529. },
  530. n = function () {
  531. G.is_root ? $("ul.setting #system").show() : $("ul.setting #system").hide(),
  532. G.is_root || 1 == AUTH["user:get"] ? $("ul.setting #user").show() : $("ul.setting #user").hide(),
  533. (e = location.hash.split("#", 2)[1]),
  534. setGoto(e),
  535. $("ul.setting li")
  536. .hover(
  537. function () {
  538. $(this).addClass("hover")
  539. },
  540. function () {
  541. $(this).toggleClass("hover")
  542. }
  543. )
  544. .click(function () {
  545. ;(e = $(this).attr("id")), setGoto(e)
  546. }),
  547. $(".box .list")
  548. .live(
  549. "hover",
  550. function () {
  551. $(this).addClass("listhover")
  552. },
  553. function () {
  554. $(this).toggleClass("listhover")
  555. }
  556. )
  557. .live("click", function () {
  558. var e = $(this),
  559. a = e.parent()
  560. switch (((type = a.attr("data-type")), (value = e.attr("data-value")), a.find(".this").removeClass("this"), e.addClass("this"), type)) {
  561. case "wall":
  562. var i = "/" + "images/wall_page/" + value + ".jpg"
  563. FrameCall.father("ui.setWall", '"' + i + '"')
  564. break
  565. case "theme":
  566. t(value)
  567. break
  568. case "musictheme":
  569. FrameCall.father("CMPlayer.changeTheme", '"music","' + value + '"')
  570. break
  571. case "movietheme":
  572. FrameCall.father("CMPlayer.changeTheme", '"movie","' + value + '"')
  573. break
  574. default:
  575. }
  576. var n = "index.html?setting/set&k=" + type + "&v=" + value
  577. ajax({
  578. url: n,
  579. type: "json",
  580. success: function (e) {
  581. e.code ? tips(e) : core.authCheck("setting:set") ? tips(LNG.config_save_error_file, !1) : tips(LNG.config_save_error_auth, !1)
  582. },
  583. })
  584. })
  585. },
  586. tools = function () {
  587. var e = $(".selected").attr("id")
  588. switch (e) {
  589. case "basic":
  590. var oldPass = $("#oldPass").val(),
  591. newPass = $("#newPass").val(),
  592. confirmPass = $("#confirmPass").val()
  593. if ("" == oldPass || "" == newPass || "" == confirmPass) {
  594. tips("信息填写不完整", "error")
  595. break
  596. }
  597. $(".userinfo-box .msg").html("")
  598. ajax({
  599. url: "/web/setting/basic/modifyMyPass.json",
  600. data: { oldPass: oldPass, newPass: newPass, confirmPass: confirmPass },
  601. type: "POST",
  602. dataType: "json",
  603. success: function (e) {
  604. if (e.status == 1) {
  605. $.dialog({
  606. id: "dialog_path_logout",
  607. fixed: !0,
  608. icon: "question",
  609. title: "退出登录",
  610. width: 300,
  611. padding: 40,
  612. lock: !0,
  613. background: "#000",
  614. opacity: 0.3,
  615. content: "密码已经修改成功,现在需要退出登录?",
  616. ok: function () {
  617. logout()
  618. },
  619. cancel: !0,
  620. })
  621. } else if (e.status == 9) {
  622. for (var k in e.data) {
  623. var msg = e.data[k]
  624. if (msg) {
  625. $(".userinfo-box ." + k).html("<font style='color:#f00;'>" + msg + "</font>")
  626. $(".userinfo-box #" + k).focus()
  627. }
  628. }
  629. } else {
  630. tips(e.msg, "error")
  631. }
  632. },
  633. })
  634. break
  635. case "wall":
  636. var i = $("#wall_url").val()
  637. if ("" == i) {
  638. tips(LNG.picture_can_not_null, "error")
  639. break
  640. }
  641. FrameCall.father("ui.setWall", '"' + i + '"'), $(".box").find(".this").removeClass("this")
  642. var n = "index.html?setting/set&k=wall&v=" + urlEncode(i)
  643. ajax({
  644. url: n,
  645. type: "json",
  646. success: function (e) {
  647. tips(e)
  648. },
  649. })
  650. default:
  651. }
  652. }
  653. return {
  654. init: n,
  655. setGoto: setGoto,
  656. tools: tools,
  657. setThemeSelf: a,
  658. setTheme: t,
  659. }
  660. }),
  661. define("site", [], function () {
  662. var siteData = {},
  663. reload = function () {
  664. ajax({
  665. url: "/web/site/getAll.json",
  666. dataType: "json",
  667. async: !1,
  668. success: function (e) {
  669. if (!e.status) return tips(e.msg), void 0
  670. var a = e.data.rows
  671. siteData = {}
  672. for (var i = 0; i < a.length; i++) {
  673. var n = a[i]
  674. siteData["" + n.id] = n
  675. }
  676. appendItem()
  677. },
  678. error: function () {
  679. return !1
  680. },
  681. }),
  682. $(".site_editor .path_ext_tips").tooltip({
  683. placement: "bottom",
  684. html: !0,
  685. }),
  686. $(".site_editor .warning").tooltip({
  687. placement: "bottom",
  688. html: !0,
  689. title: function () {
  690. return $(".site_tips").html()
  691. },
  692. })
  693. },
  694. appendItem = function () {
  695. var e = "<tr class='title'><td width='20%'>domain</td>" + "<td width='35%'>" + LNG.setting_site_name + "</td><td>创建时间</td>" + "<td width='20%'>" + LNG.action + "</td>" + "</tr>"
  696. for (var a in siteData) {
  697. var i = "<a href='javascript:void(0)' class='button edit'>" + LNG.button_edit + "</a>" + "<a href='javascript:void(0)' class='button del'> " + LNG.button_del + "</a>"
  698. 1 == siteData[a].id && (i = "默认站点不可编辑"),
  699. (e += "<tr data-id='" + siteData[a].id + "'>" + " <td>" + siteData[a].domain + "</td>" + " <td>" + siteData[a].name + "</td><td>" + (isNaN(siteData[a].createTime) ? "未记录" : new Date(siteData[a].createTime).format("yyyy-MM-dd HH:mm:ss")) + "</td><td>" + i + "</td>")
  700. }
  701. $(".site table#list").html(e)
  702. },
  703. backToAdd = function () {
  704. activeSection($(".nav .site_status")),
  705. $(".site_editor #name").val("").focus(),
  706. $(".site_editor #homePage").val(""),
  707. $(".site_editor #domain").val(""),
  708. $(".site_editor #logo").val(""),
  709. $(".site_editor #favIcon").val(""),
  710. $(".site_editor #config").val(""),
  711. //$(".site_editor #ext_not_allow").val($(".site_editor #ext_not_allow").attr("default")),
  712. $(".site_editor .tag").removeClass("this"),
  713. $(".site_editor input").removeAttr("checked"),
  714. $(".site_editor .edit_save").addClass("hidden"),
  715. $(".site_editor .edit_exit").addClass("hidden"),
  716. $(".site_editor .add_save").removeClass("hidden"),
  717. $(".nav .site_status").html(LNG.setting_site_add)
  718. },
  719. toEdit = function (e) {
  720. var a
  721. ;(a = siteData[e]),
  722. $(".site_editor .tag").removeClass("this"),
  723. $(".site_editor input").removeAttr("checked"),
  724. $(".site_editor .edit_save").removeClass("hidden"),
  725. $(".site_editor .edit_exit").removeClass("hidden"),
  726. $(".site_editor .add_save").addClass("hidden"),
  727. $(".nav .site_status").html(LNG.setting_site_edit),
  728. activeSection($(".nav .site_status")),
  729. $(".site_editor #name").val(a.name).attr("data-id", a.id),
  730. $(".site_editor #homePage").val(a.homePage),
  731. $(".site_editor #domain").val(a.domain),
  732. $(".site_editor #logo").val(a.logo),
  733. $(".site_editor #favIcon").val(a.favIcon),
  734. $(".site_editor #config").val(a.config),
  735. setConfigValue(a.config),
  736. $(".site_editor .tag").each(function () {
  737. var e = $(this),
  738. t = e.attr("data-action")
  739. ;(t = t.split(";")), (t = t[0]), a[t] && (e.addClass("this"), e.find("input").attr("checked", !0))
  740. })
  741. },
  742. getConfigValue = function () {
  743. var old = $(".site_editor #config").val()
  744. if (old == null || old == "") {
  745. old = { platform: {} }
  746. } else {
  747. old = eval("(" + old + ")")
  748. if (!old.platform) {
  749. old.platform = {}
  750. }
  751. }
  752. $(".site_editor .platform-box li").each(function () {
  753. var item = $(this)
  754. old.platform[$(".platform", item).val()] = $(".pname", item).val()
  755. })
  756. return JSON.stringify(old)
  757. },
  758. setConfigValue = function (config) {
  759. if (config == null || "" == config) {
  760. return
  761. } else {
  762. config = eval("(" + config + ")")
  763. if (!config.platform) {
  764. return
  765. }
  766. }
  767. for (var o in config.platform) {
  768. appendPlatformItem({ name: config.platform[o], platform: o })
  769. }
  770. },
  771. saveOne = function () {
  772. var name = $(".site_editor #name").val(),
  773. homePage = $(".site_editor #homePage").val(),
  774. domain = $(".site_editor #domain").val(),
  775. logo = $(".site_editor #logo").val(),
  776. favIcon = $(".site_editor #favIcon").val(),
  777. config = getConfigValue(),
  778. data = {},
  779. // param = "",
  780. add_or_edit = "add"
  781. if ("" == name || "" == domain) return tips(LNG.not_null, "error") /*,
  782. !1;
  783. if ($(".site_editor .tag.this").each(function() {
  784. for (var options = $(this).attr("data-rule").split(";"), index = 0; options.length > index; index++){
  785. data[options[index]] = 1;
  786. }
  787. }), */
  788. if ($(".site_editor .add_save").hasClass("hidden")) {
  789. add_or_edit = "edit"
  790. var id = $(".site_editor #name").attr("data-id")
  791. data.id = id
  792. }
  793. ;(data.name = name), (data.domain = domain), (data.homePage = homePage), (data.logo = logo), (data.favIcon = favIcon), (data.config = config)
  794. ajax({
  795. url: add_or_edit == "add" ? "/web/site/add.json?" : "/web/site/modify.json?",
  796. data: data,
  797. type: "POST",
  798. dataType: "json",
  799. success: function (e) {
  800. tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && (reload(), "add" == add_or_edit && backToAdd(), activeSection($(".nav a:eq(0)")))
  801. },
  802. })
  803. },
  804. remove = function () {
  805. var t = $(this).parent().parent(),
  806. id = $(t).attr("data-id"),
  807. name = siteData[id].name
  808. $.dialog({
  809. fixed: !0,
  810. icon: "question",
  811. drag: !0,
  812. title: LNG.warning,
  813. content: LNG.if_remove + name + "?",
  814. ok: function () {
  815. ajax({
  816. url: "/web/site/remove.json" + "?id=" + id,
  817. async: !1,
  818. dataType: "json",
  819. success: function (e) {
  820. tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && ($(t).detach(), reload())
  821. },
  822. })
  823. },
  824. cancel: !0,
  825. })
  826. },
  827. activeSection = function (e) {
  828. $(".nav .this").removeClass("this"), e.addClass("this")
  829. var t = e.attr("data-page")
  830. $(".section").addClass("hidden"), $("." + t).removeClass("hidden"), $(".site_editor .platform-box").empty()
  831. },
  832. appendPlatformItem = function (val) {
  833. if (!val) {
  834. val = { name: "", platform: "" }
  835. }
  836. var item = $($(".site_editor .platform-item-tmpl").html())
  837. $(".domain", item).text("." + $(".site_editor #domain").val())
  838. $(".del-item-btn", item).click(function () {
  839. $(this)
  840. .parent()
  841. .fadeOut(function () {
  842. $(this).remove()
  843. })
  844. })
  845. $(".pname", item).val(val.name)
  846. $(".platform", item).val(val.platform)
  847. $(".site_editor .platform-box").append(item)
  848. },
  849. bindEvent = function () {
  850. $(".site a.add").live("click", backToAdd),
  851. $(".site a.del").live("click", remove),
  852. $(".site a.edit").live("click", function () {
  853. var e = $(this).parent().parent()
  854. toEdit(e.attr("data-id"))
  855. }),
  856. $(".site_editor a.add_save").live("click", saveOne),
  857. $(".site_editor a.edit_save").live("click", saveOne),
  858. $(".site_editor a.edit_exit").live("click", backToAdd),
  859. $(".site_editor a.add-platform").live("click", function () {
  860. appendPlatformItem()
  861. }),
  862. $(".site_editor #domain").live("keyup", function () {
  863. $(".site_editor .domain").text("." + $(this).val())
  864. })
  865. // $(".nav a").live("click",
  866. // function() {
  867. // activeSection($(this));
  868. // })
  869. },
  870. getData = function () {
  871. return siteData
  872. }
  873. return {
  874. getData: getData,
  875. edit: toEdit,
  876. init: reload,
  877. bindEvent: bindEvent,
  878. }
  879. }),
  880. define("role", [], function () {
  881. var roleData = {},
  882. reload = function () {
  883. ajax({
  884. url: "/web/role/getAll.json",
  885. dataType: "json",
  886. async: !1,
  887. success: function (e) {
  888. if (!e.status) return tips(e.msg), void 0
  889. var a = e.data.rows
  890. roleData = {}
  891. for (var i = 0; i < a.length; i++) {
  892. var n = a[i]
  893. roleData["" + n.id] = n
  894. }
  895. appendItem()
  896. // User.init();
  897. },
  898. error: function () {
  899. return !1
  900. },
  901. }),
  902. $(".role_editor .path_ext_tips").tooltip({
  903. placement: "bottom",
  904. html: !0,
  905. }),
  906. $(".role_editor .warning").tooltip({
  907. placement: "bottom",
  908. html: !0,
  909. title: function () {
  910. return $(".role_tips").html()
  911. },
  912. })
  913. },
  914. appendItem = function () {
  915. var e = "<tr class='title'><td width='20%'>" + LNG.name + "</td>" + "<td width='35%'>" + LNG.role_desc + "</td><td>创建时间</td>" + "<td width='20%'>" + LNG.action + "</td>" + "</tr>"
  916. for (var a in roleData) {
  917. var i = "<a href='javascript:void(0)' class='button edit'>" + LNG.button_edit + "</a>" + "<a href='javascript:void(0)' class='button del'> " + LNG.button_del + "</a>"
  918. 1 == roleData[a].root && (i = LNG.default_role_can_not_do),
  919. (e += "<tr data-name='" + roleData[a].name + "' data-id='" + roleData[a].id + "'>" + " <td>" + roleData[a].name + "</td>" + " <td>" + roleData[a].discription + "</td><td>" + new Date(roleData[a].createTime).format("yyyy-MM-dd HH:mm:ss") + "</td><td>" + i + "</td>")
  920. }
  921. $(".role table#list").html(e)
  922. },
  923. backToAdd = function () {
  924. activeSection($(".nav .role_status")),
  925. $(".role_editor #name").val("").focus(),
  926. $(".role_editor #discription").val(""),
  927. //$(".role_editor #ext_not_allow").val($(".role_editor #ext_not_allow").attr("default")),
  928. $(".role_editor .tag").removeClass("this"),
  929. $(".role_editor input").removeAttr("checked"),
  930. $(".role_editor .edit_save").addClass("hidden"),
  931. $(".role_editor .edit_exit").addClass("hidden"),
  932. $(".role_editor .add_save").removeClass("hidden"),
  933. $(".nav .role_status").html(LNG.setting_role_add).removeClass("editable")
  934. },
  935. toEdit = function (e) {
  936. var a = roleData[e]
  937. var r = $(".nav .role_status")
  938. $(".role_editor .tag").removeClass("this"), $(".role_editor input").removeAttr("checked"), $(".role_editor .edit_save").removeClass("hidden"), $(".role_editor .edit_exit").removeClass("hidden"), $(".role_editor .add_save").addClass("hidden"), r.removeClass("editable")
  939. activeSection($(".nav .role_status"), a), r.html(LNG.setting_role_edit).addClass("editable"), $(".role_editor #name").val(a.name).attr("data-id", a.id), $(".role_editor #discription").val(a.discription)
  940. },
  941. saveOne = function () {
  942. var name = $(".role_editor #name").val(),
  943. discription = $(".role_editor #discription").val(),
  944. data = {},
  945. param = "",
  946. add_or_edit = "add"
  947. if ("" == name || "" == discription) return tips(LNG.not_null, "error"), !1
  948. // if (escape(name).indexOf("%u") >= 0) return tips("名称不能为中文!", "warning"),
  949. // !1;
  950. data.options = {}
  951. $("#role-app-box .app_item").each(function () {
  952. if (!$("input[type=checkbox]", $(this)).attr("checked")) {
  953. return
  954. }
  955. var d = eval("(" + $(this).attr("data") + ")")
  956. if (d.options == {}) {
  957. d.options = undefined
  958. }
  959. data.options["" + d.id] = d.options
  960. })
  961. data.options = JSON.stringify(data.options)
  962. if ($(".role_editor .add_save").hasClass("hidden")) {
  963. add_or_edit = "edit"
  964. var id = $(".role_editor #name").attr("data-id")
  965. data.id = id
  966. }
  967. ;(data.name = name), (data.discription = discription)
  968. ajax({
  969. url: add_or_edit == "add" ? "/web/role/add.json" : "/web/role/modify.json",
  970. data: data,
  971. type: "POST",
  972. dataType: "json",
  973. success: function (e) {
  974. tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && (reload(), "add" == add_or_edit && backToAdd())
  975. },
  976. })
  977. },
  978. remove = function () {
  979. var t = $(this).parent().parent(),
  980. id = $(t).attr("data-id"),
  981. name = $(t).attr("data-name")
  982. $.dialog({
  983. fixed: !0,
  984. icon: "question",
  985. drag: !0,
  986. title: LNG.warning,
  987. content: LNG.if_remove + name + "?<br/>" + LNG.role_remove_tips,
  988. ok: function () {
  989. ajax({
  990. url: "/web/role/remove.json" + "?id=" + id,
  991. async: !1,
  992. dataType: "json",
  993. success: function (e) {
  994. tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && ($(t).detach(), reload(), activeSection($(".nav a:eq(1)")))
  995. },
  996. })
  997. },
  998. cancel: !0,
  999. })
  1000. },
  1001. loadRules = function (role) {
  1002. var mr = {}
  1003. for (var k in RULES) {
  1004. var arr = k.split(",")
  1005. for (var c = 0; c < arr.length; c++) {
  1006. mr[arr[c]] = k
  1007. }
  1008. }
  1009. var loadMenus = function (content) {
  1010. var d = eval("(" + $(".app_item.selected").attr("data") + ")").options
  1011. ajax({
  1012. url: "/web/menu/getList.json?ids=" + eval("(" + content + ")").join(","),
  1013. success: function (e) {
  1014. var c = ""
  1015. for (var i = 0; i < e.data.rows.length; i++) {
  1016. var mid = "" + e.data.rows[i].id
  1017. c += '<div class="title menu" style="width:auto;"><input id="menu_' + mid + '" type="checkbox" ' + (d[mid] != undefined ? "checked" : "") + "/><i>" + e.data.rows[i].name + "</i></div>"
  1018. c += '<div style="clear:both;"></div>'
  1019. c += "<div>"
  1020. var actions = e.data.rows[i].actions.split(",")
  1021. var mrule = {}
  1022. for (var j = 0; j < actions.length; j++) {
  1023. if (actions[j] == "") {
  1024. continue
  1025. }
  1026. chk = !(d[mid] == undefined || d[mid][actions[j]] == undefined || d[mid][actions[j]] == 0)
  1027. mrule[mr[actions[j]]] = chk
  1028. }
  1029. for (var k in mrule) {
  1030. var chk = false
  1031. c += '<a class="tag menu_' + mid + (mrule[k] ? " this" : "") + '" mid="' + mid + '" href="javascript:;" data-action="' + k + '">'
  1032. c += '<input type="checkbox" class="checkbox" ' + (mrule[k] ? "checked" : "") + "><span>" + RULES[k] + "</span>"
  1033. c += "</a>"
  1034. }
  1035. c += "</div>"
  1036. c += '<div style="clear:both;"></div>'
  1037. }
  1038. $("#menu-options-box").empty().append(c)
  1039. },
  1040. })
  1041. },
  1042. appendApps = function (app) {
  1043. app.options = {}
  1044. var ro = {}
  1045. if (!(role == undefined || role.options == "" || role.options == null)) {
  1046. ro = eval("(" + role.options + ")")
  1047. for (var i in ro) {
  1048. if (i == app.id) {
  1049. for (var j in ro[i]) {
  1050. app.options[j] = ro[i][j]
  1051. }
  1052. break
  1053. }
  1054. }
  1055. }
  1056. app.icon = "waterset.png"
  1057. var i = $('<li class="app_item" data=' + JSON.stringify(app) + '><span><input type="checkbox" ' + (ro[app.id] == undefined ? "" : "checked") + "/></span>" + '<span><img src="/images/app/' + app.icon + '"/></span>' + "<span>" + app.title + "</span>" + "</li>").click(function (e) {
  1058. var chk = $("input[type=checkbox]", $(this))
  1059. if ($(this).hasClass("selected")) {
  1060. return
  1061. }
  1062. $("#menu-options-box").empty()
  1063. var data = eval("(" + $(this).attr("data") + ")")
  1064. $("li", $(this).parent()).removeClass("selected")
  1065. $(this).addClass("selected")
  1066. loadMenus(data.content)
  1067. })
  1068. $("#role-app-box").append(i)
  1069. },
  1070. init = function () {
  1071. $("#role-app-box").empty()
  1072. $("#menu-options-box").empty()
  1073. ajax({
  1074. url: "/web/app/getList.json?type=3",
  1075. success: function (d) {
  1076. var data = d.data.rows
  1077. for (var i = 0; i < data.length; i++) {
  1078. appendApps(data[i])
  1079. }
  1080. },
  1081. })
  1082. }
  1083. init()
  1084. },
  1085. activeSection = function (e, role) {
  1086. //if(e.hasClass("this")){return;}
  1087. $(".nav .this").removeClass("this"), e.addClass("this")
  1088. var t = e.attr("data-page")
  1089. $(".section").addClass("hidden"), $("." + t).removeClass("hidden")
  1090. if (t == "role_editor" && !e.hasClass("editable")) {
  1091. loadRules(role)
  1092. }
  1093. },
  1094. bindEvent = function () {
  1095. var onTagClick = function (d, e) {
  1096. if (d.options[e.attr("mid")] == undefined) {
  1097. d.options[e.attr("mid")] = {}
  1098. }
  1099. if (d.options[e.attr("mid")][e.attr("data-action")] == undefined) {
  1100. d.options[e.attr("mid")][e.attr("data-action")] = {}
  1101. }
  1102. var as = e.attr("data-action").split(",")
  1103. d.options[e.attr("mid")][e.attr("data-action")] = undefined
  1104. for (var i = 0; i < as.length; i++) {
  1105. d.options[e.attr("mid")][as[i]] = e.hasClass("this") ? 1 : undefined
  1106. }
  1107. if ($("input[checked]", e.parent()).length > 0) {
  1108. $("#menu_" + e.attr("mid")).attr("checked", !0)
  1109. } else {
  1110. $("#menu_" + e.attr("mid")).removeAttr("checked")
  1111. d.options[e.attr("mid")] = undefined
  1112. }
  1113. //console.log(JSON.stringify(d));
  1114. return d
  1115. }
  1116. $(".role a.add").live("click", backToAdd),
  1117. $(".role a.del").live("click", remove),
  1118. $(".role a.edit").live("click", function () {
  1119. var e = $(this).parent().parent()
  1120. toEdit(e.attr("data-id"))
  1121. }),
  1122. $(".role_editor a.add_save").live("click", saveOne),
  1123. $(".role_editor a.edit_save").live("click", saveOne),
  1124. $(".role_editor a.edit_exit").live("click", backToAdd),
  1125. $(".role_editor a.revert").live("click", function () {
  1126. var selectData = {}
  1127. var d = eval("(" + $(".app_item.selected").attr("data") + ")")
  1128. $(".role_editor .tag").each(function () {
  1129. var e = $(this)
  1130. $(this).hasClass("this") ? ($(this).removeClass("this"), $(this).find("input").removeAttr("checked")) : ($(this).addClass("this"), $(this).find("input").attr("checked", !0))
  1131. d = onTagClick(d, e)
  1132. }),
  1133. $(".role_editor .combox:eq(0) .tag:eq(0)").hasClass("this") || ($(".role_editor .combox:eq(0) .tag").removeClass("this"), $(".role_editor .combox:eq(0) .tag").find("input").removeAttr("checked")),
  1134. $(".role_editor .combox:eq(1) .tag:eq(0)").hasClass("this") || ($(".role_editor .combox:eq(1) .tag").removeClass("this"), $(".role_editor .combox:eq(1) .tag").find("input").removeAttr("checked"))
  1135. $(".app_item.selected").attr("data", JSON.stringify(d))
  1136. }),
  1137. $(".nav a").live("click", function () {
  1138. activeSection($(this))
  1139. }),
  1140. $(".role_editor .tag").live("click", function () {
  1141. var e = $(this)
  1142. if (((select = !1), e.toggleClass("this"), e.hasClass("this") ? ((select = !0), e.find("input").attr("checked", !0)) : ((select = !1), e.find("input").removeAttr("checked")), e.parent().hasClass("combox"))) {
  1143. var t = e.index()
  1144. 1 == t && 0 == select && (e.parent().find(".tag").removeClass("this"), e.parent().find("input").removeAttr("checked")), 1 != t && 1 == select && (e.parent().find(".tag:eq(0)").addClass("this"), e.parent().find("input:eq(0)").attr("checked", !0))
  1145. }
  1146. var d = eval("(" + $(".app_item.selected").attr("data") + ")")
  1147. d = onTagClick(d, e)
  1148. $(".app_item.selected").attr("data", JSON.stringify(d))
  1149. })
  1150. },
  1151. getData = function () {
  1152. return roleData
  1153. }
  1154. return {
  1155. getData: getData,
  1156. edit: toEdit,
  1157. init: reload,
  1158. bindEvent: bindEvent,
  1159. }
  1160. }),
  1161. define("setting/system", [], function () {
  1162. var reload = function () {
  1163. bindEvent(),
  1164. ajax({
  1165. url: "/web/setting/system/getAll.json",
  1166. type: "GET",
  1167. dataType: "json",
  1168. success: function (e) {
  1169. if (e.status == 1) {
  1170. fillFrm(e.data)
  1171. }
  1172. },
  1173. })
  1174. },
  1175. fillFrm = function (e) {
  1176. for (var s in e) {
  1177. var val = e[s]
  1178. var o = $(".system_setting input[name='" + s + "'],.system_setting select[name='" + s + "'],.system_setting textarea[name='" + s + "']")
  1179. if ("checkbox" == o.attr("type")) {
  1180. o.attr("checked", val == "1")
  1181. } else {
  1182. o.val(val)
  1183. }
  1184. }
  1185. },
  1186. bindEvent = function () {
  1187. $("input[name='first_in']").live("click", function () {
  1188. $("input[name='first_in']").removeAttr("checked"), $(this).attr("checked", "checked")
  1189. }),
  1190. $(".system_save")
  1191. .unbind("click")
  1192. .click(function () {
  1193. var e = {}
  1194. $(".system_setting .box_line input,.system_setting .box_line select,.system_setting .box_line textarea").each(function () {
  1195. var t = $(this)
  1196. if (t.hasClass("disable")) {
  1197. return true
  1198. }
  1199. if ("checkbox" == t.attr("type")) {
  1200. var a = void 0 == t.attr("checked") ? "0" : "1"
  1201. e[t.attr("name")] = a
  1202. } else "radius" != t.attr("type") && (e[t.attr("name")] = t.val())
  1203. }),
  1204. (e.first_in = $("input[name='first_in'][checked]").val()),
  1205. save(e)
  1206. }),
  1207. $(".system_setting .box_line input,.system_setting .box_line select,.system_setting .box_line textarea").live("change", function () {
  1208. $(".system_setting").attr("changed", true)
  1209. }),
  1210. $(".add-auto-open")
  1211. .unbind("click")
  1212. .click(function () {
  1213. var item = $($(".auto-open-item-tmpl").html())
  1214. $(".del-item-btn", item).click(function () {
  1215. $(".system_setting").attr("changed", true)
  1216. $(this)
  1217. .parents("li")
  1218. .fadeOut("slow", function () {
  1219. $(this).remove()
  1220. })
  1221. })
  1222. //读取角色列表
  1223. //从应用中心读取应用列表
  1224. $(".auto-open-box").append(item)
  1225. })
  1226. },
  1227. save = function (e) {
  1228. if ($(".system_setting").attr("changed") ? false : true) {
  1229. tips(LNG.not_changed, "warning")
  1230. return
  1231. }
  1232. ajax({
  1233. url: "/web/setting/system/modify.json",
  1234. type: "POST",
  1235. data: { settings: JSON.stringify(e) },
  1236. dataType: "json",
  1237. success: function (e) {
  1238. if (e.status == 1) {
  1239. $(".system_setting").removeAttr("changed")
  1240. }
  1241. tips(e.msg, e.status == 1 ? "success" : "error")
  1242. },
  1243. })
  1244. }
  1245. return {
  1246. bindEvent: bindEvent,
  1247. init: reload,
  1248. }
  1249. })
  1250. var logout = function () {
  1251. ajax({
  1252. url: "/system/logout.json",
  1253. success: function (data) {
  1254. if (data.data.loginHost) {
  1255. window.location = data.data.loginHost
  1256. }
  1257. },
  1258. })
  1259. }