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
javascript dans formulaire acrobat [ par domi ]
"Envoie par mèl du contenu du formulaire"j'ai écrit deux lignes simple en javascript dans un formulaire acrobat, il fonctionne bien avec Acrobat "prog
recherche aide [ par g2m ]
nouveau dans la création de site, je bute sur une chose simple, créer un menu déroulant horizontale avec survol.Un truc simple quoi!Dans cette barre 8
différents effets sur les liens d'une meme page [ par geoffroy ]
Salut, J'aimerais savoir comment fait on pour qu'un lien devienne plus gros au survolage de la souris . Mais j'aimerais que cet effet ne marche que su
c'est simple comme bonjour mais je ne me raplle plus... [ par escaflone1 ]
Bonjour,comme je le di je ne sais plus comment on fait pour actualiser une page mais juste une seul fois:la page charger puis 1 voir 2 sec apres hop i
tout simple [ par pierre81 ]
je débute et je voudrez savoir comment on fait pour dire que quand on clique sur la frame de gauche , je veux afficher un truc a droite merci de me do
Formulaire tout simple [ par Angel42480 ]
Bonjour, je travail en html,Je désirerais créer un formulaire, qui définisse une image.Exemple : on tape dans la case du formulaire : "arbre" . Je veu
Supprimer menubar [ par meka ]
Bonjour,Voilà, je m'enlise sur un truc simple depuis 4 jours !j' explique : j'aimerais faire disparaitre le menubar ( Menus : fichier-edition-affichag
truc surement tres simple mais bon... [ par bipross ]
Bonjour,Voici mon souci :....var nbJ = nb_jour(l,laDate); //retourne 24 par exempleif (nbJ > 31){toto = 1;}else{toto = 2;}et j'obtiens l'erreur "ob
Afficher une popup [ par BsEtZeOpLhD ]
Bonjour.Je cherche un code pour afficher une simple popup à l'affichage d'une fenetre. Une popup affichant une page web (http://perso.wanadoo.fr/bsetz
contenu d'un textarea dans des 'input text' [ par SauCisS ]
Bonjour a tousMon problème est simple, peut-t-on me dire comment faire pour mettre le contenu d'une zone de texte (texarea) dans des zones de texte si
|
Derniers Blogs
TECHDAYS PARIS 2010 : SHAREPOINT 2010 POUR LES DéVELOPPEURSTECHDAYS PARIS 2010 : SHAREPOINT 2010 POUR LES DéVELOPPEURS par ROMELARD Fabrice
Animé par: Laurent Cotton Le développement dans SharePoint 2010 passe par plusieurs axes qui seront évoqués dans cette session, mais plus particulièrement les développements simples lié au besoin Business Business Connectivity Services Ce BCS es...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLEINIèRE DERNIER JOURTECHDAYS PARIS 2010 : PLEINIèRE DERNIER JOUR par ROMELARD Fabrice
Cette session est la dernière pleinière de ces 3 jours de TechDays Paris 2010. Généralement, cette troisième journée est plus axée sur l'avenir vu par Microsoft. Après un retour sur l'avenir vu par la Science Fiction ou par ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|