uawdijnntqw1x1x1
IP : 18.116.23.218
Hostname : ns1.eurodns.top
Kernel : Linux ns1.eurodns.top 4.18.0-553.5.1.lve.1.el7h.x86_64 #1 SMP Fri Jun 14 14:24:52 UTC 2024 x86_64
Disable Function : mail,sendmail,exec,passthru,shell_exec,system,popen,curl_multi_exec,show_source,eval,open_base
OS : Linux
PATH:
/
home
/
sudancam
/
.
/
.trash
/
sudancam.sd
/
..
/
catalog.1
/
view
/
javascript
/
common.js
/
/
function getURLVar(key) { var value = []; var query = String(document.location).split('?'); if (query[1]) { var part = query[1].split('&'); for (i = 0; i < part.length; i++) { var data = part[i].split('='); if (data[0] && data[1]) { value[data[0]] = data[1]; } } if (value[key]) { return value[key]; } else { return ''; } } } // Tooltip var tooltip = function () { $('.tooltip').remove(); // Apply to all on current page $('[data-bs-toggle=\'tooltip\']').each(function(i, element) { bootstrap.Tooltip.getOrCreateInstance(element); }); } $(document).ready(tooltip); // Makes tooltips work on ajax generated content $(document).on('click', 'button', tooltip); // Alert Fade var alert = function () { window.setTimeout(function() { $('.alert-dismissible').fadeTo(1000, 0, function() { $(this).remove(); }); }, 7000); } $(document).ready(alert); $(document).on('click', 'button', alert); $(document).ready(function () { // Currency $('#form-currency .dropdown-item').on('click', function (e) { e.preventDefault(); $('#form-currency input[name=\'code\']').val($(this).attr('href')); $('#form-currency').submit(); }); // Search $('#search input[name=\'search\']').parent().find('button').on('click', function () { var url = $('base').attr('href') + 'index.php?route=product/search&language=' + $(this).attr('data-lang'); var value = $('header #search input[name=\'search\']').val(); if (value) { url += '&search=' + encodeURIComponent(value); } location = url; }); $('#search input[name=\'search\']').on('keydown', function (e) { if (e.keyCode == 13) { $('header #search input[name=\'search\']').parent().find('button').trigger('click'); } }); // Menu $('#menu .dropdown-menu').each(function () { var menu = $('#menu').offset(); var dropdown = $(this).parent().offset(); var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth()); if (i > 0) { $(this).css('margin-left', '-' + (i + 10) + 'px'); } }); // Product List $('#button-list').on('click', function () { var element = this; $('#product-list').attr('class', 'row row-cols-1 product-list'); $('#button-grid').removeClass('active'); $('#button-list').addClass('active'); localStorage.setItem('display', 'list'); }); // Product Grid $('#button-grid').on('click', function () { var element = this; // What a shame bootstrap does not take into account dynamically loaded columns $('#product-list').attr('class', 'row row-cols-1 row-cols-sm-2 row-cols-md-2 row-cols-lg-3'); $('#button-list').removeClass('active'); $('#button-grid').addClass('active'); localStorage.setItem('display', 'grid'); }); // Local Storage if (localStorage.getItem('display') == 'list') { $('#product-list').attr('class', 'row row-cols-1 product-list'); $('#button-list').addClass('active'); } else { $('#product-list').attr('class', 'row row-cols-1 row-cols-sm-2 row-cols-md-2 row-cols-lg-3'); $('#button-grid').addClass('active'); } /* Agree to Terms */ $('body').on('click', '.modal-link', function (e) { e.preventDefault(); var element = this; $('#modal-information').remove(); $.ajax({ url: $(element).attr('href'), dataType: 'html', success: function (html) { $('body').append(html); $('#modal-information').modal('show'); } }); }); // Cookie Policy $('#cookie button').on('click', function () { var element = this; $.ajax({ url: $(this).val(), type: 'get', dataType: 'json', beforeSend: function () { $(element).button('loading'); }, complete: function () { $(element).prop('disabled', false).removeClass('loading'); }, success: function (json) { if (json['success']) { $('#cookie').fadeOut(400, function () { $('#cookie').remove(); }); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); }); // Forms $(document).on('submit', 'form[data-oc-toggle=\'ajax\']', function (e) { e.preventDefault(); var element = this; var form = e.target; var action = $(form).attr('action'); var button = e.originalEvent.submitter; var formaction = $(button).attr('formaction'); if (formaction !== undefined) { action = formaction; } var method = $(form).attr('method'); if (method === undefined) { method = 'post'; } var enctype = $(element).attr('enctype'); if (enctype === undefined) { enctype = 'application/x-www-form-urlencoded'; } // https://github.com/opencart/opencart/issues/9690 if (typeof CKEDITOR != 'undefined') { for (instance in CKEDITOR.instances) { CKEDITOR.instances[instance].updateElement(); } } console.log(e); console.log('element ' + element); console.log('action ' + action); console.log('button ' + button); console.log('formaction ' + formaction); console.log('method ' + method); console.log('enctype ' + enctype); $.ajax({ url: action, type: method, data: $(form).serialize(), dataType: 'json', cache: false, contentType: enctype, processData: false, beforeSend: function () { $(button).prop('disabled', true).addClass('loading'); }, complete: function () { $(button).prop('disabled', false).removeClass('loading'); }, success: function (json) { $('.alert-dismissible').remove(); $(form).find('.is-invalid').removeClass('is-invalid'); $(form).find('.invalid-feedback').removeClass('d-block'); console.log(json); if (json['redirect']) { location = json['redirect']; } if (typeof json['error'] == 'string') { $('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fas fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>'); } if (typeof json['error'] == 'object') { if (json['error']['warning']) { $('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fas fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>'); } for (key in json['error']) { $('#input-' + key.replaceAll('_', '-')).addClass('is-invalid').find('.form-control, .form-select, .form-check-input, .form-check-label').addClass('is-invalid'); $('#error-' + key.replaceAll('_', '-')).html(json['error'][key]).addClass('d-block'); } } if (json['success']) { $('#alert').prepend('<div class="alert alert-success alert-dismissible"><i class="fas fa-exclamation-circle"></i> ' + json['success'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>'); // Refresh var url = $(form).attr('data-oc-load'); var target = $(form).attr('data-oc-target'); if (url !== undefined && target !== undefined) { $(target).load(url); } } // Replace any form values that correspond to form names. for (key in json) { $(form).find('[name=\'' + key + '\']').val(json[key]); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); // Upload $(document).on('click', 'button[data-oc-toggle=\'upload\']', function () { var element = this; if (!$(element).prop('disabled')) { $('#form-upload').remove(); $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" value=""/></form>'); $('#form-upload input[name=\'file\']').trigger('click'); $('#form-upload input[name=\'file\']').on('change', function (e) { if ((this.files[0].size / 1024) > $(element).attr('data-oc-size-max')) { alert($(element).attr('data-oc-size-error')); $(this).val(''); } }); if (typeof timer !== 'undefined') { clearInterval(timer); } var timer = setInterval(function () { if ($('#form-upload input[name=\'file\']').val() != '') { clearInterval(timer); $.ajax({ url: $(element).attr('data-oc-url'), type: 'post', data: new FormData($('#form-upload')[0]), dataType: 'json', cache: false, contentType: false, processData: false, beforeSend: function () { $(element).prop('disabled', true).addClass('loading'); }, complete: function () { $(element).prop('disabled', false).removeClass('loading'); }, success: function (json) { console.log(json); if (json['error']) { alert(json['error']); } if (json['success']) { alert(json['success']); } if (json['code']) { $($(element).attr('data-oc-target')).attr('value', json['code']); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }, 500); } }); // Chain ajax calls. class Chain { constructor() { this.start = false; this.data = []; } attach(call) { this.data.push(call); if (!this.start) { this.execute(); } } execute() { if (this.data.length) { this.start = true; var call = this.data.shift(); var jqxhr = call(); jqxhr.done(function() { chain.execute(); }); } else { this.start = false; } } } var chain = new Chain(); // Autocomplete (function($) { $.fn.autocomplete = function(option) { return this.each(function() { var $this = $(this); var $dropdown = $('#' + $this.attr('list')); this.timer = null; this.items = []; $.extend(this, option); // Focus $this.on('focus', function() { this.request(); }); // Keydown $this.on('input', function(e) { this.request(); var value = $this.val(); if (value && this.items[value]) { this.select(this.items[value]); } }); // Request this.request = function() { clearTimeout(this.timer); this.timer = setTimeout(function(object) { object.source($(object).val(), $.proxy(object.response, object)); }, 50, this); } // Response this.response = function(json) { var html = ''; var category = {}; var name; var i = 0, j = 0; if (json.length) { for (i = 0; i < json.length; i++) { // update element items this.items[json[i]['label']] = json[i]; if (!json[i]['category']) { // ungrouped items html += '<option>' + json[i]['label'] + '</option>'; } else { // grouped items name = json[i]['category']; if (!category[name]) { category[name] = []; } category[name].push(json[i]); } } for (name in category) { for (j = 0; j < category[name].length; j++) { html += '<option value="' + category[name][j]['label'] + '">' + name + '</option>'; } } } $dropdown.html(html); } }); } })(window.jQuery);
/home/sudancam/./.trash/sudancam.sd/../catalog.1/view/javascript/common.js