Quellcode durchsuchen

Fixed File Explorer applocale error

TC pushbot 5 vor 4 Jahren
Ursprung
Commit
a5c9168712

+ 120 - 119
web/SystemAO/file_system/file_explorer.html

@@ -731,7 +731,7 @@
                             <i class="dropdown icon"></i> <span locale="sidebar/vroot/user">User</span>
                         </summary>
                         <div id="userroot" class="ts list" style="padding-top:0px !important;">
-                            <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> Initiating</div>
+                            <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> <span locale="message/initiating">Initiating</span></div>
                         </div>
                     </details>
                     <details class="ts accordion fluid whiteTheme" open>
@@ -739,7 +739,7 @@
                             <i class="dropdown icon"></i> <span locale="sidebar/vroot/fsh">Storage</span>
                         </summary>
                         <div id="storageroot" class="ts list" style="padding-top:0px !important;">
-                            <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> Initiating</div>
+                            <div class="dir item whiteTheme"><i class="loading circle notched rightmargin icon"></i> <span locale="message/initiating">Initiating</span></div>
                         </div>
                     </details>
                     <!-- 
@@ -1183,141 +1183,142 @@
             let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
 
             //Intiiation functions
-            if (applocale){
-                //Applocale found. Do localization
-                applocale.init("../locale/file_explorer.json", function(){
-                    applocale.translate();
+            $(document).ready(function(){
+                if (applocale){
+                    //Applocale found. Do localization
+                    applocale.init("../locale/file_explorer.json", function(){
+                        applocale.translate();
+                        initRootDirs();
+                        initSystemInfo();
+                        initUploadMode();
+                    });
+                }else{
+                    //Applocale not found. Is this a trim down version of ArozOS?
+                    applocale = {
+                        getString: function(key, original){
+                            return original;
+                        }
+                    }
                     initRootDirs();
                     initSystemInfo();
                     initUploadMode();
-                });
-            }else{
-                //Applocale not found. Is this a trim down version of ArozOS?
-                applocale = {
-                    getString: function(key, original){
-                        return original;
-                    }
                 }
-                initRootDirs();
-                initSystemInfo();
-                initUploadMode();
-            }
            
+                if (isMobile){
+                    //Mobile css adjustment
+                    sideBarShown = false;
+                    $("#directorySidebar").hide();
+                    $("#directorySidebar").css("width",window.innerWidth + "px");
+                    $("body").css("overflow","hidden");
+                    directorySidebarWidth = window.innerWidth;
+                    $("#folderView").css({
+                        "padding-right":"1em",
+                        "padding-left":"1em",
+                        "padding-top":"1em",
+                    });
+                    $(".desktopOnly").hide();
+                    $(".mobileOnly").show();
 
-            if (isMobile){
-                //Mobile css adjustment
-                sideBarShown = false;
-                $("#directorySidebar").hide();
-                $("#directorySidebar").css("width",window.innerWidth + "px");
-                $("body").css("overflow","hidden");
-                directorySidebarWidth = window.innerWidth;
-                $("#folderView").css({
-                    "padding-right":"1em",
-                    "padding-left":"1em",
-                    "padding-top":"1em",
-                });
-                $(".desktopOnly").hide();
-                $(".mobileOnly").show();
+                    //Adjust minor css on mobile devices
+                    $(".rightPad").css("margin-right", "37px");
+                }else{
+                    $(".mobileOnly").hide();
+                    $(".desktopOnly").show();
 
-                //Adjust minor css on mobile devices
-                $(".rightPad").css("margin-right", "37px");
-            }else{
-                $(".mobileOnly").hide();
-                $(".desktopOnly").show();
+                    $(".rightPad").css("margin-right", "37px");
+                }
+                //Initialize view mode buttons
+                updateViewmodeButtons();
+                loadListModeFromDB();
 
-                $(".rightPad").css("margin-right", "37px");
-            }
-            //Initialize view mode buttons
-            updateViewmodeButtons();
-            loadListModeFromDB();
+                //Initialize system theme
+                loadPreference("file_explorer/theme",function(data){
+                    if (data.error === undefined){
+                        if (data == "darkTheme"){
+                            toggleDarkTheme();
+                        }else{
+                            //White theme
+                        
+                        }
+                    }
+                });
 
-            //Initialize system theme
-            loadPreference("file_explorer/theme",function(data){
-                if (data.error === undefined){
-                    if (data == "darkTheme"){
-                        toggleDarkTheme();
+                if (window.location.hash != ""){
+                    //Check if the hash is standard open protocol. If yes, translate it
+                    if (ao_module_loadInputFiles() === null){
+                        //Window location hash set. List the desire directory
+                        currentPath = window.location.hash.substring(1,window.location.hash.length);
+                        if (currentPath.substring(currentPath.length -1) != "/"){
+                            currentPath = currentPath + "/";
+                        }
+                        currentPath = decodeURIComponent(currentPath);
+                        loadListModeFromDB(function(){
+                            listDirectory(currentPath);
+                        });
+                        
                     }else{
-                        //White theme
-                       
+                        //This is ao_module load file input. Handle the file opening
+                        var filelist = ao_module_loadInputFiles();
+                        if (filelist.length > 0){
+                            filelist = filelist[0];
+                            //Check if this is folder or file. Only opendir when it is folder
+                            //Updates 27-12-2020: Open folder and highlight the file if it is file
+                            if (filelist.filename.includes(".") == false){
+                                //Try to open it and overwrite the hash to filesystem hash
+                                loadListModeFromDB(function(){
+                                    listDirectory(filelist.filepath);
+                                });
+                            }else{
+                                //File. Open its parent folder and highlight the target file if exists
+                                var parentdir = filelist.filepath.split("/");
+                                let focusFilename = JSON.parse(JSON.stringify(filelist.filename));
+                                parentdir.pop();
+                                parentdir = parentdir.join("/");
+                                loadListModeFromDB(function(){
+                                    listDirectory(parentdir, function(){
+                                        focusFileObject(focusFilename);
+                                    });
+                                });
+                            }
+                        }
                     }
-                }
-            });
+                }else{
 
-            if (window.location.hash != ""){
-                //Check if the hash is standard open protocol. If yes, translate it
-                if (ao_module_loadInputFiles() === null){
-                    //Window location hash set. List the desire directory
-                    currentPath = window.location.hash.substring(1,window.location.hash.length);
-                    if (currentPath.substring(currentPath.length -1) != "/"){
-                        currentPath = currentPath + "/";
-                    }
-                    currentPath = decodeURIComponent(currentPath);
+                    //Initialized directory views
                     loadListModeFromDB(function(){
                         listDirectory(currentPath);
                     });
-                    
-                }else{
-                    //This is ao_module load file input. Handle the file opening
-                    var filelist = ao_module_loadInputFiles();
-                    if (filelist.length > 0){
-                        filelist = filelist[0];
-                        //Check if this is folder or file. Only opendir when it is folder
-                        //Updates 27-12-2020: Open folder and highlight the file if it is file
-                        if (filelist.filename.includes(".") == false){
-                            //Try to open it and overwrite the hash to filesystem hash
-                            loadListModeFromDB(function(){
-                                listDirectory(filelist.filepath);
-                            });
-                        }else{
-                            //File. Open its parent folder and highlight the target file if exists
-                            var parentdir = filelist.filepath.split("/");
-                            let focusFilename = JSON.parse(JSON.stringify(filelist.filename));
-                            parentdir.pop();
-                            parentdir = parentdir.join("/");
-                            loadListModeFromDB(function(){
-                                listDirectory(parentdir, function(){
-                                    focusFileObject(focusFilename);
-                                });
-                            });
-                        }
-                    }
                 }
-            }else{
-
-                //Initialized directory views
-                loadListModeFromDB(function(){
-                    listDirectory(currentPath);
-                });
-            }
-            
+                
 
-            
-            
-            //Create a timer to check change in current folder
-            setInterval(function(){
-                if (enableAutoRefresh == false){
-                    return;
-                }
-                getDirHash(function(hash){
-                    if (hash.error !== undefined){
-                        //Something went wrong. Ignore this request
-                        console.log(hash.error)
-                    }else{
-                        //Check if the hash match with the last hash.
-                        if (hash != currentPathHash){
-                            //console.log(currentPathHash, hash);
-                            refreshList();
-                            currentPathHash = hash;
-                            if (currentPath == "user:/"){
-                                //Reload the User root folder list
-                                initRootDirs();
+                
+                
+                //Create a timer to check change in current folder
+                setInterval(function(){
+                    if (enableAutoRefresh == false){
+                        return;
+                    }
+                    getDirHash(function(hash){
+                        if (hash.error !== undefined){
+                            //Something went wrong. Ignore this request
+                            console.log(hash.error)
+                        }else{
+                            //Check if the hash match with the last hash.
+                            if (hash != currentPathHash){
+                                //console.log(currentPathHash, hash);
+                                refreshList();
+                                currentPathHash = hash;
+                                if (currentPath == "user:/"){
+                                    //Reload the User root folder list
+                                    initRootDirs();
+                                }
                             }
                         }
-                    }
 
-                });
-            }, 5000)
+                    });
+                }, 5000)
 
+            });
 
             //END OF INIT FUNCTIONS
 
@@ -1493,13 +1494,13 @@
                 if (currentTheme == "darkTheme"){
                     $("#folderList").html(`<div style="height: 100px;">
                         <div class="ts active dimmer">
-                            <div class="ts text loader">Loading</div>
+                            <div class="ts text loader">${applocale.getString("message/loading", "Loading")}</div>
                         </div>
                     </div>`);
                 }else{
                     $("#folderList").html(`<div style="height: 100px;">
                         <div class="ts active inverted dimmer">
-                            <div class="ts text loader">Loading</div>
+                            <div class="ts text loader">${applocale.getString("message/loading", "Loading")}</div>
                         </div>
                     </div>`);
                 }
@@ -3983,7 +3984,7 @@
                     }
                     $(".fileObject.selected").removeClass("selected");
                     hotSearchTimer = setTimeout(function(){
-                        existHotSearch();
+                        exitHotSearch();
                     }, 1000);
 
                     if (hotSearchBuffer.length > 0 && event.key == hotSearchBuffer.substr(hotSearchBuffer.length - 1, 1)){

+ 4 - 0
web/SystemAO/locale/file_explorer.json

@@ -131,6 +131,8 @@
                 "message/nofileSelected": "沒有選擇檔案",
                 "message/moduleNotSupport": "此模組無法開啟任何檔案",
                 "message/unknownSize": "未知大小",
+                "message/loading": "載入中",
+                "message/initiating": "正在初始化",
 
                 "message/destIdentical": "檔案來源及目的地相同",
                 "message/decodeFilelistFail": "載案置入失敗:無法讀取檔案列表",
@@ -302,6 +304,8 @@
                 "message/nofileSelected": "沒有選擇檔案",
                 "message/moduleNotSupport": "此模組無法開啟任何檔案",
                 "message/unknownSize": "未知大小",
+                "message/loading": "載入中",
+                "message/initiating": "正在初始化",
 
                 "message/destIdentical": "檔案來源及目的地相同",
                 "message/decodeFilelistFail": "載案置入失敗:無法讀取檔案列表",

+ 1 - 1
web/script/applocale.js

@@ -85,7 +85,7 @@ var applocale = {
     },
     getString: function(key, original, type = "strings") {
         var targetLang = this.lang;
-        if (this.localData.keys[targetLang] == undefined) {
+        if (this.localData.keys === undefined || this.localData.keys[targetLang] == undefined) {
             return original;
         }
         let targetString = this.localData.keys[targetLang].strings[key];