|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Widget Test Page</title> |
| 7 | + <style> |
| 8 | + * { box-sizing: border-box; } |
| 9 | + body { |
| 10 | + font-family: system-ui, -apple-system, sans-serif; |
| 11 | + max-width: 1200px; |
| 12 | + margin: 0 auto; |
| 13 | + padding: 40px 20px; |
| 14 | + background: #f5f5f5; |
| 15 | + } |
| 16 | + h1 { color: #1f2937; margin-bottom: 8px; } |
| 17 | + .subtitle { color: #6b7280; margin-bottom: 32px; } |
| 18 | + .test-section { |
| 19 | + background: white; |
| 20 | + border-radius: 12px; |
| 21 | + padding: 24px; |
| 22 | + margin-bottom: 24px; |
| 23 | + box-shadow: 0 1px 3px rgba(0,0,0,0.1); |
| 24 | + } |
| 25 | + .test-section h2 { |
| 26 | + font-size: 18px; |
| 27 | + color: #374151; |
| 28 | + margin-bottom: 16px; |
| 29 | + padding-bottom: 12px; |
| 30 | + border-bottom: 1px solid #e5e7eb; |
| 31 | + } |
| 32 | + .widget-container { |
| 33 | + min-height: 200px; |
| 34 | + border: 2px dashed #d1d5db; |
| 35 | + border-radius: 8px; |
| 36 | + padding: 16px; |
| 37 | + background: #fafafa; |
| 38 | + } |
| 39 | + .instructions { |
| 40 | + background: #eff6ff; |
| 41 | + border: 1px solid #bfdbfe; |
| 42 | + border-radius: 8px; |
| 43 | + padding: 16px; |
| 44 | + margin-bottom: 24px; |
| 45 | + } |
| 46 | + .instructions h3 { color: #1e40af; margin-bottom: 8px; font-size: 14px; } |
| 47 | + .instructions ol { margin: 0; padding-left: 20px; color: #1e3a8a; } |
| 48 | + .instructions li { margin-bottom: 4px; } |
| 49 | + .instructions code { |
| 50 | + background: #dbeafe; |
| 51 | + padding: 2px 6px; |
| 52 | + border-radius: 4px; |
| 53 | + font-size: 13px; |
| 54 | + } |
| 55 | + #widget-key-input { |
| 56 | + width: 200px; |
| 57 | + padding: 8px 12px; |
| 58 | + border: 1px solid #d1d5db; |
| 59 | + border-radius: 6px; |
| 60 | + font-family: monospace; |
| 61 | + } |
| 62 | + button { |
| 63 | + padding: 8px 16px; |
| 64 | + background: #3b82f6; |
| 65 | + color: white; |
| 66 | + border: none; |
| 67 | + border-radius: 6px; |
| 68 | + cursor: pointer; |
| 69 | + margin-left: 8px; |
| 70 | + } |
| 71 | + button:hover { background: #2563eb; } |
| 72 | + .input-group { margin-bottom: 16px; } |
| 73 | + label { display: block; margin-bottom: 4px; font-weight: 500; color: #374151; } |
| 74 | + </style> |
| 75 | +</head> |
| 76 | +<body> |
| 77 | + <h1>Widget Test Page</h1> |
| 78 | + <p class="subtitle">Test your PropertyWebBuilder embeddable widgets here</p> |
| 79 | + |
| 80 | + <div class="instructions"> |
| 81 | + <h3>How to test:</h3> |
| 82 | + <ol> |
| 83 | + <li>Create a widget at <code>/site_admin/widgets/new</code></li> |
| 84 | + <li>Copy the widget key (e.g., <code>abc123xyz</code>)</li> |
| 85 | + <li>Paste it below and click "Load Widget"</li> |
| 86 | + </ol> |
| 87 | + </div> |
| 88 | + |
| 89 | + <div class="test-section"> |
| 90 | + <h2>JavaScript Embed Test</h2> |
| 91 | + <div class="input-group"> |
| 92 | + <label for="widget-key-input">Widget Key:</label> |
| 93 | + <input type="text" id="widget-key-input" placeholder="e.g., abc123xyz"> |
| 94 | + <button onclick="loadWidget()">Load Widget</button> |
| 95 | + </div> |
| 96 | + <div id="js-widget-container" class="widget-container"> |
| 97 | + <p style="color: #9ca3af; text-align: center; margin-top: 60px;"> |
| 98 | + Enter a widget key above to load the widget |
| 99 | + </p> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + |
| 103 | + <div class="test-section"> |
| 104 | + <h2>Iframe Embed Test</h2> |
| 105 | + <div class="input-group"> |
| 106 | + <label for="iframe-key-input">Widget Key:</label> |
| 107 | + <input type="text" id="iframe-key-input" placeholder="e.g., abc123xyz"> |
| 108 | + <button onclick="loadIframe()">Load Iframe</button> |
| 109 | + </div> |
| 110 | + <div id="iframe-widget-container" class="widget-container"> |
| 111 | + <p style="color: #9ca3af; text-align: center; margin-top: 60px;"> |
| 112 | + Enter a widget key above to load the iframe widget |
| 113 | + </p> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + |
| 117 | + <script> |
| 118 | + function loadWidget() { |
| 119 | + const key = document.getElementById('widget-key-input').value.trim(); |
| 120 | + if (!key) { |
| 121 | + alert('Please enter a widget key'); |
| 122 | + return; |
| 123 | + } |
| 124 | + |
| 125 | + const container = document.getElementById('js-widget-container'); |
| 126 | + container.innerHTML = '<div id="pwb-widget-' + key + '"></div>'; |
| 127 | + |
| 128 | + // Remove any existing script |
| 129 | + const existingScript = document.getElementById('pwb-widget-script'); |
| 130 | + if (existingScript) existingScript.remove(); |
| 131 | + |
| 132 | + // Load the widget script |
| 133 | + const script = document.createElement('script'); |
| 134 | + script.id = 'pwb-widget-script'; |
| 135 | + script.src = '/widget.js'; |
| 136 | + script.dataset.widgetId = key; |
| 137 | + script.async = true; |
| 138 | + container.appendChild(script); |
| 139 | + } |
| 140 | + |
| 141 | + function loadIframe() { |
| 142 | + const key = document.getElementById('iframe-key-input').value.trim(); |
| 143 | + if (!key) { |
| 144 | + alert('Please enter a widget key'); |
| 145 | + return; |
| 146 | + } |
| 147 | + |
| 148 | + const container = document.getElementById('iframe-widget-container'); |
| 149 | + container.innerHTML = ` |
| 150 | + <iframe |
| 151 | + src="/widget/${key}" |
| 152 | + width="100%" |
| 153 | + height="600" |
| 154 | + frameborder="0" |
| 155 | + style="border: none; width: 100%; min-height: 600px;" |
| 156 | + loading="lazy" |
| 157 | + title="Property Listings"> |
| 158 | + </iframe> |
| 159 | + `; |
| 160 | + } |
| 161 | + </script> |
| 162 | +</body> |
| 163 | +</html> |
0 commit comments