WIP Update angular to something from after the stoneage

This commit is contained in:
Fabian Homborg 2020-06-21 22:05:12 +02:00
parent 4a35248465
commit 9cfcdfa105
6 changed files with 32497 additions and 9531 deletions

View file

@ -7,6 +7,7 @@
<link rel="icon" type="image/png" href="favicon.png"/>
<link rel="stylesheet" type="text/css" href="fishconfig.css"/>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript" src="js/angular-route.js"></script>
<script type="text/javascript" src="js/angular-sanitize.js"></script>
<script type="text/javascript" src="js/colorutils.js"></script>
<script type="text/javascript" src="js/filters.js"></script>

1266
share/tools/web_config/js/angular-route.js vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
fishconfig = angular.module("fishconfig", ["filters", "controllers", "ngSanitize"]);
fishconfig = angular.module("fishconfig", ["filters", "controllers", "ngRoute", "ngSanitize"]);
fishconfig.config(
["$routeProvider", function($routeProvider) {
@ -44,26 +44,29 @@ fishconfig.config(function($httpProvider, $compileProvider) {
global_error_element.text(content);
};
$httpProvider.responseInterceptors.push(function($q) {
return function(promise) {
return promise.then(function(successResponse) {
showMessage('');
return successResponse;
}, function(errorResponse) {
switch (errorResponse.status) {
case 0:
showMessage("The request received an error. Perhaps the server has shut down.");
break;
case 500:
showMessage('Server internal error: ' + errorResponse.data);
break;
default:
showMessage('Error ' + errorResponse.status + ': ' + errorResponse.data);
}
return $q.reject(errorResponse);
});
};
});
// $httpProvider.factory('myHttpInterceptor', function($q) {
// return {
// 'request' : function(promise) {
// return promise.then(function(successResponse) {
// showMessage('');
// return successResponse;
// })},
// 'requestError' : function(errorResponse) {
// switch (errorResponse.status) {
// case 0:
// showMessage("The request received an error. Perhaps the server has shut down.");
// break;
// case 500:
// showMessage('Server internal error: ' + errorResponse.data);
// break;
// default:
// showMessage('Error ' + errorResponse.status + ': ' + errorResponse.data);
// }
// return $q.reject(errorResponse);
// }
// }
// });
// $httpProvider.interceptors.push('myHttpInterceptor');
$compileProvider.directive('errorMessage', function() {
return {

View file

@ -83,14 +83,14 @@ controllers.controller("colorsController", function($scope, $http) {
$scope.getCurrentTheme = function() {
$http.get("colors/").success(function(data, status, headers, config) {
$http.get("colors/").then(function(data, status, headers, config) {
var currentScheme = { "name": "Current", "colors":[], "preferred_background": "" };
for (var i in data) {
currentScheme[data[i].name] = data[i].color;
}
$scope.colorSchemes.splice(0, 0, currentScheme);
$scope.changeSelectedColorScheme(currentScheme);
})};
})};
$scope.saveThemeButtonTitle = "Set Theme";
@ -141,7 +141,7 @@ controllers.controller("colorsController", function($scope, $http) {
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'} }).success(function(data, status, headers, config) {
$http.post("set_color/", postData, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function(data, status, headers, config) {
if (status == 200) {
remaining -= 1;
if (remaining == 0) {
@ -162,7 +162,7 @@ controllers.controller("promptController", function($scope, $http) {
$scope.savePromptButtonTitle = "Set Prompt";
$scope.fetchSamplePrompts= function() {
$http.get("sample_prompts/").success(function(data, status, headers, config) {
$http.get("sample_prompts/").then(function(data, status, headers, config) {
$scope.samplePrompts = data;
$scope.samplePromptsArrayArray = get_colors_as_nested_array($scope.samplePrompts, 1);
@ -178,7 +178,7 @@ controllers.controller("promptController", function($scope, $http) {
}
$scope.setNewPrompt = function(selectedPrompt) {
$http.post("set_prompt/", {'fish_prompt': selectedPrompt.function,}).success(function(data, status, headers, config){
$http.post("set_prompt/", {'fish_prompt': selectedPrompt.function,}).then(function(data, status, headers, config){
// Update attributes of current prompt and select it
$scope.samplePrompts[0].demo = selectedPrompt.demo;
@ -209,14 +209,14 @@ controllers.controller("functionsController", function($scope, $http) {
}
$scope.fetchFunctions= function() {
$http.get("functions/").success(function(data, status, headers, config) {
$http.get("functions/").then(function(data, status, headers, config) {
$scope.functions = data;
$scope.selectFunction($scope.functions[0]);
})};
$scope.cleanupFishFunction = function (contents) {
/* Replace leading tabs and groups of four spaces at the beginning of a line with two spaces. */
lines = contents.split('\n')
lines = contents ? contents.split('\n') : [];
rx = /^[\t ]+/
for (var i=0; i < lines.length; i++) {
line = lines[i]
@ -233,7 +233,7 @@ controllers.controller("functionsController", function($scope, $http) {
}
$scope.fetchFunctionDefinition = function(name) {
$http.post("get_function/","what=" + name, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
$http.post("get_function/","what=" + name, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function(data, status, headers, config) {
$scope.functionDefinition = $scope.cleanupFishFunction(data[0]);
})};
@ -244,7 +244,7 @@ controllers.controller("variablesController", function($scope, $http) {
$scope.query = null;
$scope.fetchVariables= function() {
$http.get("variables/").success(function(data, status, headers, config) {
$http.get("variables/").then(function(data, status, headers, config) {
$scope.variables = data;
})};
@ -318,7 +318,7 @@ controllers.controller("historyController", function($scope, $http, $timeout) {
// Get history from server
$scope.fetchHistory = function() {
$http.get("history/").success(function(data, status, headers, config) {
$http.get("history/").then(function(data, status, headers, config) {
$scope.allItems = data;
$scope.filterAndGroup();
});
@ -326,7 +326,7 @@ controllers.controller("historyController", function($scope, $http, $timeout) {
$scope.deleteHistoryItem = function(item) {
index = $scope.allItems.indexOf(item);
$http.post("delete_history_item/","what=" + encodeURIComponent(item), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
$http.post("delete_history_item/","what=" + encodeURIComponent(item), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function(data, status, headers, config) {
$scope.allItems.splice(index, 1);
$scope.filterAndGroup();
})};
@ -350,7 +350,7 @@ controllers.controller("historyController", function($scope, $http, $timeout) {
controllers.controller("bindingsController", function($scope, $http) {
$scope.bindings = [];
$scope.fetchBindings = function() {
$http.get("bindings/").success(function(data, status, headers, config) {
$http.get("bindings/").then(function(data, status, headers, config) {
$scope.bindings = data;
})};
@ -367,12 +367,13 @@ controllers.controller("abbreviationsController", function($scope, $http) {
this.hasBlank = true;
}
}, hasBlank);
if (!$scope.abbreviations) $scope.abbreviations = [];
if (! hasBlank.hasBlank) {
$scope.abbreviations.push({phrase: "", word: "", editable: true})
}
}
$scope.fetchAbbreviations = function() {
$http.get("abbreviations/").success(function(data, status, headers, config) {
$http.get("abbreviations/").then(function(data, status, headers, config) {
$scope.abbreviations = data;
$scope.addBlank();
})};
@ -383,7 +384,7 @@ controllers.controller("abbreviationsController", function($scope, $http) {
$scope.saveAbbreviation = function(abbreviation) {
if (abbreviation.word && abbreviation.phrase) {
$http.post("save_abbreviation/", abbreviation).success(function(data, status, headers, config) {
$http.post("save_abbreviation/", abbreviation).then(function(data, status, headers, config) {
abbreviation.editable = false;
$scope.addBlank();
});
@ -392,7 +393,7 @@ controllers.controller("abbreviationsController", function($scope, $http) {
$scope.removeAbbreviation = function(abbreviation) {
if (abbreviation.word) {
$http.post("remove_abbreviation/", abbreviation).success(function(data, status, headers, config) {
$http.post("remove_abbreviation/", abbreviation).then(function(data, status, headers, config) {
$scope.abbreviations.splice($scope.abbreviations.indexOf(abbreviation), 1);
$scope.addBlank();
});