aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/tools/web_config/webconfig.js
diff options
context:
space:
mode:
authorGravatar Siteshwar Vashisht <siteshwar@gmail.com>2013-09-07 22:57:25 +0530
committerGravatar Siteshwar Vashisht <siteshwar@gmail.com>2013-10-17 19:47:04 +0530
commit171bcb1ccf4368abc197849627c8f6007ca1b8ad (patch)
tree23b4752b2548484dbc88c27d78c404470aad2513 /share/tools/web_config/webconfig.js
parent5e53c1cde810b2ebff201ca33382545c000fe425 (diff)
Cleaned up index.html
Diffstat (limited to 'share/tools/web_config/webconfig.js')
-rw-r--r--share/tools/web_config/webconfig.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/share/tools/web_config/webconfig.js b/share/tools/web_config/webconfig.js
index 001e4791..d74c5a9b 100644
--- a/share/tools/web_config/webconfig.js
+++ b/share/tools/web_config/webconfig.js
@@ -164,9 +164,26 @@ webconfig.controller("functionsController", function($scope, $http) {
$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')
+ rx = /^[\t ]+/
+ for (var i=0; i < lines.length; i++) {
+ line = lines[i]
+ /* Get leading tabs and spaces */
+ whitespace_arr = rx.exec(line)
+ if (whitespace_arr) {
+ /* Replace four spaces with two spaces, and tabs with two spaces */
+ var whitespace = whitespace_arr[0]
+ new_whitespace = whitespace.replace(/( )|(\t)/g, ' ')
+ lines[i] = new_whitespace + line.slice(whitespace.length)
+ }
+ }
+ return lines.join('\n')
+ }
$scope.fetchFunctionDefinition = function(name) {
$http.post("/get_function/","what=" + name, { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
- $scope.functionDefinition = data[0];
+ $scope.functionDefinition = $scope.cleanupFishFunction(data[0]);
})};
$scope.fetchFunctions();
});