浏览代码

//allow the switch from a saved TS playground to the default JS one and vice et versa

DEV-UNITY-6\Utilisateur 6 年之前
父节点
当前提交
99b1fc7762
共有 1 个文件被更改,包括 15 次插入4 次删除
  1. 15 4
      Playground/js/main.js

+ 15 - 4
Playground/js/main.js

@@ -288,15 +288,26 @@ class Main {
         }
         }
         // Language (JS / TS)
         // Language (JS / TS)
         this.parent.utils.setToMultipleID("toTSbutton", "click", function () {
         this.parent.utils.setToMultipleID("toTSbutton", "click", function () {
-            if (this.parent.settingsPG.ScriptLanguage == "JS") {
+            if(location.hash != null && location.hash != ""){
                 this.parent.settingsPG.ScriptLanguage = "TS";
                 this.parent.settingsPG.ScriptLanguage = "TS";
-                location.reload();
+                window.location = "./";
+            }else{
+                if (this.parent.settingsPG.ScriptLanguage == "JS") {
+                    this.parent.settingsPG.ScriptLanguage = "TS";
+                    location.reload();
+                }
             }
             }
+           
         }.bind(this));
         }.bind(this));
         this.parent.utils.setToMultipleID("toJSbutton", "click", function () {
         this.parent.utils.setToMultipleID("toJSbutton", "click", function () {
-            if (this.parent.settingsPG.ScriptLanguage == "TS") {
+            if(location.hash != null && location.hash != ""){
                 this.parent.settingsPG.ScriptLanguage = "JS";
                 this.parent.settingsPG.ScriptLanguage = "JS";
-                location.reload();
+                window.location = "./";
+            }else{
+                if (this.parent.settingsPG.ScriptLanguage == "TS") {
+                    this.parent.settingsPG.ScriptLanguage = "JS";
+                    location.reload();
+                }
             }
             }
         }.bind(this));
         }.bind(this));
         // Safe mode
         // Safe mode