mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-10-24 08:02:27 +00:00
isProductionHost()
This commit is contained in:
1 parent
215057ae64
commit
e4ad8dc633
3 files changed
+12
-4
No files matched your search
@@ -703,6 +703,10 @@ export function replaceAll(s:string, search:string, replace:string) : string {
|
||||
return s.split(search).join(replace);
|
||||
}
|
||||
|
||||
export function isProductionHost() : boolean {
|
||||
return typeof window != 'undefined' && window.location.host.endsWith('8bitworkshop.com');
|
||||
}
|
||||
|
||||
export function getCookie(name: string) : string {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
|
||||
+5
-1
@@ -2,6 +2,7 @@ import { closeBrackets, deleteBracketPair } from "@codemirror/autocomplete";
|
||||
import { indentUnit } from "@codemirror/language";
|
||||
import { Compartment, EditorState, Extension } from "@codemirror/state";
|
||||
import { EditorView, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, keymap } from "@codemirror/view";
|
||||
import { isProductionHost } from "../common/util";
|
||||
import { debugHighlightTagsTooltip } from "./views/debug";
|
||||
import { insertTabKeymap, smartIndentKeymap } from "./views/tabs";
|
||||
|
||||
@@ -86,6 +87,7 @@ export function applySettingsToAll(settings: EditorSettings) {
|
||||
|
||||
export function openSettings() {
|
||||
var settings = loadSettings();
|
||||
var showInternal = !isProductionHost();
|
||||
bootbox.dialog({
|
||||
onEscape: true,
|
||||
title: "Settings",
|
||||
@@ -97,9 +99,11 @@ export function openSettings() {
|
||||
<div class="checkbox"><label><input type="checkbox" id="setting_highlightWhitespace" ${settings.highlightWhitespace ? 'checked' : ''}> Highlight whitespace</label></div>
|
||||
<div class="checkbox"><label><input type="checkbox" id="setting_highlightTrailingWhitespace" ${settings.highlightTrailingWhitespace ? 'checked' : ''}> Highlight unwanted trailing whitespace</label></div>
|
||||
<div class="checkbox"><label><input type="checkbox" id="setting_closeBrackets" ${settings.closeBrackets ? 'checked' : ''}> Automatically add and remove closing brackets</label></div>
|
||||
${showInternal ? `
|
||||
<hr>
|
||||
<h5>8bitworkshop IDE internal settings</h5>
|
||||
<div class="checkbox"><label><input type="checkbox" id="setting_debugHighlightTags" ${settings.debugHighlightTags ? 'checked' : ''}> Debug editor syntax highlighting tags</label></div>
|
||||
` : ''}
|
||||
</form>`,
|
||||
buttons: {
|
||||
cancel: {
|
||||
@@ -116,7 +120,7 @@ export function openSettings() {
|
||||
settings.highlightWhitespace = $('#setting_highlightWhitespace').is(':checked');
|
||||
settings.highlightTrailingWhitespace = $('#setting_highlightTrailingWhitespace').is(':checked');
|
||||
settings.closeBrackets = $('#setting_closeBrackets').is(':checked');
|
||||
settings.debugHighlightTags = $('#setting_debugHighlightTags').is(':checked');
|
||||
if (showInternal) settings.debugHighlightTags = $('#setting_debugHighlightTags').is(':checked');
|
||||
saveSettings(settings);
|
||||
applySettingsToAll(settings);
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import { EmuHalt, PLATFORMS } from "../common/emu";
|
||||
import { StateRecorderImpl } from "../common/recorder";
|
||||
import {
|
||||
arrayCompare, byteArrayToUTF8, decodeQueryString, getBasePlatform, getCookie, getFilenameForPath, getFilenamePrefix,
|
||||
getRootBasePlatform, getWithBinary, hex, highlightDifferences, isProbablyBinary, loadScript, parseBool, stringToByteArray
|
||||
getRootBasePlatform, getWithBinary, hex, highlightDifferences, isProbablyBinary, isProductionHost, loadScript, parseBool, stringToByteArray
|
||||
} from "../common/util";
|
||||
import { getSkeletonName, getToolMeta } from "../common/toolmeta";
|
||||
import { FileData, WorkerError, WorkerResult } from "../common/workertypes";
|
||||
@@ -1824,7 +1824,7 @@ async function showWelcomeMessage() {
|
||||
content: "This site works best on desktop browsers. For best results, rotate your device to landscape orientation."
|
||||
});
|
||||
}
|
||||
if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
if (isProductionHost()) {
|
||||
steps.unshift({
|
||||
element: "#dropdownMenuButton",
|
||||
placement: 'right',
|
||||
@@ -2285,7 +2285,7 @@ function _switchToHTTPS() {
|
||||
}
|
||||
|
||||
function redirectToHTTPS() {
|
||||
if (window.location.protocol == 'http:' && window.location.host == '8bitworkshop.com') {
|
||||
if (window.location.protocol == 'http:' && isProductionHost()) {
|
||||
if (shouldRedirectHTTPS()) {
|
||||
uninstallErrorHandler();
|
||||
window.location.replace(window.location.href.replace(/^http:/, 'https:'));
|
||||
|
||||
Reference in new issue
Block a user