@@ -122,6 +122,15 @@ class="btn btn-primary btn-sm"
122122 title="<?php echo lang ('station_logbooks_edit_logbook ' ) . ': ' . $ row ->logbook_name ;?> ">
123123 <i class="fas fa-edit"></i>
124124 </a>
125+ <?php if ($ row ->public_slug != '' ) { ?>
126+ <button class="btn btn-success btn-sm"
127+ title="Get Embed Code"
128+ data-bs-toggle="modal"
129+ data-bs-target="#embedModal"
130+ onclick="setEmbedCode('<?php echo $ row ->public_slug ; ?> ', '<?php echo addslashes ($ row ->logbook_name ); ?> ')">
131+ <i class="fas fa-code"></i>
132+ </button>
133+ <?php } ?>
125134 <?php if ($ row ->user_id == $ this ->session ->userdata ('user_id ' ) || (isset ($ row ->access_level ) && $ row ->access_level == 'admin ' )) { ?>
126135 <a href="<?php echo site_url ('logbooks/manage_sharing ' )."/ " .$ row ->logbook_id ; ?> "
127136 class="btn btn-info btn-sm"
@@ -167,3 +176,68 @@ class="btn btn-danger btn-sm"
167176<?php } ?>
168177
169178</div>
179+
180+ <!-- Embed Code Modal -->
181+ <div class="modal fade" id="embedModal" tabindex="-1" aria-labelledby="embedModalLabel" aria-hidden="true">
182+ <div class="modal-dialog modal-lg">
183+ <div class="modal-content">
184+ <div class="modal-header">
185+ <h5 class="modal-title" id="embedModalLabel">
186+ <i class="fas fa-code me-2"></i>Embed Widget - <span id="embedLogbookName"></span>
187+ </h5>
188+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
189+ </div>
190+ <div class="modal-body">
191+ <p class="text-muted mb-3">Copy the code below and paste it into your website to embed your logbook widget:</p>
192+ <div class="mb-3">
193+ <label for="embedCodeInput" class="form-label">Embed Code</label>
194+ <div class="input-group">
195+ <textarea class="form-control" id="embedCodeInput" rows="4" readonly></textarea>
196+ <button class="btn btn-primary" type="button" id="copyEmbedBtn" title="Copy to clipboard">
197+ <i class="fas fa-copy me-1"></i>Copy
198+ </button>
199+ </div>
200+ </div>
201+ <div class="alert alert-info" role="alert">
202+ <strong>Note:</strong> Make sure your logbook has a public slug configured before embedding.
203+ </div>
204+ </div>
205+ <div class="modal-footer">
206+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
207+ </div>
208+ </div>
209+ </div>
210+ </div>
211+
212+ <script>
213+ function setEmbedCode(publicSlug, logbookName) {
214+ const baseUrl = '<?php echo site_url ('widgets/qsos ' ); ?> ';
215+ const iframeCode = `<iframe src="${baseUrl}/${publicSlug}" width="100%" height="600" frameborder="0" allowfullscreen></iframe>`;
216+
217+ document.getElementById('embedCodeInput').value = iframeCode;
218+ document.getElementById('embedLogbookName').textContent = logbookName;
219+ }
220+
221+ document.addEventListener('DOMContentLoaded', function() {
222+ const copyBtn = document.getElementById('copyEmbedBtn');
223+ if (copyBtn) {
224+ copyBtn.addEventListener('click', function() {
225+ const textarea = document.getElementById('embedCodeInput');
226+ textarea.select();
227+ document.execCommand('copy');
228+
229+ // Visual feedback
230+ const originalText = copyBtn.innerHTML;
231+ copyBtn.innerHTML = '<i class="fas fa-check me-1"></i>Copied!';
232+ copyBtn.classList.add('btn-success');
233+ copyBtn.classList.remove('btn-primary');
234+
235+ setTimeout(() => {
236+ copyBtn.innerHTML = originalText;
237+ copyBtn.classList.remove('btn-success');
238+ copyBtn.classList.add('btn-primary');
239+ }, 2000);
240+ });
241+ }
242+ });
243+ </script>
0 commit comments