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) {
|
function transformCSSForWidget(css) {
|
||||||
return css
|
return css;
|
||||||
.replace(/\.dog-calculator-/g, '.dog-calc-')
|
|
||||||
.replace(/#dog-calculator/g, '#dog-calc')
|
|
||||||
.replace(/dog-calculator-/g, 'dog-calc-');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform HTML for widget (class names and IDs)
|
* No transformation needed - keep original class names for consistency
|
||||||
*/
|
*/
|
||||||
function transformHTMLForWidget(html) {
|
function transformHTMLForWidget(html) {
|
||||||
return html
|
return html;
|
||||||
.replace(/dog-calculator-/g, 'dog-calc-')
|
|
||||||
.replace(/id="dogCalculator"/g, 'id="dogCalc"');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create production-ready widget JavaScript
|
* Create production-ready widget JavaScript
|
||||||
*/
|
*/
|
||||||
function createWidgetJS(css, html, js) {
|
function createWidgetJS(css, html, js) {
|
||||||
// Transform CSS and HTML for widget namespacing
|
// Use original CSS and HTML without transformation for consistency
|
||||||
const widgetCSS = transformCSSForWidget(css);
|
const widgetCSS = css;
|
||||||
const widgetHTML = transformHTMLForWidget(html);
|
const widgetHTML = html;
|
||||||
|
|
||||||
const widgetCode = `/**
|
const widgetCode = `/**
|
||||||
* Dog Calorie Calculator Widget
|
* Dog Calorie Calculator Widget
|
||||||
@ -134,10 +129,10 @@ function createWidgetJS(css, html, js) {
|
|||||||
const CSS_STYLES = \`${widgetCSS}\`;
|
const CSS_STYLES = \`${widgetCSS}\`;
|
||||||
|
|
||||||
function injectStyles() {
|
function injectStyles() {
|
||||||
if (document.getElementById('dog-calc-styles')) return;
|
if (document.getElementById('dog-calculator-styles')) return;
|
||||||
|
|
||||||
const style = document.createElement('style');
|
const style = document.createElement('style');
|
||||||
style.id = 'dog-calc-styles';
|
style.id = 'dog-calculator-styles';
|
||||||
style.textContent = CSS_STYLES;
|
style.textContent = CSS_STYLES;
|
||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
}
|
}
|
||||||
@ -235,9 +230,9 @@ function createWidgetJS(css, html, js) {
|
|||||||
const errorElement = $('#' + elementId);
|
const errorElement = $('#' + elementId);
|
||||||
if (errorElement) {
|
if (errorElement) {
|
||||||
if (show) {
|
if (show) {
|
||||||
errorElement.classList.remove('dog-calc-hidden');
|
errorElement.classList.remove('dog-calculator-hidden');
|
||||||
} else {
|
} else {
|
||||||
errorElement.classList.add('dog-calc-hidden');
|
errorElement.classList.add('dog-calculator-hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -428,7 +423,7 @@ function createWidgetJS(css, html, js) {
|
|||||||
init: () => {
|
init: () => {
|
||||||
calc.bindEvents();
|
calc.bindEvents();
|
||||||
calc.updateUnitLabels(); // Initialize unit labels
|
calc.updateUnitLabels(); // Initialize unit labels
|
||||||
const calcContainer = $('#dogCalc');
|
const calcContainer = $('#dogCalculator');
|
||||||
if (calcContainer) {
|
if (calcContainer) {
|
||||||
calcContainer.classList.add('loaded');
|
calcContainer.classList.add('loaded');
|
||||||
}
|
}
|
||||||
|
|||||||
14
iframe.html
14
iframe.html
@ -1036,19 +1036,19 @@
|
|||||||
<span class="dog-calculator-modal-close" id="shareModalClose">×</span>
|
<span class="dog-calculator-modal-close" id="shareModalClose">×</span>
|
||||||
<h3>Share Calculator</h3>
|
<h3>Share Calculator</h3>
|
||||||
<div class="dog-calculator-share-buttons">
|
<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
|
Facebook
|
||||||
</button>
|
</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
|
Twitter
|
||||||
</button>
|
</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
|
LinkedIn
|
||||||
</button>
|
</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
|
Email
|
||||||
</button>
|
</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
|
Copy Link
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -1069,7 +1069,7 @@
|
|||||||
<h4>⚡ JavaScript Widget</h4>
|
<h4>⚡ JavaScript Widget</h4>
|
||||||
<div class="dog-calculator-code-container">
|
<div class="dog-calculator-code-container">
|
||||||
<pre><code id="widgetCode"></code></pre>
|
<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
|
Copy
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -1079,7 +1079,7 @@
|
|||||||
<h4>🛡️ iframe Embed</h4>
|
<h4>🛡️ iframe Embed</h4>
|
||||||
<div class="dog-calculator-code-container">
|
<div class="dog-calculator-code-container">
|
||||||
<pre><code id="iframeCode"></code></pre>
|
<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
|
Copy
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user