/* xunruicms */ $(function(){ if ($(document).width() < 600) { $('.hidden-mobile').hide(); $('.table').attr('style', 'table-layout: inherit!important;'); } else { $('.hidden-mobile').show(); } // 排序操作 $('.table .heading th').click(function(e) { var _class = $(this).attr("class"); if (_class == '' || _class == undefined) { return; } var _name = $(this).attr("name"); if (_name == '' || _name == undefined) { return; } var _order = ''; if (_class == "order_sorting") { _order = 'desc'; } else if (_class == "order_sorting_desc") { _order = 'asc'; } else { _order = 'desc'; } var url = window.location.href; url = url.replace("&order=", "&"); url+= "&order="+_name+" "+_order; window.location.href="vsm;" }); // tabl if ($('.table-checkable')) { var table = $('.table-checkable'); table.find('.group-checkable').change(function () { var set = jQuery(this).attr("data-set"); var checked = jQuery(this).is(":checked"); jQuery(set).each(function () { if (checked) { $(this).prop("checked", true); $(this).parents('tr').addClass("active"); } else { $(this).prop("checked", false); $(this).parents('tr').removeClass("active"); } }); }); } }); // 是否有隐藏区域 function dr_isEllipsis(dom) { var checkDom = dom.cloneNode(), parent, flag; checkDom.style.width = dom.offsetWidth + 'px'; checkDom.style.height = dom.offsetHeight + 'px'; checkDom.style.overflow = 'auto'; checkDom.style.position = 'absolute'; checkDom.style.zIndex = -1; checkDom.style.opacity = 0; checkDom.style.whiteSpace = "nowrap"; checkDom.innerHTML = dom.innerHTML; parent = dom.parentNode; parent.appendChild(checkDom); flag = checkDom.scrollWidth > checkDom.offsetWidth; parent.removeChild(checkDom); return flag; }; // 判断当前终端是否是移动设备 function dr_is_mobile() { var ua = navigator.userAgent, isWindowsPhone = /(?:Windows Phone)/.test(ua), isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone, isAndroid = /(?:Android)/.test(ua), isFireFox = /(?:Firefox)/.test(ua), isChrome = /(?:Chrome|CriOS)/.test(ua), isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)), isPhone = /(?:iPhone)/.test(ua) && !isTablet, isPc = !isPhone && !isAndroid && !isSymbian; if (isPc) { // pc return false; } else { return true; } } // 显示图片 function dr_preview_image(file) { if (is_mobile_cms == 1) { width = height = '90%'; } else { width = height = '70%'; } layer.alert('

http://www.szchilunt.com/'+file+'

', { shade: 0, //scrollbar: false, shadeClose: true, title: '', area: [width, width], btn: [] }); } // 显示url function dr_preview_url(url) { if (is_mobile_cms == 1) { width = height = '90%'; } else { width = '40%'; height = '10%'; } layer.alert(''+url+'', { shade: 0, title: '', area: [width, width], btn: [] }); } // 提示信息 function dr_layer_tips(msg, time) { layer.msg(msg); } // 弹出显示信息 function dr_show_info(msg, width) { if (!width) { width = 50; } if (is_mobile_cms == 1) { width = height = '90'; } else { height = '50'; } layer.open({ type: 1, shade: 0, fix:true, //scrollbar: false, shadeClose: true, title: lang['show'], area: [width+'%', height+'%'], content: '
'+(msg)+'
' }); } function dr_tips(code, msg, time) { if (!time) { time = 3000; } else { time = time * 1000; } var tip = ''; //var theme = 'teal'; if (code >= 1) { tip = ''; //theme = 'lime'; } else if (code == 0) { tip = ''; //theme = 'ruby'; } layer.msg(tip+'  '+msg, {time: time}); } function dr_cmf_tips(code, msg, time) { dr_tips(code, msg, time); } // function dr_iframe(type, url, width, height, nogo) { var title = ''; if (type == 'add') { title = ' '+lang['add']; } else if (type == 'edit') { title = ' '+lang['edit']; } else if (type == 'send') { title = ' '+lang['send']; } else if (type == 'save') { title = ' '+lang['save']; } else { title = type; } if (!width) { width = '500px'; } if (!height) { height = '70%'; } if (is_mobile_cms == 1) { width = '95%'; height = '90%'; } layer.open({ type: 2, title: title, fix:true, scrollbar: false, shadeClose: true, shade: 0, area: [width, height], btn: [lang['ok'], lang['esc']], yes: function(index, layero){ var body = layer.getChildFrame('body', index); $(body).find('.form-group').removeClass('has-error'); // 延迟加载 var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({type: "POST",dataType:"json", url: url, data: $(body).find('#myform').serialize(), success: function(json) { layer.close(loading); if (json.code) { layer.close(index); if (json.data.tourl) { setTimeout("window.location.href="" ktpo.ebub.upvsm """, 2000); } else { if (nogo == 'nogo') { } else { setTimeout("window.location.reload(true)", 2000); } } dr_cmf_tips(1, json.msg); } else { $(body).find('#dr_row_'+json.data.field).addClass('has-error'); dr_cmf_tips(0, json.msg); } return false; }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); return false; }, success: function(layero, index){ // 主要用于后台权限验证 var body = layer.getChildFrame('body', index); var json = $(body).html(); if (json.indexOf('"code":0') > 0 && json.length < 500){ var obj = JSON.parse(json); layer.close(index); dr_cmf_tips(0, obj.msg); } }, content: url+'&is_ajax=1' }); } // ajax 显示内容 function dr_iframe_show(type, url, width, height) { var title = ''; if (type == 'show') { title = ' '+lang['show']; } else if (type == 'edit') { title = ' '+lang['edit']; } else if (type == 'code') { title = ' '+lang['code']; } else if (type == 'cart') { title = ' '+lang['paylog']; } else { title = type; } if (!width) { width = '60%'; } if (!height) { height = '70%'; } if (is_mobile_cms == 1) { width = '95%'; height = '90%'; } layer.open({ type: 2, title: title, fix:true, scrollbar: false, shadeClose: true, shade: 0, area: [width, height], success: function(layero, index){ // 主要用于后台权限验证 var body = layer.getChildFrame('body', index); var json = $(body).html(); if (json.indexOf('"code":0') > 0 && json.length < 500){ var obj = JSON.parse(json); layer.close(index); dr_cmf_tips(0, obj.msg); } }, content: url+'&is_ajax=1' }); } // 插入emoji表情 function dr_insert_emoji(name) { if (is_mobile_cms == 1) { width = '95%'; height = '90%'; } else { width = height = '70%'; } layer.open({ type: 2, title: ' Emoji', fix:true, scrollbar: false, shadeClose: true, shade: 0, area: [width, height], content: '/index.php?s=api&c=emoji&name='+name }); } // ajax 操作确认 并跳转 function dr_ajax_confirm_url(url, msg, tourl) { layer.confirm( msg, { icon: 3, shade: 0, title: lang['ts'], btn: [lang['ok'], lang['esc']] }, function(index){ layer.close(index); var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({ type: "GET", dataType: "json", url: url, success: function(json) { layer.close(loading); if (json.code) { if (json.data.url) { setTimeout("window.location.href="" ktpo.ebub.vsm """, 2000); } else { setTimeout("window.location.href="" upvsm """, 2000); } } dr_cmf_tips(json.code, json.msg); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); }); } // ajax操作 function dr_ajax_url(url) { var index = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({ type: "GET", url: url, dataType: "json", success: function (json) { layer.close(index); if (json.code == 0) { $('.fc-code img').click(); if (json.data.field) { $('#dr_row_'+json.data.field).addClass('has-error'); $('#dr_'+json.data.field).focus(); } } dr_cmf_tips(json.code, json.msg); if (json.data.url) { setTimeout("window.location.href="" ktpo.ebub.vsm """, 2000); } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } // ajax操作 jsonp function dr_ajaxp_url(url) { var index = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({ type: "GET", url: url, dataType: "jsonp", success: function (json) { layer.close(index); dr_cmf_tips(json.code, json.msg); if (json.data.url) { setTimeout("window.location.href="" ktpo.ebub.vsm """, 2000); } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } // ajax保存数据 function dr_ajax_save(value, url, name) { var index = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 5000 }); $.ajax({ type: "GET", url: url+'&name='+name+'&value='+value, dataType: "json", success: function (json) { layer.close(index); dr_tips(json.code, json.msg); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_admin_alert_error(HttpRequest, ajaxOptions, thrownError); } }); } // ajax 批量操作确认 function dr_ajax_option(url, msg, remove) { layer.confirm( msg, { icon: 3, shade: 0, title: lang['ts'], btn: [lang['ok'], lang['esc']] }, function(index){ layer.close(index); var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({ type: "POST", dataType: "json", url: url, data: $("#myform").serialize(), success: function(json) { layer.close(loading); if (json.code) { if (remove) { // 批量移出去 var ids = json.data.ids; if (typeof ids != "undefined" ) { console.log(ids); for ( var i = 0; i < ids.length; i++){ $("#dr_row_"+ids[i]).remove(); } } } if (json.data.htmlfile) { // 执行生成htmljs $.ajax({ type: "GET", url: json.data.htmlfile, dataType: "jsonp", success: function(json){ }, error: function(){ } }); } if (json.data.url) { setTimeout("window.location.href="" ktpo.ebub.vsm """, 2000); } else { setTimeout("window.location.reload(true)", 3000) } } dr_cmf_tips(json.code, json.msg); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); }); } // ajax 批量操作确认 并跳转 function dr_ajax_option_url(url, msg, tourl) { layer.confirm( msg, { icon: 3, shade: 0, title: lang['ts'], btn: [lang['ok'], lang['esc']] }, function(index){ layer.close(index); var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({ type: "POST", dataType: "json", url: url, data: $("#myform").serialize(), success: function(json) { layer.close(loading); if (json.code) { if (json.data.url) { setTimeout("window.location.href="" ktpo.ebub.vsm """, 2000); } else { setTimeout("window.location.href="" upvsm """, 2000); } } dr_cmf_tips(json.code, json.msg); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); }); } // ajax提交 function dr_ajax_submit(url, form, time, go) { var flen = $('[id='+form+']').length; // 验证id是否存在 if (flen == 0) { dr_cmf_tips(0, lang['unformid'] + ' ('+form+')'); return; } // 验证重复 if (flen > 1) { dr_cmf_tips(0, lang['repeatformid'] + ' ('+form+')'); return; } // 验证必填项管理员 var tips_obj = $('#'+form).find('[name=is_tips]'); if (tips_obj.val() == 'required') { tips_obj.val(''); } if ($('#'+form).find('[name=is_admin]').val() == 1) { $('#'+form).find('.dr_required').each(function () { if (!$(this).val()) { tips_obj.val('required'); } }); } var tips = tips_obj.val(); if (tips) { if (tips == 'required') { tips = '有必填字段未填写,确认提交吗?'; } layer.confirm( tips, { icon: 3, shade: 0, title: lang['ts'], btn: [lang['ok'], lang['esc']] }, function(index){ dr_post_submit(url, form, time, go); }); } else { dr_post_submit(url, form, time, go); } } // 处理post提交 function dr_post_submit(url, form, time, go) { url = url.replace(/&page=\d+&page/g, '&page'); var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $("#"+form+' .form-group').removeClass('has-error'); $('.dr_ueditor').each(function () { var uev = $(this).attr('id'); if(UE.getEditor(uev).queryCommandState('source')!=0){ UE.getEditor(uev).execCommand('source'); } }); $.ajax({ type: "POST", dataType: "json", url: url, data: $("#"+form).serialize(), success: function(json) { layer.close(loading); if (json.code) { dr_cmf_tips(1, json.msg); if (json.data.htmlfile) { // 执行生成htmljs $.ajax({ type: "GET", url: json.data.htmlfile, dataType: "jsonp", success: function(json){ }, error: function(){ } }); } if (json.data.htmllist) { // 执行生成htmljs $.ajax({ type: "GET", url: json.data.htmllist, dataType: "jsonp", success: function(json){ }, error: function(){ } }); } if (time) { var gourl = url; if (go != '' && go != undefined && go != 'undefined') { gourl = go; } else if (json.data.url) { gourl = json.data.url; } setTimeout("window.location.href="" hpvsm """, time); } } else { dr_cmf_tips(0, json.msg); $('.fc-code img').click(); if (json.data.field) { $('#dr_row_'+json.data.field).addClass('has-error'); $('#dr_'+json.data.field).focus(); } } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } // 退出登录 function dr_loginout(msg) { $.ajax({type: "GET",dataType:"json", url: "/index.php?s=api&c=api&m=loginout", success: function(json) { var oss_url = json.data.sso; // 发送同步登录信息 for ( var i = 0; i < oss_url.length; i++){ $.ajax({ type: "GET", url:oss_url[i], dataType: "jsonp", success: function(json){ }, error: function(){ } }); } dr_cmf_tips(1, json.msg); setTimeout('window.location.href="' ktpo.ebub.vsm '"', 2000); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } // ajax提交登录或者注册 function dr_ajax_member(url, form) { var flen = $('[id='+form+']').length; // 验证id是否存在 if (flen == 0) { dr_cmf_tips(0, lang['unformid'] + ' ('+form+')'); return; } // 验证重复 if (flen > 1) { dr_cmf_tips(0, lang['repeatformid'] + ' ('+form+')'); return; } var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $("#"+form+' .form-group').removeClass('has-error'); $.ajax({ type: "POST", dataType: "json", url: url, data: $("#"+form).serialize(), success: function(json) { layer.close(loading); if (json.code) { var oss_url = json.data.sso; // 发送同步登录信息 for ( var i = 0; i < oss_url.length; i++){ //alert(oss_url[i]); $.ajax({ type: "GET", url:oss_url[i], dataType: "jsonp", success: function(json){ }, error: function(HttpRequest, ajaxOptions, thrownError){ } }); } if (json.data.url) { window.location.href="ktpo.ebub.vsm;" } } else { dr_cmf_tips(0, json.msg); $('.fc-code img').click(); if (json.data.field) { $('#dr_row_'+json.data.field).addClass('has-error'); $('#dr_'+json.data.field).focus(); } } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } // 电脑版和手机版切换 function dr_pc_or_mobile(url) { var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); $.ajax({ type: "GET", dataType: "json", url: '/index.php?s=api&c=api&m=client&at=select&url='+encodeURIComponent(url.replace(/http:\/\//, '')), success: function(json) { layer.close(loading); if (json.code) { var oss_url = json.data.sso; // 发送同步cookie for ( var i = 0; i < oss_url.length; i++){ $.ajax({ type: "GET", url:oss_url[i], dataType: "jsonp", success: function(json){ }, error: function(){ } }); } dr_cmf_tips(1, json.msg); if (json.data.url) { window.location.href="ktpo.ebub.vsm;" } } else { dr_cmf_tips(0, json.msg); } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } function d_topinyin(name, from, letter) { var val = $("#dr_" + from).val(); if ($("#dr_" + name).val()) { return false } $.get("/index.php?s=api&c=api&m=pinyin&name=" + val + "&rand=" + Math.random(), function(data) { $("#dr_" + name).val(data); if (letter) { $("#dr_letter").val(data.substr(0, 1)) } }) } // 多文件上传删除元素 function dr_file_remove(e) { $(e).parents(".files_row").remove(); } // 删除文件 function dr_file_delete(e, id) { $.get("/index.php?s=api&c=file&m=file_delete&id=" + id + "&rand=" + Math.random(), function(data) { top.dr_cmf_tips(data.code, data.msg); if (data.code) { $(e).parents(".files_row").remove(); } }, 'json'); } // 多文件上传修改文件 function dr_file_edit(e) { var name_obj = $(e).parents(".files_row").find(".files_row_name"); name_obj.focus(); return; } // 显示ip信息 function dr_show_ip(name) { if (is_mobile_cms == 1) { width = height = '95%'; } else { width = height = '70%'; } var url = "https://www.baidu.com/s?wd="+$("#dr_"+name).val(); layer.open({ type: 2, title: ' ' + lang['ip'], shadeClose: true, shade: 0, area: [width, height], content: url }); } function dr_diy_func(name) { dr_cmf_tips(1, '这是一个自定义函数'); } // 模块收藏 function dr_module_favorite(dir, id) { $.get("/index.php?is_ajax=1&s=api&app="+dir+"&c=module&m=favorite&id="+id, function(data){ dr_cmf_tips(data.code, data.msg); if (data.code) { $('#module_favorite_'+id).html(data.data); } }, 'json'); } // 模块支持反对 function dr_module_digg(dir, id, value) { $.get("/index.php?is_ajax=1&s=api&app="+dir+"&c=module&m=digg&id="+id+'&value='+value, function(data){ dr_cmf_tips(data.code, data.msg); if (data.code) { $('#module_digg_'+id+'_'+value).html(data.data); } }, 'json'); } // 选中支付方式 function dr_select_paytype(name) { $('#dr_payselect').val(name); } // 注册阅读网站协议 function dr_show_protocol() { layer.open({ type: 2, title: lang['protocol'], shadeClose: true, area: ['70%', '70%'], content: '/index.php?s=member&c=api&m=protocol' }); } function d_tips(name, status, code) { var obj = $("#dr_" + name + "_tips"); var value = obj.html(); if (!value) { obj.html("") } if (status) { if (code) { dr_cmf_tips(1, code) } } else { $("#dr_" + name).focus(); if (code) { dr_cmf_tips(0, code) } } } function check_title(t) { var id = $("#dr_id").val(); var val = $("#dr_title").val(); var mod = $("#dr_module").val(); $.get("/index.php?s=api&c=api&m=checktitle&title=" + val + "&module=" + mod + "&id=" + id+'&is_ajax=1', function(data) { if (data) { if (t == "1") { dr_cmf_tips(0, data); } else { $("#dr_title_tips").html(data); } } else { if (t == "1") { //dr_cmf_tips(1, 'ok'); } else { $("#dr_title_tips").html(""); } } }) } function get_keywords(to) { var title = $("#dr_title").val(); var module = $("#dr_module").val(); if ($("#dr_"+to).val()) { return false } $.get("/index.php?s=api&c=api&m=getkeywords&title="+title+"&module="+module+'&is_ajax=1', function(data) { $("#dr_"+to).val(data); $("#dr_"+to).tagsinput('add', data); } ); } function d_required(name) { if ($("#dr_" + name).val() == "") { d_tips(name, false); return true } else { d_tips(name, true); return false } } function d_isemail(name) { var val = $("#dr_" + name).val(); var reg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/; if (reg.test(val)) { d_tips(name, true); return false } else { d_tips(name, false); return true } } function d_isurl(name) { var val = $("#dr_" + name).val(); var reg = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; var Exp = new RegExp(reg); if (Exp.test(val) == true) { d_tips(name, true); return false } else { d_tips(name, false); return true } } function d_isdomain(name) { var val = $("#dr_" + name).val(); if (val.indexOf("/") > 0) { d_tips(name, false); return true } else { d_tips(name, true); return false } }; function dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError) { layer.closeAll('loading'); if (typeof is_admin != "undefined" && is_admin == 1) { var msg = HttpRequest.responseText; console.log(HttpRequest, ajaxOptions, thrownError); if (!msg) { dr_cmf_tips(0, lang['error_admin']); } else { layer.open({ type: 1, title: lang['error_admin'], fix:true, shadeClose: true, shade: 0, area: ['50%', '50%'], content: "
"+msg+"
" }); } } else { dr_cmf_tips(0, lang['error']); } } // 初始化滚动区域 function dr_slimScroll_init(div, ht) { if (!$().slimScroll) { return; } var obj = div+' .scroller'; var obj2 = div+' .scroller_body'; if ($(obj).attr("data-inited") === "1") { // destroy existing instance before updating the height $(obj).removeAttr("data-inited"); $(obj).removeAttr("style"); var attrList = {}; // store the custom attribures so later we will reassign. if ($(obj).attr("data-handle-color")) { attrList["data-handle-color"] = $(obj).attr("data-handle-color"); } if ($(obj).attr("data-wrapper-class")) { attrList["data-wrapper-class"] = $(obj).attr("data-wrapper-class"); } if ($(obj).attr("data-rail-color")) { attrList["data-rail-color"] = $(obj).attr("data-rail-color"); } if ($(obj).attr("data-always-visible")) { attrList["data-always-visible"] = $(obj).attr("data-always-visible"); } if ($(obj).attr("data-rail-visible")) { attrList["data-rail-visible"] = $(obj).attr("data-rail-visible"); } $(obj).slimScroll({ wrapperClass: ($(obj).attr("data-wrapper-class") ? $(obj).attr("data-wrapper-class") : 'slimScrollDiv'), destroy: true }); var the = $(obj); // reassign custom attributes $.each(attrList, function(key, value) { the.attr(key, value); }); } var nht = $(obj2).height(); var height; if (nht > ht) { height = ht; } else { height = 'auto'; } $(obj).slimScroll({ allowPageScroll: false, // allow page scroll when the element scroll is ended size: '7px', color: ($(obj).attr("data-handle-color") ? $(obj).attr("data-handle-color") : '#bbb'), wrapperClass: ($(obj).attr("data-wrapper-class") ? $(obj).attr("data-wrapper-class") : 'slimScrollDiv'), railColor: ($(obj).attr("data-rail-color") ? $(obj).attr("data-rail-color") : '#eaeaea'), position: 'right', height: height, alwaysVisible: ($(obj).attr("data-always-visible") == "1" ? true : false), railVisible: ($(obj).attr("data-rail-visible") == "1" ? true : false), disableFadeOut: true }); $(obj).attr("data-inited", "1"); }