| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266 |
- define(
- "/js/setting.util",
- [
- "js/lib/handlebars",
- /*"js/handlebars.helper",*/ "js/lib/jquery-lib",
- "js/common.tools",
- "js/util",
- "js/jquery.pager",
- "js/lib/ztree/js/ztree",
- "js/lib/artDialog/jquery-artDialog",
- "setting/core",
- /*"tpl/copyright.html", "tpl/search.html", "tpl/search_list.html", "tpl/upload.html",*/ "setting/setting",
- /*"menu",*/ "site",
- "role",
- "setting/system",
- ],
- function (e) {
- ;(template = Handlebars),
- (core = e("setting/core")),
- (Setting = e("setting/setting")),
- // Menu = e("menu"),
- (Role = e("role")),
- // User = e("user"),
- (System = e("setting/system")),
- (Site = e("site")),
- Setting.init(),
- // Menu.bindEvent(),
- // User.bindEvent(),
- Role.bindEvent(),
- Site.bindEvent(),
- (RULES = {
- query: "查询",
- add: "新增",
- edit: "编辑",
- remove: "删除",
- upload: "上传",
- download: "下载",
- import: "导入",
- export: "导出",
- })
- }
- ),
- define("setting/core", [], function (require, exports) {
- var t = template.compile($("#setting-template").html())
- $("#setting-box").html(t({ G: G, LNG: LNG, AUTH: AUTH, data: {} }))
- if (!G.is_root) {
- $("#system,#code,#area,#user,#role,#custom,#proxy,#resident,#menu,#site", "#setting-box").remove()
- }
- return {
- filetype: {
- image: ["jpg", "jpeg", "png", "bmp", "gif", "ico"],
- music: ["mp3", "wma", "wav", "mid", "m4a", "aac", "midi"],
- movie: ["avi", "flv", "f4v", "wmv", "3gp", "mp4", "wmv", "asf", "m4v", "mov", "mpg"],
- doc: ["doc", "docx", "docm", "xls", "xlsx", "xlsb", "xlsm", "ppt", "pptx", "pptm"],
- text: ["oexe", "inc", "inf", "csv", "log", "asc", "tsv"],
- code: [
- "abap",
- "abc",
- "as",
- "ada",
- "adb",
- "htgroups",
- "htpasswd",
- "conf",
- "htaccess",
- "htgroups",
- "htpasswd",
- "asciidoc",
- "asm",
- "ahk",
- "bat",
- "cmd",
- "c9search_results",
- "cpp",
- "c",
- "cc",
- "cxx",
- "h",
- "hh",
- "hpp",
- "cirru",
- "cr",
- "clj",
- "cljs",
- "CBL",
- "COB",
- "coffee",
- "cf",
- "cson",
- "Cakefile",
- "cfm",
- "cs",
- "css",
- "curly",
- "d",
- "di",
- "dart",
- "diff",
- "patch",
- "Dockerfile",
- "dot",
- "dummy",
- "dummy",
- "e",
- "ejs",
- "ex",
- "exs",
- "elm",
- "erl",
- "hrl",
- "frt",
- "fs",
- "ldr",
- "ftl",
- "gcode",
- "feature",
- ".gitignore",
- "glsl",
- "frag",
- "vert",
- "go",
- "groovy",
- "haml",
- "hbs",
- "handlebars",
- "tpl",
- "mustache",
- "hs",
- "hx",
- "html",
- "htm",
- "xhtml",
- "erb",
- "rhtml",
- "ini",
- "cfg",
- "prefs",
- "io",
- "jack",
- "jade",
- "java",
- "js",
- "jsm",
- "json",
- "jq",
- "jsp",
- "jsx",
- "jl",
- "tex",
- "latex",
- "ltx",
- "bib",
- "lean",
- "hlean",
- "less",
- "liquid",
- "lisp",
- "ls",
- "logic",
- "lql",
- "lsl",
- "lua",
- "lp",
- "lucene",
- "Makefile",
- "GNUmakefile",
- "makefile",
- "OCamlMakefile",
- "make",
- "md",
- "markdown",
- "mask",
- "matlab",
- "mel",
- "mc",
- "mush",
- "mysql",
- "nix",
- "m",
- "mm",
- "ml",
- "mli",
- "pas",
- "p",
- "pl",
- "pm",
- "pgsql",
- "php",
- "phtml",
- "ps1",
- "praat",
- "praatscript",
- "psc",
- "proc",
- "plg",
- "prolog",
- "properties",
- "proto",
- "py",
- "r",
- "Rd",
- "Rhtml",
- "rb",
- "ru",
- "gemspec",
- "rake",
- "Guardfile",
- "Rakefile",
- "Gemfile",
- "rs",
- "sass",
- "scad",
- "scala",
- "scm",
- "rkt",
- "scss",
- "sh",
- "bash",
- ".bashrc",
- "sjs",
- "smarty",
- "tpl",
- "snippets",
- "soy",
- "space",
- "sql",
- "styl",
- "stylus",
- "svg",
- "tcl",
- "tex",
- "txt",
- "textile",
- "toml",
- "twig",
- "ts",
- "typescript",
- "str",
- "vala",
- "vbs",
- "vb",
- "vm",
- "v",
- "vh",
- "sv",
- "svh",
- "vhd",
- "vhdl",
- "xml",
- "rdf",
- "rss",
- "wsdl",
- "xslt",
- "atom",
- "mathml",
- "mml",
- "xul",
- "xbl",
- "xaml",
- "xq",
- "yaml",
- "yml",
- "htm",
- "xib",
- "storyboard",
- "plist",
- "csproj",
- ],
- 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"],
- },
- ico: function (e) {
- var t = "/" + "images/file_16/",
- a = ["folder", "file", "edit", "search", "up", "setting", "appStore", "error", "info", "mp3", "flv", "pdf", "doc", "xls", "ppt", "html", "swf"],
- i = $.inArray(e, a)
- return -1 == i ? t + "file.png" : t + e + ".png"
- },
- contextmenu: function (e) {
- try {
- rightMenu.hidden()
- } catch (t) {}
- var t = e || window.event
- 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
- },
- pathThis: function (e) {
- e = e.replace(/\\/g, "/")
- var t = e.split("/"),
- a = t[t.length - 1]
- if (("" == a && (a = t[t.length - 2]), 0 == a.search("fileProxy"))) {
- a = urlDecode(a.substr(a.search("&path=")))
- var t = a.split("/")
- ;(a = t[t.length - 1]), "" == a && (a = t[t.length - 2])
- }
- return a
- },
- pathFather: function (e) {
- e = e.replace(/\\/g, "/")
- var t = e.lastIndexOf("/")
- return e.substr(0, t + 1)
- },
- pathExt: function (e) {
- ;(e = e.replace(/\\/g, "/")), (e = e.replace(/\/+/g, "/"))
- var t = e.lastIndexOf(".")
- return (e = e.substr(t + 1)), e.toLowerCase()
- },
- path2url: function (e) {
- if ("http" == e.substr(0, 4)) return e
- 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, "")
- var t = G.app_host + "/index.html?explorer/fileProxy&path=" + urlEncode(e)
- return G.share_page !== void 0 && (t = G.app_host + "/index.html?share/fileProxy&user=" + G.user + "&sid=" + G.sid + "&path=" + urlEncode(e)), t
- },
- authCheck: function (e, t) {
- 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
- },
- ajaxError: function (e) {
- core.tips.close(LNG.system_error, !1)
- var t = e.responseText,
- a = '<div class="ajaxError">' + t + "</div>",
- i = $.dialog.list.ajaxErrorDialog
- return "<!--user login-->" == t.substr(0, 17)
- ? (FrameCall.goRefresh(), void 0)
- : (i
- ? i.content(a)
- : $.dialog({
- id: "ajaxErrorDialog",
- padding: 0,
- fixed: !0,
- resize: !0,
- ico: core.ico("error"),
- title: "ajax error",
- content: a,
- }),
- void 0)
- },
- file_get: function (e, t) {
- var a = "setting/index.html?editor/fileGet&filename=" + urlEncode2(e)
- G.share_page !== void 0 && (a = "setting/index.html?share/fileGet&user=" + G.user + "&sid=" + G.sid + "&filename=" + urlEncode2(e)),
- ajax({
- url: a,
- dataType: "json",
- beforeSend: function () {
- core.tips.loading(LNG.loading)
- },
- error: core.ajaxError,
- success: function (e) {
- core.tips.close(LNG.success), "function" == typeof t && t(e.data.content)
- },
- })
- },
- setting: function (e) {
- void 0 == e && (e = G.is_root ? "system" : "user"),
- void 0 == window.top.frames.Opensetting_mode
- ? $.dialog.open("setting/index.html?setting#" + e, {
- id: "setting_mode",
- fixed: !0,
- ico: core.ico("setting"),
- resize: !0,
- title: LNG.setting,
- width: 960,
- height: 580,
- })
- : ($.dialog.list.setting_mode.display(!0), FrameCall.top("Opensetting_mode", "Setting.setGoto", '"' + e + '"'))
- },
- openIE: function (e) {
- $.dialog.open(e, {
- fixed: !0,
- resize: !0,
- title: LNG.app_store,
- width: "80%",
- height: "70%",
- })
- },
- openApp: function (app) {
- if ("url" == app.type) {
- var icon = app.icon
- ;-1 == app.icon.search(G.static_path) && "http" != app.icon.substring(0, 4) && (icon = "/" + "images/app/" + app.icon),
- "number" != typeof app.width && -1 == app.width.search("%") && (app.width = parseInt(app.width)),
- "number" != typeof app.height && -1 == app.height.search("%") && (app.height = parseInt(app.height)),
- $.dialog.open(app.content, {
- title: app.name,
- fixed: !0,
- ico: icon,
- resize: app.resize,
- simple: app.simple,
- title: app.name.replace(".oexe", ""),
- width: app.width,
- height: app.height,
- })
- } else {
- var exec = app.content
- eval("{" + exec + "}")
- }
- },
- setSkin_finished: function () {
- var e = $(".setSkin_finished").attr("src")
- e && ($("#link_css_list").attr("href", e), $(".setSkin_finished").remove())
- },
- setSkin: function (e, t) {
- var a = "/" + "css/skin/" + e + t
- $("body").append('<img src="' + a + '" onload="core.setSkin_finished();" onerror="core.setSkin_finished();" class="setSkin_finished">')
- },
- editorFull: function () {
- var e = $("iframe[name=OpenopenEditor]")
- e.toggleClass("frame_fullscreen")
- },
- language: function (e) {
- Cookie.set("sys_user_language", e, 8760), window.location.reload()
- },
- tips: {
- topHeight: function () {
- return "undefined" != typeof Global && Global.topbar_height ? Global.topbar_height : 0
- },
- loading: function (e) {
- Tips.loading(e, "info", core.tips.topHeight())
- },
- close: function (e, t) {
- "object" == typeof e ? Tips.close(e.data, e.code, core.tips.topHeight()) : Tips.close(e, t, core.tips.topHeight())
- },
- tips: function (e, t) {
- "object" == typeof e ? Tips.tips(e.data, e.code, core.tips.topHeight()) : Tips.tips(e, t, core.tips.topHeight())
- },
- },
- fullScreen: function () {
- "true" == $("body").attr("fullScreen") && core.exitfullScreen(), $("body").attr("fullScreen", "true")
- var e = document.documentElement
- e.requestFullscreen ? e.requestFullscreen() : e.mozRequestFullScreen ? e.mozRequestFullScreen() : e.webkitRequestFullScreen && e.webkitRequestFullScreen()
- },
- exitfullScreen: function () {
- $("body").attr("fullScreen", "false"), document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitCancelFullScreen && document.webkitCancelFullScreen()
- },
- }
- }),
- define("setting/setting", [], function () {
- var e,
- t = function (e) {
- core.setSkin(e, "setting.css"), FrameCall.father("ui.setTheme", '"' + e + '"')
- },
- a = function (e) {
- core.setSkin(e, "setting.css")
- },
- setGoto = function (t) {
- ;("" == t || void 0 == t) && (t = "basic")
- core.tips.loading("正在载入,请稍候...")
- ;(e = t), "menu&" == t.substring(0, 4) && (t = "menu"), $(".selected").removeClass("selected"), $("ul.setting li#" + t).addClass("selected"), (window.location.href = "#" + t)
- // if(window.timer){ clearInterval(window.timer); }
- if (t == "custom" || t == "area" || t == "code" || t == "proxy" || t == "resident" || t == "menu" || t == "user") {
- var m = {
- custom: { url: "setting_custom.html", title: "客户管理" },
- area: { url: "setting_area.html", title: "区域管理" },
- code: { url: "setting_code.html", title: "代码管理" },
- menu: { url: "setting_menu.html", title: "菜单管理" },
- user: { url: "setting_user.html", title: "用户管理" },
- resident: { url: "setting_resident.html", title: "居民信息管理" },
- proxy: { url: "setting_proxy.html", title: "服务机构管理" },
- }
- var title = "" //'<div class="h1"><i class="fa fa-group"></i>' + m[t].title + '</div>';
- var iframe = $('<iframe src="' + m[t].url + '" style="height:100%;width:100%;border:0px;"></iframe>')
- // var autoHeight = function(){
- // var win = iframe[0].contentWindow,doc = win.document,html = doc.documentElement,body = doc.body,
- // h = Math.max(body.scrollHeight, body.offsetHeight,html.clientHeight, html.scrollHeight, html.offsetHeight);
- // iframe.css({height:h});
- // };
- iframe.load(function () {
- window.loadtimer = setInterval(function () {
- core.tips.close("载入成功")
- clearInterval(window.loadtimer)
- window.loadtimer = undefined
- }, 2000)
- })
- // window.timer = setInterval(autoHeight, 800);
- $(".main").css({ margin: "0px", position: "fixed", height: "100%" }).empty().append(title).append(iframe)
- return
- } else {
- $(".main").css({ margin: "30px 0 0 20px", position: "none", height: "auto" })
- }
- ajax({
- url: "setting_" + t + ".html?slider=" + t,
- beforeSend: function () {
- $(".main").html("<img src='" + "/" + "images/loading.gif'/>")
- },
- success: function (a) {
- core.tips.close("载入成功")
- $(".main").css("display", "none")
- if (t == "basic") {
- var firstMsg = "您是首次登录"
- var data = eval("(" + JSON.stringify(AUTH.user) + ")")
- data.currLoginTime = new Date(data.currLoginTime).format("yyyy年MM月dd日 HH:mm:ss")
- if (data.lastLoginTime) {
- data.lastLoginTime = new Date(data.lastLoginTime).format("yyyy年MM月dd日 HH:mm:ss")
- } else {
- data.lastLoginTime = firstMsg
- }
- if (data.lastLoginIp == null || data.lastLoginIp == "" || data.lastLoginIp == undefined) {
- data.lastLoginIp = firstMsg
- }
- data.lastLoginIp = data.lastLoginIp ? data.lastLoginIp.split(",")[0] : ""
- data.currLoginIp = data.currLoginIp ? data.currLoginIp.split(",")[0] : ""
- $(".main").html(template.compile(a)({ G: G, LNG: LNG, data: data }))
- $.get("/queryIp?type=1&ip=" + data.currLoginIp, function (s) {
- var msg = "载入中..."
- if (s.code == 0) {
- msg = s.address
- } else {
- msg = "获取失败"
- }
- $("#currLoginAddr").text(msg)
- })
- if (firstMsg == data.lastLoginIp) {
- $("#lastLoginAddr").text(firstMsg)
- } else {
- //https://www.ip.cn/api/index?type=1&ip= Nignx代理到此地址,否则会出现跨域错误
- $.get("/queryIp?type=1&ip=" + data.lastLoginIp, function (s) {
- var msg = "载入中..."
- if (s && s.code == 0) {
- msg = s.address
- } else {
- msg = "获取失败"
- }
- $("#lastLoginAddr").text(msg)
- })
- }
- } else {
- $(".main").html(template.compile(a)({ G: G, LNG: LNG, AUTH: AUTH, data: {} }))
- }
- $(".main").fadeIn("fast")
- // "menu" == t && Menu.init(e),
- "role" == t && Role.init(), "site" == t && Site.init(), "system" == t && System.init(), (e = t)
- },
- })
- },
- n = function () {
- G.is_root ? $("ul.setting #system").show() : $("ul.setting #system").hide(),
- G.is_root || 1 == AUTH["user:get"] ? $("ul.setting #user").show() : $("ul.setting #user").hide(),
- (e = location.hash.split("#", 2)[1]),
- setGoto(e),
- $("ul.setting li")
- .hover(
- function () {
- $(this).addClass("hover")
- },
- function () {
- $(this).toggleClass("hover")
- }
- )
- .click(function () {
- ;(e = $(this).attr("id")), setGoto(e)
- }),
- $(".box .list")
- .live(
- "hover",
- function () {
- $(this).addClass("listhover")
- },
- function () {
- $(this).toggleClass("listhover")
- }
- )
- .live("click", function () {
- var e = $(this),
- a = e.parent()
- switch (((type = a.attr("data-type")), (value = e.attr("data-value")), a.find(".this").removeClass("this"), e.addClass("this"), type)) {
- case "wall":
- var i = "/" + "images/wall_page/" + value + ".jpg"
- FrameCall.father("ui.setWall", '"' + i + '"')
- break
- case "theme":
- t(value)
- break
- case "musictheme":
- FrameCall.father("CMPlayer.changeTheme", '"music","' + value + '"')
- break
- case "movietheme":
- FrameCall.father("CMPlayer.changeTheme", '"movie","' + value + '"')
- break
- default:
- }
- var n = "index.html?setting/set&k=" + type + "&v=" + value
- ajax({
- url: n,
- type: "json",
- success: function (e) {
- e.code ? tips(e) : core.authCheck("setting:set") ? tips(LNG.config_save_error_file, !1) : tips(LNG.config_save_error_auth, !1)
- },
- })
- })
- },
- tools = function () {
- var e = $(".selected").attr("id")
- switch (e) {
- case "basic":
- var oldPass = $("#oldPass").val(),
- newPass = $("#newPass").val(),
- confirmPass = $("#confirmPass").val()
- if ("" == oldPass || "" == newPass || "" == confirmPass) {
- tips("信息填写不完整", "error")
- break
- }
- $(".userinfo-box .msg").html("")
- ajax({
- url: "/web/setting/basic/modifyMyPass.json",
- data: { oldPass: oldPass, newPass: newPass, confirmPass: confirmPass },
- type: "POST",
- dataType: "json",
- success: function (e) {
- if (e.status == 1) {
- $.dialog({
- id: "dialog_path_logout",
- fixed: !0,
- icon: "question",
- title: "退出登录",
- width: 300,
- padding: 40,
- lock: !0,
- background: "#000",
- opacity: 0.3,
- content: "密码已经修改成功,现在需要退出登录?",
- ok: function () {
- logout()
- },
- cancel: !0,
- })
- } else if (e.status == 9) {
- for (var k in e.data) {
- var msg = e.data[k]
- if (msg) {
- $(".userinfo-box ." + k).html("<font style='color:#f00;'>" + msg + "</font>")
- $(".userinfo-box #" + k).focus()
- }
- }
- } else {
- tips(e.msg, "error")
- }
- },
- })
- break
- case "wall":
- var i = $("#wall_url").val()
- if ("" == i) {
- tips(LNG.picture_can_not_null, "error")
- break
- }
- FrameCall.father("ui.setWall", '"' + i + '"'), $(".box").find(".this").removeClass("this")
- var n = "index.html?setting/set&k=wall&v=" + urlEncode(i)
- ajax({
- url: n,
- type: "json",
- success: function (e) {
- tips(e)
- },
- })
- default:
- }
- }
- return {
- init: n,
- setGoto: setGoto,
- tools: tools,
- setThemeSelf: a,
- setTheme: t,
- }
- }),
- define("site", [], function () {
- var siteData = {},
- reload = function () {
- ajax({
- url: "/web/site/getAll.json",
- dataType: "json",
- async: !1,
- success: function (e) {
- if (!e.status) return tips(e.msg), void 0
- var a = e.data.rows
- siteData = {}
- for (var i = 0; i < a.length; i++) {
- var n = a[i]
- siteData["" + n.id] = n
- }
- appendItem()
- },
- error: function () {
- return !1
- },
- }),
- $(".site_editor .path_ext_tips").tooltip({
- placement: "bottom",
- html: !0,
- }),
- $(".site_editor .warning").tooltip({
- placement: "bottom",
- html: !0,
- title: function () {
- return $(".site_tips").html()
- },
- })
- },
- appendItem = function () {
- 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>"
- for (var a in siteData) {
- 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>"
- 1 == siteData[a].id && (i = "默认站点不可编辑"),
- (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>")
- }
- $(".site table#list").html(e)
- },
- backToAdd = function () {
- activeSection($(".nav .site_status")),
- $(".site_editor #name").val("").focus(),
- $(".site_editor #homePage").val(""),
- $(".site_editor #domain").val(""),
- $(".site_editor #logo").val(""),
- $(".site_editor #favIcon").val(""),
- $(".site_editor #config").val(""),
- //$(".site_editor #ext_not_allow").val($(".site_editor #ext_not_allow").attr("default")),
- $(".site_editor .tag").removeClass("this"),
- $(".site_editor input").removeAttr("checked"),
- $(".site_editor .edit_save").addClass("hidden"),
- $(".site_editor .edit_exit").addClass("hidden"),
- $(".site_editor .add_save").removeClass("hidden"),
- $(".nav .site_status").html(LNG.setting_site_add)
- },
- toEdit = function (e) {
- var a
- ;(a = siteData[e]),
- $(".site_editor .tag").removeClass("this"),
- $(".site_editor input").removeAttr("checked"),
- $(".site_editor .edit_save").removeClass("hidden"),
- $(".site_editor .edit_exit").removeClass("hidden"),
- $(".site_editor .add_save").addClass("hidden"),
- $(".nav .site_status").html(LNG.setting_site_edit),
- activeSection($(".nav .site_status")),
- $(".site_editor #name").val(a.name).attr("data-id", a.id),
- $(".site_editor #homePage").val(a.homePage),
- $(".site_editor #domain").val(a.domain),
- $(".site_editor #logo").val(a.logo),
- $(".site_editor #favIcon").val(a.favIcon),
- $(".site_editor #config").val(a.config),
- setConfigValue(a.config),
- $(".site_editor .tag").each(function () {
- var e = $(this),
- t = e.attr("data-action")
- ;(t = t.split(";")), (t = t[0]), a[t] && (e.addClass("this"), e.find("input").attr("checked", !0))
- })
- },
- getConfigValue = function () {
- var old = $(".site_editor #config").val()
- if (old == null || old == "") {
- old = { platform: {} }
- } else {
- old = eval("(" + old + ")")
- if (!old.platform) {
- old.platform = {}
- }
- }
- $(".site_editor .platform-box li").each(function () {
- var item = $(this)
- old.platform[$(".platform", item).val()] = $(".pname", item).val()
- })
- return JSON.stringify(old)
- },
- setConfigValue = function (config) {
- if (config == null || "" == config) {
- return
- } else {
- config = eval("(" + config + ")")
- if (!config.platform) {
- return
- }
- }
- for (var o in config.platform) {
- appendPlatformItem({ name: config.platform[o], platform: o })
- }
- },
- saveOne = function () {
- var name = $(".site_editor #name").val(),
- homePage = $(".site_editor #homePage").val(),
- domain = $(".site_editor #domain").val(),
- logo = $(".site_editor #logo").val(),
- favIcon = $(".site_editor #favIcon").val(),
- config = getConfigValue(),
- data = {},
- // param = "",
- add_or_edit = "add"
- if ("" == name || "" == domain) return tips(LNG.not_null, "error") /*,
- !1;
- if ($(".site_editor .tag.this").each(function() {
- for (var options = $(this).attr("data-rule").split(";"), index = 0; options.length > index; index++){
- data[options[index]] = 1;
- }
- }), */
- if ($(".site_editor .add_save").hasClass("hidden")) {
- add_or_edit = "edit"
- var id = $(".site_editor #name").attr("data-id")
- data.id = id
- }
- ;(data.name = name), (data.domain = domain), (data.homePage = homePage), (data.logo = logo), (data.favIcon = favIcon), (data.config = config)
- ajax({
- url: add_or_edit == "add" ? "/web/site/add.json?" : "/web/site/modify.json?",
- data: data,
- type: "POST",
- dataType: "json",
- success: function (e) {
- tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && (reload(), "add" == add_or_edit && backToAdd(), activeSection($(".nav a:eq(0)")))
- },
- })
- },
- remove = function () {
- var t = $(this).parent().parent(),
- id = $(t).attr("data-id"),
- name = siteData[id].name
- $.dialog({
- fixed: !0,
- icon: "question",
- drag: !0,
- title: LNG.warning,
- content: LNG.if_remove + name + "?",
- ok: function () {
- ajax({
- url: "/web/site/remove.json" + "?id=" + id,
- async: !1,
- dataType: "json",
- success: function (e) {
- tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && ($(t).detach(), reload())
- },
- })
- },
- cancel: !0,
- })
- },
- activeSection = function (e) {
- $(".nav .this").removeClass("this"), e.addClass("this")
- var t = e.attr("data-page")
- $(".section").addClass("hidden"), $("." + t).removeClass("hidden"), $(".site_editor .platform-box").empty()
- },
- appendPlatformItem = function (val) {
- if (!val) {
- val = { name: "", platform: "" }
- }
- var item = $($(".site_editor .platform-item-tmpl").html())
- $(".domain", item).text("." + $(".site_editor #domain").val())
- $(".del-item-btn", item).click(function () {
- $(this)
- .parent()
- .fadeOut(function () {
- $(this).remove()
- })
- })
- $(".pname", item).val(val.name)
- $(".platform", item).val(val.platform)
- $(".site_editor .platform-box").append(item)
- },
- bindEvent = function () {
- $(".site a.add").live("click", backToAdd),
- $(".site a.del").live("click", remove),
- $(".site a.edit").live("click", function () {
- var e = $(this).parent().parent()
- toEdit(e.attr("data-id"))
- }),
- $(".site_editor a.add_save").live("click", saveOne),
- $(".site_editor a.edit_save").live("click", saveOne),
- $(".site_editor a.edit_exit").live("click", backToAdd),
- $(".site_editor a.add-platform").live("click", function () {
- appendPlatformItem()
- }),
- $(".site_editor #domain").live("keyup", function () {
- $(".site_editor .domain").text("." + $(this).val())
- })
- // $(".nav a").live("click",
- // function() {
- // activeSection($(this));
- // })
- },
- getData = function () {
- return siteData
- }
- return {
- getData: getData,
- edit: toEdit,
- init: reload,
- bindEvent: bindEvent,
- }
- }),
- define("role", [], function () {
- var roleData = {},
- reload = function () {
- ajax({
- url: "/web/role/getAll.json",
- dataType: "json",
- async: !1,
- success: function (e) {
- if (!e.status) return tips(e.msg), void 0
- var a = e.data.rows
- roleData = {}
- for (var i = 0; i < a.length; i++) {
- var n = a[i]
- roleData["" + n.id] = n
- }
- appendItem()
- // User.init();
- },
- error: function () {
- return !1
- },
- }),
- $(".role_editor .path_ext_tips").tooltip({
- placement: "bottom",
- html: !0,
- }),
- $(".role_editor .warning").tooltip({
- placement: "bottom",
- html: !0,
- title: function () {
- return $(".role_tips").html()
- },
- })
- },
- appendItem = function () {
- 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>"
- for (var a in roleData) {
- 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>"
- 1 == roleData[a].root && (i = LNG.default_role_can_not_do),
- (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>")
- }
- $(".role table#list").html(e)
- },
- backToAdd = function () {
- activeSection($(".nav .role_status")),
- $(".role_editor #name").val("").focus(),
- $(".role_editor #discription").val(""),
- //$(".role_editor #ext_not_allow").val($(".role_editor #ext_not_allow").attr("default")),
- $(".role_editor .tag").removeClass("this"),
- $(".role_editor input").removeAttr("checked"),
- $(".role_editor .edit_save").addClass("hidden"),
- $(".role_editor .edit_exit").addClass("hidden"),
- $(".role_editor .add_save").removeClass("hidden"),
- $(".nav .role_status").html(LNG.setting_role_add).removeClass("editable")
- },
- toEdit = function (e) {
- var a = roleData[e]
- var r = $(".nav .role_status")
- $(".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")
- 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)
- },
- saveOne = function () {
- var name = $(".role_editor #name").val(),
- discription = $(".role_editor #discription").val(),
- data = {},
- param = "",
- add_or_edit = "add"
- if ("" == name || "" == discription) return tips(LNG.not_null, "error"), !1
- // if (escape(name).indexOf("%u") >= 0) return tips("名称不能为中文!", "warning"),
- // !1;
- data.options = {}
- $("#role-app-box .app_item").each(function () {
- if (!$("input[type=checkbox]", $(this)).attr("checked")) {
- return
- }
- var d = eval("(" + $(this).attr("data") + ")")
- if (d.options == {}) {
- d.options = undefined
- }
- data.options["" + d.id] = d.options
- })
- data.options = JSON.stringify(data.options)
- if ($(".role_editor .add_save").hasClass("hidden")) {
- add_or_edit = "edit"
- var id = $(".role_editor #name").attr("data-id")
- data.id = id
- }
- ;(data.name = name), (data.discription = discription)
- ajax({
- url: add_or_edit == "add" ? "/web/role/add.json" : "/web/role/modify.json",
- data: data,
- type: "POST",
- dataType: "json",
- success: function (e) {
- tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && (reload(), "add" == add_or_edit && backToAdd())
- },
- })
- },
- remove = function () {
- var t = $(this).parent().parent(),
- id = $(t).attr("data-id"),
- name = $(t).attr("data-name")
- $.dialog({
- fixed: !0,
- icon: "question",
- drag: !0,
- title: LNG.warning,
- content: LNG.if_remove + name + "?<br/>" + LNG.role_remove_tips,
- ok: function () {
- ajax({
- url: "/web/role/remove.json" + "?id=" + id,
- async: !1,
- dataType: "json",
- success: function (e) {
- tips(e.msg, e.status != 1 ? "error" : "success"), e.status == 1 && ($(t).detach(), reload(), activeSection($(".nav a:eq(1)")))
- },
- })
- },
- cancel: !0,
- })
- },
- loadRules = function (role) {
- var mr = {}
- for (var k in RULES) {
- var arr = k.split(",")
- for (var c = 0; c < arr.length; c++) {
- mr[arr[c]] = k
- }
- }
- var loadMenus = function (content) {
- var d = eval("(" + $(".app_item.selected").attr("data") + ")").options
- ajax({
- url: "/web/menu/getList.json?ids=" + eval("(" + content + ")").join(","),
- success: function (e) {
- var c = ""
- for (var i = 0; i < e.data.rows.length; i++) {
- var mid = "" + e.data.rows[i].id
- 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>"
- c += '<div style="clear:both;"></div>'
- c += "<div>"
- var actions = e.data.rows[i].actions.split(",")
- var mrule = {}
- for (var j = 0; j < actions.length; j++) {
- if (actions[j] == "") {
- continue
- }
- chk = !(d[mid] == undefined || d[mid][actions[j]] == undefined || d[mid][actions[j]] == 0)
- mrule[mr[actions[j]]] = chk
- }
- for (var k in mrule) {
- var chk = false
- c += '<a class="tag menu_' + mid + (mrule[k] ? " this" : "") + '" mid="' + mid + '" href="javascript:;" data-action="' + k + '">'
- c += '<input type="checkbox" class="checkbox" ' + (mrule[k] ? "checked" : "") + "><span>" + RULES[k] + "</span>"
- c += "</a>"
- }
- c += "</div>"
- c += '<div style="clear:both;"></div>'
- }
- $("#menu-options-box").empty().append(c)
- },
- })
- },
- appendApps = function (app) {
- app.options = {}
- var ro = {}
- if (!(role == undefined || role.options == "" || role.options == null)) {
- ro = eval("(" + role.options + ")")
- for (var i in ro) {
- if (i == app.id) {
- for (var j in ro[i]) {
- app.options[j] = ro[i][j]
- }
- break
- }
- }
- }
- app.icon = "waterset.png"
- 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) {
- var chk = $("input[type=checkbox]", $(this))
- if ($(this).hasClass("selected")) {
- return
- }
- $("#menu-options-box").empty()
- var data = eval("(" + $(this).attr("data") + ")")
- $("li", $(this).parent()).removeClass("selected")
- $(this).addClass("selected")
- loadMenus(data.content)
- })
- $("#role-app-box").append(i)
- },
- init = function () {
- $("#role-app-box").empty()
- $("#menu-options-box").empty()
- ajax({
- url: "/web/app/getList.json?type=3",
- success: function (d) {
- var data = d.data.rows
- for (var i = 0; i < data.length; i++) {
- appendApps(data[i])
- }
- },
- })
- }
- init()
- },
- activeSection = function (e, role) {
- //if(e.hasClass("this")){return;}
- $(".nav .this").removeClass("this"), e.addClass("this")
- var t = e.attr("data-page")
- $(".section").addClass("hidden"), $("." + t).removeClass("hidden")
- if (t == "role_editor" && !e.hasClass("editable")) {
- loadRules(role)
- }
- },
- bindEvent = function () {
- var onTagClick = function (d, e) {
- if (d.options[e.attr("mid")] == undefined) {
- d.options[e.attr("mid")] = {}
- }
- if (d.options[e.attr("mid")][e.attr("data-action")] == undefined) {
- d.options[e.attr("mid")][e.attr("data-action")] = {}
- }
- var as = e.attr("data-action").split(",")
- d.options[e.attr("mid")][e.attr("data-action")] = undefined
- for (var i = 0; i < as.length; i++) {
- d.options[e.attr("mid")][as[i]] = e.hasClass("this") ? 1 : undefined
- }
- if ($("input[checked]", e.parent()).length > 0) {
- $("#menu_" + e.attr("mid")).attr("checked", !0)
- } else {
- $("#menu_" + e.attr("mid")).removeAttr("checked")
- d.options[e.attr("mid")] = undefined
- }
- //console.log(JSON.stringify(d));
- return d
- }
- $(".role a.add").live("click", backToAdd),
- $(".role a.del").live("click", remove),
- $(".role a.edit").live("click", function () {
- var e = $(this).parent().parent()
- toEdit(e.attr("data-id"))
- }),
- $(".role_editor a.add_save").live("click", saveOne),
- $(".role_editor a.edit_save").live("click", saveOne),
- $(".role_editor a.edit_exit").live("click", backToAdd),
- $(".role_editor a.revert").live("click", function () {
- var selectData = {}
- var d = eval("(" + $(".app_item.selected").attr("data") + ")")
- $(".role_editor .tag").each(function () {
- var e = $(this)
- $(this).hasClass("this") ? ($(this).removeClass("this"), $(this).find("input").removeAttr("checked")) : ($(this).addClass("this"), $(this).find("input").attr("checked", !0))
- d = onTagClick(d, e)
- }),
- $(".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")),
- $(".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"))
- $(".app_item.selected").attr("data", JSON.stringify(d))
- }),
- $(".nav a").live("click", function () {
- activeSection($(this))
- }),
- $(".role_editor .tag").live("click", function () {
- var e = $(this)
- 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"))) {
- var t = e.index()
- 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))
- }
- var d = eval("(" + $(".app_item.selected").attr("data") + ")")
- d = onTagClick(d, e)
- $(".app_item.selected").attr("data", JSON.stringify(d))
- })
- },
- getData = function () {
- return roleData
- }
- return {
- getData: getData,
- edit: toEdit,
- init: reload,
- bindEvent: bindEvent,
- }
- }),
- define("setting/system", [], function () {
- var reload = function () {
- bindEvent(),
- ajax({
- url: "/web/setting/system/getAll.json",
- type: "GET",
- dataType: "json",
- success: function (e) {
- if (e.status == 1) {
- fillFrm(e.data)
- }
- },
- })
- },
- fillFrm = function (e) {
- for (var s in e) {
- var val = e[s]
- var o = $(".system_setting input[name='" + s + "'],.system_setting select[name='" + s + "'],.system_setting textarea[name='" + s + "']")
- if ("checkbox" == o.attr("type")) {
- o.attr("checked", val == "1")
- } else {
- o.val(val)
- }
- }
- },
- bindEvent = function () {
- $("input[name='first_in']").live("click", function () {
- $("input[name='first_in']").removeAttr("checked"), $(this).attr("checked", "checked")
- }),
- $(".system_save")
- .unbind("click")
- .click(function () {
- var e = {}
- $(".system_setting .box_line input,.system_setting .box_line select,.system_setting .box_line textarea").each(function () {
- var t = $(this)
- if (t.hasClass("disable")) {
- return true
- }
- if ("checkbox" == t.attr("type")) {
- var a = void 0 == t.attr("checked") ? "0" : "1"
- e[t.attr("name")] = a
- } else "radius" != t.attr("type") && (e[t.attr("name")] = t.val())
- }),
- (e.first_in = $("input[name='first_in'][checked]").val()),
- save(e)
- }),
- $(".system_setting .box_line input,.system_setting .box_line select,.system_setting .box_line textarea").live("change", function () {
- $(".system_setting").attr("changed", true)
- }),
- $(".add-auto-open")
- .unbind("click")
- .click(function () {
- var item = $($(".auto-open-item-tmpl").html())
- $(".del-item-btn", item).click(function () {
- $(".system_setting").attr("changed", true)
- $(this)
- .parents("li")
- .fadeOut("slow", function () {
- $(this).remove()
- })
- })
- //读取角色列表
- //从应用中心读取应用列表
- $(".auto-open-box").append(item)
- })
- },
- save = function (e) {
- if ($(".system_setting").attr("changed") ? false : true) {
- tips(LNG.not_changed, "warning")
- return
- }
- ajax({
- url: "/web/setting/system/modify.json",
- type: "POST",
- data: { settings: JSON.stringify(e) },
- dataType: "json",
- success: function (e) {
- if (e.status == 1) {
- $(".system_setting").removeAttr("changed")
- }
- tips(e.msg, e.status == 1 ? "success" : "error")
- },
- })
- }
- return {
- bindEvent: bindEvent,
- init: reload,
- }
- })
- var logout = function () {
- ajax({
- url: "/system/logout.json",
- success: function (data) {
- if (data.data.loginHost) {
- window.location = data.data.loginHost
- }
- },
- })
- }
|