From b840b0f3b56ff0f5f4b7de8fe2fa3efa93551d96 Mon Sep 17 00:00:00 2001 From: Jason White Date: Tue, 2 May 2017 22:24:03 -0400 Subject: [PATCH] additional support for scoreboard view --- .../static/js/goatApp/templates/scoreboard.html | 16 ++++++++++++++++ .../static/js/goatApp/view/ScoreboardView.js | 15 ++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 webgoat-container/src/main/resources/static/js/goatApp/templates/scoreboard.html diff --git a/webgoat-container/src/main/resources/static/js/goatApp/templates/scoreboard.html b/webgoat-container/src/main/resources/static/js/goatApp/templates/scoreboard.html new file mode 100644 index 000000000..141c3f5af --- /dev/null +++ b/webgoat-container/src/main/resources/static/js/goatApp/templates/scoreboard.html @@ -0,0 +1,16 @@ +
+ + + +
\ No newline at end of file diff --git a/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js b/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js index f7f607a8e..09ed711f4 100644 --- a/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js +++ b/webgoat-container/src/main/resources/static/js/goatApp/view/ScoreboardView.js @@ -1,25 +1,34 @@ define(['jquery', 'underscore', 'backbone', - 'goatApp/model/FlagsCollection'], + 'goatApp/model/FlagsCollection', + 'text!templates/scoreboard.html'], function($, _, Backbone, - FlagsCollection) { + FlagsCollection, + ScoreboardTemplate) { return Backbone.View.extend({ el:'#scoreboard', initialize: function() { + template:ScoreboardTemplate, this.collection = new FlagsCollection(); this.listenTo(this.collection,'reset',this.render) this.collection.fetch({reset:true}); }, render: function() { - this.$el.html('test') + //this.$el.html('test'); + var t = _.template(this.template); + this.$el.html(t({'flags':this.collection.toJSON()})); //TODO: add template (table) to iterate over ... //this.collection.toJSON(); << put that in the template data //TODO: set up next poll here with listenToOnce + }, + + pollData: function() { + this.collection.fetch({reset:true}); } }); }); \ No newline at end of file