incremental progress on new UI code, mod to AbstractLesson for menu
This commit is contained in:
parent
53c4ffc1cf
commit
8aa4b8109f
@ -563,12 +563,8 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
|
||||
|
||||
// mvc update:
|
||||
link.append(getPath()).append("/");
|
||||
//link.append(WebSession.SCREEN);
|
||||
//link.append("=");
|
||||
link.append(getScreenId());
|
||||
link.append("/");
|
||||
//link.append(WebSession.MENU);
|
||||
//link.append("=");
|
||||
link.append(getCategory().getRanking());
|
||||
return link.toString();
|
||||
}
|
||||
|
@ -117,9 +117,10 @@
|
||||
<!--<span id="curHintContainer"></span>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body" id="lesson_content">
|
||||
<b>This should default to the "How to Work with Webgoat" lesson</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12" align="left">
|
||||
<div id="lessonContentWrapper" class="panel">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
1805
src/main/webapp/js/backbone/backbone-edge.js
Normal file
1805
src/main/webapp/js/backbone/backbone-edge.js
Normal file
File diff suppressed because it is too large
Load Diff
2
src/main/webapp/js/backbone/backbone-min.js
vendored
Normal file
2
src/main/webapp/js/backbone/backbone-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1608
src/main/webapp/js/backbone/backbone.js
Normal file
1608
src/main/webapp/js/backbone/backbone.js
Normal file
File diff suppressed because it is too large
Load Diff
6
src/main/webapp/js/backbone/underscore-min.js
vendored
Normal file
6
src/main/webapp/js/backbone/underscore-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1416
src/main/webapp/js/backbone/underscore.js
Normal file
1416
src/main/webapp/js/backbone/underscore.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@ define(['jquery',
|
||||
'goatApp/model/LessonContentData',
|
||||
'goatApp/view/LessonContentView'
|
||||
],
|
||||
function($,_,Backbone,LessonContent) {
|
||||
function($,_,Backbone,LessonContentData,LessonContentView) {
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -12,14 +12,15 @@ define(['jquery',
|
||||
this.lessonView = options.lessonView;
|
||||
this.lessonContent = new LessonContentData();
|
||||
|
||||
_.extend(this,Backbone.Events);
|
||||
_.extend(Controller.prototype,Backbone.Events);
|
||||
this.start = function() {
|
||||
this.listenTo(this.lessonContent,'contentLoaded',this.onContentLoaded);
|
||||
|
||||
}
|
||||
|
||||
//load View, which can pull data
|
||||
this.loadLesson = function(scr,menu) {
|
||||
this.lessonContent.loadContent({
|
||||
this.lessonContent.loadData({
|
||||
'screen': encodeURIComponent(scr),
|
||||
'menu': encodeURIComponent(menu),
|
||||
});
|
||||
@ -29,8 +30,19 @@ define(['jquery',
|
||||
|
||||
this.onContentLoaded = function() {
|
||||
//this.lessonView = new LessonContentView({content:LessonContent.content});
|
||||
//this.lessonView.render();
|
||||
console.debug('loading other stuff');
|
||||
this.lessonView.model = this.lessonContent;
|
||||
this.lessonView.render();
|
||||
//load cookies/parameters view
|
||||
|
||||
//load help view
|
||||
|
||||
//load title
|
||||
|
||||
//plan
|
||||
|
||||
//solution
|
||||
|
||||
//source
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,4 +1,17 @@
|
||||
define(['jquery','underscore','backbone','goatApp/model/MenuData','goatApp/view/MenuView'],
|
||||
function($,_,Backbone,MenuData,MenuView) {
|
||||
define(['jquery','underscore','backbone','goatApp/view/MenuView'],
|
||||
function($,_,Backbone,MenuView) {
|
||||
Controller = function(options){
|
||||
options = options || {};
|
||||
this.menuView = options.menuView;
|
||||
this.initMenu = function() {
|
||||
console.debug('initing menu');
|
||||
}
|
||||
|
||||
this.updateMenu = function() {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return Controller;
|
||||
});
|
@ -1,13 +1,13 @@
|
||||
define(['jquery','underscore','backbone','goatApp/view/goatRouter','goatApp/controller/LessonController','goatApp/controller/MenuController'],
|
||||
function($,_,Backbone,Router,LessonController,MenuController){
|
||||
define(['jquery','underscore','backbone','goatApp/view/GoatRouter'],
|
||||
function($,_,Backbone,Router){
|
||||
'use strict'
|
||||
//var goatRouter = new Router();
|
||||
|
||||
return {
|
||||
initApp: function() {
|
||||
//TODO: add query/ability to load from where they left off
|
||||
console.log('initApp')
|
||||
//Router.init();
|
||||
}
|
||||
var goatRouter = new Router();
|
||||
goatRouter.init();
|
||||
}
|
||||
};
|
||||
});
|
@ -1,4 +1,7 @@
|
||||
define(['jquery', 'underscore','backbone'], function($,_,Backbone){
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,_,Backbone){
|
||||
|
||||
return Backbone.Model.extend({
|
||||
urlRoot:null,
|
||||
@ -11,12 +14,36 @@ define(['jquery', 'underscore','backbone'], function($,_,Backbone){
|
||||
},
|
||||
loadData: function(options) {
|
||||
this.urlRoot = this.baseUrlRoot + +options.screen + '&menu=' + options.menu;
|
||||
var self = this;
|
||||
this.fetch().then(function(content){
|
||||
alert('content loaded');
|
||||
self.content = content;
|
||||
self.trigger('contentLoaded');
|
||||
var self=this;
|
||||
this.fetch().then(function(data) {
|
||||
self.setContent(data);
|
||||
});
|
||||
// success: function(content) {
|
||||
// console.log("content:" + content);
|
||||
// },
|
||||
// error: function(err) {
|
||||
// console.log("error:" + err);
|
||||
// },
|
||||
// done: function(a,b) {
|
||||
// console.log(a);
|
||||
// console.log(b);
|
||||
// }
|
||||
// });
|
||||
},
|
||||
setContent: function(content) {
|
||||
this.set('content',content);
|
||||
this.trigger('contentLoaded');
|
||||
},
|
||||
fetch: function (options) {
|
||||
options = options || {};
|
||||
return Backbone.Model.prototype.fetch.call(this, _.extend({ dataType: "html"}, options));
|
||||
// var self=this;
|
||||
// Backbone.Model.prototype.fetch.apply(this, arguments).then(
|
||||
// function(content){
|
||||
// self.setContent(content);
|
||||
// });
|
||||
|
||||
// //override with prototype
|
||||
}
|
||||
});
|
||||
});
|
21
src/main/webapp/js/goatApp/model/MenuItemCollection.js
Normal file
21
src/main/webapp/js/goatApp/model/MenuItemCollection.js
Normal file
@ -0,0 +1,21 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/MenuItemModel'],
|
||||
function($,_,Backbone,MenuItemModel) {
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: MenuItemModel,
|
||||
url:'service/lessonmenu.mvc',
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch().then(function (data) {
|
||||
this.models = data;
|
||||
self.onDataLoaded();
|
||||
});
|
||||
},
|
||||
onDataLoaded:function() {
|
||||
this.trigger('menuData:loaded');
|
||||
}
|
||||
});
|
||||
});
|
51
src/main/webapp/js/goatApp/model/MenuItemModel.js
Normal file
51
src/main/webapp/js/goatApp/model/MenuItemModel.js
Normal file
@ -0,0 +1,51 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,_,Backbone) {
|
||||
|
||||
return Backbone.Model.extend({
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// accordionMenu = function(id) {
|
||||
// if ($('ul#' + id).attr('isOpen') == 0) {
|
||||
// $scope.expandMe = true;
|
||||
// } else {
|
||||
// $('ul#' + id).slideUp(300).attr('isOpen', 0);u
|
||||
// return;
|
||||
// }
|
||||
// $scope.openMenu = id;
|
||||
// $('.lessonsAndStages').not('ul#' + id).slideUp(300).attr('isOpen', 0);
|
||||
// if ($scope.expandMe) {
|
||||
// $('ul#' + id).slideDown(300).attr('isOpen', 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//urlRoot:'service/lessonmenu.mvc',
|
||||
// defaults: {
|
||||
// items:null,
|
||||
// selectedItem:null
|
||||
// },
|
||||
// initialize: function () {
|
||||
// var self = this;
|
||||
// this.fetch().then(function(menuItems){
|
||||
// menuItems = goatUtils.enhanceMenuData(menuItems,this.selectedItem);
|
||||
// this.setDataItems(menuItems);
|
||||
// });
|
||||
// },
|
||||
|
||||
// update: function() {
|
||||
// var self = this;
|
||||
// this.fetch().then(function(menuItems) {
|
||||
// menuItems = goatUtils.enhanceMenuData(menuItems,this.selectedItem);
|
||||
// self.setDataItems(menuItems);
|
||||
// });
|
||||
// },
|
||||
|
||||
// setDataItems: function (data) {
|
||||
// this.items = data;
|
||||
// }
|
||||
// });
|
46
src/main/webapp/js/goatApp/view/GoatRouter.js
Normal file
46
src/main/webapp/js/goatApp/view/GoatRouter.js
Normal file
@ -0,0 +1,46 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/controller/LessonController',
|
||||
'goatApp/controller/MenuController',
|
||||
'goatApp/view/LessonContentView',
|
||||
'goatApp/view/MenuView'
|
||||
], function ($,_,Backbone,LessonController,MenuController,LessonContentView,MenuView) {
|
||||
|
||||
var lessonView = new LessonContentView();
|
||||
var menuView = new MenuView();
|
||||
var GoatAppRouter = Backbone.Router.extend({
|
||||
routes: {
|
||||
//#....
|
||||
'welcome':'welcomeRoute',
|
||||
'attack/:scr/:menu':'attackRoute' //
|
||||
},
|
||||
lessonController: new LessonController({
|
||||
lessonView:lessonView
|
||||
}),
|
||||
menuController: new MenuController({
|
||||
menuView:menuView
|
||||
}),
|
||||
|
||||
init:function() {
|
||||
goatRouter = new GoatAppRouter();
|
||||
this.lessonController.start();
|
||||
this.menuController.initMenu();
|
||||
|
||||
goatRouter.on('route:attackRoute', function(scr,menu) {
|
||||
console.log('attack route');
|
||||
this.lessonController.loadLesson(scr,menu);
|
||||
this.menuController.updateMenu(scr,menu);
|
||||
//update menu
|
||||
});
|
||||
goatRouter.on('route:welcomeRoute', function() {
|
||||
alert('welcome route');
|
||||
});
|
||||
|
||||
Backbone.history.start();
|
||||
}
|
||||
});
|
||||
|
||||
return GoatAppRouter;
|
||||
|
||||
});
|
@ -4,22 +4,16 @@ define(['jquery',
|
||||
'backbone',
|
||||
'goatApp/model/LessonContentData'],
|
||||
function($,_,Backbone,LessonData) {
|
||||
var contentView = Backbone.View.extend({
|
||||
el:'#lessonContent',
|
||||
return Backbone.View.extend({
|
||||
el:'#lessonContentWrapper', //TODO << get this fixed up in DOM
|
||||
initialize: function(options) {
|
||||
//this.content = options.content;
|
||||
this.lessonData = {};
|
||||
this.listenTo(this.lessonData,'sync',this.render);
|
||||
},
|
||||
loadLesson: function(options) {
|
||||
this.lessonData = new LessonData(options.screen,options.menu);
|
||||
|
||||
options = options || {};
|
||||
},
|
||||
render: function() {
|
||||
alert('render');
|
||||
this.$el.html(this.content);
|
||||
//alert('render');
|
||||
this.$el.html(this.model.get('content'));
|
||||
}
|
||||
});
|
||||
|
||||
return contentView;
|
||||
|
||||
});
|
14
src/main/webapp/js/goatApp/view/MenuItemView.js
Normal file
14
src/main/webapp/js/goatApp/view/MenuItemView.js
Normal file
@ -0,0 +1,14 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'], function($,_,Backbone) {
|
||||
|
||||
return Backbone.View.extend({
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
@ -1,12 +1,19 @@
|
||||
define(['jquery','underscore','backbone','goatApp/model/MenuData'], function($,_,Backbone,MenuData) {
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/MenuItemCollection'],
|
||||
function($,_,Backbone,MenuItemCollection) {
|
||||
|
||||
return Backbone.View.extend({
|
||||
el:'#menuContainer',
|
||||
//TODO: set template
|
||||
|
||||
initialize: function() {
|
||||
this.collection = new MenuItemCollection();
|
||||
this.listenTo(this.collection,'menuData:loaded',this.render);
|
||||
},
|
||||
render: function (model){
|
||||
//TODO: implement own HTML Encoder
|
||||
this.$el.html(buildMenu(items));
|
||||
this.$el.html('render ' + this.collection.length + ' items');//buildMenu(items)
|
||||
},
|
||||
buildMenu: function(items) {
|
||||
|
||||
@ -44,6 +51,7 @@ define(['jquery','underscore','backbone','goatApp/model/MenuData'], function($,_
|
||||
$(goatConstants.getDOMContainers().lessonMenu).html('').append($wholeMenu);
|
||||
};
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user