fixed CSP error with inline js
This commit is contained in:
@@ -111,6 +111,7 @@ cached: dict = {
|
||||
"css_response": open("styles/human_readable.css", "r").read(),
|
||||
"css_collapsible": open("styles/collapsible.css", "r").read(),
|
||||
"js_collapsible": open("js/collapsible.js", "r").read(),
|
||||
"js_shortcode": open("js/shortcode.js", "r").read(),
|
||||
}
|
||||
|
||||
# Fill the chapter list with unique chapters for seeking back and forward by index.
|
||||
@@ -125,6 +126,13 @@ for book in range(1, 67):
|
||||
"SELECT c FROM fts_kjv where b = ? ORDER BY id DESC LIMIT 1;", (book,)
|
||||
).fetchone()[0]
|
||||
|
||||
@app.get("/js/shortcode.js")
|
||||
def serve_shortcode_js():
|
||||
return cached.get("js_shortcode")
|
||||
|
||||
@app.get("/js/collapsible.js")
|
||||
def serve_collapsible_js():
|
||||
return cached.get("js_collapsible")
|
||||
|
||||
def generate_short_id():
|
||||
remain = random.randrange(614_656, 17_210_367) # resolves to length of 5
|
||||
@@ -467,7 +475,7 @@ def parse_query(query_override: str = None):
|
||||
)
|
||||
result += "<div class='definition'>" + definition + "</div>"
|
||||
logging.debug(f"parse_query.define = '{word}'")
|
||||
result += "<script>" + cached["js_collapsible"] + "</script>"
|
||||
result += "<script src='/js/collapsible.js'></script>"
|
||||
result += "<hr>"
|
||||
# result += search()
|
||||
#logging.debug(f"parse_query.search = '{result}'")
|
||||
|
||||
+2
-9
@@ -22,14 +22,7 @@
|
||||
<a href="{next_chapter_link}">{next_chapter_name}</a>
|
||||
→
|
||||
</div>
|
||||
<script>
|
||||
function make_shortcode(){{
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
var theUrl = "/mksc/" + document.getElementById("searchBar").value;
|
||||
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
|
||||
xmlHttp.send( null );
|
||||
document.getElementById("context_href").innerHTML = xmlHttp.responseText;
|
||||
document.getElementById('context_href').setAttribute("href", "/" + xmlHttp.responseText);
|
||||
}}
|
||||
<script src="js/shortcode.js">
|
||||
make_shortcode();
|
||||
</script>
|
||||
</header>
|
||||
@@ -0,0 +1,8 @@
|
||||
function make_shortcode(){{
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
const theUrl = "/mksc/" + document.getElementById("searchBar").value;
|
||||
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
|
||||
xmlHttp.send( null );
|
||||
document.getElementById("context_href").innerHTML = xmlHttp.responseText;
|
||||
document.getElementById('context_href').setAttribute("href", "/" + xmlHttp.responseText);
|
||||
}}
|
||||
Reference in New Issue
Block a user