TC pushbot 5 4 роки тому
батько
коміт
6eb544865e

+ 7 - 1
desktop.go

@@ -556,6 +556,7 @@ func desktop_theme_handler(w http.ResponseWriter, r *http.Request) {
 func desktop_preference_handler(w http.ResponseWriter, r *http.Request) {
 	preferenceType, _ := mv(r, "preference", false)
 	value, _ := mv(r, "value", false)
+	remove, _ := mv(r, "remove", false)
 	username, err := authAgent.GetUserName(w, r)
 	if err != nil {
 		//user not logged in. Redirect to login page.
@@ -566,13 +567,18 @@ func desktop_preference_handler(w http.ResponseWriter, r *http.Request) {
 		//Invalid options. Return error reply.
 		sendTextResponse(w, "Error. Undefined paramter.")
 		return
-	} else if preferenceType != "" && value == "" {
+	} else if preferenceType != "" && value == "" && remove == "" {
 		//Getting config from the key.
 		result := ""
 		sysdb.Read("desktop", username+"/preference/"+preferenceType, &result)
 		jsonString, _ := json.Marshal(result)
 		sendJSONResponse(w, string(jsonString))
 		return
+	} else if preferenceType != "" && value == "" && remove == "true" {
+		//Remove mode
+		sysdb.Delete("desktop", username+"/preference/"+preferenceType)
+		sendOK(w)
+		return
 	} else if preferenceType != "" && value != "" {
 		//Setting config from the key
 		sysdb.Write("desktop", username+"/preference/"+preferenceType, value)

+ 76 - 1
web/SystemAO/desktop/personalization.html

@@ -30,6 +30,7 @@
     <body>
         <div class="ui tabular menu" style="position:fixed; top:0px; left:0px; width: 100%;">
             <div class="active item" data-tab="wallpaper">Wallpaper</div>
+            <div class="item" data-tab="sound">Sound</div>
             <div class="item" data-tab="theme">Theme</div>
             <div class="item" data-tab="advance">Advance</div>
         </div>
@@ -123,6 +124,28 @@
                 </div>
                 <br><br><br>
             </div>
+            <div class="ui tab" data-tab="sound">
+                <br>
+                <div class="ui container">
+                    <h3 class="ui header">
+                        <i class="music icon"></i>
+                        <div class="content">
+                            System Sound
+                            <div class="sub header">Customize system sound effect</div>
+                        </div>
+                    </h3>
+                    <div class="ui divider"></div>
+                    <h4 class="ui header">
+                        Custom Startup Sound
+                        <div class="sub header">User defined startup sound to play when login to the web desktop</div>
+                    </h4>
+                    <h3 id="userSelectedStartupSound">Disabled</h3>
+                    <button class="ui small right floated button" onclick="clearStartupAudioSelection()"><i class="remove icon"></i> Clear Selection</button>
+                    <button class="ui small black right floated button" onclick="selectStartupAudio();"><i class="folder open icon"></i> Select File</button>
+                    <br><br>
+                    <div class="ui divider"></div>
+                </div>
+            </div>
             <div class="ui tab" data-tab="theme">
                 <!-- Theme Color Related !-->
                 <br>
@@ -190,6 +213,7 @@
                 initCurrentBackgroundPreview(themeName);
             });
             generateColorGrids();
+            getStartupAudio();
 
             //Return the data stored in the theme settings
             //Will return either theme pack name or path for user defined folder
@@ -222,6 +246,57 @@
                 }
             }
 
+            //Startup sound 
+            function selectStartupAudio(){
+                ao_module_openFileSelector(setStartupAudio, undefined,"file",{
+                    filter: ["mp3", "aac", "ogg", "wav"]
+                });
+            }
+
+            function setStartupAudio(filedata){
+                var filename = filedata[0].filename;
+                var filepath = filedata[0].filepath;
+                $("#userSelectedStartupSound").text(filepath);
+                $.ajax({
+                    url: "../../system/desktop/preference",
+                    method: "GET",
+                    data: {preference: "startup-audio", value: filepath},
+                    success: function(data){
+                        console.log(data);
+                    }
+                });
+            }
+
+            function getStartupAudio(callback=undefined){
+                $.ajax({
+                    url: "../../system/desktop/preference",
+                    method: "GET",
+                    data: {preference: "startup-audio"},
+                    success: function(data){
+                        if (data != undefined && data != ""){
+                            $("#userSelectedStartupSound").text(data);
+                        }
+                        
+                        if (callback != undefined){
+                            callback(data);
+                        }else{
+                            console.log(data);
+                        }
+                    }
+                });
+            }
+
+            function clearStartupAudioSelection(){
+                $.ajax({
+                    url: "../../system/desktop/preference",
+                    method: "GET",
+                    data: {preference: "startup-audio", remove: "true"},
+                    success: function(data){
+                        $("#userSelectedStartupSound").text("Disabled");
+                    }
+                });
+            }
+
             //Change the interval to the given 
             function handleIntervalChange(newInterval){
                 //Show change finsihed
@@ -277,7 +352,7 @@
                             parent.changeDesktopTheme("default");
                          }
 
-                          //Re-enable the default theme seelct
+                        //Re-enable the default theme seelct
                         $(".allowSelectDefaultThemes").removeClass("disabled");
                         $("#userSelectedFolderPath").text("Disabled");
 

+ 7 - 2
web/SystemAO/file_system/file_explorer.html

@@ -2290,6 +2290,7 @@
                 if (newName == oldName){
                     msgbox("remove","New filename is identical to the original filename.")
                     $("#renameBox").fadeOut(100);
+                    $(".popupWrapper").fadeOut(100);
                     return;
                 }
                 var newNameWithoutExt = newName;
@@ -2332,12 +2333,16 @@
                         success: function(data){
                             if (data.error !== undefined){
                                 msgbox("remove",data.error);
-                                $("#renameBox").fadeOut(100);
                             }else{
                                 refreshList();
                                 msgbox("checkmark","Rename suceed");
-                                $("#renameBox").fadeOut(100);
                             }
+                            $("#renameBox").fadeOut(100);
+                            $(".popupWrapper").fadeOut(100);
+                        },
+                        error: function(){
+                            $("#renameBox").fadeOut(100);
+                            $(".popupWrapper").fadeOut(100);
                         }
                     });
                     renameFileObjects = [];

+ 24 - 0
web/desktop.system

@@ -1050,6 +1050,7 @@
         hookFloatWindowEvents();
         hookLaunchMenuEvents();
         initTheme();
+        initStartupSounds();
 
         //Login cookie expire check
         setInterval(function() {
@@ -1133,6 +1134,29 @@
             $("#quickAccessPanel").slideUp("fast");
         }
 
+        function initStartupSounds(){
+            $.ajax({
+                url: "../../system/desktop/preference",
+                method: "GET",
+                data: {preference: "startup-audio"},
+                success: function(data){
+                    if (data == undefined || data == ""){
+                        return;
+                    }
+                    var currentGlobalVol = localStorage.getItem("global_volume");
+                    if (currentGlobalVol != null && currentGlobalVol != undefined && currentGlobalVol != ""){
+                        
+                    }else{
+                        currentGlobalVol = 0;
+                    }
+
+                    var audio = new Audio("media?file=" + data);
+                    audio.volume = currentGlobalVol;
+                    audio.play();
+                }
+            });
+        }
+
         function initDesktopUserInfo(){
             $.get("system/desktop/user", function(data){
                 if (data.error !== undefined){