Compare commits
2 Commits
69739c63a9
...
19416c7592
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19416c7592 | ||
|
|
ed7205a9c2 |
29
build.js
29
build.js
@ -86,31 +86,26 @@ function generateIframe(css, html, js) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform CSS classes from dog-calculator- to dog-calc-
|
||||
* No transformation needed - keep original class names for consistency
|
||||
*/
|
||||
function transformCSSForWidget(css) {
|
||||
return css
|
||||
.replace(/\.dog-calculator-/g, '.dog-calc-')
|
||||
.replace(/#dog-calculator/g, '#dog-calc')
|
||||
.replace(/dog-calculator-/g, 'dog-calc-');
|
||||
return css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform HTML for widget (class names and IDs)
|
||||
* No transformation needed - keep original class names for consistency
|
||||
*/
|
||||
function transformHTMLForWidget(html) {
|
||||
return html
|
||||
.replace(/dog-calculator-/g, 'dog-calc-')
|
||||
.replace(/id="dogCalculator"/g, 'id="dogCalc"');
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create production-ready widget JavaScript
|
||||
*/
|
||||
function createWidgetJS(css, html, js) {
|
||||
// Transform CSS and HTML for widget namespacing
|
||||
const widgetCSS = transformCSSForWidget(css);
|
||||
const widgetHTML = transformHTMLForWidget(html);
|
||||
// Use original CSS and HTML without transformation for consistency
|
||||
const widgetCSS = css;
|
||||
const widgetHTML = html;
|
||||
|
||||
const widgetCode = `/**
|
||||
* Dog Calorie Calculator Widget
|
||||
@ -134,10 +129,10 @@ function createWidgetJS(css, html, js) {
|
||||
const CSS_STYLES = \`${widgetCSS}\`;
|
||||
|
||||
function injectStyles() {
|
||||
if (document.getElementById('dog-calc-styles')) return;
|
||||
if (document.getElementById('dog-calculator-styles')) return;
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.id = 'dog-calc-styles';
|
||||
style.id = 'dog-calculator-styles';
|
||||
style.textContent = CSS_STYLES;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
@ -235,9 +230,9 @@ function createWidgetJS(css, html, js) {
|
||||
const errorElement = $('#' + elementId);
|
||||
if (errorElement) {
|
||||
if (show) {
|
||||
errorElement.classList.remove('dog-calc-hidden');
|
||||
errorElement.classList.remove('dog-calculator-hidden');
|
||||
} else {
|
||||
errorElement.classList.add('dog-calc-hidden');
|
||||
errorElement.classList.add('dog-calculator-hidden');
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -428,7 +423,7 @@ function createWidgetJS(css, html, js) {
|
||||
init: () => {
|
||||
calc.bindEvents();
|
||||
calc.updateUnitLabels(); // Initialize unit labels
|
||||
const calcContainer = $('#dogCalc');
|
||||
const calcContainer = $('#dogCalculator');
|
||||
if (calcContainer) {
|
||||
calcContainer.classList.add('loaded');
|
||||
}
|
||||
|
||||
14
iframe.html
14
iframe.html
@ -1036,19 +1036,19 @@
|
||||
<span class="dog-calculator-modal-close" id="shareModalClose">×</span>
|
||||
<h3>Share Calculator</h3>
|
||||
<div class="dog-calculator-share-buttons">
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-facebook" id="shareFacebook">
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-facebook plausible-event-name=Calculator+Usage plausible-event-action=calculator-share-facebook" id="shareFacebook">
|
||||
Facebook
|
||||
</button>
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-twitter" id="shareTwitter">
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-twitter plausible-event-name=Calculator+Usage plausible-event-action=calculator-share-twitter" id="shareTwitter">
|
||||
Twitter
|
||||
</button>
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-linkedin" id="shareLinkedIn">
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-linkedin plausible-event-name=Calculator+Usage plausible-event-action=calculator-share-linkedin" id="shareLinkedIn">
|
||||
LinkedIn
|
||||
</button>
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-email" id="shareEmail">
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-email plausible-event-name=Calculator+Usage plausible-event-action=calculator-share-email" id="shareEmail">
|
||||
Email
|
||||
</button>
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-copy" id="shareCopy">
|
||||
<button class="dog-calculator-share-btn dog-calculator-share-copy plausible-event-name=Calculator+Usage plausible-event-action=calculator-share-copy-link" id="shareCopy">
|
||||
Copy Link
|
||||
</button>
|
||||
</div>
|
||||
@ -1069,7 +1069,7 @@
|
||||
<h4>⚡ JavaScript Widget</h4>
|
||||
<div class="dog-calculator-code-container">
|
||||
<pre><code id="widgetCode"></code></pre>
|
||||
<button class="dog-calculator-copy-btn" id="copyWidget">
|
||||
<button class="dog-calculator-copy-btn plausible-event-name=Calculator+Usage plausible-event-action=calculator-embed-js" id="copyWidget">
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
@ -1079,7 +1079,7 @@
|
||||
<h4>🛡️ iframe Embed</h4>
|
||||
<div class="dog-calculator-code-container">
|
||||
<pre><code id="iframeCode"></code></pre>
|
||||
<button class="dog-calculator-copy-btn" id="copyIframe">
|
||||
<button class="dog-calculator-copy-btn plausible-event-name=Calculator+Usage plausible-event-action=calculator-embed-iframe" id="copyIframe">
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user