function fillreturnmsg(o, t, msg) {
var tip = $("span.formcolumn-item-tipstxt", $(o).parent());
if ($("span.formcolumn-item-errtipstxt", $(o).parent()).length > 0) {
tip = $("span.formcolumn-item-errtipstxt", $(o).parent());
}
tip.html(msg);
if (t == 1) {
$(o).removeclass("needfill");
tip.css("color", "green");
}
else if (t == 0) {
$(o).addclass("needfill");
tip.css("color", "red");
}
else if (t == 2) {
$(o).removeclass("needfill");
tip.css("color", "#999999");
}
}
function initformverify(cfg) {
if (typeof (initextcountry) == "function") {
initextcountry();
}
$("input[exrequired='true'],textarea[exrequired='true']", cfg.el).after(" *");
$("input[exrequired='true'],textarea[exrequired='true']", cfg.el).each(function () {
if ($(this).attr("onblur") == undefined) {
$(this).on("blur", function () {
var v = $(this).val();
if (v != "") {
fillreturnmsg(this, 1, " ");
}
else {
if ($(this).attr("title")) {
fillreturnmsg(this, 0, getlangtxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]));
}
else {
fillreturnmsg(this, 0, "");
}
}
});
}
});
}
function initformverify_v2(cfg) {
if (typeof (initextcountry) == "function") {
initextcountry();
}
// $("input[exrequired='true'],textarea[exrequired='true']", cfg.el).after(" *");
$("input[exrequired='true'],textarea[exrequired='true']", cfg.el).each(function () {
if ($(this).attr("onblur") == undefined) {
$(this).on("blur", function () {
$(".help-block", $(this).parents(".form-group")).remove();
var v = $(this).val();
if (v != "") {
$(this).parents(".form-group").removeclass("has-error");
}
else {
$(this).parents(".form-group").addclass("has-error");
if ($(this).attr("title") && $(this).attr("show-help") == "true") {
$(this).parents(".form-group").append('' + getlangtxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]) + '');
}
}
});
}
});
}
function ajaxreturn(ret, callback) {
var rc = ret.value;
if (rc) {
callback();
}
else {
alert(ret.error.message);
}
}
function opendialog(cfg) {
if ($.fn.dialog != undefined) {
$(cfg.el).dialog({
title: cfg.title,
autoopen: true,
modal: true,
width: cfg.width,
height: cfg.height,
resizable: false,
close: function () {
$("body").css("overflow", "auto");
nowopendialogel = '';
},
open: function () {
$("body").css("overflow", "hidden");
if (cfg.opencallback != undefined) {
cfg.opencallback();
}
}
});
}
else {
try {
var modalel = cfg.el + "_modal";
var modalelstr = modalel.replace("#", "").replace(".", "");
if ($(modalel).length == 0) {
var html = '
';
$("body").append(html);
$(cfg.el).show();
$(".modal-body", modalel).append($(cfg.el));
$(modalel).modal({
backdrop: false,
keyboard: false,
show: true
});
$(modalel).on('shown.bs.modal', function (e) {
if (cfg.opencallback != undefined) {
cfg.opencallback();
}
});
}
else {
$(modalel).modal("show");
}
}
catch(e){ }
}
}
function alert(msg, title, width) {
if (title == undefined) {
title = "" + rclng.sysalert;
}
if (width == undefined) {
width = 400;
}
if ($("#alertdialog").length == 0) {
$("body").append(' ');
}
opendialog({
el: "#alertdialog",
width: width,
title: title,
buttons: [
{
text: "" + rclng.sysok,
icons: {
primary: "ui-icon-heart"
},
click: function () {
$(this).dialog("close");
}
}
],
opencallback: function () {
$("#alertmsgbox").html(msg);
}
});
}
function closedialog(el) {
if ($.fn.dialog != undefined) {
$(el).dialog("close");
}
else {
try {
var modalel = el + "_modal";
$(modalel).modal("hide");
}
catch (e) {
}
}
}
function autocenterdialog(el) {
if ($.fn.dialog != undefined) {
$(el).dialog("option", "position", "center");
}
}
function initclosebtn(o) {
if (o != undefined) {
$("input[closebtn='true']", o).bind("click", function () {
var el = $(this).attr("reel");
closedialog("#" + el);
})
}
else {
$("input[closebtn='true']").bind("click", function () {
var el = $(this).attr("reel");
closedialog("#" + el);
})
}
}
function getextattrvalues(cfg) {
var extv = {};
$("input[dataref='true'],textarea[dataref='true'],select[dataref='true'],span[addresstype],span[countrytype]", $(cfg.el)).each(function () {
if (extv[$(this).attr("classname")] == undefined) {
extv[$(this).attr("classname")] = {};
}
if ($(this).hasclass("address_extipt")) {
var vxv = "";
if ($(this).attr("areacode") != "") {
vxv = $(this).attr("areacode") + "|" + $(this).attr("areatitle");
}
extv[$(this).attr("classname")][$(this).attr("relkey")] = vxv;
}
else if ($(this).hasclass("country_extipt")) {
var vxv = "";
if ($(this).attr("countrycode") != "") {
vxv = $(this).attr("countrytitle") + "|" + $(this).attr("countrycode");
}
extv[$(this).attr("classname")][$(this).attr("relkey")] = vxv;
}
else {
extv[$(this).attr("classname")][$(this).attr("relkey")] = $(this).val();
}
});
var r = {};
r.str = json2.stringify(extv);
r.json = extv;
return r;
}
function clearformdata(cfg, callback) {
$("input[dataref='true'][type!='checkbox'],textarea[dataref='true'],input[data-ref][type!='checkbox'],textarea[data-ref]", $(cfg.el)).val("");
if (callback != undefined) {
callback();
}
}
function verifyformdata(cfg, callback) {
var success = true;
var postdata = {};
$("input[dataref='true'],textarea[dataref='true'],select[dataref='true'],input[data-ref],textarea[data-ref],span[addresstype],span[countrytype]", $(cfg.el)).each(function () {
var v = "";
if ($(this).attr("addresstype") != undefined || $(this).attr("countrytype") != undefined) {
v = $(this).attr("areacode");
}
else {
v = $(this).val();
}
if ($(this).attr("exrequired") == "true" && v == "") {
alert(getlangtxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]));
success = false;
$(this).focus();
return false;
}
if ($(this).attr("data-ref") != undefined) {
if ($(this).attr("type") != undefined) {
if ($(this).attr("type") == "checkbox") {
if ($(this).is(":checked")) {
postdata[$(this).attr("data-ref")] = v;
}
else {
postdata[$(this).attr("data-ref")] = "";
}
}
else {
postdata[$(this).attr("data-ref")] = v;
}
}
else {
postdata[$(this).attr("data-ref")] = v;
}
}
});
if (success) {
var extdata = getextattrvalues(cfg);
callback(postdata, extdata.str, extdata.json);
}
}
function jsontodict(data) {
var dict = new ajax.web.dictionary("dictionary");
for (var jd in data) {
dict.add(jd, data[jd]);
}
return dict;
}
function inituserloginstatus(cfg) {
$.get("/index.aspx?a=checkuserlogin&mfrsh=" + math.random(), {}, function (data) {
if (cfg.callback == undefined) {
if (data.result == "1") {
$(cfg.el).html(rclng.hello + '!' + data.username + ' ' + rclng.membercenter + ' ' + rclng.loginout + ' ');
}
else if (data.result == "-1") {
$(cfg.el).html('' + rclng.login + ' ' + rclng.register + ' ');
}
if (cfg.ondone != undefined) {
cfg.ondone(data);
}
}
else {
cfg.callback(data);
}
}, "json");
}
function viewverifyimage(cfg) {
$(cfg.el).html('');
}
function refreashverifyimg(o) {
var verifytype = $(o).attr("verifytype");
var veid = $(o).attr("vref");
$(o).attr("src", "/index.aspx?a=verifycode&verifytype=" + verifytype + "&r=" + math.random());
$(veid).val("");
}
function verifycodecheck(o) {
var v = $(o).val();
web960.web.index.verifyregcode(v, "userlogin", function (res) {
ajaxreturn(res, function () {
var rv = res.value;
if (rv.status == "1") {
}
else {
// rv.clientmsg
}
});
});
}
function initdatamapping() {
$.get("/index.aspx?a=getuserinfo", {}, function (data) {
if (data.intresult == 1) {
//logined;
var comment = eval("(" + data.objresult.comment + ");");
$("input[data-mapping],textarea[data-mapping],select[data-mapping]").each(function () {
var mapping = $.trim($(this).attr("data-mapping"));
if (mapping != "") {
try {
var v = eval("(comment." + mapping + ");");
$(this).val(v);
}
catch (e) { }
}
})
}
}, "json");
}
function getguestextsettings(callback) {
$.get("/index.aspx?a=g&getmethod=getsettings", {}, function (data) {
if (data.intresult == 1) {
var json = eval('(' + data.strresult + ')');
callback(json);
}
}, "json");
}
function getextforms(formid, callback) {
$.get("/index.aspx?a=g&getmethod=getextforms&formid=" + formid, {}, function (data) {
if (data.intresult == 1) {
callback(data.strresult);
}
}, "json");
}
function guid(callback) {
$.get("/index.aspx?a=guid&rnd=" + math.random(1), {}, function (data) {
callback(data.guid);
}, "json");
}
function gotopage(o) {
var v = $.trim($(o).val());
var patrn = /^[1-9]*[1-9][0-9]*$/;
if (patrn.exec(v)) {
var page = parseint(v);
var url = $(o).attr("pageurl");
var pagecount = parseint($(o).attr("pagecount"));
if (page <= 1) {
url = url.replace("-{0}", "").replace("_{0}", "");
}
else if (page > pagecount) {
page = pagecount;
url = url.replace("{0}", page);
}
else {
url = url.replace("{0}", page);
}
location.href = url;
}
}
function jumppropage(o) {
var v = $.trim($(o).val());
var url = $("#wpagenavgotuipt").attr("pageurl");
var pagecount = parseint($(o).attr("pagecount"));
url = url.replace("-{0}", "").replace("_{0}", "").replace("page={0}", "page=").replace("&psize", "&apsizeq").replace("?psize", "?apsizeq");
if (url.indexof("?") == -1) {
location.href = url + "?psize=" + v;
} else {
location.href = url + "&psize=" + v;
}
}
function getsimpmoneyunit(m) {
switch (m) {
case "cny":
case "元":
return "¥";
case "usd":
return "$";
case "hkd":
return "hk$";
case "eur":
return "€";
}
}
function initbrowsehistorycookie(cookiename, cookievalue, savetime) {
var str = cookiename + "=" + escape(cookievalue);
var date = new date();
var ms = savetime * 60 * 1000;
date.settime(date.gettime() + ms);
str += ";expires=" + date.togmtstring();
document.cookie = str;
}
var nowextuploadrefid = "";
var bfcallback = null;
function extupload(t, elid, callback) {
bfcallback = callback;
var dialoghtml = '';
if ($("#extuploaddialog").length == 0) {
$("body").append(dialoghtml);
extupload(t, elid);
}
else {
$("#uploadnoticediv").html("");
nowextuploadrefid = elid;
if (t == 1) {
title = rclng.uploadimage;
$("#extuploadform").attr("action", "/admin/filehandler.aspx?t=100&dir=image&id=0&n=0&cb=extuploadcallback");
} else if (t == 2) {
title = rclng.uploadfile;
$("#extuploadform").attr("action", "/admin/filehandler.aspx?t=110&dir=file&id=0&n=0&cb=extuploadcallback");
}
opendialog({ el: "#extuploaddialog", width: 410, title: title });
}
}
function extuploadcallback(res) {
if (res.error == "1") {
alert(res.message);
}
else {
var filename = res.filename;
$("input[id$='" + nowextuploadrefid + "'").val(filename);
if (bfcallback) {
bfcallback(filename);
}
closedialog("#extuploaddialog");
}
}
function getshopchatcountfornowuser(cfg) {
$.get("/index.aspx?a=ajax&plu=goodsmanage&ajaxmethod=shopcharcount&rnd=" + math.random(), {}, function (data) {
if (cfg.callback == undefined) {
}
else {
cfg.callback(data);
}
}, "json");
}
///获取待确认订单的数量
function getcountorderwating() {
$.get("/index.aspx?a=getorderwatingcount", {}, function (data) {
var res = data;
if (data.result == 1) {
var ct = data.count;
if ($(".ordermanage_orderwating").length > 0) {
var sphtm = "" + ct + "";
$(".ordermanage_orderwating a").append(sphtm);
}
}
}, "json");
}
function requestloginauthinfo(callback) {
var html = '';
html = '';
if ($("#loginauthinfobox").length == 0) {
$("body").append(html);
}
$('#loginauthinfobox').modal('show');
$("#loginauthinfotext").on("keypress", function () {
if (event.keycode == 13) {
var v = $("#loginauthinfotext").val();
if (v != "") {
$("#loginauthinfotext").val("");
$('#loginauthinfobox').modal('hide')
callback(v);
}
}
});
$("#loginauthinfobutton").unbind("click").click(function () {
var v = $("#loginauthinfotext").val();
if (v != "") {
$("#loginauthinfotext").val("");
$('#loginauthinfobox').modal('hide')
callback(v);
}
});
//opendialog({
// el: "#loginauthinfobox", width: 300, title: rclng.loginpassword, opencallback: function () {
// $("#loginauthinfobutton").unbind("click").click(function () {
// var v = $("#loginauthinfotext").val();
// if (v != "") {
// $("#loginauthinfotext").val("");
// closedialog("#loginauthinfobox");
// callback(v);
// }
// });
// }
//});
}
function getfields(target) {
///
/// 根据属性field 从指定的页面区域获取内容 , 返回实体 :{navid="...",navname=".."}
/// 多实体格式 {entity1:{field1:123,field2:234},entity2:{fiel:123,fiel2:123},otherfield:"abc"}
/// 对选支持:格式[]
///
///
/// 页面区域
///
///
/// 实体内容
///
var entity = {};
if (target == undefined)
target = this._container;
var allfileds = $("[field]", target);
allfileds.each(function (i) {
var tagname = this.tagname;
var element = $(this);
var key = element.attr("field");
var tokens = key.tostring().split('.');
var tokevalue = function (v) {
///
/// 实体赋值
///
if (tokens != undefined && tokens.length && tokens.length > 1) {
if (entity[tokens[0]] == undefined)
entity[tokens[0]] = {};
entity[tokens[0]][tokens[1]] = v;
}
else {
entity[key] = v;
}
};
//根据元素不同做不同处理
if (element.attr("type") == "radio") {
$("[name='" + element.attr("name") + "']", target).each(function () {
var r = $(this);
if (r.prop("checked")) {
tokevalue($.trim(r.val()));
}
});
} else if (element.attr("type") == "checkbox") {
if (element.attr("name") == undefined) {
if (element.is(":checked")) {
tokevalue($.trim(element.val()));
}
}
else {
var last = [];
$("[name='" + element.attr("name") + "']", target).each(function () {
var r = $(this);
if (r.attr("checked")) {
last.push($.trim(r.val()));
}
});
tokevalue(last);
}
} else if (tagname == "div") {
tokevalue($(this).html());
}
else {
//tokevalue($.trim($(this).val()));
tokevalue($(this).val());
}
});
return entity;
}
function setfields(data, target) {
///
/// 初始化页面
/// 多实体格式 {entity1:{field1:123,field2:234},entity2:{fiel:123,fiel2:123},otherfield:"abc"}
/// html:...
/// 支持多选,多选返回[]
///
///
/// 实体内容
///
///
/// 页面区域
///
var entity = data;
if (entity == null) {
return;
}
if (entity == undefined)
return;
if (target == undefined)
target = this._container;
var allfileds = $("[field]", target);
var a = "";
allfileds.each(function (i) {
var element = $(this);
var key = element.attr("field");
var tokens = key.tostring().split('.');
var val;
if (tokens != undefined && tokens.length && tokens.length > 1) {
var ent = entity[tokens[0]];
if (ent != undefined)
val = ent[tokens[1]];
}
else {
val = entity[key];
}
if (val != undefined) {
if (val == null) {
val = "";
}
if (element.attr("type") == "radio") {
$("[name='" + element.attr("name") + "']", target).each(function () {
if ($(this).val() == val)
$(this).attr("checked", "checked");
else
$(this).removeattr("checked");
});
} else if (element.attr("type") == "checkbox") {
$.each(val, function (index) {
var thatelemetn = $("[name='" + element.attr("name") + "'][value='" + val[index] + "']", target);
thatelemetn.attr("checked", "checked");
});
}
else {
if (this.nodename == "td" || this.nodename == "div") {
element.html(val);
} else {
element.val(val);
}
}
}
});
}
function jsontourlpath(json) {
var r = "";
for (var key in json) {
r += "&" + key + "=" + escape(json[key]);
}
r = r.length > 0 ? r.substr(1) : r;
return r;
}