IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Modifier un script en ligne


Sujet :

JavaScript

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Août 2012
    Messages : 6
    Points : 9
    Points
    9
    Par défaut Modifier un script en ligne
    Bonjour à tous,

    Pour commencer je ne connais pas très bien le javascript, quelques notions, cependant je sais programmer en général et lire du code sans soucis.

    Alors voilà, je joue à un jeu concours, il y a un cadre avec 12 photos, et on voit chacune des photos être mise en surbrillance tour à tour (de façon aléatoire j'imagine), l'animation est donc une animation javascript que j'ai cru pouvoir identifier avec Chrome (options F12) ... Lors de l'appui sur un bouton, une photo est sélectionnée au hasard avec un laps de temps défini dans le code.

    Mes questions sont les suivantes, est-il possible d'identifier quels sont les scripts actif sur une page donnée (par exemple une boucle active etc...), d'autres part est-il possible de modifier l'issu d'un choix normalement aléatoire (modification du code javascript) ?

    Je ne cherche pas à pirater ou quoi, mais je me dis que le JS est executé coté client et donc que ceci doit être possible...

    Merci d'avance.

    Bonne soirée

    Voici le code d'animation :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    //********************************************
    // spinner
    // hotels.com
    //
     
    (function($) {
    	//********************************************
    	$.spinner = function(element, options) {
    		//references
    		var plugin = this;
    		var $element = $(element); //jquery instance
     
    		var div = $element;
     
    		//public settings
    		plugin.settings = $.extend({}, $.spinner.defaults, options);
     
    		//private
    		var _list = div.children('ul').children('li');
    		var _list_total = _list.length;
     
    		var _is_spinning = false;
    		var _current_speed = plugin.settings['speed'];
     
    		var _stop_div = $(plugin.settings['stop_div']);
    		var _slow_spinner = false;
    		var _spinner_multiplier = plugin.settings['slow_rate'];
     
    		var _popup_div = $(element).children('.popup');
    		var _label_div = $(plugin.settings['label_div']);
     
    		var _selected_index = (plugin.settings['index'] !== undefined) ? plugin.settings['index'] : 0;
     
    		//*****************
    		plugin.start = function(parameters) {
    			if (_is_spinning) {return;}
     
    			if (!parameters) {parameters = {};}
     
    			//which to end on
    			_selected_index = (plugin.settings['index'] !== undefined) ? plugin.settings['index'] : 0;
     
    			//reset parameters
    			_is_spinning = true;
    			_current_speed = plugin.settings['speed'];
    			_slow_spinner = false;
     
    			plugin.select_random();
    		}
     
    		//*****************
    		plugin.stop = function(parameters) {
    			if (_slow_spinner) {return;}
     
    			//start slowing the spinner
    			_slow_spinner = true;
     
    			//setup random multiplier speed (don't allow it to be less that 1)
    			_spinner_multiplier = plugin.settings['slow_rate'] + (Math.random() * plugin.settings['slow_variance']);
    			if (_spinner_multiplier <= 1) {_spinner_multiplier = 1.1;}
     
    			//fade out label
     
    			if (_label_div.length > 0) {
    				_label_div.fadeTo(500, .01); //fade but don't hide since we need this block for padding
    			}
     
    			//callback
    			if (typeof plugin.settings['on_click'] == 'function') {plugin.settings['on_click']();}
    		}
     
    		//*****************
    		plugin.select_random = function(parameters) {
    			if (!parameters) {parameters = {};}
     
    			var index = (parameters['index'] !== undefined) ? parameters['index'] : null;
    			var has_timer = (parameters['has_timer'] !== undefined) ? parameters['has_timer'] : true;
     
    			//adjust speed
    			if (_slow_spinner) {
    				_current_speed = _current_speed * _spinner_multiplier;
     
    				//stop the animation (and then rotate)
    				if (_current_speed > plugin.settings['max_speed']) {
    					_is_spinning = false;
     
    					index = _selected_index;
    					has_timer = false;
    				}
    			}
     
    			//build list of available items
    			var available_items = [];
    			for (var i=0; i<_list_total; i++) {
    				available_items.push(i);
    			}
     
    			var selected = _list.filter('.selected');
     
    			//if previously selected, adjust available items and remove the selection
    			if (selected.length > 0) {
    				//remove this index from available to avoid the same one being picked
    				available_items.splice(_list.index(selected), 1);
     
    				$(selected).removeClass('selected');
    			}
     
    			//if not provided an index, randomly pick one from the available list
    			if (index === null) {
    				index = available_items[Math.floor(Math.random() * available_items.length)];
    			}
     
    			//select item
    			_list.eq(index).addClass('selected');
     
    			//set next timer (only if still spinning)
    			if (has_timer && _is_spinning) {
    				div.oneTime(_current_speed, function() {
    					plugin.select_random();
    				});
    			}
     
    			//if no longer spinning, then start the final animation
    			if (!_is_spinning) {
    				plugin.blink({
    					index: index
    				});
    			}
    		}
     
    		//*****************
    		plugin.blink = function(parameters) {
    			if (!parameters) {parameters = {};}
     
    			var index = (parameters['index'] !== undefined) ? parameters['index'] : _selected_index;
    			var blink_speed = plugin.settings['blink_speed'];
     
    			for(var i=0; i<plugin.settings['blink']; i++) {
    				_list.eq(index).fadeTo(blink_speed, 0.5).fadeTo(blink_speed, 1.0);
    			}
     
    			//wait a second before rotating
    			div.oneTime((blink_speed * (plugin.settings['blink'] * 2)) + plugin.settings['pause_speed'], function() {
    				plugin.rotate_to(parameters);
    			});
    		}
     
    		//*****************
    		plugin.rotate_to = function(parameters) {
    			if (!parameters) {parameters = {};}
     
    			var index = (parameters['index'] !== undefined) ? parameters['index'] : _selected_index;
     
    			//no need to rotate
    			if (index == 0) {
    				plugin.on_complete();
    				return;
    			}
     
    			//chose animation direction
    			var is_clockwise = (index >= 7) ? true : false;
     
    			//number of moves
    			var count = (is_clockwise) ? (_list_total - index) : index;
     
    			div.everyTime(plugin.settings['rotate_speed'], function(current_step) {
    				if (is_clockwise) {
    					//clockwise
    					var temp_html = _list.eq(_list_total - 1).html();
     
    					for (var i=_list_total-1; i>0; i--) {
    						_list.eq(i).html(_list.eq(i - 1).html());
    					}
     
    					_list.eq(0).html(temp_html);
    				} else {
    					//counter clockwise
    					var temp_html = _list.eq(0).html();
     
    					for (var i=0; i<_list_total; i++) {
    						_list.eq(i).html(_list.eq(i + 1).html());
    					}
     
    					_list.eq(_list_total - 1).html(temp_html);
    				}
     
    				//remove selected
    				_list.removeClass('selected');
     
    				//select new item
    				var new_index = (is_clockwise) ? index + current_step : index - current_step;
    				if (new_index >= _list_total) {new_index = 0;}
     
    				_list.eq(new_index).addClass('selected');
    			}, count);
     
    			//complete
    			_popup_div.oneTime((count + 1) * plugin.settings['rotate_speed'], function() {
    				plugin.on_complete();
    			});
    		}
     
    		//*****************
    		plugin.fade_hint = function() {
    			var hint_div = _stop_div.children('.hint');
    			if (hint_div.length == 0 || hint_div.hasClass('hidden')) {return;}
     
    			//stop auto hide
    			_stop_div.stopTime();
     
    			$(hint_div).addClass('hidden').fadeOut(500);
    		}
     
    		//*****************
    		plugin.on_complete = function() {
    			_popup_div.show();
     
    			//callback
    			if (typeof plugin.settings['on_complete'] == 'function') {plugin.settings['on_complete']();}
    		}
     
    		//*****************
    		//events
     
    		//auto hide the hint
    		if (plugin.settings['hint_delay'] > 0) {
    			_stop_div.oneTime(plugin.settings['hint_delay'], function() {
    				plugin.fade_hint();
    			});
    		}
     
    		_stop_div.click(function(e) {
    			e.preventDefault();
     
    			plugin.fade_hint();
    			plugin.stop();
    		});
     
    		//*****************
    		//private events
    		var _update = function() {
    		}
     
    		//autostart
    		if (plugin.settings['autostart'] === true) {
    			plugin.start();
    		}
    	}
     
    	//********************************************
    	$.spinner.defaults = {
    		stop_div: '#bell',
    		label_div: '#game_label',
     
    		slow_rate: 1.2,
    		slow_variance: .2,
     
    		speed: 100, //base speed of the spinner
    		max_speed: 650, //max speed where the spinner stops
     
    		blink: 3,
    		blink_speed: 100,
    		pause_speed: 500, //amount of pause between blink and rotate animation
    		rotate_speed: 200,
    		hint_delay: 5000, //amount of delay before auto hiding the hint box
     
    		autostart: true, //flag to tell spinner to start immediately, otherwise, waits for start() call
     
    		on_click: function() {}, //called once the bell is clicked
    		on_complete: function() {} //called once the spinner lands on a space
    	};
     
    	//********************************************
    	//register the plugin
    	$.fn.spinner = function(method) {
    		var options = arguments;
    		var plugin = $(this).data('spinner');
     
    		if (plugin !== undefined && typeof plugin[method] == 'function') {
    			//method exists
    			return plugin[method].apply(this, Array.prototype.slice.call(options, 1));
    		} else if (typeof method === 'object' || !method) {
    			return this.each(function() {
    				//create reference to plugin
    				if ($(this).data('spinner') === undefined) {
    					$(this).data('spinner', (new $.spinner(this, options[0])));
    				}
    			});
    		} else {
    			$.error(method + '() does not exist for jQuery.spinner');
    		}
    	}
    })(jQuery);

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 672
    Points
    66 672
    Billets dans le blog
    1
    Par défaut
    regarde du coté de firebug ...
    il y a un tuto sur son utilisation sur developpez...
    Ma page Developpez - Mon Blog Developpez
    Président du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts)
    Deux règles du succès: 1) Ne communiquez jamais à quelqu'un tout votre savoir...
    Votre post est résolu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de Développez !

Discussions similaires

  1. [Upload] Modifier ce script... (script d'upload)
    Par CyberTwister dans le forum Langage
    Réponses: 4
    Dernier message: 21/02/2006, 09h54
  2. Utilisation d'un script en ligne de commande
    Par Thylia dans le forum Langage
    Réponses: 5
    Dernier message: 23/01/2006, 16h28
  3. Liste modifiable, choix de la ligne
    Par Ender dans le forum Access
    Réponses: 10
    Dernier message: 06/09/2005, 11h41
  4. [SQL*Plus] Lancer un script en ligne de commandes
    Par Jibees dans le forum Décisions SGBD
    Réponses: 2
    Dernier message: 04/07/2005, 17h05
  5. [SQL*Plus] Lancer un script en ligne de commandes
    Par Jibees dans le forum Oracle
    Réponses: 6
    Dernier message: 04/07/2005, 15h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo