/******************************************************************* Module : /assets/js/simulator.js Desc. : JS Class Simulator Data dalam Code Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : March 18th, 2021. Last Modified : December 26th, 2025. (c) 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ var Simulator = function(options){ var vars = { 'url': '', 'param': [] }; this.construct = function(options){ if (typeof options == 'object') { $.extend(vars, options); } else vars.url = options; }; this.set_url = function (url){ vars.url = url; }; this.add_param = function (par_id, par_val){ var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id; vars.param.push(_getvalue); }, this.doPreview = function(){ if (!vars.url) console.warn(vars.param + ", cek url php!"); $.ajax({ type: 'POST', url: vars.url, data: FoniaJS.RequestParam(vars.param), success: function(data){ if (data.length == 0) { FoniaJS.showInfo('Tidak ada data !'); return false; } var _divd = ''; for (var no = 0; no < data.length; no++) { _divd += '
' + data[no] + '
'; } var _wtxt = ''; if ($('#winAPPSim')) $('#winAPPSim').modal('dispose').remove(); $(_wtxt).on('shown.bs.modal', function(e){ $('#winAPPSim').find('#tombSalin').click(function(){ window.getSelection().removeAllRanges(); $('.sim-code').each(function(i, ele) { var range = document.createRange(); range.selectNode(ele); window.getSelection().addRange(range); }); document.execCommand('copy'); window.getSelection().removeAllRanges(); FoniaJS.showInfo('Sukses salin semua Kode !'); }); $('#winAPPSim').find('.sim-code').click(function(){ var range = document.createRange(); range.selectNode(this); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); document.execCommand('copy'); window.getSelection().removeAllRanges(); //$(this).addClass('bg-success'); $(this).addClass('d-none'); }); }).on('hidden.bs.modal', function(e){ $(this).remove(); }).modal('show'); }, error: (typeof vars.onFailure === "function") ? vars.onFailure : null, dataType: 'json' }); }; this.construct(options); };