n = function(a) {
this.detectGeoLocation = void 0 === a.detectGeoLocation ? !0 : a.detectGeoLocation;
this.detector = a.detector || w;
this.listHelper = a.listHelper || x.getInstance({
dataUrl: a.dataUrl
});
this.selectGroup = new g({
parent: this,
labels: a.labels,
elements: a.elements
});
var b = this;
this.listHelper.fetch(function() {
c("exec fetech callback");
b.selectGroup.init();
b.detectGeoLocation && b.detector()
})
};
n.prototype.report = function() {
return this.selectGroup.getValues()
};
n.prototype.select = function(a) {
this.selectGroup.setValues(a)
};
n.prototype.selectID = function(a) {
this.selectGroup.setValuesID(a)
};
w = function() {
c("Detect!!!!");
var a = this,
b;
t("http://j.maxmind.com/app/geoip.js",
function() {
c("Maxmind API Loaded!");
b = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%0A%20%20url%3D%22http%3A%2F%2Fmaps.google.com%2Fmaps%2Fapi%2Fgeocode%2Fjson%3Flatlng%3D" + geoip_latitude() + "%2C" + geoip_longitude() + "%26sensor%3Dfalse%26language%3Dzh-CN%22&format=json&diagnostics=true&callback=locationselectcb";
s(b,
function(b) {
c("Geocoder Request Completed through YQL ", b);
if ("OK" === b.query.results.json.status) {
b = b.query.results.json.results[0].address_components;
var e, j;
c("Geocoder statuts ok", b);
h(b,
function(a) {
var b = a.types[0];
"locality" === b ? e = a.long_name: "administrative_area_level_1" === b && (j = a.long_name)
});
a.select([j, e])
}
})
})
};
var v;
x = {
getInstance: function(a) {
if (!v) {
var b = a.dataUrl || "js/areas.js",
d, e = {};
d = {
get: function(a) {
return e[a]
},
set: function(a, b) {
e[a] = b
}
};
v = {
fetch: function(a) {
c("feteching areas data");
r({
url: b,
callback: function(b) {
c("area data : ", b);
d.set("province", b.province);
d.set("city", b.city);
d.set("district", b.district);
a()
}
})
},
find: function(a, b) {
var e = [];
c("querying by record id : ", b, "by list in level : ", a);
if (d.get(b)) c("lucky! we have it cached"),
e = d.get(b);
else if (c("finding it in areas data"), -1 === a) c("this is a query for province data"),
e = d.get("province");
else {
var f = b.toString().substring(0, 2 * (a + 1)),
k = RegExp("^" + f + "\\d*"),
g = 0 === a ? d.get("city") : d.get("district");
h(g,
function(a, b) {
k.test(a.id) && e.push(g[b])
})
}
c("Return results : ", e);
return e
}
}
}
return v
}
};
com.elfvision.kit.LocationSelect = n;
com.elfvision.ajax.XhrFactory = q;
com.elfvision.ajax.getJson = r;
com.elfvision.ajax.jsonp = s;
com.elfvision.ajax.getScript = t
})();void 0 !== window.jQuery && ($.LocationSelect = {
build: function(f) {
var k;
f.elements = this.get();
k = new com.elfvision.kit.LocationSelect(f);
$.LocationSelect.all[f.name] = k;
return this
}
},
$.LocationSelect.all = {},
$.fn.LocationSelect = $.LocationSelect.build);
上面是JS代码,
具体情况是我一个wecenter程序用了七牛之后,无法选择居住地(也就是获取不到areas.js的内容)。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不知道是不是七牛自动采用了gzip压缩导致的,去掉这个http头看一下:
Content-Encoding:gzip