Ниже приводится код JS, когда Xiaomi бросается на покупку.
Кода -копия выглядит следующим образом:
HdControl ({"Stime": 1381645438, "status": {"Alling": false, "miphone": {"hdstart": false, "hdstop": false, "hdurl": "", "продолжительность": null} , "mibox": {"hdstart": false, "hdstop": false, "hdurl": "", "duration": null}}})
Кода -копия выглядит следующим образом:
Функция fornum (a) {
вернуть 10> a? "0"+a: a
}
Обратный отсчет функции (a, b) {
varc = newdate (b) .getTime ()/1E3,
D = CA,
e = parseint (d%60),
f = parseint (d/60%60), g = parseint (d/3600%24),
h = parseint (d/3600/24),
i = [e.toString (),
f.toString (),
g.toString ()];
return0> = d? ])+"минута"+fornum (i [0])+"второй", [h+"<pan> day </span>"+fornum (i [2])+"<pan> time </span>" +fornum (i [1])+"<pran> min </span>"+fornum (i [0])+"<pan> second </span>",! 1]) :( window._timest = fornum (i [2])+"Time"+fornum (i [1])+"Minute"+fornum (i [0])+"второй", [fornum (i [2])+"<pan> /span > "+fornum (i [1])+" <pan> min </span> "+fornum (i [0])+" <pan> second </span> ",! 1])}}}
functionWevEventTrigger (a, b) {
пытаться{
if (мы && we.trigger)
вернуть "String"! = typeofB && (b = json.stringify (b)), we.trigger (a, b)
} catch (c) {}
Вернуться! 1
}
functionisApp () {
пытаться{
Если (мы) вернемся! 0
} catch (a) {}
Вернуться! 1
}
varquickbuy = {init: function () {
vara = это;
this.config = {},
this.config.hdurl={miphone:"m3/840410D8656D74E5F334591BD8A408A726799AEC13477D90B5E48DAD36547351/4334F49A1EE391261005E8AC5A0C9 D2FDA23BB72A2D20AB3F58343496FD4983D/tip_SaledOverAll.html",mibox:"tv/B1CF7B57BFEAE1EBC37700694C123D894C668BF11F6F25D59311FD369 42B3D6A/130F1B18D11F53CA1D0147B24E926C5A9B7676E57BE3D47959D6557545E8A339/tip_SaledOverAll.html"
},
this.config.mode = "",
this.mode = {miphone:! 1, mibox :! 1},
this.modemodals = {miphone: "#modal_miphone", mibox: "#modal_mibox"},
this.modecookies = {miphone: "xm_hd_so_phone", mibox: "xm_hd_so_box"},
this.config.startdate =+newdate ("15.10.201312: 00: 00"),
this.maskload = $ ("#maskload"),
this.config.minsigntime = 120,
this.results = null,
this.timer = null,
this.timecount = math.floor (math.abs (10*math.random ()-5))+5;
varb =! 0;
для (varcinthis.mode)
$ .cookie (this.modecookies [c]) || (b =! 1), $. cookie (this.modecookies [c]) && this.saleout ();
b || ($. cookie ("xm_diff_hd")? (this.config.servertime = this.localtime ()+parseint ($. cookie ("xm_diff_hd"), 10), this.config.servertime> = parseint (this .Config.StartDate/1E3,10)? $. cookie ("xm_hd_so_phone") && $. ::::::::::::::::: ::::::::::::::: Saunch ()): this.getData ())}, getData: function (a, b) {
varc = это, a = a || null;
b && (b = b),
$ .ajax ({
URL: "http://tc.hd.xiaomi.com/hdget",
Datatype: "jsonp",
jsonpcallback: "hdcontrol",
Тайм -аут: 7e3,
beforesend: function () {
c.maskload.css ("display", "block")},
ошибка: function () {
c.maskload.css ("display", "none"),
Alert («Сервер находится под большим давлением, пожалуйста, обновите страницу!»)
},
Успех: функция (D) {
if (c.maskload.css ("display", "none"), "undefined" == typeofd)
returnlert («Сервер находится под большим давлением, пожалуйста, обновите страницу!»),
void0;
if (c.results = d, a || (c.config.servertime = c.results.stime),! $. cookie ("xm_diff_hd")) {
vare = parseint (c.config.servertime-c.localtime (), 10);
$ .cookie ("xm_diff_hd", e, {
путь:"/",
Домен: ". Xiaomi.com",
Истекает: 1
})
}
if (a) {
c.initialdata ();
для (varfinc.mode)
if (c.config [f] .hdstart ===! 1 && c.config [f] .hdstop ===! 0) {
varg = c.modecookies [f];
$ .cookie (g, 1, {path: "/", домен: ". xiaomi.com", истекает: 1}),
c.saleout ()
} elseb && b.call ()
}
a || c.launch ()
}})},
initialData: function () {
this.config.allow = this.results.status.allow,
this.config.mibox = this.results.status.mibox,
this.config.miphone = this.results.status.miphone
},
запуск: function () {
this.imestart (),
this.countdown ()
},
TimeStart: function () {
vara = это,
b = 1e3*a.config.servertime,
c = a.config.startdate,
D = C-1E3*60*A.Config.MinsignTime;
b> = d && c> b &&! isApp ()?
$ .cookie ("userid")?
($ ("#view_button"). CSS («Видимость», «Скрытый»),
$ ("#buy_btn_1") .html ('<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1-1.html"> сведения о активности </a>'),
$ ("#buy_btn_2"). html ('<class = "btn_buybtn_02" href = "javascript :;"> rougin </a>')): a.tologin (): b> = c && a.tobuy ()
},
tologin: function () {
$ ("#view_button"). CSS («Видимость», «скрытый»),
$ ("#buy_btn_1") .html ('<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1-1.html"> сведения о активности </a>'),
$ ("#buy_btn_2"). html ('<aclass = "btn_buybtn_02" href = "javascript :;"> Войти заранее </a>'),),
$ ("#buy_btn_2"). Найти (". Btn_02"). On ("click", function () {
Webeventtrigger ("login", null) || (window.location.href = "http://m.xiaomi.com/mshopapi/index.php/v1/authorize/sso?client_id=180100031013&c allback ="+encodeuricomponent (окно Расположение.
)},
Обратный отсчет: function () {
vara = это,
b = null,
c = a.config.startdate;
b = a.config.servertime? A.config.servertime: parseint (+newdate/1e3,10);
vard = c-1e3*60*a.config.minsigntime,
e = setInterval (function () {
varf = обратный отсчет (b, c);
f [1]? (clearInterval (e), $ ("#countdown"). CSS ("Display", "none"), A.Tobuy ()) :( 1e3*b! = d || isApp () | | ($. cookie ("userid")? ($ ("#view_button"). CSS («Видимость», «скрытая»),
$ ("#buy_btn_1") .html ('<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1-1.html"> сведения о активности </a>'),
$ ("#buy_btn_2"). html ('<aclass = "btn_buy" href = "javascript :;"> login </a>')): a.tologin ()), b ++),
$ ("#countdown"). html (f [0])}, 1e3)},
tobuy: function () {
vara = это;
a.gobuy ();
varb = a.modemodals [a.config.mode];
$ (b) .find (". Close"). On ("click", function () {
$ (b) .css ("дисплей", "нет"),
window.cleartimeout (a.timer),
a.timer = null})},
saleout: function () {
vara = {miphone: "#buy_btn_2", mibox: "#buy_btn_1"},
b = {miphone: "http://t.hd.xiaomi.com/r/?_a=payment_check&_m=1", mibox: "http://m.xiaomi.com/index.html#ac=home&op=addcart&product_id = 2505 "},
c = {miphone: «Платеть Xiaomi Mobile 3», Mibox: «Платеть Xiaomi TV»};
для (vardintthis.mode)
$ .cookie (this.modecookies [d]) && ($ (a [d]). html ('<aclass = "btn_buy" href = "'+b [d]+'">'+c [d]+ "</a>"),
$ (this.modemodals [d]). IS (": visible") && $ (this.modemodals [d]). Найти (". Close"). Click ())},
localtime: function () {
vara = parseint (+newdate/1e3,10);
возвращение
},
toprocess: function (a) {
varb = это,
c = B.Timer,
d = B.TimeCount || 10, E = $ (B.Modemodals [a]). Найти (". re_countdown"),
f = $ (b.modemodals [a]). Найти (". Modal_btn"),
g = function () {0 == d? (f.html ('<aclass = "int_buy_btn" href = "javascript :;"> Введите Activity </a>'),
B.tobuygo (b.config.mode),
c && window.cleartimeout (c),
c = null) :( e.html ("("+d+")"),
D--,
b.timer = window.settimeout (function () {g ()}, 1e3))};
c && window.cleartimeout (c), g ()},
gobuy: function () {
vara = это,
b = {miphone: "купить Xiaomi Mobile 3", Mibox: "купить Xiaomi TV"},
c = {miphone: "#buy_btn_2", mibox: "#buy_btn_1"};
для (vardina.mode)
$ .cookie (a.modecookies [d]) || ($ (c [d]). html ('<aclass = "btn_buybtn_buy_go" data-type = "'+d+'" href = "javascript :; +b [d]+"</a>"),
$ (c [D]). IS (": hidden") && $ (c [D]). CSS ("Display", "block"));
$ ("#open_button"). Найти (". Btn_buy_go"). On ("click", function () {a.mode [$ (this) .attr ("data-type")] =! 0;
varb = a.config.mode = $ (this) .attr ("тип данных");
if ($. cookie ("userid")) a.getdata (! 0, function () {
$ (a.modemodals [b]). CSS ("Display", "Block"),
$ (a.modemodals [b]). Найти (". Close"). On ("click", function () {
$ (a.modemodals [b]). css ("display", "none"), window.cleartimeout (a.timer), a.timer = null}), a.toprocess (b)});
else {if (webeventtrigger ("login", null)) return;
window.location.href = "http://m.xiaomi.com/mshopapi/index.php/v1/authorize/sso?client_id=180100031013&callback="+encodeuricomponent (w indow.location.href)})},,
Tobuygo: function (a) {
varb = это;
window.cleartimeout (b.timer),
B.Timer = null,
$ (b.modemodals [a]). Найти (".. MODAL_BTN"). Найти (". into_buy_btn"). On ("click", function (c) {c.preventdefault (), b.getdata (! 0, function () {
if ($ (b.modemodals [a]). css ("display", "block"), b.config.allow) if (b.config [a] .hdurl) {
varc = "http://t.hd.xiaomi.com/s/"+b.config [a] .hdurl+"& _m = 1";
window.settimeout (function () {window.location.href = c}, 500)
}еще{
vard = "http://p.www.xiaomi.com/m/activities/open/"+b.config.hdurl [a];
window.settimeout (function () {window.location.href = d}, 500)
} elseif (
b.config [a] .hdstart ===! 1 && b.config [a] .hdstop ===! 0) {
vard = "http://p.www.xiaomi.com/m/activities/open/"+b.config.hdurl [a];
window.settimeout (function () {window.location.href = d}, 500)
} else $ (b.modemodals [a]). find (".. modal_btn"). html ('<class = "re_enter" href = "javascript :;"> reent </a>'),
b.toprocess (а)
})})}};