Skip to content

Commit

Permalink
use domain name parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Nov 7, 2024
1 parent f944e33 commit 1486492
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 36 deletions.
26 changes: 9 additions & 17 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ let theStaticRoot: string = '';
let currentTab: string;
let theUserIsLoggedIn: boolean;
let selectedURI: JQuery<HTMLElement>;
let theDomainName: string = '';
//create a synth and connect it to the main output (your speakers)
//const synth = new Tone.Synth().toDestination();

Expand Down Expand Up @@ -123,10 +124,11 @@ const slides_template = `
export interface InitializeAppOptions {
readonly level: number;
readonly keywordLanguage: string;
readonly domainName: string
/**
* The URL root where static content is hosted
*/
readonly staticRoot?: string;
readonly staticRoot?: string;
}

/**
Expand All @@ -138,6 +140,7 @@ export function initializeApp(options: InitializeAppOptions) {
theStaticRoot = options.staticRoot ?? '';
// When we are in Alpha or in dev the static root already points to an internal directory
theStaticRoot = theStaticRoot === '/' ? '' : theStaticRoot;
theDomainName = options.domainName;
initializeCopyToClipboard();

// Close the dropdown menu if the user clicks outside of it
Expand Down Expand Up @@ -1557,22 +1560,11 @@ export function toggle_blur_code() {
}
}

export async function change_language(lang: string) {
await tryCatchPopup(async () => {
const response = await postJson('/change_language', { lang });
if (response) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);

if (lang === 'en' || urlParams.get("language") !== null) {
urlParams.set("language", lang)
urlParams.set('keyword_language', lang);
window.location.search = urlParams.toString();
} else {
location.reload();
}
}
});
export async function change_language(lang: string) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
urlParams.set('keyword_language', lang);
location.href = `${location.protocol}//${lang}.${theDomainName}${location.pathname}?${urlParams.toString()}`
}

function update_view(selector_container: string, new_lang: string) {
Expand Down
24 changes: 9 additions & 15 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -120557,6 +120557,7 @@ def note_with_error(value, err):
var currentTab;
var theUserIsLoggedIn;
var selectedURI;
var theDomainName = "";
var synth = new PolySynth(Synth).toDestination();
var slides_template = `
<!DOCTYPE html>
Expand Down Expand Up @@ -120624,6 +120625,7 @@ def note_with_error(value, err):
theKeywordLanguage = options.keywordLanguage;
theStaticRoot = (_a3 = options.staticRoot) != null ? _a3 : "";
theStaticRoot = theStaticRoot === "/" ? "" : theStaticRoot;
theDomainName = options.domainName;
initializeCopyToClipboard();
$(document).on("click", function(event2) {
if (!$(event2.target).closest(".dropdown").length) {
Expand Down Expand Up @@ -121698,20 +121700,10 @@ def note_with_error(value, err):
}
}
async function change_language(lang) {
await tryCatchPopup(async () => {
const response = await postJson("/change_language", { lang });
if (response) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
if (lang === "en" || urlParams.get("language") !== null) {
urlParams.set("language", lang);
urlParams.set("keyword_language", lang);
window.location.search = urlParams.toString();
} else {
location.reload();
}
}
});
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
urlParams.set("keyword_language", lang);
location.href = `${location.protocol}//${lang}.${theDomainName}${location.pathname}?${urlParams.toString()}`;
}
function update_view(selector_container, new_lang) {
$("#" + selector_container + " > div").map(function() {
Expand Down Expand Up @@ -122301,7 +122293,8 @@ def note_with_error(value, err):
initializeApp({
level: level3,
keywordLanguage: options.keyword_language,
staticRoot: options.staticRoot
staticRoot: options.staticRoot,
domainName: options.domainName
});
initializeFormSubmits();
initializeTutorial();
Expand Down Expand Up @@ -127482,6 +127475,7 @@ def note_with_error(value, err):
lang: js.lang,
level: parseInt(js.level),
keyword_language: js.lang,
domainName: js.domainName,
javascriptPageOptions: js
});
}, 1e3);
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions static/js/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export interface InitializeOptions {
*/
readonly staticRoot?: string;

/**
* The domain name used in this page, as set up in the back-end
*/
readonly domainName: string;

readonly javascriptPageOptions?: InitializePageOptions;
}

Expand Down Expand Up @@ -77,6 +82,7 @@ export function initialize(options: InitializeOptions) {
level: level,
keywordLanguage: options.keyword_language,
staticRoot: options.staticRoot,
domainName: options.domainName
});
initializeFormSubmits();
initializeTutorial();
Expand Down
8 changes: 6 additions & 2 deletions static/js/public-adventures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ document.addEventListener("updateTSCode", (e: any) => {
const js = e.detail;
updateURL();
initialize({
lang: js.lang, level: parseInt(js.level), keyword_language: js.lang,
javascriptPageOptions: js
lang: js.lang,
level: parseInt(js.level),
keyword_language: js.lang,
domainName: js.domainName,
javascriptPageOptions: js,

});
}, 1000);
})
1 change: 1 addition & 0 deletions templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ <h2>{{ _('levels')|capitalize }}</h2>
level: {{ level|tojson|safe }},
keyword_language: {{ g.keyword_lang|tojson|safe }},
staticRoot: {{ static('')|tojson|safe }},
domainName: {{ config['SERVER_NAME']|tojson|safe }},
{% if initialize_logs %}logs: true,{% endif %}
javascriptPageOptions: {{ javascript_page_options|tojson|safe }},
});</script>
Expand Down
1 change: 1 addition & 0 deletions website/public_adventures.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def filtering(self, user, index_page=False):
level=level,
adventures=adventures,
initial_tab='',
domainName=config['domain_name'],
current_user_name=user['username'],
)

Expand Down

0 comments on commit 1486492

Please sign in to comment.