From 171bcb1ccf4368abc197849627c8f6007ca1b8ad Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Sat, 7 Sep 2013 22:57:25 +0530 Subject: [PATCH] Cleaned up index.html --- share/tools/web_config/index.html | 458 +--------------------------- share/tools/web_config/webconfig.js | 19 +- 2 files changed, 21 insertions(+), 456 deletions(-) diff --git a/share/tools/web_config/index.html b/share/tools/web_config/index.html index 698971b14..d79c4af9d 100644 --- a/share/tools/web_config/index.html +++ b/share/tools/web_config/index.html @@ -10,72 +10,9 @@ diff --git a/share/tools/web_config/webconfig.js b/share/tools/web_config/webconfig.js index 001e4791e..d74c5a9bc 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(); });