Accueil > > > SIMPLEJS : LIBRAIRIE AJAX COMBINÉE À DES EFFETS VISUELS.
SIMPLEJS : LIBRAIRIE AJAX COMBINÉE À DES EFFETS VISUELS.
Information sur la source
Description
Pour 10ko, vous avez une librairie de fonctions faciles pour afficher des pages via Ajax avec des effets visuels du genre de Script.aculo.us. Bien qu'en beta , aucuns bugs signalés, pourtant je suis certains qu'il y a moyen d'améliorer le code, car le javascript n'est pas ma spécialité. Le formatage (pres d'un tier du poids!) a été volontairement supprimmé, en fait elle est compressée. J'assayerai de retrouver mon code formaté si nécessaire. J'ai créer cette librairie afin de pouvoir utiliser rapidement mes fonctions préférées de Scipt.aculo.us, sans devoir charger les plus de 100 ko nécéssaires. Néamoins, c'est pas du tout basé sur prototype. Par contre, elle reprend le code de Sack qui me semble parfait. N'hésitez pas à faire des commentaires constructifs car j'ai l'intention de continuer ce projet d'ici 2-3 mois. J'attendais que l'on me signale des bugs, mais au lieu de ça, on me demande sans cesse de l'aide pour des raisons ridicules (marche pas en HTML 4.0, Ajax sans serveur,...). vous pouvez vous rendre sur cette page: http://simplejs.bleebot.com/ pour la voir en action, optenir les infos sur l'utilisation et télécharger le script avec ces plug-ins
Source
- /*
- SimpleJS ver 0.02 beta
- ----------------------
- SimpleJS is developed by Christophe "Dyo" Lefevre (http://bleebot.com/)
-
- $ajax function is based on Simple AJAX Code-Kit (SACK)
- Gregory Wild-Smith (http://www.twilightuniverse.com/)
- */
- var enableCache = true;
- var jsCache = new Array();
- var DynObj = new Array();
- function $ajax(file) {
- this.xmlhttp = null;
- this.resetData = function() {
- this.method = "POST";
- this.queryStringSeparator = "?";
- this.argumentSeparator = "&";
- this.URLString = "";
- this.encodeURIString = true;
- this.execute = false;
- this.element = null;
- this.elementObj = null;
- this.requestFile = file;
- this.vars = new Object();
- this.responseStatus = new Array(2);
- }
- ;
- this.resetFunctions = function() {
- this.onLoading = function() {
- }
- ;
- this.onLoaded = function() {
- }
- ;
- this.onInteractive = function() {
- }
- ;
- this.onCompletion = function() {
- }
- ;
- this.onError = function() {
- }
- ;
- this.onFail = function() {
- }
- ;
- }
- ;
- this.reset = function() {
- this.resetFunctions();
- this.resetData();
- }
- ;
- this.crAjx = function() {
- try {
- this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (e1) {
- try {
- this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- catch (e2) {
- this.xmlhttp = null;
- }
- }
- if (! this.xmlhttp) {
- if (typeof XMLHttpRequest != "undefined") {
- this.xmlhttp = new XMLHttpRequest();
- }
- else {
- this.failed = true;
- }
- }
- }
- ;
- this.setVar = function(name, value) {
- this.vars[name] = Array(value, false);
- }
- ;
- this.encVar = function(name, value, returnvars) {
- if (true == returnvars) {
- return Array(encodeURIComponent(name), encodeURIComponent(value));
- }
- else {
- this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
- }
- }
- this.processURLString = function(string, encode) {
- encoded = encodeURIComponent(this.argumentSeparator);
- regexp = new RegExp(this.argumentSeparator + "|" + encoded);
- varArray = string.split(regexp);
- for (i = 0; i < varArray.length; i++) {
- urlVars = varArray[i].split("=");
- if (true == encode) {
- this.encVar(urlVars[0], urlVars[1]);
- }
- else {
- this.setVar(urlVars[0], urlVars[1]);
- }
- }
- }
- this.createURLString = function(urlstring) {
- if (this.encodeURIString && this.URLString.length) {
- this.processURLString(this.URLString, true);
- }
- if (urlstring) {
- if (this.URLString.length) {
- this.URLString += this.argumentSeparator + urlstring;
- }
- else {
- this.URLString = urlstring;
- }
- }
- // prevents caching of URLString
- this.setVar("rndval", new Date().getTime());
- urlstringtemp = new Array();
- for (key in this.vars) {
- if (false == this.vars[key][1] && true == this.encodeURIString) {
- encoded = this.encVar(key, this.vars[key][0], true);
- delete this.vars[key];
- this.vars[encoded[0]] = Array(encoded[1], true);
- key = encoded[0];
- }
- urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
- }
- if (urlstring) {
- this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
- }
- else {
- this.URLString += urlstringtemp.join(this.argumentSeparator);
- }
- }
- this.runResponse = function() {
- eval(this.response);
- }
- this.runAJAX = function(urlstring) {
- if (this.failed) {
- this.onFail();
- }
- else {
- this.createURLString(urlstring);
- if (this.element) {
- this.elementObj = $(this.element);
- }
- if (this.xmlhttp) {
- var self = this;
- if (this.method == "GET") {
- totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
- this.xmlhttp.open(this.method, totalurlstring, true);
- }
- else {
- this.xmlhttp.open(this.method, this.requestFile, true);
- try {
- this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") }
- catch (e) {
- }
- }
- this.xmlhttp.onreadystatechange = function() {
- switch (self.xmlhttp.readyState) {
- case 1 : self.onLoading();
- break;
- case 2 : self.onLoaded();
- break;
- case 3 : self.onInteractive();
- break;
- case 4 : self.response = self.xmlhttp.responseText;
- self.responseXML = self.xmlhttp.responseXML;
- self.responseStatus[0] = self.xmlhttp.status;
- self.responseStatus[1] = self.xmlhttp.statusText;
- if (self.execute) {
- self.runResponse();
- }
- if (self.elementObj) {
- elemNodeName = self.elementObj.nodeName;
- elemNodeName.toLowerCase();
- if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea") {
- self.elementObj.value = self.response;
- }
- else {
- self.elementObj.innerHTML = self.response;
- }
- }
- if (self.responseStatus[0] == "200") {
- self.onCompletion();
- }
- else {
- self.onError();
- }
- self.URLString = "";
- break;
- }
- }
- ;
- this.xmlhttp.send(this.URLString);
- }
- }
- }
- ;
- this.reset();
- this.crAjx();
- }
- function ajax_installScript(script) {
- if (!script) return;
- if (window.execScript) {
- window.execScript(script);
- }
- else if(window.jQuery && jQuery.browser.safari) {
- STO(script, 0);
- }
- else {
- STO( script, 0 );
- }
- }
- function $ajax_show(divId, Aorj, url, loader, effect) {
- if (effect == 'appear') $opacity(divId, 0, 101, 600);
- if (effect == 'highlight') $highlight(divId);
- var targetObj = $(divId);
- targetObj.innerHTML = DynObj[Aorj].response;
- if (effect == 'blind') {
- $(divId).style.position = '';
- $blinddown(divId);
- }
- if(enableCache) {
- jsCache[url] = DynObj[Aorj].response;
- }
- DynObj[Aorj] = false;
- ajax_parseJs(targetObj) }
- function $ajaxreplace(divId, url) {
- $opacity(divId, 100, 0, 400);
- $(divId).style.height = '';
- scr = "$ajaxload('" + divId + "','" + url + "',false,'appear',false)";
- STO(scr, 400);
- }
- function $ajaxload(divId, url, loader, effect, ecache) {
- if (effect == 'appear') changeOpac(0, divId);
- if (effect == 'blind') {
- var ids = $(divId).style;
- ids.overflow = 'hidden';
- ids.display = 'block';
- ids.height = '0px';
- }
- if (ecache) {
- if(enableCache && jsCache[url]) {
- if (effect == 'appear') $opacity(divId, 0, 101, 600);
- if (effect == 'highlight') $highlight(divId);
- $(divId).innerHTML = jsCache[url];
- if (effect == 'blind') {
- $(divId).style.position = '';
- $blinddown(divId);
- }
- return;
- }
- }
- var Aorj = DynObj.length;
- if (loader != false) $(divId).innerHTML = loader;
- DynObj[Aorj] = new $ajax();
- DynObj[Aorj].requestFile = url;
- DynObj[Aorj].onCompletion = function() {
- $ajax_show(divId, Aorj, url, loader, effect);
- }
- ;
- DynObj[Aorj].runAJAX();
- }
- function ajax_parseJs(obj) {
- var scriptTags = obj.getElementsByTagName('SCRIPT');
- var string = '';
- var jsCode = '';
- for(var no = 0; no < scriptTags.length; no++) {
- if(scriptTags[no].src) {
- var head = document.getElementsByTagName("head")[0];
- var scriptObj = document.createElement("script");
- scriptObj.setAttribute("type", "text/javascript");
- scriptObj.setAttribute("src", scriptTags[no].src);
- }
- else {
- if(DHTMLSuite.clientInfoObj.isOpera) {
- jsCode = jsCode + scriptTags[no].text + '\n';
- }
- else jsCode = jsCode + scriptTags[no].innerHTML;
- }
- }
- if(jsCode)ajax_installScript(jsCode);
- }
- //generic fonctions
- function $(id) {
- return document.getElementById(id);
- }
- function STO(func,time) {
- return window.setTimeout(func,time);
- }
- function DecToHexa(DecNb) {
- var digits = parseInt(DecNb).toString(16);
- if (DecNb < 16) digits = '0' + digits;
- return digits;
- }
- function addslashes(str) {
- str = str.replace(/\"/g,"\\\"");
- str = str.replace(/\'/g,"\\\'");
- return str;
- }
- //blinds effects
- function $toggle(id) {
- if (act_height(id) == 0) $blinddown(id);
- else $blindup(id);
- }
- function act_height(id) {
- height = $(id).clientHeight;
- if(height == 0) height = $(id).offsetHeight;
- return height;
- }
- function act_width(id) {
- width = $(id).clientWidth;
- if(width == 0) width = $(id).offsetWidth;
- return width;
- }
- function max_height(id) {
- var ids = $(id).style;
- ids.overflow = 'hidden';
- if (act_height(id)!=0) return act_height(id);
- else
- {
- origdisp = ids.display;
- origheight = ids.height;
- origpos = ids.position;
- origvis = ids.visibility;
- ids.visibility = 'hidden';
- ids.height = '';
- ids.display = 'block';
- ids.position = 'absolute';
- height = act_height(id);
- ids.display = origdisp;
- ids.height = origheight;
- ids.position = origpos;
- ids.visibility = origvis;
- return height;
- }
- }
- function $blindup(id, time) {
- if (!time)time = 200;
- acth = act_height(id);
- maxh = max_height(id);
- if (acth == maxh) {
- $(id).style.display = 'block';
- var steps;
- steps = Math.ceil(time / acth);
- for(i = 0; i <= acth; i++) {
- newh = acth - i;
- STO("$('" + id + "').style.height='" + newh + "px'", steps * i);
- }
- }
- }
- function $blinddown(id, time) {
- if (!time)time = 200;
- acth = act_height(id);
- if (acth == 0) {
- maxh = max_height(id);
- $(id).style.display = 'block';
- $(id).style.height = '0px';
- var steps;
- steps = Math.ceil(time / maxh);
- for(i = 1; i <= maxh; i++) {
- STO("$('" + id + "').style.height='" + i + "px'", steps * i);
- }
- }
- }
- //$opacity effects
- function $opacity(id, opacStart, opacEnd, time) {
- if($(id).style.width==0) $(id).style.width=act_width(id);
- var speed = Math.round(time / 100);
- var timer = 0;
- if(opacStart > opacEnd) {
- for(i = opacStart; i >= opacEnd; i--) {
- STO("changeOpac(" + i + ",'" + id + "')", (timer * speed));
- timer++;
- }
- }
- else if(opacStart < opacEnd) {
- for(i = opacStart; i <= opacEnd; i++) {
- STO("changeOpac(" + i + ",'" + id + "')", (timer * speed));
- timer++;
- }
- }
- }
- function changeOpac(opacity, id) {
- var ids = $(id).style;
- ids.opacity = (opacity / 100);
- ids.MozOpacity = (opacity / 100);
- ids.KhtmlOpacity = (opacity / 100);
- ids.filter = "alpha(opacity=" + opacity + ")";
- }
- function $shiftOpacity(id, time) {
- if($(id).style.opacity < 0.50) {
- $opacity(id, 0, 100, time);
- }
- else {
- $opacity(id, 100, 0, time);
- }
- }
- function currentOpac(id, opacEnd, time) {
- var currentOpac = 100;
- if($(id).style.opacity < 100) {
- currentOpac = $(id).style.opacity * 100;
- }
- $opacity(id, currentOpac, opacEnd, time)}
- //$colorize effects
- function $highlight(id, time, ncol, hcol) {
- if(time) milli = time;
- else milli = 900;
- if(ncol) endcol = ncol;
- else endcol = '#FFFFFF';
- if(hcol) origcol = hcol;
- else origcol = '#FFFFA6';
- $colorize(origcol, endcol, id, milli, 'high');
- }
- function $textColor(id, startcol, endcol, time) {
- if(time) milli = time;
- else milli = 900;
- $colorize(startcol, endcol, id, milli, 'text');
- }
- function $morphColor(id, starttextcol, endtextcol, startbackcol, endbackcol, startbordercol, endbordercol, time) {
- if(time) milli = time;
- else milli = 900;
- $colorize(starttextcol, endtextcol, id, milli, 'text');
- $colorize(startbackcol, endbackcol, id, milli, 'back');
- if (startbordercol != false) $colorize(startbordercol, endbordercol, id, milli, 'border');
- }
- function $colorize(start, end, id, time, elem) {
- dr = parseInt(start.substring(1, 3), 16);
- dg = parseInt(start.substring(3, 5), 16);
- db = parseInt(start.substring(5, 7), 16);
- fr = parseInt(end.substring(1, 3), 16);
- fg = parseInt(end.substring(3, 5), 16);
- fb = parseInt(end.substring(5, 7), 16);
- steps = time / 10;
- cr = dr;
- cg = dg;
- cb = db;
- sr = (fr - dr) / steps;
- sg = (fg - dg) / steps;
- sb = (fb - db) / steps;
- var zzi = 10;
- for (var x = 0; x < steps; x++) {
- color = '#' + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb);
- if (x==(steps-1)) {
- if (elem == "high") color='';
- else color=end;
- }
- mytime = (x);
- if (elem == "back" || elem == "high")
- newfonc = '$("' + id + '").style.backgroundColor="' + color + '";';
- else if (elem == "text")
- newfonc = '$("' + id + '").style.color="' + color + '";';
- else if (elem == "border")
- newfonc = '$("' + id + '").style.borderColor="' + color + '";';
- STO(newfonc, zzi);
- cr += sr;
- cg += sg;
- cb += sb;
- zzi += 10;
- }
- }
/*
SimpleJS ver 0.02 beta
----------------------
SimpleJS is developed by Christophe "Dyo" Lefevre (http://bleebot.com/)
$ajax function is based on Simple AJAX Code-Kit (SACK)
Gregory Wild-Smith (http://www.twilightuniverse.com/)
*/
var enableCache = true;
var jsCache = new Array();
var DynObj = new Array();
function $ajax(file) {
this.xmlhttp = null;
this.resetData = function() {
this.method = "POST";
this.queryStringSeparator = "?";
this.argumentSeparator = "&";
this.URLString = "";
this.encodeURIString = true;
this.execute = false;
this.element = null;
this.elementObj = null;
this.requestFile = file;
this.vars = new Object();
this.responseStatus = new Array(2);
}
;
this.resetFunctions = function() {
this.onLoading = function() {
}
;
this.onLoaded = function() {
}
;
this.onInteractive = function() {
}
;
this.onCompletion = function() {
}
;
this.onError = function() {
}
;
this.onFail = function() {
}
;
}
;
this.reset = function() {
this.resetFunctions();
this.resetData();
}
;
this.crAjx = function() {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2) {
this.xmlhttp = null;
}
}
if (! this.xmlhttp) {
if (typeof XMLHttpRequest != "undefined") {
this.xmlhttp = new XMLHttpRequest();
}
else {
this.failed = true;
}
}
}
;
this.setVar = function(name, value) {
this.vars[name] = Array(value, false);
}
;
this.encVar = function(name, value, returnvars) {
if (true == returnvars) {
return Array(encodeURIComponent(name), encodeURIComponent(value));
}
else {
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
}
}
this.processURLString = function(string, encode) {
encoded = encodeURIComponent(this.argumentSeparator);
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
varArray = string.split(regexp);
for (i = 0; i < varArray.length; i++) {
urlVars = varArray[i].split("=");
if (true == encode) {
this.encVar(urlVars[0], urlVars[1]);
}
else {
this.setVar(urlVars[0], urlVars[1]);
}
}
}
this.createURLString = function(urlstring) {
if (this.encodeURIString && this.URLString.length) {
this.processURLString(this.URLString, true);
}
if (urlstring) {
if (this.URLString.length) {
this.URLString += this.argumentSeparator + urlstring;
}
else {
this.URLString = urlstring;
}
}
// prevents caching of URLString
this.setVar("rndval", new Date().getTime());
urlstringtemp = new Array();
for (key in this.vars) {
if (false == this.vars[key][1] && true == this.encodeURIString) {
encoded = this.encVar(key, this.vars[key][0], true);
delete this.vars[key];
this.vars[encoded[0]] = Array(encoded[1], true);
key = encoded[0];
}
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
}
if (urlstring) {
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
}
else {
this.URLString += urlstringtemp.join(this.argumentSeparator);
}
}
this.runResponse = function() {
eval(this.response);
}
this.runAJAX = function(urlstring) {
if (this.failed) {
this.onFail();
}
else {
this.createURLString(urlstring);
if (this.element) {
this.elementObj = $(this.element);
}
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
}
else {
this.xmlhttp.open(this.method, this.requestFile, true);
try {
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") }
catch (e) {
}
}
this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState) {
case 1 : self.onLoading();
break;
case 2 : self.onLoaded();
break;
case 3 : self.onInteractive();
break;
case 4 : self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
if (self.execute) {
self.runResponse();
}
if (self.elementObj) {
elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea") {
self.elementObj.value = self.response;
}
else {
self.elementObj.innerHTML = self.response;
}
}
if (self.responseStatus[0] == "200") {
self.onCompletion();
}
else {
self.onError();
}
self.URLString = "";
break;
}
}
;
this.xmlhttp.send(this.URLString);
}
}
}
;
this.reset();
this.crAjx();
}
function ajax_installScript(script) {
if (!script) return;
if (window.execScript) {
window.execScript(script);
}
else if(window.jQuery && jQuery.browser.safari) {
STO(script, 0);
}
else {
STO( script, 0 );
}
}
function $ajax_show(divId, Aorj, url, loader, effect) {
if (effect == 'appear') $opacity(divId, 0, 101, 600);
if (effect == 'highlight') $highlight(divId);
var targetObj = $(divId);
targetObj.innerHTML = DynObj[Aorj].response;
if (effect == 'blind') {
$(divId).style.position = '';
$blinddown(divId);
}
if(enableCache) {
jsCache[url] = DynObj[Aorj].response;
}
DynObj[Aorj] = false;
ajax_parseJs(targetObj) }
function $ajaxreplace(divId, url) {
$opacity(divId, 100, 0, 400);
$(divId).style.height = '';
scr = "$ajaxload('" + divId + "','" + url + "',false,'appear',false)";
STO(scr, 400);
}
function $ajaxload(divId, url, loader, effect, ecache) {
if (effect == 'appear') changeOpac(0, divId);
if (effect == 'blind') {
var ids = $(divId).style;
ids.overflow = 'hidden';
ids.display = 'block';
ids.height = '0px';
}
if (ecache) {
if(enableCache && jsCache[url]) {
if (effect == 'appear') $opacity(divId, 0, 101, 600);
if (effect == 'highlight') $highlight(divId);
$(divId).innerHTML = jsCache[url];
if (effect == 'blind') {
$(divId).style.position = '';
$blinddown(divId);
}
return;
}
}
var Aorj = DynObj.length;
if (loader != false) $(divId).innerHTML = loader;
DynObj[Aorj] = new $ajax();
DynObj[Aorj].requestFile = url;
DynObj[Aorj].onCompletion = function() {
$ajax_show(divId, Aorj, url, loader, effect);
}
;
DynObj[Aorj].runAJAX();
}
function ajax_parseJs(obj) {
var scriptTags = obj.getElementsByTagName('SCRIPT');
var string = '';
var jsCode = '';
for(var no = 0; no < scriptTags.length; no++) {
if(scriptTags[no].src) {
var head = document.getElementsByTagName("head")[0];
var scriptObj = document.createElement("script");
scriptObj.setAttribute("type", "text/javascript");
scriptObj.setAttribute("src", scriptTags[no].src);
}
else {
if(DHTMLSuite.clientInfoObj.isOpera) {
jsCode = jsCode + scriptTags[no].text + '\n';
}
else jsCode = jsCode + scriptTags[no].innerHTML;
}
}
if(jsCode)ajax_installScript(jsCode);
}
//generic fonctions
function $(id) {
return document.getElementById(id);
}
function STO(func,time) {
return window.setTimeout(func,time);
}
function DecToHexa(DecNb) {
var digits = parseInt(DecNb).toString(16);
if (DecNb < 16) digits = '0' + digits;
return digits;
}
function addslashes(str) {
str = str.replace(/\"/g,"\\\"");
str = str.replace(/\'/g,"\\\'");
return str;
}
//blinds effects
function $toggle(id) {
if (act_height(id) == 0) $blinddown(id);
else $blindup(id);
}
function act_height(id) {
height = $(id).clientHeight;
if(height == 0) height = $(id).offsetHeight;
return height;
}
function act_width(id) {
width = $(id).clientWidth;
if(width == 0) width = $(id).offsetWidth;
return width;
}
function max_height(id) {
var ids = $(id).style;
ids.overflow = 'hidden';
if (act_height(id)!=0) return act_height(id);
else
{
origdisp = ids.display;
origheight = ids.height;
origpos = ids.position;
origvis = ids.visibility;
ids.visibility = 'hidden';
ids.height = '';
ids.display = 'block';
ids.position = 'absolute';
height = act_height(id);
ids.display = origdisp;
ids.height = origheight;
ids.position = origpos;
ids.visibility = origvis;
return height;
}
}
function $blindup(id, time) {
if (!time)time = 200;
acth = act_height(id);
maxh = max_height(id);
if (acth == maxh) {
$(id).style.display = 'block';
var steps;
steps = Math.ceil(time / acth);
for(i = 0; i <= acth; i++) {
newh = acth - i;
STO("$('" + id + "').style.height='" + newh + "px'", steps * i);
}
}
}
function $blinddown(id, time) {
if (!time)time = 200;
acth = act_height(id);
if (acth == 0) {
maxh = max_height(id);
$(id).style.display = 'block';
$(id).style.height = '0px';
var steps;
steps = Math.ceil(time / maxh);
for(i = 1; i <= maxh; i++) {
STO("$('" + id + "').style.height='" + i + "px'", steps * i);
}
}
}
//$opacity effects
function $opacity(id, opacStart, opacEnd, time) {
if($(id).style.width==0) $(id).style.width=act_width(id);
var speed = Math.round(time / 100);
var timer = 0;
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
STO("changeOpac(" + i + ",'" + id + "')", (timer * speed));
timer++;
}
}
else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++) {
STO("changeOpac(" + i + ",'" + id + "')", (timer * speed));
timer++;
}
}
}
function changeOpac(opacity, id) {
var ids = $(id).style;
ids.opacity = (opacity / 100);
ids.MozOpacity = (opacity / 100);
ids.KhtmlOpacity = (opacity / 100);
ids.filter = "alpha(opacity=" + opacity + ")";
}
function $shiftOpacity(id, time) {
if($(id).style.opacity < 0.50) {
$opacity(id, 0, 100, time);
}
else {
$opacity(id, 100, 0, time);
}
}
function currentOpac(id, opacEnd, time) {
var currentOpac = 100;
if($(id).style.opacity < 100) {
currentOpac = $(id).style.opacity * 100;
}
$opacity(id, currentOpac, opacEnd, time)}
//$colorize effects
function $highlight(id, time, ncol, hcol) {
if(time) milli = time;
else milli = 900;
if(ncol) endcol = ncol;
else endcol = '#FFFFFF';
if(hcol) origcol = hcol;
else origcol = '#FFFFA6';
$colorize(origcol, endcol, id, milli, 'high');
}
function $textColor(id, startcol, endcol, time) {
if(time) milli = time;
else milli = 900;
$colorize(startcol, endcol, id, milli, 'text');
}
function $morphColor(id, starttextcol, endtextcol, startbackcol, endbackcol, startbordercol, endbordercol, time) {
if(time) milli = time;
else milli = 900;
$colorize(starttextcol, endtextcol, id, milli, 'text');
$colorize(startbackcol, endbackcol, id, milli, 'back');
if (startbordercol != false) $colorize(startbordercol, endbordercol, id, milli, 'border');
}
function $colorize(start, end, id, time, elem) {
dr = parseInt(start.substring(1, 3), 16);
dg = parseInt(start.substring(3, 5), 16);
db = parseInt(start.substring(5, 7), 16);
fr = parseInt(end.substring(1, 3), 16);
fg = parseInt(end.substring(3, 5), 16);
fb = parseInt(end.substring(5, 7), 16);
steps = time / 10;
cr = dr;
cg = dg;
cb = db;
sr = (fr - dr) / steps;
sg = (fg - dg) / steps;
sb = (fb - db) / steps;
var zzi = 10;
for (var x = 0; x < steps; x++) {
color = '#' + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb);
if (x==(steps-1)) {
if (elem == "high") color='';
else color=end;
}
mytime = (x);
if (elem == "back" || elem == "high")
newfonc = '$("' + id + '").style.backgroundColor="' + color + '";';
else if (elem == "text")
newfonc = '$("' + id + '").style.color="' + color + '";';
else if (elem == "border")
newfonc = '$("' + id + '").style.borderColor="' + color + '";';
STO(newfonc, zzi);
cr += sr;
cg += sg;
cb += sb;
zzi += 10;
}
}
Conclusion
Ne me dite pas "elle n'est pas commentée", je sais, j'avais pas prévu de la placer ici. C'est d'ailleurs ma première source
Historique
- 16 janvier 2007 00:34:17 :
- amusez vous
- 19 janvier 2007 20:26:23 :
- j'ai remplacé par ma version non compressée (ou décryptée si vous voulez)
- 21 janvier 2007 16:06:34 :
- remise en état de la function $(id)
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Prototype periodicalUpdater et Internet explorer ! [ par monoski ]
Voilà j'ai plusieurs valeurs à actualiser j'utilise donc prototype.js et la fonction Ajax.PeriodicalUpdater. Voici le code : [code=js] new Ajax.Perio
Champs texte et liste déroulanteliés par ajax [ par shonguiz0 ]
Bonjour, je ne suis pas du tout familier avec le langage ajax ( et donc js aussi) mais voilà on m'a fait comprendre que pour mon problème, ajax est
responseText ne renvoi rien [ par Orel88 ]
Bonjour, J'étais en train de faire un bout de code ajax pour incrémenter une base de donnée lors d'un clic d'utilisateur mais mon responseText ne ren
Calcul dans un formulaire [ par lacigale69 ]
Bonjour, j'ai crée dans [u]PDF Converter Entreprise 6.0[/u], un formulaire tres simple. Je souhaite trouver le moyen de calculer une multiplication.
Tres Urgent cherche un Formulaire avec les controle d'Ajax suivant [ par ikbel1992 ]
Salut à tous C'est une affaire hyper urgente j'ai que 2 journée pour résoudre ce probléme . Je veux créer un Formulaire avec les Controle de saisie s
Modélisation file d'attente de commande avec html/ajax/mysql [ par soumsoumdu06 ]
Salut à tous, je souhaiterai développer une file de commande (FIFO premier entré, premier sorti). J'ai une table Mysql (ID++(n°commande)|Date|Nom|Prén
Besoin d'aide pour une prob javascript très simple ! [ par hellworld ]
Bonjour, J'ai trouvé un bout de code permettant de changer de photo sans recharger la page en cliquant sur une miniature. Voici un lien sur un exemp
Image.prototype.MaMethode [ par paillekane ]
Bonjour à tous, Voilà je cherche à ajouter des propriétés et méthodes à l'objet Image. Voici un bout de code : [code=js]//Ajout de propriétés et méth
affichage dynamique d'une base de données avec ajax/php [ par cyrilherve ]
salut à tous, je suis debutant en ajax, et mon soucis est le suivant: sur la meme page j ai deux div. le premier doit etre visible et contient un cha
Probleme Envoi Mail Ajax [ par olivier93612 ]
Bonjour, j'ai suivi ce tuto : http://www.javascriptfr.com/codes/ENVOI-FORMULAIRE-AVEC-AJAX_41732.aspx Mais je ne reçois aucun mail alors que le messag
|
Derniers Blogs
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|