mirror of
https://github.com/aljazceru/njump.git
synced 2026-01-04 15:14:30 +01:00
Include embed.js in the binary
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
func renderEmbedjs(w http.ResponseWriter, r *http.Request) {
|
func renderEmbedjs(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/javascript")
|
w.Header().Set("Content-Type", "application/javascript")
|
||||||
http.ServeFile(w, r, "templates/embed.js")
|
|
||||||
return
|
fileContent, _ := static.ReadFile("static/embed.js")
|
||||||
|
w.Write(fileContent)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,8 @@
|
|||||||
var height = scriptElement.getAttribute('height') || 'auto';
|
var height = scriptElement.getAttribute('height') || 'auto';
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.src = host + '/' + eventParam + '?embed=yes';
|
iframe.src = host + '/' + eventParam + '?embed=yes';
|
||||||
|
|
||||||
// Basic styles
|
|
||||||
iframe.style.width = width;
|
iframe.style.width = width;
|
||||||
iframe.style.height = height;
|
iframe.style.height = height;
|
||||||
// iframe.style.border = '2px solid #b6b6b6';
|
|
||||||
// iframe.style.borderRadius = '10px';
|
|
||||||
|
|
||||||
// Add a class to easily permit overwriting the styles
|
// Add a class to easily permit overwriting the styles
|
||||||
iframe.classList.add("nostr-embedded")
|
iframe.classList.add("nostr-embedded")
|
||||||
@@ -29,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
.nostr-embedded {
|
.nostr-embedded {
|
||||||
border-color: #393939; /* Adjust the color for dark mode */
|
border-color: #393939;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -55,9 +51,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if dark mode is preferred
|
||||||
const darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
const darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
if (darkModeQuery.matches) {
|
if (darkModeQuery.matches) {
|
||||||
// Dark mode is preferred
|
|
||||||
iframe.contentWindow.postMessage({setDarkMode: true}, '*');
|
iframe.contentWindow.postMessage({setDarkMode: true}, '*');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user