Ce qui suit est le code JS lorsque Xiaomi se précipite à acheter.
La copie de code est la suivante:
hdControl ({"stime": 1381645438, "status": {"allow": false, "miphone": {"hdstart": false, "hdstop": false, "hdurl": "", "durée": null} , "mibox": {"hdstart": false, "hdstop": false, "hdurl": "", "durée": null}}})
La copie de code est la suivante:
fonction fornum (a) {
retour 10> a? "0" + a: a
}
Compte à rebours de la fonction (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? ["00 heures 00 minutes 00 secondes",! 0]: h> 0? (window._timestr = h + "day" + fornum (i [2]) + "time" + fornum (i [1 ]) + "minute" + fornum (i [0]) + "second", [h + "<span> jour </span>" + fornum (i [2]) + "<span> time </span>" + fornum (i [1]) + "<span> min </span>" + fornum (i [0]) + "<span> seconde </span>" ,! 1]) :( window._timestr = fornum (i [2]) + "time" + fornum (i [1]) + "minute" + fornum (i [0]) + "second", [fornum (i [2]) + "<span> / span > "+ fornum (i [1]) +" <span> min </span> "+ fornum (i [0]) +" <span> seconde </span> ",! 1])}
functionwebeventTrigger (a, b) {
essayer{
if (we && we.trigger)
return "String"! = typeofb && (b = json.stringify (b)), we.trigger (a, b)
} catch (c) {}
Retour! 1
}
functionisapp () {
essayer{
Si (nous) retourne! 0
} catch (a) {}
Retour! 1
}
varQuckBuy = {init: function () {
vara = this;
this.config = {},
this.config.hdurl = {miphone: "M3 / 840410D8656D74E5F334591BD8A408A726799AEC1347D90B5E48DAD36547351 / 4334F49A1EE391261005E8AC5A 20AB3F58343496FD4983D / TIP_SALEDOVERALL.HTML ", MIBOX:" TV / B1CF7B57BFEAE1EBC37700694C123D894C668BF11F6F25D59311 E926C5A9B7676E57BE3D47959D6557545E8A339 / 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;
pour (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.serververtime> = parseInt (this that (this) .config.startdate / 1e3,10)? $. Cookie ("xm_hd_so_phone") && $. Cookie ("xm_hd_so_box") || this.getData (! 0, fonction () {a.gobuy ()}): ce. : :::::::::::::::::::::::::::::::::::- :::::::::::::: lancé ()): this.getData ())}, getData: fonction (a, b) {
varc = this, a = a || null;
b && (b = b),
$ .ajax ({
URL: "http://tc.hd.xiaomi.com/hdget",
type de données: "JSONP",
JSONPCallback: "hdControl",
Timeout: 7e3,
beforesend: function () {
c.maskload.css ("affichage", "bloc")},
error: function () {
c.maskload.css ("affichage", "aucun"),
alerte ("Le serveur est sous une grande pression, veuillez actualiser la page!")
},
Succès: fonction (d) {
if (c.maskload.css ("affichage", "aucun"), "Undefined" == typeofd)
returnlert ("Le serveur est sous une grande pression, veuillez actualiser la page!"),
void0;
if (c.Results = d, a || (c.config.servertime = c.results.stime) ,! $. Cookie ("xm_diff_hd")) {
Vare = paSeInt (C.Config.ServerTime-C.LocalTime (), 10);
$ .cookie ("xm_diff_hd", e, {
chemin:"/",
domaine: ". xiaomi.com",
Expire: 1
})
}
if (a) {
C.InitialData ();
pour (varfinc.mode)
if (c.config [f] .hdstart ===! 1 && c.config [f] .hdstop ===! 0) {
varg = c.ModeCookies [f];
$ .cookie (g, 1, {chemin: "/", domaine: ". xiaomi.com", expire: 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
},
lancement: function () {
this.timestart (),
this.CountDown ()
},
timestart: function () {
Vara = ceci,
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 ("Visibilité", "Hidden"),
$ ("# achat_btn_1") .html ('<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1-1.html"> Détails de l'activité </a>'),
$ ("# achat_btn_2"). html ('<class = "btn_buybtn_02" href = "javascript :;"> login </a>')): a.tologin (): b> = c && a.tobuy ()
},
tologin: function () {
$ ("# View_button"). CSS ("Visibilité", "Hidden"),
$ ("# achat_btn_1") .html ('<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1-1.html"> Détails de l'activité </a>'),
$ ("# achat_btn_2"). html ('<aclass = "btn_buybtn_02" href = "javascript :;"> Connexion à l'avance </a>'),
$ ("# achat_btn_2"). trouver (". btn_02"). sur ("cliquez", fonction () {
WebEventTrigger ("Login", null) || (window.location.href = "http://m.xiaomi.com/mshopapi/index.php/v1/authorize/sso?client_id=180100031013&c allback =" + EncodeuRICono Emplacement de Href))}
)},
Countdown: function () {
Vara = ceci,
b = nul,
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 = compte à rebours (b, c);
f [1]? (ClearInterval (e), $ ("# Countdown"). CSS ("Affichage", "Aucun"), a.tobuy ()) :( 1E3 * B! = D || ISAPP () | | ($. Cookie ("userId")? ($ ("# View_Button"). CSS ("Visibilité", "Hidden"),
$ ("# achat_btn_1") .html ('<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1-1.html"> Détails de l'activité </a>'),
$ ("# achat_btn_2"). html ('<aclass = "btn_buy" href = "javascript :;"> login </a>')): a.tologin ()), b ++),
$ ("# Countdown"). html (f [0])}, 1e3)},
tobuy: function () {
vara = this;
a.gobuy ();
varb = a.ModeModals [a.config.mode];
$ (b) .find (". close"). sur ("cliquez", fonction () {
$ (b) .css ("affichage", "aucun"),
window.cleartimeout (a.timer),
a.timer = null})},
Saleout: function () {
vara = {miphone: "# achat_btn_2", mibox: "# achat_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: "Payer xiaomi mobile 3", mibox: "payer xiaomi tv"};
pour (vardinthis.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]). trouver (". Close"). Click ())},
localtime: function () {
vara = parseInt (+ newdate / 1e3,10);
retournera
},
toprocess: fonction (a) {
varb = ceci,
c = b.timer,
d = b.timeCount || 10, e = $ (b.ModeModals [a]). trouver (". re_countown"),
f = $ (b.ModeModals [a]). trouver (". modal_btn"),
g = function () {0 == d? (f.html ('<aclass = "int_buy_btn" href = "javascript :;"> Entrez l'activité </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 = ceci,
b = {miphone: "acheter xiaomi mobile 3", mibox: "acheter xiaomi tv"},
c = {miphone: "# achat_btn_2", mibox: "# achat_btn_1"};
pour (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 ("affiche", "bloc"));
$ ("# open_button"). trouver (". btn_buy_go"). sur ("cliquez", function () {a.Mode [$ (this) .attr ("data-type")] =! 0;
varb = a.config.mode = $ (this) .attr ("data-type");
if ($. cookie ("userId")) a.getData (! 0, function () {
$ (a.Modemodals [b]). CSS ("affichage", "bloc"),
$ (a.ModeModals [b]). trouver (". Close"). sur ("cliquez", fonction () {
$ (a.ModeModals [b]). CSS ("Affichage", "Aucun"), 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: fonction (a) {
varb = this;
window.cleartimeout (b.timer),
b.timer = null,
$ (b.ModeModals [a]). trouver (". modal_btn"). trouver (". Into_buy_btn"). sur ("cliquez", fonction (c) {c.preventDefault (), B.GetData (! 0, fonction(){
if ($ (b.ModeModals [a]). css ("afficher", "bloc"), 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)
}autre{
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]). trouver (". modal_btn"). html ('<class = "re_enter" href = "javascript :;"> reent </a>'),
B.Toprocess (a)
})})}};