Premier avril - Script aquarium ne fonctionne plus

2 participants

Voir le sujet précédent Voir le sujet suivant Aller en bas

Résolu Premier avril - Script aquarium ne fonctionne plus

Message par Neptunia Mar 24 Mar 2015 - 23:58

Détails techniques


Version du forum : PunBB
Poste occupé : Fondateur
Navigateur(s) concerné(s) : Mozilla Firefox, Google Chrome
Personnes concernées par le problème : Tous les utilisateurs
Problème apparu depuis : Fonctionnait l'an dernier, ne fonctionne plus.
Lien du forum : http://www.planet-series.com/ (mais le script n'est pas activé)

Description du problème

Bonsoir ^^


J'ai utilisé l'an dernier un script qui affichait des poissons se balladant sur l'écran. Script fourni par Adam_Sfp si ma mémoire est encore bonne.

Le CSS :
Code:
.ghost {
    position: absolute;
    width: 200px;
    height: 281px;
    z-index: 999;
    display: block;
    opacity: 0.8;
    background: transparent url('http://i.imgur.com/IjhHy9Y.png') no-repeat;
}
.ghost.moving-left {
    -moz-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    transform: scaleX(-1);
    filter: fliph; /*IE*/
}

Un javascript qui fonctionnait sous PunBB (ainsi que phpBB2)
Code:
var Ghost = function() { var that = {}; if(jQuery.browser.msie) { if(jQuery.browser.version <  { return that } } that.html = '<div class="ghost"></div>'; that.element = null; that.timer = null; that.interval = Math.floor(Math.random() * 1E3) + 1E3; that.directionX = Math.round(Math.random()); that.directionY = Math.round(Math.random()); if(that.directionX == 0) { that.directionX = -1 } if(that.directionY == 0) { that.directionY = -1 } that.screenWidth = null; that.screenHeight = null; that.elementWidth = 150; that.elementHeight = 145; that.init = function() { that.getBrowserSize(); jQuery(window).resize(function() { that.getBrowserSize() }); that.element = jQuery(that.html); that.timer = window.setInterval(that.move, that.interval); jQuery("body").append(that.element); that.move(true); that.move(); return that }; that.move = function(instant) { var distX = Math.floor(Math.random() * 100 + 100); var distY = Math.floor(Math.random() * 100 + 100); var currentX = that.element.offset().left; var currentY = that.element.offset().top; var newX = currentX + that.directionX * distX; var newY = currentY + that.directionY * distY; var maxX = that.screenWidth - that.elementWidth - 20; var maxY = that.screenHeight - that.elementHeight; if(newX > maxX) { newX = maxX; that.directionX = -that.directionX }else { if(newX < 0) { newX = 0; that.directionX = -that.directionX } } if(newY > maxY) { newY = maxY; that.directionY = -that.directionY }else { if(newY < 0) { newY = 0; that.directionY = -that.directionY } } var newAlpha = Math.random() - 0.1; if(newAlpha < 0.4) { newAlpha = 0.4 } if(instant) { that.element.css("top", Math.floor(Math.random() * that.screenHeight - that.elementHeight)); that.element.css("left", Math.floor(Math.random() * that.screenWidth - that.elementWidth)) }else { that.element.removeClass("moving-left"); that.element.removeClass("moving-right"); if(newX > currentX) { that.element.addClass("moving-right") }else { if(newX < currentX) { that.element.addClass("moving-left") } } that.element.stop(); that.element.animate({top:newY, left:newX, opacity:newAlpha}, {duration:that.interval, easing:"swing"}) } }; that.getBrowserSize = function() { that.screenWidth = jQuery(document).width(); that.screenHeight = jQuery(document).height() }; that.init(); return that };
jQuery(function(){
                var Ghosts = new Array();
                for (var i = 0; i < 5; i++) {
                    Ghosts.push(new Ghost());
                }
            })

Un script alternatif fonctionnant sous toutes les versions.
Code:
var Ghost = function() { var that = {}; if(jQuery.browser.msie) { if(jQuery.browser.version < { return that } } that.html = '<div class="ghost"></div>'; that.element = null; that.timer = null; that.interval = Math.floor(Math.random() * 1E3) + 1E3; that.directionX = Math.round(Math.random()); that.directionY = Math.round(Math.random()); if(that.directionX == 0) { that.directionX = -1 } if(that.directionY == 0) { that.directionY = -1 } that.screenWidth = null; that.screenHeight = null; that.elementWidth = 150; that.elementHeight = 145; that.init = function() { that.getBrowserSize(); jQuery(window).resize(function() { that.getBrowserSize() }); that.element = jQuery(that.html); that.timer = window.setInterval(that.move, that.interval); jQuery("body").append(that.element); that.move(true); that.move(); return that }; that.move = function(instant) { var distX = Math.floor(Math.random() * 100 + 100); var distY = Math.floor(Math.random() * 100 + 100); var currentX = that.element.offset().left; var currentY = that.element.offset().top; var newX = currentX + that.directionX * distX; var newY = currentY + that.directionY * distY; var maxX = that.screenWidth - that.elementWidth - 20; var maxY = that.screenHeight - that.elementHeight; if(newX > maxX) { newX = maxX; that.directionX = -that.directionX }else { if(newX < 0) { newX = 0; that.directionX = -that.directionX } } if(newY > maxY) { newY = maxY; that.directionY = -that.directionY }else { if(newY < 0) { newY = 0; that.directionY = -that.directionY } } var newAlpha = Math.random() - 0.1; if(newAlpha < 0.4) { newAlpha = 0.4 } if(instant) { that.element.css("top", Math.floor(Math.random() * that.screenHeight - that.elementHeight)); that.element.css("left", Math.floor(Math.random() * that.screenWidth - that.elementWidth)) }else { that.element.removeClass("moving-left"); that.element.removeClass("moving-right"); if(newX > currentX) { that.element.addClass("moving-right") }else { if(newX < currentX) { that.element.addClass("moving-left") } } that.element.stop(); that.element.animate({top:newY, left:newX, opacity:newAlpha}, {duration:that.interval, easing:"swing"}) } }; that.getBrowserSize = function() { that.screenWidth = jQuery(document).width(); that.screenHeight = jQuery(document).height() }; that.init(); return that };
jQuery(function(){
              var Ghosts = new Array();
              for (var i = 0; i < 5; i++) {
                  Ghosts.push(new Ghost());
              }
          })

Ni l'un ni l'autre ne fonctionne à ce jour (erreur de syntaxe dans la console du navigateur)




Votre mission, si vous l'acceptez, consistera à faire fonctionner ce script au plus tard le 31 mars prochain.
Si vous vous faites pincer (par un poisson), nous nierons avoir eu connaissance de vos activités.

Ce message s'auto-archivera dans maximum 7 jours.
Bonne chance et merci.
Neptunia

Neptunia
Membre actif

Féminin
Messages : 17853
Inscrit(e) le : 08/08/2010

https://www.galaxie-series.net/
Neptunia a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Premier avril - Script aquarium ne fonctionne plus

Message par Neptunia Jeu 26 Mar 2015 - 1:03

:up: Remonte petit sujet, remonte ! :up:
Neptunia

Neptunia
Membre actif

Féminin
Messages : 17853
Inscrit(e) le : 08/08/2010

https://www.galaxie-series.net/
Neptunia a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Premier avril - Script aquarium ne fonctionne plus

Message par Scoubifitz Jeu 26 Mar 2015 - 3:41

bonsoir,

en ôtant le début du script , pour les versions des navigateurs , ça fonctionne :

Code:
var Ghost = function() { var that = {};that.html = '<div class="ghost"></div>'; that.element = null; that.timer = null; that.interval = Math.floor(Math.random() * 1E3) + 1E3; that.directionX = Math.round(Math.random()); that.directionY = Math.round(Math.random()); if(that.directionX === 0) { that.directionX = -1; } if(that.directionY === 0) { that.directionY = -1; } that.screenWidth = null; that.screenHeight = null; that.elementWidth = 150; that.elementHeight = 145; that.init = function() { that.getBrowserSize(); jQuery(window).resize(function() { that.getBrowserSize(); }); that.element = jQuery(that.html); that.timer = window.setInterval(that.move, that.interval); jQuery("body").append(that.element); that.move(true); that.move(); return that; }; that.move = function(instant) { var distX = Math.floor(Math.random() * 100 + 100); var distY = Math.floor(Math.random() * 100 + 100); var currentX = that.element.offset().left; var currentY = that.element.offset().top; var newX = currentX + that.directionX * distX; var newY = currentY + that.directionY * distY; var maxX = that.screenWidth - that.elementWidth - 20; var maxY = that.screenHeight - that.elementHeight; if(newX > maxX) { newX = maxX; that.directionX = -that.directionX; }else { if(newX < 0) { newX = 0; that.directionX = -that.directionX; } } if(newY > maxY) { newY = maxY; that.directionY = -that.directionY; }else { if(newY < 0) { newY = 0; that.directionY = -that.directionY; } } var newAlpha = Math.random() - 0.1; if(newAlpha < 0.4) { newAlpha = 0.4; } if(instant) { that.element.css("top", Math.floor(Math.random() * that.screenHeight - that.elementHeight)); that.element.css("left", Math.floor(Math.random() * that.screenWidth - that.elementWidth)); }else { that.element.removeClass("moving-left"); that.element.removeClass("moving-right"); if(newX > currentX) { that.element.addClass("moving-right"); }else { if(newX < currentX) { that.element.addClass("moving-left"); } } that.element.stop(); that.element.animate({top:newY, left:newX, opacity:newAlpha}, {duration:that.interval, easing:"swing"}); } }; that.getBrowserSize = function() { that.screenWidth = jQuery(document).width(); that.screenHeight = jQuery(document).height(); }; that.init(); return that; };
jQuery(function(){
var Ghosts = new Array();
for (var i = 0; i < 5; i++) {
Ghosts.push(new Ghost());
}
});
Scoubifitz

Scoubifitz
Membre actif

Masculin
Messages : 3687
Inscrit(e) le : 19/03/2008

http://scoubidous.superforum.fr/
Scoubifitz a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Premier avril - Script aquarium ne fonctionne plus

Message par Neptunia Jeu 26 Mar 2015 - 4:14

Bonsoir !


Parfait...
Et le bout de code enlevé, mis à part que ça concernait Explorer, à quoi servait-il ?

Là je viens de tester sous IE8, ça fonctionne impec.
Neptunia

Neptunia
Membre actif

Féminin
Messages : 17853
Inscrit(e) le : 08/08/2010

https://www.galaxie-series.net/
Neptunia a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Premier avril - Script aquarium ne fonctionne plus

Message par Scoubifitz Jeu 26 Mar 2015 - 5:16

comme il y a un "return" , je pense que le script ne devait pas s'activer s'il rencontre une ancienne version ...
mais comme cette partie n'était pas complète , je ne peux que le supposer ...
Scoubifitz

Scoubifitz
Membre actif

Masculin
Messages : 3687
Inscrit(e) le : 19/03/2008

http://scoubidous.superforum.fr/
Scoubifitz a été remercié(e) par l'auteur de ce sujet.
  • 0

Résolu Re: Premier avril - Script aquarium ne fonctionne plus

Message par Neptunia Jeu 26 Mar 2015 - 5:23

Oki.

Et comme il marchait en l'état l'année dernière j'imagine qu'une des commandes jQuery n'est plus présente dans les nouvelles versions de la bibliothèque.


merci bien agent Phelps

Ce message s'auto-archivera dans 6 heures.

résolu
Neptunia

Neptunia
Membre actif

Féminin
Messages : 17853
Inscrit(e) le : 08/08/2010

https://www.galaxie-series.net/
Neptunia a été remercié(e) par l'auteur de ce sujet.

Voir le sujet précédent Voir le sujet suivant Revenir en haut


Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum