switch to HTTPS menu option
This commit is contained in:
parent
decccdf0d7
commit
89c608dc2c
|
@ -63,6 +63,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||||
<hr>
|
<hr>
|
||||||
<li><a class="dropdown-item" href="#" id="item_addfile_include">Add Include File...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_addfile_include">Add Include File...</a></li>
|
||||||
<li><a class="dropdown-item" href="#" id="item_addfile_link">Add Linked File...</a></li>
|
<li><a class="dropdown-item" href="#" id="item_addfile_link">Add Linked File...</a></li>
|
||||||
|
<li><a class="dropdown-item" href="#" id="item_switch_https" style="display:none">Switch to HTTPS...</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown dropdown-submenu">
|
<li class="dropdown dropdown-submenu">
|
||||||
|
|
2
nanoasm
2
nanoasm
|
@ -1 +1 @@
|
||||||
Subproject commit 5e79821e85a9e4dda78973456ed9f8a04991093c
|
Subproject commit 53470410c34d2738a9f52e65bf8ffe1eabbef19b
|
|
@ -2,6 +2,12 @@
|
||||||
"name": "8bitworkshop",
|
"name": "8bitworkshop",
|
||||||
"version": "3.4.0",
|
"version": "3.4.0",
|
||||||
"author": "Steven Hugg",
|
"author": "Steven Hugg",
|
||||||
|
"description": "A programming IDE for retro hardware.",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/sehugg/8bitworkshop/"
|
||||||
|
},
|
||||||
|
"license": "GPLv3 and others, see README",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bootbox": "^4.4.36",
|
"@types/bootbox": "^4.4.36",
|
||||||
|
|
19
src/ui.ts
19
src/ui.ts
|
@ -1910,6 +1910,10 @@ function convertLegacyVCS(store) {
|
||||||
|
|
||||||
const useHTTPSCookieName = "__use_https";
|
const useHTTPSCookieName = "__use_https";
|
||||||
|
|
||||||
|
function setHTTPSCookie(val : number) {
|
||||||
|
document.cookie = useHTTPSCookieName + "=" + val + ";domain=8bitworkshop.com;path=/;max-age=315360000";
|
||||||
|
}
|
||||||
|
|
||||||
function shouldRedirectHTTPS() : boolean {
|
function shouldRedirectHTTPS() : boolean {
|
||||||
// cookie set? either true or false
|
// cookie set? either true or false
|
||||||
var shouldRedir = getCookie(useHTTPSCookieName);
|
var shouldRedir = getCookie(useHTTPSCookieName);
|
||||||
|
@ -1918,16 +1922,27 @@ function shouldRedirectHTTPS() : boolean {
|
||||||
}
|
}
|
||||||
// set a 10yr cookie, value depends on if it's our first time here
|
// set a 10yr cookie, value depends on if it's our first time here
|
||||||
var val = hasLocalStorage && !localStorage.getItem("__lastplatform") ? 1 : 0;
|
var val = hasLocalStorage && !localStorage.getItem("__lastplatform") ? 1 : 0;
|
||||||
document.cookie = useHTTPSCookieName + "=" + val + ";domain=8bitworkshop.com;path=/;max-age=315360000";
|
setHTTPSCookie(val);
|
||||||
return !!val;
|
return !!val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _switchToHTTPS() {
|
||||||
|
bootbox.confirm('<p>Do you want to force the browser to use HTTPS from now on?</p>'+
|
||||||
|
'<p>WARNING: This will make all of your local files unavailable, so you should "Download All Changes" first for each platform where you have done work.</p>'+
|
||||||
|
'<p>You can go back to HTTP by setting the "'+useHTTPSCookieName+'" cookie to 0.</p>', (ok) => {
|
||||||
|
if (ok) {
|
||||||
|
setHTTPSCookie(1);
|
||||||
|
redirectToHTTPS();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function redirectToHTTPS() {
|
function redirectToHTTPS() {
|
||||||
if (window.location.protocol == 'http:' && window.location.host == '8bitworkshop.com') {
|
if (window.location.protocol == 'http:' && window.location.host == '8bitworkshop.com') {
|
||||||
if (shouldRedirectHTTPS()) {
|
if (shouldRedirectHTTPS()) {
|
||||||
window.location.replace(window.location.href.replace(/^http:/, 'https:'));
|
window.location.replace(window.location.href.replace(/^http:/, 'https:'));
|
||||||
} else {
|
} else {
|
||||||
$("#http_warning").show(); // TODO
|
$("#item_switch_https").click(_switchToHTTPS).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue