mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-03 03:41:14 -03:00
Webconfig: Pass colorscheme in one json request
This used to pass each color in a separate url-encoded request, which is just wasteful. Also it passed separate parameters for modifiers like bold and underlined, but never gave them actual values. Instead the color is passed as one string. So we just use json, and then iterate over it server-side.
This commit is contained in:
@@ -143,6 +143,10 @@ controllers.controller("colorsController", function($scope, $http) {
|
||||
"fish_pager_color_progress"
|
||||
];
|
||||
var remaining = settingNames.length;
|
||||
postdata = {
|
||||
"theme" : $scope.selectedColorScheme["name"],
|
||||
"colors": [],
|
||||
}
|
||||
for (name of settingNames) {
|
||||
var selected;
|
||||
// Skip colors undefined in the current theme
|
||||
@@ -157,17 +161,16 @@ controllers.controller("colorsController", function($scope, $http) {
|
||||
} else {
|
||||
selected = $scope.selectedColorScheme[name];
|
||||
}
|
||||
var postData = "what=" + name + "&color=" + selected + "&background_color=&bold=&underline=&dim=&reverse=&italics=";
|
||||
$http.post("set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function(arg) {
|
||||
if (arg.status == 200) {
|
||||
remaining -= 1;
|
||||
if (remaining == 0) {
|
||||
/* All styles set! */
|
||||
$scope.saveThemeButtonTitle = "Theme Set!";
|
||||
}
|
||||
}
|
||||
})
|
||||
postdata.colors.push({
|
||||
"what" : name,
|
||||
"color" : selected,
|
||||
});
|
||||
}
|
||||
$http.post("set_color/", postdata, { headers: {'Content-Type': 'application/json'} }).then(function(arg) {
|
||||
if (arg.status == 200) {
|
||||
$scope.saveThemeButtonTitle = "Theme Set!";
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$scope.getCurrentTheme();
|
||||
|
||||
Reference in New Issue
Block a user