PageSourceSearch

https://fijionenews.com.fj/wp-content/themes/fijitv/assets/js/main.js

js fijionenews.com.fj collected 2026-10-02 16:31:32 UTC 14,484 bytes, 480 lines download raw bytes

1$(document).ready(function () {
2  $(".primary_menu_prev").click(function () {
3    $("#main_menu_list_container").animate({ scrollLeft: "-=100px" });
4  });
5
6  $(".primary_menu_next").click(function () {
7    $("#main_menu_list_container").animate({ scrollLeft: "+=100px" });
8  });
9  $(".primary_menu_prev").hover(function () {
10    $("#main_menu_list_container").animate({ scrollLeft: "-=100px" });
11  });
12
13  $(".primary_menu_next").hover(function () {
14    $("#main_menu_list_container").animate({ scrollLeft: "+=100px" });
15  });
16  // $("body").css("min-height", $(window).height());
17});
18
19$(document).ready(function () {
20  function updateTime() {
21    var date = new Date();
22
23    var weekday = new Array(7);
24    weekday[0] = "Sun";
25    weekday[1] = "Mon";
26    weekday[2] = "Tues";
27    weekday[3] = "Wed";
28    weekday[4] = "Thur";
29    weekday[5] = "Fri";
30    weekday[6] = "Sat";
31
32    var day = weekday[date.getDay()];
33
34    function getSuffixForDate(day) {
35      if (day == 1 || day == 21 || day == 31) {
36        return "st";
37      } else if (day == 2 || day == 22) {
38        return "nd";
39      } else if (day == 3 || day == 23) {
40        return "rd";
41      } else {
42        return "th";
43      }
44    }
45
46    const monthNames = [
47      "Jan",
48      "Feb",
49      "Mar",
50      "Apr",
51      "May",
52      "Jun",
53      "Jul",
54      "Aug",
55      "Sep",
56      "Oct",
57      "Nov",
58      "Dec",
59    ];
60
61    function formatAMPM(date) {
62      var hours = date.getHours();
63      var minutes = date.getMinutes();
64      var ampm = hours >= 12 ? "PM" : "AM";
65      hours = hours % 12;
66      hours = hours ? hours : 12; // the hour '0' should be '12'
67      minutes = minutes < 10 ? "0" + minutes : minutes;
68      var strTime = hours + ":" + minutes + " " + ampm;
69      return strTime;
70    }
71
72    $(".zone_time").html(
73      day +
74        " " +
75        date.getDate() +
76        getSuffixForDate(date.getDate()) +
77        " " +
78        monthNames[date.getMonth()] +
79        " " +
80        formatAMPM(date)
81    );
82  }
83
84  setInterval(function () {
85    updateTime();
86  }, 1000);
87});
88$(".menu_hamburger").click(function () {
89  if ($("#secondary_menu").css("display") == "block") {
90    $("#secondary_menu_div").css("display", "none");
91    $("#secondary_menu").hide("slow", function () {});
92    $(".menu_hamburger_icon").html('<i class="fas fa-bars"></i>');
93  } else {
94    $("#secondary_menu_div").css("display", "none");
95    $("#secondary_menu").show("slow", function () {
96      $("#secondary_menu_div").css("display", "block");
97    });
98    $(".mobile-nav").css("display", "none");
99    $(".menu_hamburger_icon").html('<i class="fas fa-times"></i>');
100  }
101});
102$(".mobile_hamb_close_btn").click(function () {
103  $(".mobile-nav").css("display", "block");
104  $("#secondary_menu").hide("slow");
105});
106
107$(".open_mobile_nav").click(function () {
108  $("html, body").css({
109    overflow: "hidden",
110  });
111  document.getElementById("mySidenav").style.width = "100%";
112  // $("#mobile_menu").toggle('right');
113});
114$("#close_mobile_menu").click(function () {
115  $("html, body").css({
116    overflow: "auto",
117  });
118  document.getElementById("mySidenav").style.width = "0";
119  // $("#mobile_menu").animate({'width': 'toggle'})
120});
121
122function renderNews() {
123  var url = $("#read_more_btn").attr("data-url");
124  var category = $("#read_more_btn").attr("data-cat");
125  var count = $("#read_more_btn").attr("data-count");
126  data = {
127    action: "load_more_news",
128    category: category,
129    count: count,
130    count_news: count,
131  };
132
133  $.ajax({
134    url: url,
135    type: "POST",
136    data: data,
137    success: function (result) {
138      $(".loader_div").remove();
139      var data = JSON.parse(result);
140      var left = true;
141      $.each(data.data, function (key, value) {
142        if (left) {
143          $("#left_news").append(small_news_html(value));
144          left = false;
145        } else {
146          $("#right_news").append(small_news_html(value));
147          left = true;
148        }
149      });
150      $("#read_more_btn").css("display", "inline-block");
151      let countnews = $(".news__sidepanel_li").length;
152      if (countnews >= data.counting) {
153        /* var intcount = parseInt(count);
154            intcount = intcount + 1;
155            $("#read_more_btn").attr("data-count", intcount++)
156        }else{*/
157        $("#read_more_btn").remove();
158      }
159    },
160    error: function (result) {
161      console.log(result);
162    },
163  });
164}
165
166$("#read_more_btn").click(function (e) {
167  e.stopPropagation();
168  var loader = loader_div_html();
169  $("#more_news_div").append(loader);
170  $("#read_more_btn").css("display", "none");
171  let count_news = $(".news__sidepanel_li").length;
172  var url = $(this).attr("data-url");
173  var category = $(this).attr("data-cat");
174  var count = $(this).attr("data-count");
175  data = {
176    action: "load_more_news",
177    category: category,
178    count: count,
179    count_news: count_news,
180  };
181
182  $.ajax({
183    url: url,
184    type: "POST",
185    data: data,
186    success: function (result) {
187      $(".loader_div").remove();
188      var data = JSON.parse(result);
189      var left = true;
190      $.each(data.data, function (key, value) {
191        if (left) {
192          $("#left_news").append(small_news_html(value));
193          left = false;
194        } else {
195          $("#right_news").append(small_news_html(value));
196          left = true;
197        }
198      });
199      /*if(data.continue){
200              var intcount = parseInt(count);
201              $("#read_more_btn").css("display","inline-block");
202              intcount = intcount + 1;
203              $("#read_more_btn").attr("data-count", intcount++)
204          }else{
205              $("#read_more_btn").remove();
206          }*/
207      let countnews = $(".news__sidepanel_li").length;
208      if (countnews >= data.counting) {
209        /* var intcount = parseInt(count);
210				intcount = intcount + 1;
211				$("#read_more_btn").attr("data-count", intcount++)
212			}else{*/
213        $("#read_more_btn").remove();
214      } else {
215        $("#read_more_btn").css("display", "inline-block");
216      }
217    },
218    error: function (result) {
219      console.log(result);
220    },
221  });
222});
223
224function small_news_html(data) {
225  var html =
226    '<div class="news__sidepanel_li box_hover">' +
227    '<a class="single_page_links" href="' +
228    data.permalink +
229    '">' +
230    '<div class="row">' +
231    '<div class="col-12">' +
232    '<div class="square five_pad">' +
233    '<img class="img-fluid small_image" src="' +
234    data.image +
235    '" alt="">' +
236    '<p class="small_news_title">' +
237    data.post_name +
238    "</p>" +
239    '<p class="small_date pt-2">' +
240    data.post_date +
241    "</p>" +
242    "</div>" +
243    "</div>" +
244    "</div>" +
245    "</a>" +
246    "</div>";
247  return html;
248}
249
250function loader_div_html() {
251  return (
252    '<div class="loader_div">' +
253    "<div><h4>Loading</h4></div>" +
254    '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>' +
255    "</div>"
256  );
257}
258
259$("form#contactForm").on("submit", function (e) {
260  e.preventDefault();
261  let testEmail = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
262
263  let full_name = $("#full_name ").val(); //required
264  let email = $("#email ").val(); //required
265  let country = $("#country ").val();
266  let phone = $("#phone ").val(); //required
267  let message = $("#message ").val(); //required
268
269  $("#btn_contact").css({ opacity: "1" }); //btn
270  $("#btn_contact").css({ cursor: "not-allowed" }); //btn
271  $("#btn_contact").attr("disabled", true); //btn
272  // $("#btn_contact").html("<img width='29px' src=" + imgfolder + " />"); //btn
273
274  //reset
275  $("#name_validation").html("");
276  $("#email_validation ").html("");
277  $("#phone_validation ").html("");
278  $("#message_validation ").html("");
279  $("#country_validation ").html("");
280  $("#message").css({ border: "1px solid #ced4da" }); //border of input
281  $("#btn_contact").html("Submiting...");
282
283  if (full_name == "") {
284    $("#full_name").css({ "border-bottom": "2px solid #dc3545" }); //border of input
285    $("#name_validation").html(
286      '<span style="color:red;">Full Name is required</span>'
287    ); //validation text
288    $("#btn_contact").attr("disabled", false); //btn
289    $("#btn_contact").css({ cursor: "pointer" }); //btn
290    $("#btn_contact").html("Submit"); //btn
291  } else if (full_name.length < 3) {
292    $("#full_name").css({ "border-bottom": "2px solid #dc3545" }); //border of input
293    $("#name_validation").html(
294      '<span style="color:red;">Full Name should be more than 3 letters</span>'
295    ); //validation text
296    $("#btn_contact").attr("disabled", false); //btn
297    $("#btn_contact").css({ cursor: "pointer" }); //btn
298    $("#btn_contact").html("Submit"); //btn
299  }
300  if (email == "") {
301    $("#email").css({ border: "2px solid #dc3545" }); //border of input
302    $("#email_validation").html(
303      '<span style="color:red;">Email is required</span>'
304    ); //validation text
305    $("#btn_contact").attr("disabled", false); //btn
306    $("#btn_contact").css({ cursor: "pointer" }); //btn
307    $("#btn_contact").html("Submit"); //btn
308  } else if (!testEmail.test(email)) {
309    $("#email").css({ border: "2px solid #dc3545" }); //border of input
310    $("#email_validation").html(
311      '<span style="color:red;">Please Enter Valid Email Address</span>'
312    ); //validation text
313    $("#btn_contact").attr("disabled", false); //btn
314    $("#btn_contact").css({ cursor: "pointer" }); //btn
315    $("#btn_contact").html("Submit"); //btn
316  }
317  if (!phone.match(/^\d+$/)) {
318    $("#phone").css({ border: "2px solid #dc3545" }); //border of input
319    $("#phone_validation").html(
320      '<span style="color:red;">Please Enter Valid Phone Number</span>'
321    ); //validation text
322    $("#btn_contact").attr("disabled", false); //btn
323    $("#btn_contact").css({ cursor: "pointer" }); //btn
324    $("#btn_contact").html("Submit"); //btn
325  } else if (phone.length > 10) {
326    $("#phone").css({ border: "2px solid #dc3545" }); //border of input
327    $("#phone_validation").html(
328      '<span style="color:red;">Please Enter Valid Phone Number. Do not include + sign</span>'
329    ); //validation text
330    $("#btn_contact").attr("disabled", false); //btn
331    $("#btn_contact").css({ cursor: "pointer" }); //btn
332    $("#btn_contact").html("Submit"); //btn
333  }
334  if (message == "") {
335    $("#message").css({ border: "2px solid #dc3545" }); //border of input
336    $("#message_validation").html(
337      '<span style="color:red;">Message is required</span>'
338    ); //validation text
339    $("#btn_contact").attr("disabled", false); //btn
340    $("#btn_contact").css({ cursor: "pointer" }); //btn
341    $("#btn_contact").html("Submit"); //btn
342  } else if (message.length < 5) {
343    $("#message").css({ border: "2px solid #dc3545" }); //border of input
344    $("#message_validation").html(
345      '<span style="color:red;">Message should be more than 5 letters</span>'
346    ); //validation text
347    $("#btn_contact").attr("disabled", false); //btn
348    $("#btn_contact").css({ cursor: "pointer" }); //btn
349    $("#btn_contact").html("Submit"); //btn
350  } else {
351    let url = $(this).attr("action");
352    // formData = {
353    //   full_name : full_name,
354    //   email : email,
355    //   country : country,
356    //   phone : phone,
357    //   message : message,
358    // }
359    var formData = $(this).serializeArray();
360    // var formData = new FormData($('#contactForm')[0]);
361    $.ajax({
362      url: url,
363      type: "POST",
364      data: formData,
365      success: function (data) {
366        let json = JSON.parse(data);
367        if (json.code == 0) {
368          $("#btn_contact").html("Submit");
369          $("#" + json.type + "").html(
370            '<span style="color:red;">
370' + json.message + "</span>"
371          );
372          $("#btn_contact").attr("disabled", false); //btn
373          $("#btn_contact").css({ cursor: "pointer" }); //btn
374          $("#btn_contact").html("Submit"); //btn
375        } else {
376          //reset
377          $("#btn_contact").html("Submit");
378          $("#btn_contact").attr("disabled", false); //btn
379          $("#btn_contact").css({ cursor: "pointer" }); //btn
380          $("#btn_contact").html("Submit"); //btn
381          $("#error").html(
382            '<span class="text-success">' + json.message + "</span>"
383          ); //btn
384          $("input").val("");
385          $("textarea").val("");
386        }
387      },
388      error: function (result) {
389        console.log(result);
390      },
391    });
392  }
393}); //submit
394function test_new() {
395  console.log("lg");
396}
397function myPrintFunction() {
398  window.print();
399}
400
401// Adrotate start
402(function ($) {
403  $.fn.gslider = function (settings) {
404    var config = { groupid: 0, speed: 3000 };
405    if (settings) $.extend(true, config, settings);
406
407    this.each(function (i) {
408      var $cont = $(this);
409      var gallery = $(this).children();
410      var length = gallery.length;
411      var timer = 0;
412      var counter = 1;
413
414      if (length == 1) {
415        // Impression tracker (Single ad)
416        var tracker = $cont.find(".c-1 a").attr("data-track");
417        if (typeof tracker !== "undefined") {
418          impressiontracker(tracker);
419        }
420      }
421
422      if (length > 1) {
423        $cont.find(".c-1").show();
424        for (n = 2; n <= length; n++) {
425          $cont.find(".c-" + n).hide();
426        }
427
428        timer = setInterval(function () {
429          play();
430        }, config.speed);
431      }
432
433      function transitionTo(gallery, index) {
434        if (counter >= length || index >= length) {
435          counter = 1;
436        } else {
437          counter++;
438        }
439        $cont.find(".c-" + counter).show();
440
441        // Impression tracker (Multiple ads)
442        var tracker = $cont.find(".c-" + counter + " a").attr("data-track");
443        if (typeof tracker !== "undefined") {
444          impressiontracker(tracker);
445        }
446        $cont.find(".c-" + index).hide();
447      }
448
449      function play() {
450        transitionTo(gallery, counter);
451      }
452
453      function impressiontracker(tracker) {
454        admeta = atob(tracker).split(",");
455        var name = escape("adrotate-" + admeta[0]);
456        var now = Math.round(Date.now() / 1000);
457        var expired = now - admeta[3];
458        var session = sessionStorage.getItem(name); // Get session data
459
460        if (session == null) {
461          // New session, no previous data
462          session = 0;
463        }
464
465        if (session <= expired) {
466          // Count new impression?
467          $.post(impression_object.ajax_url, {
468            action: "adrotate_impression",
469            track: tracker,
470          });
471          sessionStorage.setItem(name, now);
472          delete tracker;
473        }
474      }
475    });
476    return this;
477  };
478})(jQuery);
479
480// Adrotate end

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.