(function ($) { 'use strict' var $user = JSON.parse(localStorage.getItem("user")) $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), "authorization": ($user != null) ? $user.api_token : null, "x-device-type": ($user != null && $user['device-type'] != null) ? $user.device - type : null, "x-device-token": ($user != null && $user['device-token'] != null) ? $user.device - token : null, /*'Content-Type': 'application/json; charset=utf-8'*/ } }); if ($('[data-toggle="popover"]').length > 0) { $('[data-toggle="popover"]').popover(); } // Remember checkbox if ($('.chk-remember').length) { $('.chk-remember').iCheck({ checkboxClass: 'icheckbox_square-orange', radioClass: 'iradio_square-orange', }); } $(document).on("ifChanged", "#agree", function () { var $ME = $(this); if ($ME.is(':checked')) { $("button[type=submit]").prop("disabled", false); } else { $("button[type=submit]").prop("disabled", true); } }); $('form.ajax-form').each(function ($key, $form) { var $action = $($form).attr("data-action"); var $redirectTo = $($form).attr("data-redirect"); var $method = $($form).attr("method"); var $rules = {}; var $messages = {}; if ($($form).find(".required-field").length > 0) { $($form).find(".required-field").each(function ($inputKey, $input) { var $name = $($input).prop("name"); $rules[$name] = { required: true }; $messages[$name] = { required: "The " + $name.replace("_", " ") + " field is required." }; }); } $($form).validate({ errorElement: "strong", errorClass: "is-invalid", focusInvalid: false, // do not focus the last invalid input rules: $rules, messages: $messages, invalidHandler: function (event, validator) { //$("div.danger-message h3").text("Sorry, there was a problem!"); //$("div.danger-message").removeClass("hide"); //window.bundleObj.showDangerMessage(); }, errorPlacement: function ($error, $element) { //var $errorId = ".error_" + $($element).prop("id"); //$($form).find($errorId).text($($error).text()); if ($element.parent('.input-group').length) { $error.insertAfter($element.parent()); } else if ($element.siblings("span.invalid-feedback").length) { $element.siblings("span.invalid-feedback").html($($error)); } else { $error.insertAfter($element); } }, success: function ($label, $element) { }, submitHandler: function ($form) { if ($($form).serialize() == '') { alert("You have at least one field."); return; } $.ajax({ url: $action, type: $method, beforeSend: showSpinner(), redirect: true, //data: new FormData($(this)), data: new FormData($form), //data : $($form).serialize(), processData: false, contentType: false, success: function ($response) { hideSpinner(); serverResponse($response, $redirectTo); } }).fail(function ($response) { $response = $response.responseJSON; hideSpinner(); serverResponse($response, $redirectTo); var $errors = $response.data; console.log($response); $.each($errors, function ($errorKey, $errorValue) { //$('.error_' + $errorKey).text($errorValue).show(); $("#" + $errorKey).addClass("is-invalid"); $("#" + $errorKey).siblings("span.invalid-feedback").html("" + $errorValue + ""); }); }); } }); }); function showSpinner() { getSpinner(); $(".ajax-loader").removeClass("d-none"); $("button[type=submit]").prop("disabled", true); $("input[type=submit]").prop("disabled", true); } function hideSpinner() { $(".ajax-loader").addClass("d-none"); $("button[type=submit]").prop("disabled", false); $("input[type=submit]").prop("disabled", false); } function getSpinner() { var $spinner = '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
'; $(".ajax-loader").html($spinner); } function serverResponse($response, $redirectTo) { switch ($response.code) { case 200: { if (typeof $response.identifier != "undefined" && typeof $response.data.id != "undefined") { localStorage.setItem($response.identifier, JSON.stringify($response.data)) } serverMessageHtml("success", $response); setTimeout(function () { window.location.href = $redirectTo; }, 2000); break; } case 401: { serverMessageHtml("warning", $response) break; } case 400: { serverMessageHtml("error", $response) break; } case 422: { serverMessageHtml("error", $response) break; } case 429: { serverMessageHtml("warning", $response) break; } default: { break; } } } function serverMessageHtml($className, $response) { var $options = { progressBar: true, closeButton: true }; toastr[$className]($response.message, reverseSlugify($className) + "!", $options); } function reverseSlugify($str) { return $str.toLowerCase().replace(/\b[a-z]/g, function (letter) { return letter.toUpperCase(); }); } })(jQuery); function checkedSelect($this) { let value = ($($this).val() == 'true') ? false : true; $($this).prop("value", value) } // new code $(document).ready(function () { $(document).on("click", "a.delete", function () { //$('a.delete').on('click', function() { if (confirm('Are you sure you want to delete this item?')) { var ME = $(this); var actionUrl = ME.data('action'); //alert(actionUrl); $('.ajax-loader').show(); $.ajax({ url: actionUrl, success: function (result) { var success_html = ''; success_html += '
'; success_html += ''; success_html += ''; success_html += ' Your item has been deleted successfully.'; success_html += '
'; //alert(success_html); $("#success-msg").html(success_html); ME.parents('tr').remove(); $('.ajax-loader').hide(); } }); } }); $('#multiple_delete').click(function () { var ME = $(this); var ids = new Array(); var actionUrl = ME.data('action'); var loadUrl = ME.data('load'); //alert(loadUrl); return; $('input[name="id[]"]').each(function () { if ($(this).is(':checked')) { ids.push($(this).val()); } }); if (ids != '') { if (confirm('Are you sure you want to delete the selected item(s)?')) { $('.ajax-loader').show(); $.ajax({ url: actionUrl, type: 'post', data: 'id=' + ids, success: function (result) { var obj = $.parseJSON(result); var success_html = ''; success_html += '
'; success_html += ''; success_html += ''; success_html += ' Your item(s) has been deleted successfully.'; success_html += '
'; //alert(success_html); $("#success-msg").html(success_html); $('.ajax-loader').hide(); //$(document).load(loadUrl); window.location = loadUrl; } }); } } else { alert('Please select records!'); } }); // Loading remote data $("select.select2-ajax").each(function (index, value) { var $ME = $(this); var $action = $ME.attr("data-action"); $ME.select2({ allowClear: true, ajax: { url: `${$action}`, dataType: 'json', delay: 250, data: function (params) { return { search: {name: params.term}, // search term }; }, processResults: function ($response) { return { results: $.map($response.data, function (obj) { return { id: obj.id, text: obj.name, slug: ((typeof obj.slug != "undefined") ? obj.slug : '') }; }) }; }, cache: true }, escapeMarkup: function (markup) { return markup; }, // let our custom formatter work //templateResult: formatRepo, // omitted for brevity, see the source of this page //minimumInputLength: 1, templateSelection: formatRepoSelection // omitted for brevity, see the source of this page }).on("select2:select", function ($e) { var $data = $e.params.data; if ($data.slug != "") { $("#slug").val($data.slug); } }); }); $("select.sortable-select2-ajax").each(function (index, value) { var $ME = $(this); var $action = $ME.attr("data-action"); $ME.select2({ allowClear: true, ajax: { url: `${$action}`, dataType: 'json', delay: 250, data: function (params) { return { search: {name: params.term, not: $ME.val()}, // search term }; }, processResults: function ($response) { return { results: $.map($response.data, function (obj) { return { id: obj.id, text: obj.name, slug: ((typeof obj.slug != "undefined") ? obj.slug : ''), not_in: $ME.val() }; }) }; }, cache: true }, escapeMarkup: function (markup) { return markup; }, // let our custom formatter work //templateResult: formatRepo, // omitted for brevity, see the source of this page //minimumInputLength: 1, templateSelection: formatRepoSelection // omitted for brevity, see the source of this page }).on("select2:select", function ($e) { var $data = $e.params.data; if ($data.slug != "") { $("#slug").val($data.slug); } }); }); // select2-dependent $("select.default-selected").each(function (index, value) { var $ME = $(this); var $action = $ME.attr("data-action"); if ($ME.length > 0) { if ($ME.attr("data-default-selected").length > 0) { $.ajax({ url: `${$action}?id=${$ME.attr("data-default-selected")}`, type: 'GET', success: function ($result) { var $data = $result.data; $.each($data, function ($index, $value) { /* var $selected = ''; if($value.id == $ME.attr("data-default-selected")){ $selected = "selected='selected'"; }*/ $ME.html(``) }) } }); } } }); $(".select2-search").select2({ allowClear: true }).on("select2:select", function ($e) { var $data = $e.params.data; if (typeof $($(this).attr("data-dependent")).attr("data-dependent") != "undefined") { dependenceLoad($(this).attr("data-dependent"), $data); } }); if($(".select2-dependent").length > 0){ $(".select2-dependent").select2({ allowClear: true }); $(".select2-dependent").each(function (index, value) { var $this = this; if($($this).attr("id") == "team_one"){ let team1_title = $('.teams-1 option:Selected').text().replace(/\s/g, ' '); let team1_url = $('.teams-1 option:Selected').text().replace(/\s/g, '-').toLowerCase(); let team2_title = $('teams-2 option:Selected').text().replace(/\s/g, ' '); let team2_url = $('teams-2 option:Selected').text().replace(/\s/g, '-').toLowerCase(); $("#event_name").val(team1_title); $("#page_title").val(team1_title + " Watch Online Live Stream"); $("#slug").val(team1_url + "-live-streaming"); $("#meta_keyword, #meta_description, #article").val("Watch " + team1_title + " Live Stream, Watch Live sports streams online on your pc and mobile, Watch " + team1_title + " Live Stream, Watch " + team1_title + " Live Mobile Stream, " + team1_title + " Live Streaming, " + team1_title + " Live, Watch " + team1_title + " Online, " + team1_title + " Stream, " + team1_title + " Online, " + team1_title + " Streams, " + team1_title + " Free Stream, " + team1_title + " Football, " + team1_title + " UK streaming in HD, " + team1_title + " video stream, Free " + team1_title + " HD Streaming, Free " + team1_title + " Watch online."); } if($($this).attr("id") == "team_two"){ let team1_title = $('.teams-1 option:Selected').text().replace(/\s/g, ' '); let team1_url = $('.teams-1 option:Selected').text().replace(/\s/g, '-').toLowerCase(); let team2_title = $('.teams-2 option:Selected').text().replace(/\s/g, ' '); let team2_url = $('.teams-2 option:Selected').text().replace(/\s/g, '-').toLowerCase(); $("#event_name").val(team1_title + " vs " + team2_title); $("#page_title").val(team1_title + " vs " + team2_title + " Watch Online Live Stream"); $("#slug").val(team1_url + "-vs-" + team2_url + "-live-streaming"); $("#meta_keyword, #meta_description, #article").val("Watch "+team1_title+" vs "+team2_title+" Live Stream, Watch Live sports streams online on your pc and mobile, Watch "+team1_title+" vs "+team2_title+" Live Stream, Watch "+team1_title+" vs "+team2_title+" Live Mobile Stream, "+team1_title+" vs "+team2_title+" Live Streaming, "+team1_title+" vs "+team2_title+" Live, Watch "+team1_title+" vs "+team2_title+" Online, "+team1_title+" vs "+team2_title+" Stream, "+team1_title+" vs "+team2_title+" Online, "+team1_title+" vs "+team2_title+" Streams, "+team1_title+" vs "+team2_title+" Free Stream, "+team1_title+" vs "+team2_title+" Football, "+team1_title+" vs "+team2_title+" UK streaming in HD, "+team1_title+" vs "+team2_title+" video stream, Free "+team1_title+" vs "+team2_title+" HD Streaming, Free "+team1_title+" vs "+team2_title+" Watch online."); } dependenceLoad($this, {id : $($this).val()}) }) } function dependenceLoad(element, $data,) { var $dependent = $(element).attr("data-dependent"); var $action = $($dependent).attr("data-action"); $($dependent).select2({ allowClear: true, ajax: { url: `${$action}`, dataType: 'json', delay: 250, data: function (params) { return { search: {name: params.term, dependent_id: $data.id, category_id: $("#categories").val(), competition_id: $("#competitions").val(), team_one: $("#team_one").val(), team_two: $("#team_two").val()}, // search term }; }, processResults: function ($response) { return { results: $.map($response.data, function (obj) { return { id: obj.id, text: obj.name, slug: ((typeof obj.slug != "undefined") ? obj.slug : '') }; }) }; }, cache: true }, escapeMarkup: function (markup) { return markup; }, // let our custom formatter work //templateResult: formatRepo, // omitted for brevity, see the source of this page //minimumInputLength: 1, templateSelection: formatRepoSelection // omitted for brevity, see the source of this page }).on("select2:select", function ($e) { var $data = $e.params.data; if ($data.slug != "") { $("#slug").val($data.slug); } }); } function formatRepoSelection(repo) { return repo.text; } $("#name").blur(function () { var name = $(this).val(); if (name != '') { //var $slug = name.replace(/\s+/g, '-').toLowerCase(); var $slug = name.toLowerCase().trim().replace(/ /g, '-').replace(/[^\w-]+/g, ''); //var $slug = name.toLowerCase().replace(/[^\w ]+/g,'').replace(/ +/g,'-'); $("#slug").val($slug + "-live-streaming"); $("#page_title").val(name + " Live Streaming Watch Online"); $("#meta_keyword").val(name + " Live Streaming, Watch " + name + " Live Streaming, Watch Online " + name + " Live Streaming"); $("#meta_description").val(name + " Live Streaming, Watch " + name + " Live Streaming, Watch Online " + name + " Live Streaming"); $("#article").val(name + " Live Streaming, Watch " + name + " Live Streaming, Watch Online " + name + " Live Streaming"); } else { $("#slug").val(""); $("#page_title").val(""); $("#meta_keyword").val(""); $("#meta_description").val(""); $("#article").val(""); } }); if ($('#start_time, #end_time').length > 0) { $('#start_time, #end_time').daterangepicker({ singleDatePicker: true, timePicker: true, //autoApply: true, timePicker24Hour: true, //startDate: new Date(), //minDate: moment().format('YYYY/MM/DD'), maxYear: parseInt(moment().format('YYYY'), 10), dateFormat: 'yyyy-mm-dd HH:mm:ss', locale: { format: 'YYYY-MM-DD HH:mm:ss' } }); } // vijay cricFree code // A $( document ).ready() block. /* if($('#start_time, #end_time').length > 0){ $('#start_time, #end_time').datetimepicker({ //showTodayButton: true, collapse: true, format: 'YYYY-MM-DD HH:mm:ss' }); }*/ $("#client_channel_name, #client_name").blur(function () { var name = $(this).val().trim(); var slug = name.replace(/\s+/g, '-').toLowerCase(); $("#slug").val(slug); }); /*$('.participants-categories').select2(); $('.participants-competitions').select2(); $('.participants-teams').select2(); $('.continents').select2();*/ /* $('.countries').select2();*/ /*$(".schedule-channels").select2();*/ var s2item = $(".schedule-channels"); if (s2item.length > 0) { var s2ul = s2item.next(".select2-container").find("ul.select2-selection__rendered"); s2ul.sortable({ containment: "parent", items: "li:not(.select2-search)", tolerance: "pointer", stop: function () { $(s2ul.find(".select2-selection__choice").get().reverse()).each(function () { s2item.prepend(s2item.find('option[value="' + $(this).data("data").id + '"]')[0]); }); } }); } //beCtbSelect2.events.bind(".schedule-channels"); /*$('.schedule-channels').multiSelect({ keepOrder: true selectableHeader: "
Selectable items
", selectionHeader: "
Selection items
", selectableFooter: "
Selectable footer
", selectionFooter: "
Selection footer
" }); $("ul.ms-list").sortable({ containment: 'parent' });*/ /*$('.schedule-channels').select2({ tags: true }); //$('.schedule-channels').select2Sortable(); // init sortable $("ul.select2-selection__rendered").sortable({ containment: 'parent' }); $(".schedule-channels").on("select2:select", function (evt) { var element = evt.params.data.element; var $element = $(element); $element.detach(); $(this).append($element); //$(this).trigger("change"); });*/ /* $('.search-select').select2({ allowClear: true }); $('.team-categories').select2({ allowClear: true }); */ /*$('.parent-channels').select2({ allowClear: true });*/ /* $('.competition-categories').select2({ allowClear: true });*/ /* $('.categories').select2({ allowClear: true }).on('change', function (e) { $('.ajax-loader').show(); var ME = $(this); var URL = ME.data('action'); var dataAssign = ME.data('assign'); $.ajax({ url: URL, type: 'post', data: "category_id=" + ME.val(), success: function (result) { var obj = $.parseJSON(result); var leagueOptions = ''; $(dataAssign).html($("