Reformat Javascript
Pass all JavaScript files through `clang-format -i --style=Chromium`
BUG=None
TEST=manual
Change-Id: I9c55cb771917557e952a6d31d5461308c2c16ec4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/optofidelity_TPPT_analysis/+/3173764
Tested-by: Sean O'Brien <seobrien@chromium.org>
Reviewed-by: Harry Cutts <hcutts@chromium.org>
Commit-Queue: Sean O'Brien <seobrien@chromium.org>
diff --git a/TPPTAnalysisSW/static/script/mainpage.js b/TPPTAnalysisSW/static/script/mainpage.js
index bb5849a..7a4e3db 100644
--- a/TPPTAnalysisSW/static/script/mainpage.js
+++ b/TPPTAnalysisSW/static/script/mainpage.js
@@ -1,209 +1,208 @@
-$(document).ready(function () {
+$(document).ready(function() {
+ //
+ // Main page status related functions
+ //
- //
- // Main page status related functions
- //
-
- var loadstate = function () {
- if(typeof(Storage)!=="undefined") {
- if (sessionStorage.view) {
- if (sessionStorage.view == 'latest') {
- select_latest()
- }
- else if (sessionStorage.view == 'manufacturers') {
- select_manufacturers()
- }
- }
- else {
- select_latest()
- }
- if (sessionStorage.manufacturers) {
- var mselections = JSON.parse(sessionStorage.manufacturers)
- if ($.isArray(mselections)) {
- show_manufacturers(mselections);
- }
- }
+ var loadstate = function() {
+ if (typeof (Storage) !== 'undefined') {
+ if (sessionStorage.view) {
+ if (sessionStorage.view == 'latest') {
+ select_latest()
+ } else if (sessionStorage.view == 'manufacturers') {
+ select_manufacturers()
}
- };
-
- var show_manufacturers = function (mselections) {
- // This breaks if the tree is changed while browsing -> currently "too bad"
- $(".collapsing-header").each(function () {
- if ($.inArray($(this).data('indx'), mselections) != -1) {
- togglerow.call(this)
- }
- });
- };
-
- var saveview = function (currentview) {
- if(typeof(Storage)!=="undefined") {
- sessionStorage.view = currentview;
+ } else {
+ select_latest()
+ }
+ if (sessionStorage.manufacturers) {
+ var mselections = JSON.parse(sessionStorage.manufacturers)
+ if ($.isArray(mselections)) {
+ show_manufacturers(mselections);
}
- };
-
- // Save individual manufacturer row (indx) state (true=visible, false=hidden)
- var savemselection = function (indx, state) {
- if(typeof(Storage)!=="undefined") {
- if (sessionStorage.manufacturers) {
- var mselections = JSON.parse(sessionStorage.manufacturers);
- }
- else {
- var mselections = [];
- }
- if (state) {
- mselections.push(indx);
- }
- else {
- var index = $.inArray($(this).data('indx'), mselections);
- if (index != -1) {
- mselections.splice(index, 1);
- }
- }
-
- sessionStorage.manufacturers = JSON.stringify(mselections);
- }
- };
-
- //
- // Navigation
- //
-
- var select_latest = function() {
- $("#view_latest").show();
- $("#view_manufacturers").hide();
- $(".viewselector").removeClass("selected");
- $("#viewsel_latest").addClass("selected");
- saveview('latest');
+ }
}
+ };
- var select_manufacturers = function () {
- $("#view_latest").hide();
- $("#view_manufacturers").show();
- $(".viewselector").removeClass("selected");
- $("#viewsel_manufacturers").addClass("selected");
- saveview('manufacturers');
+ var show_manufacturers = function(mselections) {
+ // This breaks if the tree is changed while browsing -> currently "too bad"
+ $('.collapsing-header').each(function() {
+ if ($.inArray($(this).data('indx'), mselections) != -1) {
+ togglerow.call(this)
+ }
+ });
+ };
+
+ var saveview = function(currentview) {
+ if (typeof (Storage) !== 'undefined') {
+ sessionStorage.view = currentview;
}
+ };
- $("#viewsel_latest").click(select_latest);
-
- $("#viewsel_manufacturers").click(select_manufacturers);
-
- var togglerow = function () {
- if (!$(this).data('shown')) {
- // Save the table-row display style to jquery memory...
- $(this).siblings().css('display', 'table-row');
- $(this).siblings().toggle();
- $(this).data('shown', 'true');
- }
- $(this).siblings().toggle("fast");
- $(this).children(".collapsing-icon").children().toggle(); // Change + -> -
- };
-
- $(".collapsing-header").click(function () {
- togglerow.call(this);
-
- if ($(this).css('display') == 'none') {
- savemselection($(this).data('indx'), false);
+ // Save individual manufacturer row (indx) state (true=visible, false=hidden)
+ var savemselection = function(indx, state) {
+ if (typeof (Storage) !== 'undefined') {
+ if (sessionStorage.manufacturers) {
+ var mselections = JSON.parse(sessionStorage.manufacturers);
+ } else {
+ var mselections = [];
+ }
+ if (state) {
+ mselections.push(indx);
+ } else {
+ var index = $.inArray($(this).data('indx'), mselections);
+ if (index != -1) {
+ mselections.splice(index, 1);
}
- else {
- savemselection($(this).data('indx'), true);
- }
+ }
+
+ sessionStorage.manufacturers = JSON.stringify(mselections);
+ }
+ };
+
+ //
+ // Navigation
+ //
+
+ var select_latest =
+ function() {
+ $('#view_latest').show();
+ $('#view_manufacturers').hide();
+ $('.viewselector').removeClass('selected');
+ $('#viewsel_latest').addClass('selected');
+ saveview('latest');
+ }
+
+ var select_manufacturers =
+ function() {
+ $('#view_latest').hide();
+ $('#view_manufacturers').show();
+ $('.viewselector').removeClass('selected');
+ $('#viewsel_manufacturers').addClass('selected');
+ saveview('manufacturers');
+ }
+
+ $('#viewsel_latest')
+ .click(select_latest);
+
+ $('#viewsel_manufacturers').click(select_manufacturers);
+
+ var togglerow = function() {
+ if (!$(this).data('shown')) {
+ // Save the table-row display style to jquery memory...
+ $(this).siblings().css('display', 'table-row');
+ $(this).siblings().toggle();
+ $(this).data('shown', 'true');
+ }
+ $(this).siblings().toggle('fast');
+ $(this).children('.collapsing-icon').children().toggle(); // Change + -> -
+ };
+
+ $('.collapsing-header').click(function() {
+ togglerow.call(this);
+
+ if ($(this).css('display') == 'none') {
+ savemselection($(this).data('indx'), false);
+ } else {
+ savemselection($(this).data('indx'), true);
+ }
+ });
+
+ //
+ // Test session navigation
+ //
+
+ $('.test_session_row td:not(:last-child)').click(function(e) {
+ if ($(this).hasClass('ban')) {
+ e.stopPropagation();
+ } else {
+ window.location = 'testsessions/' + $(this).parent().data('id');
+ }
+ });
+
+ $(function() {
+ $('#deleteRequest').click(function() {
+ $('#deletemodal').modal('hide');
+ $.ajax({
+ type: 'POST',
+ url: '/',
+ async: false,
+ data: {params: 'delete', id: $(this).data('id')},
+ })
+ .done(location.reload(true))
+ .fail(deletefail);
});
+ });
- //
- // Test session navigation
- //
+ $('#deletemodal').on('show.bs.modal', function(event) {
+ var cell = $(event.relatedTarget);
+ var sessionId = cell.data('id');
+ var modal = $(this);
+ modal.find('.idspan').text(sessionId);
+ var button = modal.find('#deleteRequest');
+ button.data('id', sessionId);
+ });
- $('.test_session_row td:not(:last-child)').click(function(e) {
- if($(this).hasClass("ban")) {
- e.stopPropagation();
- } else {
- window.location = "testsessions/" + $(this).parent().data("id");
- }
- });
+ //
+ // Recalculate all
+ //
- $(function() {
- $('#deleteRequest').click(function(){
- $('#deletemodal').modal('hide');
- $.ajax({
- type: "POST",
- url: "/",
- async: false,
- data: { params: "delete",
- id: $(this).data("id") },
- }).done(location.reload(true)).fail(deletefail);
- });
- });
+ var progress;
- $('#deletemodal').on('show.bs.modal', function(event) {
- var cell = $(event.relatedTarget);
- var sessionId = cell.data('id');
- var modal = $(this);
- modal.find('.idspan').text(sessionId);
- var button = modal.find('#deleteRequest');
- button.data("id", sessionId);
- });
+ var postsuccess = function(data) {
+ progress.close();
+ $('#Main').show();
+ $('#loading').hide();
+ location.reload(true);
+ };
- //
- // Recalculate all
- //
+ var postfail = function(data) {
+ progress.close();
+ alert('Recalculation failed: server error');
+ $('#Main').show();
+ $('#loading').hide();
+ };
- var progress;
+ var deletefail = function(data) {
+ alert('Deletion failed: server error');
+ $('#Main').show();
+ $('#loading').hide();
+ };
- var postsuccess = function (data) {
- progress.close();
- $("#Main").show();
- $("#loading").hide();
- location.reload(true);
+ $('#recalculate_button').click(function() {
+ $('#Main').hide();
+ $('#loading').show();
+
+ progress = new EventSource('?event=progress');
+
+ progress.onmessage = function(event) {
+ var val = Math.round(event.data * 100);
+ if (val <= 99) {
+ $('.prog').text(val);
+ $('.progress-bar').css('width', val + '%').attr('aria-valuenow', val);
+ } else {
+ $('.prog').text(100);
+ $('.progress-bar').css('width', 100 + '%').attr('aria-valuenow', 100);
+ }
};
- var postfail = function (data) {
- progress.close();
- alert('Recalculation failed: server error');
- $("#Main").show();
- $("#loading").hide();
- };
+ $.ajax({
+ type: 'POST',
+ url: '/',
+ data: {params: 'recalculate'},
+ })
+ .done(postsuccess)
+ .fail(postfail);
+ });
- var deletefail = function (data) {
- alert('Deletion failed: server error');
- $("#Main").show();
- $("#loading").hide();
- };
+ //
+ // Initializations
+ //
- $("#recalculate_button").click(function () {
- $("#Main").hide();
- $("#loading").show();
+ $('.notes').each(function() {
+ text = $(this).text();
+ if (text.length > 20)
+ $(this).text(text.substr(0, 20));
+ });
- progress = new EventSource('?event=progress');
-
- progress.onmessage = function(event) {
- var val = Math.round(event.data * 100);
- if(val <= 99) {
- $('.prog').text(val);
- $('.progress-bar').css('width', val + '%').attr('aria-valuenow', val);
- } else {
- $('.prog').text(100);
- $('.progress-bar').css('width', 100 + '%').attr('aria-valuenow', 100);
- }
- };
-
- $.ajax({
- type: "POST",
- url: "/",
- data: { params: "recalculate" },
- }).done(postsuccess).fail(postfail);
- });
-
- //
- // Initializations
- //
-
- $(".notes").each(function () {
- text = $(this).text();
- if (text.length > 20)
- $(this).text(text.substr(0, 20));
- });
-
- loadstate();
-
+ loadstate();
});
diff --git a/TPPTAnalysisSW/static/script/settings.js b/TPPTAnalysisSW/static/script/settings.js
index f093615..8db1ebe 100644
--- a/TPPTAnalysisSW/static/script/settings.js
+++ b/TPPTAnalysisSW/static/script/settings.js
@@ -1,142 +1,141 @@
-$(document).ready(function(){
+$(document).ready(function() {
+ $('.alert').parent().hide();
- $('.alert').parent().hide();
-
- $(function() {
- $(document).on('click', '.alert-close', function() {
- $(this).parent().hide();
- });
+ $(function() {
+ $(document).on('click', '.alert-close', function() {
+ $(this).parent().hide();
});
+ });
- var postsuccess = function (data) {
- $("#Main").show()
- $("#loading").hide()
- location.reload(true)
- };
+ var postsuccess = function(data) {
+ $('#Main').show()
+ $('#loading').hide()
+ location.reload(true)
+ };
- var postfailure = function (data) {
- progress.close();
- $("#Main").show()
- $("#loading").hide()
- $('.errormsg').text('Settings could not be saved. Please check the logs for details.')
- $('.errormsg').slideDown('fast')
- };
+ var postfailure = function(data) {
+ progress.close();
+ $('#Main').show()
+ $('#loading').hide()
+ $('.errormsg')
+ .text('Settings could not be saved. Please check the logs for details.')
+ $('.errormsg').slideDown('fast')
+ };
- $('.setting_value_input').bind('input', function() {
- var text = $(this).val()
- if (text.indexOf(',') >= 0) {
- // Replace ',' with '.' -> allow comma decimal separator (e.g. Finnish locale)
- text = text.split(',').join('.');
+ $('.setting_value_input').bind('input', function() {
+ var text = $(this).val()
+ if (text.indexOf(',') >= 0) {
+ // Replace ',' with '.' -> allow comma decimal separator (e.g. Finnish
+ // locale)
+ text = text.split(',').join('.');
+ }
+
+ var name = $(this).attr('name')
+
+ // Check if the input text is a legal value for the input
+ var valid = false
+ if (name.match(/^edgelimit/) || name.match(/^ztouchlimit/)) {
+ // Allow negative and zero values
+ if (text.match(/^-?\d+(\.\d+)?$/) && !isNaN(text)) {
+ valid = true;
+ }
+ }
+ // else if (name.match(/missing/)) {
+ else {
+ // Do not allow negative values
+ if (text.match(/^\d+(\.\d+)?$/) && parseFloat(text) >= 0) {
+ valid = true;
+ }
+ }
+ /*
+ else {
+ // Do not allow negative or zero values
+ if (text.match(/^\d+(\.\d+)?$/) && parseFloat(text) > 0) {
+ valid = true;
}
+ }
+ */
- var name = $(this).attr('name')
+ if (valid && $(this).hasClass('invalid')) {
+ $(this).removeClass('invalid');
+ } else if (!valid && !$(this).hasClass('invalid')) {
+ $(this).addClass('invalid');
+ }
+ });
- // Check if the input text is a legal value for the input
- var valid = false
- if (name.match(/^edgelimit/) || name.match(/^ztouchlimit/)) {
- // Allow negative and zero values
- if (text.match(/^-?\d+(\.\d+)?$/) && !isNaN(text)) {
- valid = true;
- }
- }
- //else if (name.match(/missing/)) {
- else {
- // Do not allow negative values
- if (text.match(/^\d+(\.\d+)?$/) && parseFloat(text) >= 0) {
- valid = true;
- }
- }
- /*
- else {
- // Do not allow negative or zero values
- if (text.match(/^\d+(\.\d+)?$/) && parseFloat(text) > 0) {
- valid = true;
- }
- }
- */
+ var progress;
- if (valid && $(this).hasClass('invalid')) {
- $(this).removeClass('invalid');
- }
- else if(!valid && !$(this).hasClass('invalid')) {
- $(this).addClass('invalid');
- }
- });
+ $('#save').on('submit', function(e) {
+ // Check if there are invalid values
+ e.preventDefault();
- var progress;
+ if ($('.invalid').length > 0) {
+ $('.errormsg').text('Please check the invalid values before saving');
+ $('.errormsg').slideDown('fast');
+ } else {
+ if ($('#save').context.activeElement.value === 'recalculate') {
+ $('#Main').hide();
+ $('#loading').show();
+ }
- $("#save").on('submit', function(e) {
-
- // Check if there are invalid values
- e.preventDefault();
-
- if ($('.invalid').length > 0) {
- $('.errormsg').text('Please check the invalid values before saving');
- $('.errormsg').slideDown('fast');
- }
- else
- {
-
- if($("#save").context.activeElement.value === "recalculate") {
- $("#Main").hide();
- $("#loading").show();
- }
-
- var idvalues = [];
- $(".settings_table :input").each(function(){
- var idvalue = {id : $(this).attr("name"), value : $(this).val()};
- idvalues.push(idvalue);
- });
+ var idvalues = [];
+ $('.settings_table :input').each(function() {
+ var idvalue = {id: $(this).attr('name'), value: $(this).val()};
+ idvalues.push(idvalue);
+ });
- if($("#save").context.activeElement.value === "recalculate") {
+ if ($('#save').context.activeElement.value === 'recalculate') {
+ progress = new EventSource('/settings?event=progress');
- progress = new EventSource('/settings?event=progress');
+ progress.onmessage = function(event) {
+ var val = Math.round(event.data * 100);
+ if (val <= 99) {
+ $('.prog').text(val);
+ $('.progress-bar')
+ .css('width', val + '%')
+ .attr('aria-valuenow', val);
+ } else {
+ $('.prog').text(100);
+ $('.progress-bar')
+ .css('width', 100 + '%')
+ .attr('aria-valuenow', 100);
+ }
+ };
- progress.onmessage = function(event) {
- var val = Math.round(event.data * 100);
- if(val <= 99) {
- $('.prog').text(val);
- $('.progress-bar').css('width', val + '%').attr('aria-valuenow', val);
- } else {
- $('.prog').text(100);
- $('.progress-bar').css('width', 100 + '%').attr('aria-valuenow', 100);
- }
- };
+ $.ajax({
+ type: 'POST',
+ url: '/settings',
+ data: {
+ params: JSON.stringify(idvalues),
+ mode: $('#save').context.activeElement.value
+ },
+ success: function(msg) {
+ progress.close();
+ location.reload(true);
+ $(document).ready(function() {
+ $('.alert').text(msg);
+ $('.alert').parent().show();
+ $('html, body').animate({scrollTop: 0}, 0);
+ });
+ }
+ }).fail(postfailure);
- $.ajax({
- type: "POST",
- url: "/settings",
- data: {params: JSON.stringify(idvalues),
- mode: $("#save").context.activeElement.value},
- success : function(msg) {
- progress.close();
- location.reload(true);
- $(document).ready(function() {
- $('.alert').text(msg);
- $('.alert').parent().show();
- $('html, body').animate({ scrollTop: 0 }, 0);
- });
- }
- }).fail(postfailure);
-
- } else {
-
- $.ajax({
- type: "POST",
- url: "/settings",
- data: {params: JSON.stringify(idvalues),
- mode: $("#save").context.activeElement.value},
- success : function(msg) {
- $('.alert').text(msg);
- $('.alert').parent().show();
- $('html, body').animate({ scrollTop: 0 }, 0);
- }
- }).fail(postfailure);
-
- }
- }
-
- });
-
+ } else {
+ $.ajax({
+ type: 'POST',
+ url: '/settings',
+ data: {
+ params: JSON.stringify(idvalues),
+ mode: $('#save').context.activeElement.value
+ },
+ success: function(msg) {
+ $('.alert').text(msg);
+ $('.alert').parent().show();
+ $('html, body').animate({scrollTop: 0}, 0);
+ }
+ }).fail(postfailure);
+ }
+ }
+ });
});
\ No newline at end of file
diff --git a/TPPTAnalysisSW/static/script/test_dut_settings.js b/TPPTAnalysisSW/static/script/test_dut_settings.js
index cb9d3be..942edc9 100644
--- a/TPPTAnalysisSW/static/script/test_dut_settings.js
+++ b/TPPTAnalysisSW/static/script/test_dut_settings.js
@@ -1,81 +1,81 @@
-$(document).ready(function () {
+$(document).ready(function() {
+ var postsuccess = function(data) {
+ $('#Main').show()
+ $('#loading').hide()
+ location.reload(true)
+ };
- var postsuccess = function (data) {
- $("#Main").show()
- $("#loading").hide()
- location.reload(true)
- };
+ var postfailure = function(data) {
+ $('#Main').show()
+ $('#loading').hide()
+ $('.errormsg')
+ .text('Settings could not be saved. Please check the logs for details.')
+ $('.errormsg').slideDown('fast')
+ };
- var postfailure = function (data) {
- $("#Main").show()
- $("#loading").hide()
- $('.errormsg').text('Settings could not be saved. Please check the logs for details.')
- $('.errormsg').slideDown('fast')
- };
+ $('.setting_value_input').bind('input', function() {
+ var text = $(this).val()
+ if (text.indexOf(',') >= 0) {
+ // Replace ',' with '.' -> allow comma decimal separator (e.g. Finnish
+ // locale)
+ text = text.split(',').join('.');
+ }
- $('.setting_value_input').bind('input', function() {
- var text = $(this).val()
- if (text.indexOf(',') >= 0) {
- // Replace ',' with '.' -> allow comma decimal separator (e.g. Finnish locale)
- text = text.split(',').join('.');
- }
+ var name = $(this).attr('name')
- var name = $(this).attr('name')
+ // Check if the input text is a legal value for the input
+ var valid = false
+ if (name.match(/^offset/)) {
+ // Allow negative and zero values
+ if (text.match(/^-?\d+(\.\d+)?$/) && !isNaN(text)) {
+ valid = true;
+ }
+ }
+ else {
+ // Do not allow negative or zero values
+ if (text.match(/^\d+(\.\d+)?$/) && parseFloat(text) > 0) {
+ valid = true;
+ }
+ }
- // Check if the input text is a legal value for the input
- var valid = false
- if (name.match(/^offset/)) {
- // Allow negative and zero values
- if (text.match(/^-?\d+(\.\d+)?$/) && !isNaN(text)) {
- valid = true;
- }
- }
- else {
- // Do not allow negative or zero values
- if (text.match(/^\d+(\.\d+)?$/) && parseFloat(text) > 0) {
- valid = true;
- }
- }
+ if (valid && $(this).hasClass('invalid')) {
+ $(this).removeClass('invalid');
+ } else if (!valid && !$(this).hasClass('invalid')) {
+ $(this).addClass('invalid');
+ }
+ })
- if (valid && $(this).hasClass('invalid')) {
- $(this).removeClass('invalid');
- }
- else if(!valid && !$(this).hasClass('invalid')) {
- $(this).addClass('invalid');
- }
- })
+ $('#save_button').click(function() {
+ // Check if there are invalid values
+ if ($('.invalid').length > 0) {
+ $('.errormsg').text('Please check the invalid values before saving')
+ $('.errormsg').slideDown('fast')
+ } else {
+ $('#Main').hide()
+ $('#loading').show()
- $("#save_button").click(function () {
- // Check if there are invalid values
- if ($('.invalid').length > 0) {
- $('.errormsg').text('Please check the invalid values before saving')
- $('.errormsg').slideDown('fast')
- }
- else
- {
- $("#Main").hide()
- $("#loading").show()
+ $('.errormsg').hide();
+ var saveValues = {};
+ $('.setting_value_input').each(function() {
+ saveValues[$(this).attr('name')] = $(this).val();
+ });
+ $('.setting_value_checkbox:checked').each(function() {
+ saveValues[$(this).attr('name')] = $(this).val();
+ });
+ $('.dut_value_input').each(function() {
+ saveValues[$(this).attr('name')] = $(this).val();
+ });
- $('.errormsg').hide();
- var saveValues = {};
- $('.setting_value_input').each(function() {
- saveValues[$(this).attr('name')] = $(this).val();
- });
- $('.setting_value_checkbox:checked').each(function() {
- saveValues[$(this).attr('name')] = $(this).val();
- });
- $('.dut_value_input').each(function () {
- saveValues[$(this).attr('name')] = $(this).val();
- });
+ // Debug output
+ //$('#output').text(JSON.stringify(saveValues, null, " "));
- // Debug output
- //$('#output').text(JSON.stringify(saveValues, null, " "));
-
- $.ajax({
- type: 'POST',
- data: {data: JSON.stringify(saveValues)},
- dataType: 'text'}).done(postsuccess).fail(postfailure);
- }
- });
+ $.ajax({
+ type: 'POST',
+ data: {data: JSON.stringify(saveValues)},
+ dataType: 'text'
+ })
+ .done(postsuccess)
+ .fail(postfailure);
+ }
+ });
});
-
diff --git a/TPPTAnalysisSW/static/script/test_page.js b/TPPTAnalysisSW/static/script/test_page.js
index a40af12..94d13e5 100644
--- a/TPPTAnalysisSW/static/script/test_page.js
+++ b/TPPTAnalysisSW/static/script/test_page.js
@@ -1,56 +1,46 @@
/**
- * Enum of possible states a test can be in. Should match the equivalent Enum defined in spec_validators.py
+ * Enum of possible states a test can be in. Should match the equivalent Enum
+ * defined in spec_validators.py
* @enum {string}
*/
const TestStatus = {
kPass: 'Pass',
kBorderline: 'Borderline',
kFail: 'Fail',
-}
+};
-$(document).ready(function()
-{
- $(".pass_select").each(function()
- {
- if ($(this).hasClass("select_initially_passed"))
- {
- $(this).val(TestStatus.kPass)
- $(this).addClass(TestStatus.kPass)
- $(this).removeClass(TestStatus.kFail)
- }
- else
- {
- $(this).val(TestStatus.kFail)
- $(this).addClass(TestStatus.kFail)
- $(this).removeClass(TestStatus.kPass)
- }
- });
+$(document).ready(function() {
+ $('.pass_select').each(function() {
+ if ($(this).hasClass('select_initially_passed')) {
+ $(this).val(TestStatus.kPass)
+ $(this).addClass(TestStatus.kPass)
+ $(this).removeClass(TestStatus.kFail)
+ } else {
+ $(this).val(TestStatus.kFail)
+ $(this).addClass(TestStatus.kFail)
+ $(this).removeClass(TestStatus.kPass)
+ }
+ });
- $(".pass_select").change(function()
- {
- if ($('option:selected', this).hasClass(TestStatus.kPass))
- {
- $(this).addClass(TestStatus.kPass)
- $(this).removeClass(TestStatus.kFail)
- }
- else
- {
- $(this).addClass(TestStatus.kFail)
- $(this).removeClass(TestStatus.kPass)
- }
- });
+ $('.pass_select').change(function() {
+ if ($('option:selected', this).hasClass(TestStatus.kPass)) {
+ $(this).addClass(TestStatus.kPass)
+ $(this).removeClass(TestStatus.kFail)
+ } else {
+ $(this).addClass(TestStatus.kFail)
+ $(this).removeClass(TestStatus.kPass)
+ }
+ });
- $("#print_button").click(function()
- {
- window.print();
- });
+ $('#print_button').click(function() {
+ window.print();
+ });
- $("#upload_button").click(function () {
- $.post(window.location.href.split('?')[0] + '/upload', function(data) {
- alert(JSON.stringify(data));
- window.location.reload();
- });
+ $('#upload_button').click(function() {
+ $.post(window.location.href.split('?')[0] + '/upload', function(data) {
+ alert(JSON.stringify(data));
+ window.location.reload();
});
-
+ });
});
diff --git a/TPPTAnalysisSW/static/script/test_page_subplots.js b/TPPTAnalysisSW/static/script/test_page_subplots.js
index 81e73dd..1d6c444 100644
--- a/TPPTAnalysisSW/static/script/test_page_subplots.js
+++ b/TPPTAnalysisSW/static/script/test_page_subplots.js
@@ -2,77 +2,78 @@
var loadcount = 0
function imageLoaded() {
- loadcount -= 1;
- if (loadcount === 0) {
- $("#print_button").attr("disabled", false)
- }
+ loadcount -= 1;
+ if (loadcount === 0) {
+ $('#print_button').attr('disabled', false)
+ }
}
function imageLoading() {
- loadcount += 1;
- if (loadcount === 1) {
- $("#print_button").attr("disabled", true)
- }
+ loadcount += 1;
+ if (loadcount === 1) {
+ $('#print_button').attr('disabled', true)
+ }
}
function showPlot(plotObject) {
- // plotObject is a (single) jQuery object for .plot instance
- if (!plotObject.data("shown")) {
- $.map($('.plot'), function(el) {
- var imgsrc = $(el).data("src");
- imageLoading();
- $(el).html("<img src=\"" + imgsrc + "\" onload=\"imageLoaded()\" />");
- $(el).data("shown", true);
- });
- }
+ // plotObject is a (single) jQuery object for .plot instance
+ if (!plotObject.data('shown')) {
+ $.map($('.plot'), function(el) {
+ var imgsrc = $(el).data('src');
+ imageLoading();
+ $(el).html('<img src="' + imgsrc + '" onload="imageLoaded()" />');
+ $(el).data('shown', true);
+ });
+ }
}
function toggleState(set) {
- // Toggles the visibility state of given jQuery set
- set.each(function () { showPlot($(this)) });
- // Set the display value to same as the first one
- set.first().toggle();
- var display = set.css("display");
- set.css("display", display);
+ // Toggles the visibility state of given jQuery set
+ set.each(function() {
+ showPlot($(this))
+ });
+ // Set the display value to same as the first one
+ set.first().toggle();
+ var display = set.css('display');
+ set.css('display', display);
}
-$(document).ready(function () {
+$(document).ready(function() {
+ $('.all_lines_button').click(function() {
+ // Select all plots
+ var selector = '.plot'
+ if ($(this).is('[data-target]')) {
+ // Target defined
+ selector = '#'.concat($(this).attr('data-target')) + ' ' + selector
+ }
- $(".all_lines_button").click(function () {
- // Select all plots
- var selector = ".plot"
- if ($(this).is("[data-target]")) {
- // Target defined
- selector = "#".concat($(this).attr("data-target")) + " " + selector
- }
+ toggleState($(selector))
+ });
- toggleState($(selector))
- });
+ $('.failed_lines_button').click(function() {
+ // Select failed plots
+ var selector = `.${TestStatus.kFail} ~ .plot`
+ if ($(this).is('[data-target]')) {
+ // Target defined
+ selector = '#'.concat($(this).attr('data-target')) + ' ' + selector
+ }
- $(".failed_lines_button").click(function () {
- // Select failed plots
- var selector = `.${TestStatus.kFail} ~ .plot`
- if ($(this).is("[data-target]")) {
- // Target defined
- selector = "#".concat($(this).attr("data-target")) + " " + selector
- }
+ toggleState($(selector))
+ });
- toggleState($(selector))
- });
+ $('.passed_lines_button').click(function() {
+ // Select passed plots
+ var selector = `.${TestStatus.kPass} ~ .plot`
+ if ($(this).is('[data-target]')) {
+ // Target defined
+ selector = '#'.concat($(this).attr('data-target')) + ' ' + selector
+ }
- $(".passed_lines_button").click(function () {
- // Select passed plots
- var selector = `.${TestStatus.kPass} ~ .plot`
- if ($(this).is("[data-target]")) {
- // Target defined
- selector = "#".concat($(this).attr("data-target")) + " " + selector
- }
+ toggleState($(selector))
+ });
- toggleState($(selector))
- });
-
- $(".subplot_table .show_plot").click(function () {
- showPlot($(this).parent().siblings(".plot"));
- $(this).parent().siblings(".plot").toggle();
- });
+ $('.subplot_table .show_plot').click(function() {
+ showPlot($(this).parent().siblings('.plot'));
+ $(this).parent().siblings('.plot').toggle();
+ });
});
diff --git a/TPPTAnalysisSW/static/script/test_summary.js b/TPPTAnalysisSW/static/script/test_summary.js
index 9b1de2e..3d6d13c 100644
--- a/TPPTAnalysisSW/static/script/test_summary.js
+++ b/TPPTAnalysisSW/static/script/test_summary.js
@@ -1,60 +1,67 @@
-$(document).ready(function () {
- var loadcount = 1 + $("#test_summaries").data("count"); // Session + tests
+$(document).ready(function() {
+ var loadcount = 1 + $('#test_summaries').data('count'); // Session + tests
- function loadDone() {
- loadcount -= 1;
- if (loadcount == 0) {
- $("#print_button").prop('disabled', false);
- }
+ function loadDone() {
+ loadcount -= 1;
+ if (loadcount == 0) {
+ $('#print_button').prop('disabled', false);
}
+ }
- function sessionLoaded(data) {
- var dom = $(data);
- // Remove elements not belonging to the summary
- dom.find(".no_summary").remove();
- var content = dom.find('.content').html();
- $(this).html(dom.find('.content').html());
-
- $(".test_row").click(function () {
- window.location = "/tests/" + $(this).data("test-id");
- });
+ function sessionLoaded(data) {
+ var dom = $(data);
+ // Remove elements not belonging to the summary
+ dom.find('.no_summary').remove();
+ var content = dom.find('.content').html();
+ $(this).html(dom.find('.content').html());
- loadDone();
- }
-
- function testLoaded(data) {
- var dom = $(data);
-
- // Add title
- var contents = dom.find(".test_title");
- contents.find('.no_summary').remove();
- $(this).append(contents);
-
- // Add the summary table
- var contents = dom.find(".test_verdicts");
- contents.find('.no_summary').remove();
- $(this).append(contents);
-
- loadDone();
- }
-
- function loadFailed() {
- alert("Report loading failed")
- }
-
- $(".test_sesession").each(function () {
- $.ajax({ url: "http://localhost:8081/testsessions/".concat($(this).attr("id")),
- context: this,
- }).done(sessionLoaded).fail(loadFailed);
+ $('.test_row').click(function() {
+ window.location = '/tests/' + $(this).data('test-id');
});
- $(".test_div").each(function() {
- $.ajax({ url: "http://localhost:8081/tests/" + $(this).attr("id") + "?noimages=true",
- context: this,
- }).done(testLoaded).fail(loadFailed);
- });
+ loadDone();
+ }
- $("#print_button").click(function() {
- window.print();
- });
+ function testLoaded(data) {
+ var dom = $(data);
+
+ // Add title
+ var contents = dom.find('.test_title');
+ contents.find('.no_summary').remove();
+ $(this).append(contents);
+
+ // Add the summary table
+ var contents = dom.find('.test_verdicts');
+ contents.find('.no_summary').remove();
+ $(this).append(contents);
+
+ loadDone();
+ }
+
+ function loadFailed() {
+ alert('Report loading failed')
+ }
+
+ $('.test_sesession').each(function() {
+ $.ajax({
+ url: 'http://localhost:8081/testsessions/'.concat($(this).attr('id')),
+ context: this,
+ })
+ .done(sessionLoaded)
+ .fail(loadFailed);
+ });
+
+ $('.test_div').each(function() {
+ $.ajax({
+ url: 'http://localhost:8081/tests/' + $(this).attr('id') +
+ '?noimages=true',
+ context: this,
+ })
+ .done(testLoaded)
+ .fail(loadFailed);
+ });
+
+ $('#print_button').click(function() {
+ window.print();
+ });
});
\ No newline at end of file
diff --git a/TPPTAnalysisSW/static/script/testsession.js b/TPPTAnalysisSW/static/script/testsession.js
index 4e98f28..72b40da 100644
--- a/TPPTAnalysisSW/static/script/testsession.js
+++ b/TPPTAnalysisSW/static/script/testsession.js
@@ -1,56 +1,54 @@
-$(document).ready(function () {
- function notesSaved(data) {
- //alert(data);
- $('#notes').html(data);
- $("#notes").show();
- $("#notes_editor").hide();
- $("#notes_edit").show();
- $("#notes_save").hide();
- }
+$(document).ready(function() {
+ function notesSaved(data) {
+ // alert(data);
+ $('#notes').html(data);
+ $('#notes').show();
+ $('#notes_editor').hide();
+ $('#notes_edit').show();
+ $('#notes_save').hide();
+ }
- function notesError() {
- alert('Saving of notes failed');
- }
+ function notesError() {
+ alert('Saving of notes failed');
+ }
- $(".test_row").click(function () {
- window.location = "/tests/" + $(this).data("test-id");
+ $('.test_row').click(function() {
+ window.location = '/tests/' + $(this).data('test-id');
+ });
+
+ $('.upload_test_button').click(function() {
+ var location = window.location.href.split('?')[0] +
+ '/upload_test?test_id=' + $(this).data('test-id');
+
+ $.post(location, function(data) {
+ alert(JSON.stringify(data));
+ // Reload to refresh the disabled status for all the buttons on the page
+ window.location.reload();
});
+ });
- $(".upload_test_button").click(function () {
- var location = window.location.href.split('?')[0] + '/upload_test?test_id=' + $(this).data("test-id");
+ $('#upload_session_button').click(function() {
+ var location = window.location.href.split('?')[0] +
+ '/upload_session?session_id=' + $(this).data('session-id');
- $.post(location, function(data) {
- alert(JSON.stringify(data));
- // Reload to refresh the disabled status for all the buttons on the page
- window.location.reload();
- });
+ $.post(location, function(data) {
+ alert(JSON.stringify(data));
+ // Reload to refresh the disabled status for all the buttons on the page
+ window.location.reload();
});
+ });
- $("#upload_session_button").click(function () {
- var location = window.location.href.split('?')[0] + '/upload_session?session_id=' + $(this).data("session-id");
+ $('#notes_save').click(function() {
+ var data = {command: 'set_notes', value: $('#notes_editor').val()};
+ $.ajax({type: 'POST', data: {data: JSON.stringify(data)}, datatype: 'text'})
+ .done(notesSaved)
+ .fail(notesError);
+ });
- $.post(location, function(data) {
- alert(JSON.stringify(data));
- // Reload to refresh the disabled status for all the buttons on the page
- window.location.reload();
- });
- });
-
- $("#notes_save").click(function () {
- var data = { command: 'set_notes',
- value: $('#notes_editor').val()
- };
- $.ajax({ type: "POST",
- data: { data: JSON.stringify(data)
- },
- datatype: 'text'
- }).done(notesSaved).fail(notesError);
- });
-
- $("#notes_edit").click(function () {
- $("#notes").hide();
- $("#notes_editor").show();
- $("#notes_edit").hide();
- $("#notes_save").show();
- });
+ $('#notes_edit').click(function() {
+ $('#notes').hide();
+ $('#notes_editor').show();
+ $('#notes_edit').hide();
+ $('#notes_save').show();
+ });
});