PageSourceSearch

https://platformarest.ru/wp-content/themes/theme/js/spark.js?v=1.0.0&ver=7.1.2

js platformarest.ru collected 2026-10-04 09:30:19 UTC 4,317 bytes, 70 lines download raw bytes

1if(document.querySelector("#fire_sparks")) {
2(function(){
3  var parent = document.getElementById("fire_sparks");
4  var styles = document.getElementById("fire_sparks_styles");
5  var total_sparks = 69;
6  var random_size_and_speed = true; //parameters are in the for loop below
7  
8  var small_random = function(min, max) {
9    return (Math.random() * (max - min) + min).toFixed(2);
10  }
11  var big_random = function(min, max){
12    return (Math.random() * (max - min) + min).toFixed(0);
13  }
14  
15  // the HTML creator function
16  var spark_HTML = function(index, inner_speed, inner_delay, spark_travel_speed, spark_travel_delay) {
17    let fixed_index;
18    let fixed_inner_speed;
19    // check if we random_size_and_speed is true or not
20    random_size_and_speed == false ? (fixed_index = '', fixed_inner_speed = 2000) : (fixed_index = index, fixed_inner_speed = inner_speed);
21    // we are returning the HTML code for each spark here every time the spark_HTML function is called by the loop below
22    return '<div class="spark" style="animation-name: travel'+index+'; animation-duration: '+spark_travel_speed+'ms; animation-delay: '+spark_travel_delay+'ms;"><div class="spark_inner" style="animation-name: scaling'+fixed_index+'; animation-duration: '+fixed_inner_speed+'ms; animation-delay:'+inner_delay+'ms;"></div></div>';
23  }
24
25  // loop to create all sparks
26  
27  for(let i=0; i<(total_sparks+1); i++) {
28    // if random random_size_and_speed is not activated we add the keyframe once
29    if (random_size_and_speed == false && i == 0) {
30      styles.innerHTML = "@keyframes scaling {0% {transform: scale3d(0.4, 0.4, 1);} 50% {transform: scale3d(1.4, 1.4, 1);} 100% {transform: scale3d(0.4, 0.4, 1);}}";
31    }
32    // if random_size_and_speed is activated we add a different value keyframe for each spark
33    if (random_size_and_speed == true) {
34      let min = small_random(0.1, 0.4); // set the min size value range
35      let max = small_random(1, 1.5); // set the max size value range
36      styles.innerHTML += "@keyframes scaling"+i+" {0% {transform: scale3d("+min+", "+min+", 1);} 50% {transform: scale3d("+max+", "+max+", 1);} 100% {transform: scale3d("+min+", "+min+", 1);}}";
37    }
38    
39    /*// random travel directions; play around with the coordinates, they are expressed in CSS vh and vw units, you can also remove or add more keyframes, just make sure you add the correct number of variables as well
40    let point1w = big_random(0, 100);
41    let point1h = big_random(0, 60);
42    let point2w = big_random(0, 100);
43    let point2h = big_random(60, 100);
44    let point3w = big_random(0, 130);
45    let point3h = big_random(100, 130);
46    styles.innerHTML += "@keyframes travel"+i+" {0% {transform: translate3d("+point1w+"vw, "+point1h+"vh, 0)} 50% {transform: translate3d("+point2w+"vw, "+point2h+"vh, 0)} 100% {transform: translate3d("+point3w+"vw, -"+point3h+"vh, 0)}}";*/
47    
48    
49    // random travel directions; play around with the coordinates, they are expressed in CSS vh and vw units, you can also remove or add more keyframes, just make sure you add the correct number of variables as well
50    let random_sign = function () { return Math.cos(Math.PI * Math.round(Math.random())); } // we need random negative or positive values for future positions of sparks
51    let point1w = big_random(0, 100); // this is the X position of the initial spark
52    let point1h = 103; // this is the Y position of the initial spark
53    let point2w = big_random(0, 100);
54    let point2h = -3;
55    styles.innerHTML += "@keyframes travel"+i+" { 0% {transform: translate("+point1w+"vw, "+point1h+"vh)} 100% {transform: translate("+point2w+"vw, "+point2h+"vh);} }";    
56    
57    let inner_speed = big_random(1500, 2000); // miliseconds
58    // call the random function to get a random inner_delay
59    let inner_delay = big_random(1, 1200); // miliseconds
60    // call the random function to get a random number for this spark's travel duration
61    let speed = big_random(6000, 18000); // miliseconds
62    // call the random function to get a random number for this spark's travel speed
63    let delay = big_random(1, 15000); // miliseconds
64    
65
66    // duplicate the HTML structure for the fire sparks but with different parameters every time
67    parent.innerHTML += spark_HTML(i, inner_speed, inner_delay, speed, delay);
68  }
69})();
70}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.