//copyright Onisoft 2020-2022 var OnisofOmnibus = function(app){ var root = this; var vars = { cdebug : false, lang: 'pl_PL', css:'', wraperHtml: '', isInit: false, }; /* * Public method * Can be called outside class */ /* * Constructor */ this.construct = function(app){ if(app != ''){ vars.appPurl = atob(app); } }; this.setAppUrl = function(appPurl){ vars.appPurl = appPurl; }; this.loadDataJson = function (url, ctype, cdata) { var lastChar = vars.appPurl.substr(-1); let lUrl = vars.appPurl; if (lastChar !== '/') { lUrl = lUrl + '/' + url; } else{ lUrl = lUrl + url; } root.printDebugV(lUrl); root.printDebugV(cdata); return(jQuery.ajax({ url: lUrl, type: ctype, data: cdata, async: true, jsonp: 'jsonp' })); } this.loadOptions = function(options){ $.extend(vars , options); if(typeof vars.aplication_debug != 'undefined'){ if(vars.aplication_debug == '1'){ vars.cdebug = true; } } root.printDebug('option list'); root.printDebugV(vars); }; this.printDebugV = function(info) { if(vars.cdebug == true){ console.log(info); } }; this.printDebug = function(info) { if(vars.cdebug == true){ console.log(vars.appName +' : ' + info); } }; this.printInfo = function(info) { console.log(vars.appName +' : ' + info); }; this.loadProductStock = function(productid, stockid){ let adata = {product_id:productid, stock_id:stockid}; root.printDebugV(adata); return(this.loadDataJson('execAjax.php', 'GET', adata)); }; this.init = function(callback) { root.printDebug('init'); if($('body.shop_product').length > 0){ var prid = $('.form-basket').find('input[name="product_id"]').val(); var prstockid = $('.form-basket').find('input[name="stock_id"]').val(); $.when( this.loadProductStock(prid, prstockid) ).then(function(resultData) { console.log(resultData); if(resultData.status == true){ let odate = resultData.data.omn_date; let oprice = resultData.data.omn_price; let plnNbr = new Intl.NumberFormat('pl-PL', { style: 'currency', currency: 'PLN', }); let otext = "Najniższa cena z 30 dni: "+ plnNbr.format(oprice); $('.basket .price').after('
'+otext+'
'); } }); var addCss = root.prepareCss(); if(typeof addCss != 'undefined' && addCss != ''){ $('body').append(''); } } root.printDebug('init end'); }; /* * Private method */ this.prepareCss=function(){ root.printDebug('prepareCss - start'); vars.css = ''; root.printDebug('prepareCss - end'); return(vars.css); }; var setEvents = function(){ }; this.construct(app); setEvents(); };$(function() { var appOmnibus = new OnisofOmnibus(''); appOmnibus.setAppUrl('https://metryicentymetry.pl/_aps/shoper_omnibus/'); appOmnibus.loadOptions({cdebug : true,appName: 'Omnibus'}); appOmnibus.init( function() { } ); });