Ce sont toutes des fonctions couramment utilisées, donc je ne parlerai pas beaucoup de bêtises ici. Amis, veuillez le lire vous-même.
Fournir le code:
La copie de code est la suivante:
// cookie
fonction setcookie (nom, valeur, iday)
{
if (iday! == false)
{
var odate = new Date ();
odate.setDate (odate.getDate () + iday);
document.cookie = name + '=' + valeur + '; expires =' + odate + '; path = /';
}
autre
{
document.cookie = name + '=' + valeur;
}
}
fonction getcookie (nom)
{
var arr = document.cookie.split (';');
var i = 0;
pour (i = 0; i <arr.length; i ++)
{
var arr2 = arr [i] .split ('=');
if (arr2 [0] == nom)
{
Retour Arr2 [1];
}
}
retour '';
}
Fonction RemoveCookie (nom)
{
setcookie (nom, 'a', -1);
}
//événement
fonction myAddevent (obj, ev, fn) {
obj.attachevent? obj.attachevent ('on' + ev, fn): obj.addeventListener (ev, fn, false);
}
fonction myDelevent (obj, ev, fn) {
obj.detachevent? obj.detachevent ('on' + ev, fn): obj.removeeventListener (ev, fn, false);
}
Fonction GetByClass (Oparent, Sclass)
{
var aele = oparent.getElementsByTagName ('*');
var re = new regexp ('// b' + sclass + '// b', 'i');
var aresult = [];
pour (var i = 0; i <aele.length; i ++)
{
if (re.test (aele [i] .classname)))
{
aresult.push (aele [i]);
}
}
retour Aresult;
}
Fonction BindEvent (obj, ev, fn)
{
obj.addeventListener? obj.addeventListener (ev, fn, false): obj.attachevent ('on' + ev, fn);
}
Fonction Unodouvent (OBJ, EV, FN)
{
obj.reMoveEventListener? Obj.RemoveEventListener (ev, fn, false): obj.detachevent ('on' + ev, fn);
}
// générer des nombres aléatoires
fonction rnd (n, m)
{
return math.random () * (mn) + n;
}
fonction Time2Date (t)
{
fonction d (n) {return n <10? '0' + n: '' + n;}
var odate = new Date (t * 1000);
return odate.getlyear () + '-' + d (odate.getMonth () + 1) + '-' + d (odate.getDate ()) + '' + d (odate.gethours ()) + ':' + d (odate.getMinutes ()) + ':' + d (odate.getMinutes ()) + ':' + d (odate.getSecds ());
}
Fonction Time2day (t)
{
fonction d (n) {return n <10? '0' + n: '' + n;}
var odate = new Date (t * 1000);
return odate.getlyar () + '-' + d (odate.getMonth () + 1) + '-' + d (odate.getDate ());
}
// traîner et glisser
Fonction Drag (Objev, Objmove, fnmoveCallback)
{
var disx = 0, disy = 0;
objev.onmousedown = fonction (ev)
{
var oevent = ev || événement;
disx = (document.documentElement.scrollleft || document.body.scrollleft) + oevent.clientx-objmove.offsetLeft;
disy = (document.documentElement.scrollTop || document.body.scrolltop) + oevent.clienty-objmove.offsetTop;
if (objev.setCapture)
{
objev.onmousemove = fnmove;
objev.onMouseUp = fnup;
objev.setCapture ();
}
autre
{
document.onMouseMove = fnmove;
document.onMouseUp = fnup;
retourne false;
}
};
fonction fnmove (ev)
{
var oevent = ev || événement;
var l = (document.DocumentElement.Scrollleft || document.body.scrollleft) + oevent.clientx-disx;
var t = (document.DocumentElement.ScrollTop || Document.Body.ScrollTop) + OEVENT.CLIENTY-DISY;
fnmoveCallback (l, t);
}
fonction fnup ()
{
this.onmousemove = null;
this.onmouseup = null;
if (this.releascapture) this.releSeleCapture ();
}
}
Fonction Moussescroll (OBJ, fncallback)
{
BINSEVENT (OBJ, «Mousewheel», fnscroll);
BINSEVENT (OBJ, «DOMMOUSECROLL», fnscroll);
fonction fnscroll (ev)
{
var oevent = ev || événement;
var bddown;
if (oevent.wheeldelta)
{
bdown = oevent.wheeldelta <0;
}
autre
{
bdown = oevent.detail> 0;
}
fncallback (bdown);
if (Oevent.PreventDefault) Oevent.PreventDefault ();
retourne false;
}
}
// Swing Movement
zns.site.fx.swing = fonction (obj, cur, cible, fnddo, fnend, acc)
{
if (zns.site.fx.browser_test.ie6)
{
fnddo && fnddo.call (obj, cible);
fnend && fnend.call (obj, cible);
retour;
}
if (! ACC) ACC = 0,1;
var maintenant = {};
var x = 0; // 0-100
if (! obj .__ swing_v) obj .__ swing_v = 0;
if (! Obj .__ Last_timer) Obj .__ Last_timer = 0;
var t = new Date (). getTime ();
if (t-obj .__ last_timer> 20)
{
fnmove ();
obj .__ last_timer = t;
}
ClearInterval (obj.timer);
obj.timer = setInterval (fnmove, 20);
fonction fnmove () {
si (x <50)
{
obj .__ swing_v + = acc;
}
autre
{
obj .__ swing_v- = acc;
}
//if(math.abs(obj.__flex_v)>max_speed)obj.__flex_v=obj.__flex_v>0?max_speed:-max_speed;
x + = obj .__ swing_v;
//alert(x+','+obj.__swing_v);
pour (var i dans cur)
{
maintenant [i] = (cible [i] -cur [i]) * x / 100 + cur [i];
}
if (fnddo) fnddo.call (obj, maintenant);
if (/ * math.abs (obj .__ swing_v) <1 || * / math.abs (100-x) <1)
{
ClearInterval (obj.timer);
if (fnend) fnend.call (obj, cible);
obj .__ swing_v = 0;
}
}
};
// mouvement élastique
zns.site.fx.flex = fonction (obj, cur, cible, fnddo, fnend, fs, ms)
{
if (zns.site.fx.browser_test.ie6)
{
fnddo && fnddo.call (obj, cible);
fnend && fnend.call (obj, cible);
retour;
}
var max_speed = 16;
if (! fs) fs = 6;
if (! ms) ms = 0,75;
var maintenant = {};
var x = 0; // 0-100
if (! obj .__ flex_v) obj .__ flex_v = 0;
if (! Obj .__ Last_timer) Obj .__ Last_timer = 0;
var t = new Date (). getTime ();
if (t-obj .__ last_timer> 20)
{
fnmove ();
obj .__ last_timer = t;
}
ClearInterval (obj.timer);
obj.timer = setInterval (fnmove, 20);
fonction fnmove () {
obj .__ flex_v + = (100-x) / fs;
obj .__ flex_v * = ms;
if (math.abs (obj .__ flex_v)> max_speed) obj .__ flex_v = obj .__ flex_v> 0? max_speed: -max_speed;
x + = obj .__ flex_v;
pour (var i dans cur)
{
maintenant [i] = (cible [i] -cur [i]) * x / 100 + cur [i];
}
if (fnddo) fnddo.call (obj, maintenant);
if (math.abs (obj .__ flex_v) <1 && math.abs (100-x) <1)
{
ClearInterval (obj.timer);
if (fnend) fnend.call (obj, cible);
obj .__ flex_v = 0;
}
}
};