#318 providing support for multiple jQuery versions and exposing it via webgoat.customjs namespace

This commit is contained in:
Jason White 2017-01-27 15:31:23 -05:00
parent 693d791075
commit f3884fe605
5 changed files with 34 additions and 4 deletions

View File

@ -1,4 +1,5 @@
define(['jquery', define(['jquery',
'libs/jquery-vuln',
'underscore', 'underscore',
'backbone', 'backbone',
'goatApp/controller/LessonController', 'goatApp/controller/LessonController',
@ -8,6 +9,7 @@ define(['jquery',
'goatApp/view/DeveloperControlsView', 'goatApp/view/DeveloperControlsView',
'goatApp/view/TitleView' 'goatApp/view/TitleView'
], function ($, ], function ($,
$vuln,
_, _,
Backbone, Backbone,
LessonController, LessonController,
@ -48,6 +50,7 @@ define(['jquery',
setUpCustomJS: function () { setUpCustomJS: function () {
webgoat.customjs.jquery = $; //passing jquery into custom js scope ... still klunky, but works for now webgoat.customjs.jquery = $; //passing jquery into custom js scope ... still klunky, but works for now
webgoat.customjs.jqueryVuln = $vuln;
// temporary shim to support dom-xss lesson // temporary shim to support dom-xss lesson
webgoat.customjs.phoneHome = function (e) { webgoat.customjs.phoneHome = function (e) {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
// AMD (Asynchronous Module Definition) wrapper for jQuery 1.8
define([
// Load the jQuery source file
'/WebGoat/js/libs/jquery-2.2.4.min.js'
],
function(){
// Tell Require.js that this module returns a reference to jQuery
return $; // Return the global scope object
});

View File

@ -0,0 +1,9 @@
// AMD (Asynchronous Module Definition) wrapper for jQuery 1.8
define([
// Load the jQuery source file
'/WebGoat/js/libs/jquery-2.1.4.min.js'
],
function(){
// Tell Require.js that this module returns a reference to jQuery
return $.noConflict(true); // Return the global scope object
});

View File

@ -13,14 +13,19 @@ js/main.js << main file for require.js
require.config({ require.config({
baseUrl: "js/", baseUrl: "js/",
paths: { paths: {
//jquery: 'libs/jquery-1.10.2.min', jquery: 'libs/jquery-2.2.4.min',
jquery: 'libs/jquery-2.1.4.min',
underscore: 'libs/underscore-min', underscore: 'libs/underscore-min',
backbone: 'libs/backbone-min', backbone: 'libs/backbone-min',
text: 'libs/text', text: 'libs/text',
templates: 'goatApp/templates', templates: 'goatApp/templates',
polyglot: 'libs/polyglot.min' polyglot: 'libs/polyglot.min'
}, },
map: {
'libs/jquery-base' : {'jquery':'libs/jquery-2.2.4.min'},
'libs/jquery-vuln' : {'jquery':'libs/jquery-2.1.4.min'}
},
shim: { shim: {
underscore: { underscore: {
exports: "_" exports: "_"
@ -32,6 +37,6 @@ require.config({
} }
}); });
require(['jquery','underscore','backbone','goatApp/goatApp'], function($,_,Backbone,Goat){ require(['jquery','libs/jquery-base','libs/jquery-vuln','underscore','backbone','goatApp/goatApp'], function($,jqueryBase,jqueryVuln,_,Backbone,Goat){
Goat.initApp(); Goat.initApp();
}); });