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 = '
' + t + "
",
i = $.dialog.list.ajaxErrorDialog
return "" == 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('
')
},
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 = "" //'' + m[t].title + '
';
var 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("
")
},
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("" + msg + "")
$(".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 = "| domain | " + "" + LNG.setting_site_name + " | 创建时间 | " + "" + LNG.action + " | " + "
"
for (var a in siteData) {
var i = "" + LNG.button_edit + "" + " " + LNG.button_del + ""
1 == siteData[a].id && (i = "默认站点不可编辑"),
(e += "" + " | " + siteData[a].domain + " | " + " " + siteData[a].name + " | " + (isNaN(siteData[a].createTime) ? "未记录" : new Date(siteData[a].createTime).format("yyyy-MM-dd HH:mm:ss")) + " | " + i + " | ")
}
$(".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 = "
| " + LNG.name + " | " + "" + LNG.role_desc + " | 创建时间 | " + "" + LNG.action + " | " + "
"
for (var a in roleData) {
var i = "" + LNG.button_edit + "" + " " + LNG.button_del + ""
1 == roleData[a].root && (i = LNG.default_role_can_not_do),
(e += "" + " | " + roleData[a].name + " | " + " " + roleData[a].discription + " | " + new Date(roleData[a].createTime).format("yyyy-MM-dd HH:mm:ss") + " | " + i + " | ")
}
$(".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 + "?
" + 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 += '"
c += ''
c += ""
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 += '"
}
c += "
"
c += ''
}
$("#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 = $('" + '
' + "" + app.title + "" + "").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
}
},
})
}