From: Stas Vilchik Date: Mon, 1 Dec 2014 13:06:26 +0000 (+0100) Subject: Remove unused javascript code X-Git-Tag: 5.0-RC1~129 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4058a1b3533e50348f995ff55b618043de59e43d;p=sonarqube.git Remove unused javascript code --- diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index ffdacbcb715..39241055789 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -102,8 +102,6 @@ module.exports = (grunt) -> '<%= pkg.assets %>js/application.js' '<%= pkg.assets %>js/csv.js' '<%= pkg.assets %>js/dashboard.js' - '<%= pkg.assets %>js/duplication.js' - '<%= pkg.assets %>js/resource.js' '<%= pkg.assets %>js/issue.js' '<%= pkg.assets %>js/recent-history.js' ] @@ -138,8 +136,6 @@ module.exports = (grunt) -> '<%= pkg.assets %>js/application.js' '<%= pkg.assets %>js/csv.js' '<%= pkg.assets %>js/dashboard.js' - '<%= pkg.assets %>js/duplication.js' - '<%= pkg.assets %>js/resource.js' '<%= pkg.assets %>js/issue.js' '<%= pkg.assets %>js/recent-history.js' ] diff --git a/server/sonar-web/src/main/js/application.js b/server/sonar-web/src/main/js/application.js index e9d99a006fa..629f45e7612 100644 --- a/server/sonar-web/src/main/js/application.js +++ b/server/sonar-web/src/main/js/application.js @@ -45,144 +45,6 @@ function dashboardParameters() { return parameters; } -function resourceViewerOnBulkIssues() { - var issuesTab = 'tab=issues'; - if (window.location.search.indexOf('tab=') >= 0) { - // If a tab is already selected - if (window.location.search.indexOf(issuesTab) >= 0) { - // If tab is issues, keep it and reload page - window.location.reload(); - } else { - // Else, switch to issues tab - window.location.search = window.location.search.replace(/tab=\w+/, issuesTab); - } - } else { - // No tab selected, see how to add tab parameter - if (window.location.search.indexOf('?') === 0) { - window.location.search += ('&' + issuesTab); - } else { - window.location.search += ('?' + issuesTab); - } - } -} - -var SelectBox = { - cache: {}, - init: function (id) { - var box = document.getElementById(id); - SelectBox.cache[id] = []; - var cache = SelectBox.cache[id]; - for (var i = 0, j = box.options.length; i < j; i++) { - var node = box.options[i]; - cache.push({value: node.value, text: node.text, displayed: 1}); - } - }, - redisplay: function (id) { - // Repopulate HTML select box from cache - var box = document.getElementById(id); - // clear all options - box.options.length = 0; - for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) { - var node = SelectBox.cache[id][i]; - if (node.displayed) { - box.options[box.options.length] = new Option(node.text, node.value, false, false); - } - } - }, - filter: function (id, text) { - // Redisplay the HTML select box, displaying only the choices containing ALL - // the words in text. (It's an AND search.) - var tokens = text.toLowerCase().split(/\s+/); - for (var i = 0, n = SelectBox.cache[id].length; i < n; i++) { - var node = SelectBox.cache[id][i]; - node.displayed = 1; - for (var j = 0, k = tokens.length; j < k; j++) { - var token = tokens[j]; - if (node.text.toLowerCase().indexOf(token) === -1) { - node.displayed = 0; - } - } - } - SelectBox.redisplay(id); - }, - delete_from_cache: function (id, value) { - var delete_index = null; - for (var i = 0, n = SelectBox.cache[id].length; i < n; i++) { - var node = SelectBox.cache[id][i]; - if (node.value === value) { - delete_index = i; - break; - } - } - var j = SelectBox.cache[id].length - 1; - for (i = delete_index; i < j; i++) { - SelectBox.cache[id][i] = SelectBox.cache[id][i + 1]; - } - SelectBox.cache[id].length--; - }, - add_to_cache: function (id, option) { - SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1}); - }, - cache_contains: function (id, value) { - // Check if an item is contained in the cache - for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) { - var node = SelectBox.cache[id][i]; - if (node.value === value) { - return true; - } - } - return false; - }, - move: function (from, to) { - var from_box = document.getElementById(from); - for (var i = 0, j = from_box.options.length; i < j; i++) { - var option = from_box.options[i]; - if (option.selected && SelectBox.cache_contains(from, option.value)) { - SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1}); - SelectBox.delete_from_cache(from, option.value); - } - } - SelectBox.redisplay(from); - SelectBox.redisplay(to); - }, - move_all: function (from, to) { - var from_box = document.getElementById(from); - for (var i = 0, j = from_box.options.length; i < j; i++) { - var option = from_box.options[i]; - if (SelectBox.cache_contains(from, option.value)) { - SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1}); - SelectBox.delete_from_cache(from, option.value); - } - } - SelectBox.redisplay(from); - SelectBox.redisplay(to); - }, - sort: function (id) { - SelectBox.cache[id].sort(function (a, b) { - a = a.text.toLowerCase(); - b = b.text.toLowerCase(); - try { - if (a > b) { - return 1; - } - if (a < b) { - return -1; - } - } - catch (e) { - // silently fail on IE 'unknown' exception - } - return 0; - }); - }, - select_all: function (id) { - var box = document.getElementById(id); - for (var i = 0; i < box.options.length; i++) { - box.options[i].selected = 'selected'; - } - } -}; - var treemaps = {}; diff --git a/server/sonar-web/src/main/js/duplication.js b/server/sonar-web/src/main/js/duplication.js deleted file mode 100644 index 00732651ecb..00000000000 --- a/server/sonar-web/src/main/js/duplication.js +++ /dev/null @@ -1,22 +0,0 @@ -// JS scripts used in the duplication tab of the resource viewer - -function updateDuplicationLines(url, groupId, itemId, linesCount, fromLine, toLine) { - $j('#duplGroup_' + groupId + ' p.selected').removeClass('selected'); - $j('#duplCount-' + groupId + '-' + itemId).addClass('selected'); - $j('#duplFrom-' + groupId + '-' + itemId).addClass('selected'); - $j('#duplName-' + groupId + '-' + itemId).addClass('selected'); - $j('#duplLoading-' + groupId).addClass('loading'); - - if ($j('#source-' + groupId+ ' :first-child').hasClass('expanded')) { - toLine = fromLine + linesCount - 1; - } - $j.ajax({ - url: url + "&to_line=" + toLine + "&from_line=" + fromLine + "&lines_count=" + linesCount + - "&group_index=" + groupId, - success:function(response){ - $j('#source-' + groupId).html(response); - }, - type:'get' - }); - return false; -} diff --git a/server/sonar-web/src/main/js/resource.js b/server/sonar-web/src/main/js/resource.js deleted file mode 100644 index 98fbf939ec6..00000000000 --- a/server/sonar-web/src/main/js/resource.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - Functions used in resource viewers - */ - -/* Source decoration functions */ -function highlightUsages(event){ - var isAlreadyHighlighted = false; - var selectedElementClasses = $j(this).attr('class').split(' '); - if(selectedElementClasses.indexOf('highlighted') !== -1) { - isAlreadyHighlighted = true; - } - $j('#' + event.data.id + ' span.highlighted').removeClass('highlighted'); - - if(!isAlreadyHighlighted) { - var selectedClass = selectedElementClasses[0]; - $j('#' + event.data.id + ' span.' + selectedClass).addClass('highlighted'); - } -}