$(function () { inputChanges(); // Clipboard Copy new Clipboard('#copyCode', { text: function (trigger) { $(".copyLabelPopup").show().delay(1000).fadeOut(500); return inputChanges(); } }); }); function esc(input) { return ('' + input) /* Forces the conversion to string. */ .replace(/&/g, '&') /* This MUST be the 1st replacement. */ .replace(/'/g, ''') /* The 4 other predefined entities, required. */ .replace(/"/g, '"') .replace(//g, '>') /* You may add other replacements here for HTML only (but it's not necessary). Or for XML, only if the named entities are defined in its DTD. */ ; } Vue.use(VeeValidate); var dictionary = { en: { attributes: { price: 'Price', checkoutDesc: 'Checkout Description', orderId: 'Order Id', serverIpn: 'Server IPN', notifyEmail: 'Send Email Notifications', browserRedirect: 'Browser Redirect', payButtonImageUrl: "Pay Button Image Url" } } }; VeeValidate.Validator.localize(dictionary); function getStyles (styles) { return document.getElementById(styles).innerHTML.trim().replace(/\s{2}/g, '') + '\n' } function inputChanges(event, buttonSize) { if (buttonSize !== null && buttonSize !== undefined) { srvModel.buttonSize = buttonSize; } var isFixedAmount = srvModel.buttonType == 0 var isCustomAmount = srvModel.buttonType == 1 var isSlider = srvModel.buttonType == 2 var width = "209px"; var widthInput = "3em"; if (srvModel.buttonSize === 0) { width = "146px"; widthInput = "2em"; } else if (srvModel.buttonSize === 1) { width = "168px"; } else if (srvModel.buttonSize === 2) { width = "209px"; } var html = // Styles getStyles('template-paybutton-styles') + (isSlider ? getStyles('template-slider-styles') : '') + // Form '
\n' + addInput("storeId", srvModel.storeId); if (srvModel.checkoutDesc) html += addInput("checkoutDesc", srvModel.checkoutDesc); if (srvModel.orderId) html += addInput("orderId", srvModel.orderId); if (srvModel.serverIpn) html += addInput("serverIpn", srvModel.serverIpn); if (srvModel.browserRedirect) html += addInput("browserRedirect", srvModel.browserRedirect); if (srvModel.notifyEmail) html += addInput("notifyEmail", srvModel.notifyEmail); if (srvModel.checkoutQueryString) html += addInput("checkoutQueryString", srvModel.checkoutQueryString); // Fixed amount: Add price and currency as hidden inputs if (isFixedAmount) { html += addInput("price", srvModel.price); html += addInput("currency", srvModel.currency); } // Custom amount else if (isCustomAmount) { html += '
\n
\n'; html += srvModel.simpleInput ? '' : addPlusMinusButton("-"); html += ' ' + addInputPrice(srvModel.price, widthInput, "", srvModel.simpleInput ? "number": null, srvModel.min, srvModel.max, srvModel.step); html += srvModel.simpleInput ? '' : addPlusMinusButton("+"); html += '
\n'; html += addSelectCurrency(srvModel.currency); html += '
\n'; } // Slider else if (isSlider) { html += '
\n'; html += addInputPrice(srvModel.price, width, 'onchange="document.querySelector(\'#btcpay-input-range\').value = document.querySelector(\'#btcpay-input-price\').value"'); html += addSelectCurrency(srvModel.currency); html += addSlider(srvModel.price, srvModel.min, srvModel.max, srvModel.step, width); html += '
\n'; } html += ' \n'; html += '
'; $("#mainCode").text(html).html(); $("#preview").html(html); $('pre code').each(function (i, block) { hljs.highlightBlock(block); }); return html; } function addInput(name, value) { return ' \n'; } function addPlusMinusButton(type) { return ' \n'; } function addInputPrice(price, widthInput, customFn, type, min, max, step) { return ' \n'; } function addSelectCurrency(currency) { return ' \n' } function addSlider(price, min, max, step, width) { return ' \n'; }