Commit 1ec1b025 authored by Jonathon Duerig's avatar Jonathon Duerig

Finish basic conversion into RequireJS modules.

parent 489f1472
......@@ -2,32 +2,36 @@ require.config({
baseUrl: '.',
paths: {
'jquery': 'js/lib/jquery-2.0.3.min',
'bootstrap': 'bootstrap/js/bootstrap'
'bootstrap': 'bootstrap/js/bootstrap',
'dateformat': 'js/lib/date.format',
'd3': 'js/lib/d3.v3'
},
shim: {
'bootstrap': { deps: ['jquery'] }
'bootstrap': { deps: ['jquery'] },
'dateformat': { exports: 'dateFormat' },
'd3': { exports: 'd3' }
},
});
require(['jquery',
require(['jquery', 'js/quickvm_sup',
// jQuery modules
'bootstrap'],
function ($)
function ($, sup)
{
'use strict';
function initialize()
{
UpdateProfileSelection($('#profile_name li:eq(0)'));
sup.UpdateProfileSelection($('#profile_name li:eq(0)'));
$('#quickvm_topomodal').on('hidden.bs.modal', function() {
ShowProfileList($('.current'))
sup.ShowProfileList($('.current'))
});
InitProfileSelector();
sup.InitProfileSelector();
console.log('APT_OPTIONS: ' + JSON.stringify(window.APT_OPTIONS));
if (window.APT_OPTIONS.isNewUser)
{
ShowModal('#working');
sup.ShowModal('#working');
}
initButtons();
......@@ -39,18 +43,18 @@ function ($)
{
$('button#reset-form').click(function (event) {
event.preventDefault();
resetForm($('#quickvm_form'));
sup.resetForm($('#quickvm_form'));
});
$('button#profile').click(function (event) {
event.preventDefault();
ShowModal('#quickvm_topomodal');
sup.ShowModal('#quickvm_topomodal');
});
$('li.profile-item').click(function (event) {
event.preventDefault();
ShowProfileList(event.target);
sup.ShowProfileList(event.target);
});
$('button#showtopo_select').click(function (event) {
UpdateProfileSelection($('.selected'));
sup.UpdateProfileSelection($('.selected'));
});
}
......
define(['jquery', 'd3', 'dateformat'],
function ($, d3) {
var myuuid = null;
function ShowModal(which)
......@@ -777,10 +780,9 @@ function maketopmap(divname, width, height, json)
var node = nodeg.append("svg:rect")
.attr("class", "nodebox")
.attr("onclick",
function(d) {
return "NewSSHTab('" + d.hostport + "', " +
" '" + d.client_id + "')" })
.on("click", function(d) {
NewSSHTab(d.hostport, d.client_id);
})
.attr("x", "-10px")
.attr("y", "-10px")
.attr("width", "20px")
......@@ -916,3 +918,13 @@ function ConvertManifestToJSON(name, xml)
}
return json;
}
// Exports from this module for use elsewhere
return {
InitProfileSelector: InitProfileSelector,
resetForm: resetForm,
ShowModal: ShowModal,
ShowProfileList: ShowProfileList,
UpdateProfileSelection: UpdateProfileSelection
};
});
......@@ -129,7 +129,6 @@ function SPITFORM($username, $email, $sshkey, $profile, $newuser, $errors)
if ($internal_error) {
echo "<center><h2>$internal_error</h2></center><br>\n";
}
echo "<script src='js/d3.v3.js'></script>\n";
echo "<div class='row'>
<div class='col-lg-6 col-lg-offset-3
col-md-6 col-md-offset-3
......
......@@ -33,8 +33,6 @@ function SPITHEADER($thinheader = 0)
<link rel='stylesheet' href='bootstrap/css/bootstrap.css'>
<link rel='stylesheet' href='quickvm.css'>
<script src='js/lib/require.js' data-main='js/main'></script>
<script src='js/quickvm_sup.js'></script>
<script src='js/date.format.js'></script>
<script src='https://www.emulab.net/emulab_sup.js'></script>
</head>
<body style='display: none'>\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment