In the block of forum IPB added a small JS as follows:

var Events = {}; Events.text = [ ['Начнётся через', '<font color="green">Открыт, до начала</font>'], ['Появится через', '<font color="red">Торопись, осталось</font>'] ]; Events.sked = [ ['Информация 1', 0, '08:40', '02:30', '04:30', '06:30', '08:30', '10:30', '12:30', '14:30', '16:30', '18:30', '20:30', '22:30', ], ['Информация 2', 0, '01:00', '05:00', '09:00', '13:00', '17:00', '21:00'], ['Информация ', 0, '01:30', '03:30', '05:30', '07:30', '09:30', '11:30', '13:30', '15:30', '17:30', '19:30', '21:30', '23:30'], ['Информация 3', 0, '02:00', '06:00', '10:00', '14:00', '18:00', '22:00'], ['Информация 4', 0, '02:30', '08:30', '14:30', '20:30'], ['Информация ', 0, '20:00'], ['Информация 5', 1, '02:15', '06:15', '10:15', '14:15', '18:15', '22:15'], ['Информация 6', 1, '02:30', '08:30', '14:30', '20:30'], ['Информация 7', 1, '02:40', '06:40', '10:40', '14:40', '18:40', '22:40'], ['Информация 8', 1, '04:30', '12:30', '23:59'], ]; Events.init = function (e) { if (typeof e == "string") var g = new Date(new Date().toString().replace(/\date('H')+:\date('i')+:\date('s')+/g, e)); var f = (typeof e == "number" ? e : (g.getHours() * 60 + g.getMinutes()) * 60 + g.getSeconds()), q = Events.sked, j = []; for (var a = 0; a < q.length; a++) { var n = q[a]; for (var k = 2; k < q[a].length; k++) { var b = 0, p = q[a][k].split(":"), o = (p[0] * 60 + p[1] * 1) * 60, c = q[a][2].split(":"); if (q[a].length - 1 == k && (o - f) < 0) b = 1; var r = b ? (1440 * 60 - f) + ((c[0] * 60 + c[1] * 1) * 60) : o - f; if (f <= o || b) { var l = Math.floor((r / 60) / 60), l = l < 10 ? "0" + l : l, d = Math.floor((r / 60) % 60), d = d < 10 ? "0" + d : d, u = r % 60, u = u < 10 ? "0" + u : u; j.push('<div class="event_title">' + '<b><span>' + q[a][b ? 2 : k] + "</span></b><b>" + n[0] + '</b></div><div class="event_info"><span>' + (l + ":" + d + ":" + u) + '</span>' + (Events.text[q[a][1]][+(l == 0 && d < (q[a][1] ? 1 : 5))]) + "</div>"); break; }; }; }; document.getElementById("events").innerHTML = j.join(""); setTimeout(function () { Events.init(f == 86400 ? 1 : ++f); }, 1000); }; 

The code itself from the block is called as follows:

 <script type="text/javascript" src="uploads/events.js"></script> <script type="text/javascript">Events.init('00:00');</script> 

enter image description here

Everything works as it should, but as soon as I switch to any topic on the forum, I get the error "Uncaught SyntaxError: Unexpected token <" in the console, and of course JS refuses to work.

enter image description here enter image description here

Good people, please help me figure it out, for I am very far from JS.

  • Tried to open the events.js file in the browser directly? - andreymal pm
  • In the above code, there is no such syntax error. See the uploads/events.js for errors - Stepan Kasyanenko

0