Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 24, 2024
2 parents 96b3e0b + d89d0b0 commit 081ca52
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 46 deletions.
1 change: 1 addition & 0 deletions Manual/contents/GameMaker_Language.htm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<title>Język GameMaker</title>
<meta name="topic-status" content="Draft" />
<link rel="stylesheet" type="text/css" href="assets/css/default.css" />
<script src="assets/scripts/main_script.js" type="module"></script>
<meta name="template" content="assets/masterpages/Manual_Page.htt" />
<meta name="rh-authors" content="Gurpreet S. Matharoo" />
</head>
Expand Down
108 changes: 63 additions & 45 deletions Manual/contents/assets/scripts/main_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2589,36 +2589,69 @@ document.addEventListener('DOMContentLoaded', (event) => {
// ----------------------------------------------------------------------------------------------
// Language select dropdown (create and navigate)
// ----------------------------------------------------------------------------------------------

var myParent = document.body;
// Create default style (full context view) and get parent elm
var listStyle = `float: right;
background-color: #333;
border: 0;
color: white;
padding: 8px;
border-radius: 4px;`

var myParent = window.parent.document.body.getElementsByClassName("header")[0];

// No context view style and parent elm
if (myParent == undefined) {
myParent = window.parent.document.getElementById("rh-topic-header");
listStyle += `
margin-right: 11px;
margin-bottom: 11px;
margin-left: 30px;
`;
}

//Create array of options to be added
var array = [
{ name: "English", code: "en" },
{ name: "French", code: "fr" },
{ name: "Spanish", code: "es" },
{ name: "German", code: "de" },
{ name: "Russian", code: "ru" },
{ name: "Italian", code: "it" },
{ name: "Polish", code: "pl" },
{ name: "Brazilian", code: "br" },
{ name: "Korean", code: "ko" },
{ name: "Chinese", code: "zh" },
{ name: "Japanese", code: "ja" }
];
{ name: "Français", code: "fr" },
{ name: "Español", code: "es" },
{ name: "Deutsch", code: "de" },
{ name: "Русский", code: "ru" },
{ name: "Italiano", code: "it" },
{ name: "Polski", code: "pl" },
{ name: "Português Brasileiro", code: "br" },
{ name: "한국인", code: "ko" },
{ name: "中国人", code: "zh" },
{ name: "日本語", code: "ja" }
];

//Create and append select list
var selectList = document.createElement("select");
selectList.id = "mySelect";
myParent.insertBefore(selectList, myParent.firstChild);
selectList.style = listStyle;
myParent.insertBefore(selectList, myParent.lastChild.nextSibling);

//Create and append the options
for (var i = 0; i < array.length; i++) {
var option = document.createElement("option");
option.value = JSON.stringify(array[i]);
option.text = array[i].name;
selectList.appendChild(option);
} // end for

//Create and append the options
for (var i = 0; i < array.length; i++) {
var option = document.createElement("option");
option.value = JSON.stringify(array[i]);
option.text = array[i].name;
selectList.appendChild(option);
} // end for

// are we on the main site???? if so then lets find the index of the current language
var urlCurrent = new URL(window.location.href);
if (urlCurrent.hostname.endsWith( ".gamemaker.io")) {
if (window.location.hostname.endsWith( ".gamemaker.io")) {
// lets get the language from the pathname
const folders = urlCurrent.pathname.split("/");
if (folders.length >= 2) {
var language = folders[1];
const folders = window.location.pathname.split("/");
if (folders.length >= 3) {
var language = folders[2];
// find the language index from the
for( var i=0; i<array.length; ++i) {
if (array[i].code == language) {
Expand All @@ -2629,21 +2662,13 @@ if (urlCurrent.hostname.endsWith( ".gamemaker.io")) {
} // end if
} // end if

//Create and append the options
for (var i = 0; i < array.length; i++) {
var option = document.createElement("option");
option.value = JSON.stringify(array[i]);
option.text = array[i].name;
selectList.appendChild(option);
} // end for

selectList.addEventListener( "change", function(e) {
//var tg = selectList.target.value;
//console.log("Hello entry " + tg.name + " " + tg.code + ", " + JSON.stringify(selectList));
var index = selectList.selectedIndex;
var entry = array[index];
var url = new URL(window.location.href);
var urlParams = url.searchParams;
var url = window.location.href;
//var urlParams = url.searchParams;

// some logging for debugging
//console.log("Hello entry " + JSON.stringify(array[index]));
Expand All @@ -2655,24 +2680,17 @@ selectList.addEventListener( "change", function(e) {
//}

// check to see if this is localhost (i.e. we are testing locally)
if (!url.hostname.endsWith( ".gamemaker.io")) {
url.hostname = "manual.gamemaker.io";
url.protocol = "https";
url.port = "";
url.hash = `#t=${url.pathname.substring(1)}`;
url.pathname = `/beta/${entry.code}/`;
if (!url.includes( ".gamemaker.io")) {
url = `https://manual.gamemaker.io/monthly/${entry.code}/#t=${window.location.pathname.substring(1)}`;
console.log( `new url - ${url}`);
window.parent.location.href = url;
} // end if
else {
const folders = urlCurrent.pathname.split("/");
if (folders.length >= 2) {
folders[1] = entry.code;
}
url.pathname = `/${folders.join('/')}/`;
const folders = window.location.pathname.split("/");
if (folders.length >= 3) {
folders[2] = entry.code;
} // end if
window.parent.location.pathname = `${folders.join('/')}`;
}

console.log( `new url - ${url}`);
window.location.href = url;
});



2 changes: 1 addition & 1 deletion Manual/publish/skins/Charcoal_Grey/html5.skn
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<key>41080</key>
<image>go-to-page.png</image>
<selected_image>go-to-page.png</selected_image>
<title>Go To GitHub File</title>
<title>Go To GitHub File (There may be newer changes in the source file)</title>
<onclick>let local = (location.hostname === &#39;localhost&#39; || location.hostname === &#39;127.0.0.1&#39;); let curl = window.location.href; let parts = curl.split(&#39;/&#39;); let version = parts[3]; let lang = parts[4]; if (lang==&#39;br&#39;) lang=&#39;pt-br&#39;; let repo = &#39;GameMaker-Manual&#39;; if (!local &amp;&amp; lang != &#39;en&#39;) repo = repo + &#39;-&#39; + lang; let branch = (!local &amp;&amp; version==&#39;lts&#39;) ? &#39;main-lts&#39; : &#39;develop&#39;; let match = (local ? /https?:\/\/.*:[0-9]+|https?:\/\/localhost\// : /https:\/\/manual\.gamemaker\.io\/[a-zA-Z]+\/[a-zA-Z]+\//).exec(curl); let path = curl.replace(match[0], &#39;&#39;).replace(&#39;index.htm?#t=&#39;, &#39;&#39;).replace(&#39;index.htm#t=&#39;, &#39;&#39;).replace(&#39;#t=&#39;, &#39;&#39;).replace(&#39;%2F&#39;, &#39;/&#39;).split(&#39;%23&#39;)[0]; path = `https://github.com/YoYoGames/${repo}/tree/${branch}/Manual/contents/${path}`; window.open(path, &#39;_blank&#39;).focus();</onclick>
</custom_buttonsitem>
</custom_buttons>
Expand Down

0 comments on commit 081ca52

Please sign in to comment.