PageSourceSearch

https://dposs.ru/static/jivosite.js

js dposs.ru collected 2026-10-09 22:44:20 UTC 3,458 bytes, 130 lines download raw bytes

1var speaking_data = {
2  1:{
3        //"image":"http://mz-clinik.ru/images/speakingsite/1.jpg",
4        "text":"124",
5        "duration":"15",
6        "start_time":"2000-01-01 00:00:00",
7        "end_time":"2026-01-01 00:00:00",
8        "probability":"100"
9    },
10};
11(function ($) {
12   $.getJSON('/json/jivosite', function(data) {  
13        var s = new Object();
14        
15	$.each(data, function(key, val) {   
16          s[key] = [];
17            $.each(val, function(key2, val2) {   
18              s[key][key2]=val2;  
19            }); 
20        });  
21        speaking_data = s;
22        console.log(speaking_data);
23    });  
24
25    window.rotatorText = false;
26
27    function setItem(id, animate) {
28      var item = speaking_data[ id ];
29      if (!item || item.text == null) {
30        return;
31      }
32
33      setTimeout(function () {
34        if (Object.keys(speaking_data).length > 1 && animate !== false) {
35          $('div#jivo-label-text')
36            .animate({opacity: 0}, 1000, function () {
37              $(this).html('<span style="background-image: url(' + item.image + ')"></span>' + item.text)
38              .animate({opacity: 1}, 1000);
39            });
40          }
41        else {
42          $('div#jivo-label-text').html('<span style="background-image: url(' + item.image + ')"></span>' + item.text);
43        }
44        $('div#jivo-label-status').remove();
45      }, 10);
46
47      setTimeout(function () {
48        updateData(id);
49      }, (item.duration * 1000));
50    }
51
52    function clone(obj) {
53        if(obj == null || typeof(obj) != 'object')
54            return obj;
55
56        var temp = obj.constructor(); // changed
57
58        for(var key in obj) {
59            if(obj.hasOwnProperty(key)) {
60                temp[key] = clone(obj[key]);
61            }
62        }
63        return temp;
64    }
65
66    function updateData(exclude, animate) {
67      var data = clone(speaking_data),
68          sum = 0
69          factor = [],
70          ids = [];
71
72      if (data.length == 0) {
73        return;
74      }
75
76      if (Object.keys(data).length === 1) {
77        setItem( Object.keys(data)[0] );
78        return;
79      }
80
81      if (exclude && data[ exclude ]) {
82        delete data[ exclude ];
83      }
84
85      Object.keys(data).reduce(function (previous, key) {
86        sum += parseInt(data[key].probability, 10);
87      }, 0);
88
89      $.each(data, function (index, value) {
90        ids.push(index);
91        factor.push((value.probability / (sum - value.probability)));
92        //factor.push(100);
93      });
94
95      var rand = function(min, max) {
96        return Math.random() * (max - min) + min;
97      };
98
99      var getRandomItem = function(list, weight, animate) {
100        var totalWeight = weight.reduce(function (prev, cur, i, arr) {
101              return prev + cur;
102            }),
103            randomNum = rand(0, totalWeight),
104            weightSum = 0;
105
106
107        for (var i = 0; i < list.length; i++) {
108          weightSum += weight[ i ];
109          weightSum = +weightSum.toFixed(2);
110
111          if (randomNum <= weightSum) {
112            setItem(list[ i ], animate);
113            return;
114          }
115        }
116      };
117
118      getRandomItem(ids, factor, animate);
119    }
120    
121  $(document).bind('DOMSubtreeModified', function() {
122    if ($('#jivo_chat_widget').length && !window.rotatorText) {
123      var data = speaking_data;
124        if ($('#jivo-label-text').length) {
125          window.rotatorText = true;
126          updateData(undefined, false);
127        }
128    }
129  });
130})(jQuery);

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.