Skip to content

Commit

Permalink
Separate css and js from ejs
Browse files Browse the repository at this point in the history
  • Loading branch information
yeojoey committed Mar 29, 2017
1 parent bd1fa31 commit 573002a
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 126 deletions.
53 changes: 53 additions & 0 deletions public/css/dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
body {
background-color: #E9E9E9;
}

ul {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #141311;
}

li {
float: left;
}

li a {
font-family: 'Lato', serif;
font-size: 1.5vw;
color: #FFFFFF;
display: block;
padding: 10px;
text-align: center;
text-decoration: none;
}

li a:hover {
background-color: #B7B7B6;
}

h2 {
font-family: 'Lato', serif;
font-weight: bold;
font-size: 24px;
text-align: center;
color: #A2482E;
}

#logout {
cursor: pointer;
}

.avatarWardrobe {
text-align: center;
}

.moduleList {
text-align: center;
}

.col-md-12 {
margin-top: 3.5%;
height: 80vh;
}
49 changes: 49 additions & 0 deletions public/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var tutorials = [];

function syncIVLE() {
$.ajax({
method:'POST',
url:'/api/dashboard/forceSyncIVLE',
dataType:'json',
success: function(data){
if (data.success){
console.log("Successful Sync");
getTutorials();
}
else {
console.log('Failed Sync, Error: ' + data.message);
}

}
});
}

function getTutorials() {
$.ajax({
type: 'POST',
url: '/api/dashboard/getTutorials',
data: { },
dataType: 'json',
success: function(data) {
showTutorials(data.data);
}
});
}

function showTutorials(tuts) {
for (i = 0; i < tuts.count; i++) {
var tut = tuts.rows[i];
tutorials.push(tut);
$('#tutorials').append(tut.coursecode + " " + tut.coursename + " <button class='btn btn-primary' id='lobby-button' data-id='" + i + "' value='' name='tut-id'> Join Class </button><br><br>");
}
}


$(document).on('click', '#lobby-button', function () {
var index = $(this).attr('data-id');
var tut = tutorials[index];
$(this).attr('value', tut.id);
$('#form').attr('action', 'lobby/'+tut.coursecode+'/'+tut.name);
});

syncIVLE();
133 changes: 7 additions & 126 deletions source/view/dashboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
<script type="text/javascript" src="https://cdn.socket.io/socket.io-1.4.5.js"></script>

<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Lato">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/dashboard.css">
</head>

<body>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">


<ul>
<li><a class="active" href="/">Welcome to Attack on Tutor, (<%= user.name %>) </a></li>

<!-- , (<%= user.id %>) -->

<li style="float:right"><a class="active" href="https://github.com/nus-mtp/etutorial">GitHub Repository</a></li>
<li style="float:right"><a class="active" href="https://github.com/nus-mtp/e-tutorial">GitHub Repository</a></li>

<% if(user){ %>
<li style="float:right"><a class="active" id="logout" >Log Out</a></li>
Expand All @@ -34,19 +34,10 @@

<div class="container">
<div class="row">
<!--<div class="col-md-6" style="background-color:#141311">
<h2>Avatar Wardrobe</h2>
<div class="avatarWardrobe">
<img src="https://aquelia.files.wordpress.com/2013/08/p4_characterscreen.jpg" alt="Avatar Wardrobe">
</div>
</div>-->


<div class="col-md-12" style="background-color:#141311">
<h2>Modules</h2>
<div class="moduleList">
<!--<img src="https://www.w3schools.com/css/trolltunga.jpg" alt="Troll Tunga" height="200" width="550">
<img src="https://www.w3schools.com/css/trolltunga.jpg" alt="Troll Tunga" height="200" width="550">-->

<form id='form' style='display: hidden' action='' method='POST'>
<ul id="tutorials"></ul>
</form>
Expand All @@ -61,115 +52,5 @@

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<script type="application/javascript">
var tutorials = [];
function syncIVLE() {
$.ajax({
method:'POST',
url:'/api/dashboard/forceSyncIVLE',
dataType:'json',
success: function(data){
if (data.success){
console.log("Successful Sync");
getTutorials();
}
else {
console.log('Failed Sync, Error: ' + data.message);
}
<script src="js/dashboard.js" type="application/javascript"></script>

}
});
}
function getTutorials() {
$.ajax({
type: 'POST',
url: '/api/dashboard/getTutorials',
data: { },
dataType: 'json',
success: function(data) {
showTutorials(data.data);
}
});
}
function showTutorials(tuts) {
for (i = 0; i < tuts.count; i++) {
var tut = tuts.rows[i];
console.log(tut);
tutorials.push(tut);
$('#tutorials').append(tut.coursecode + " " + tut.coursename + " <button class='btn btn-primary' id='lobby-button' data-id='" + i + "' value='' name='tut-id'> Join Class </button><br><br>");
}
}
$(document).on('click', '#lobby-button', function () {
var index = $(this).attr('data-id');
var tut = tutorials[index];
$(this).attr('value', tut.id);
$('#form').attr('action', 'lobby/'+tut.coursecode+'/'+tut.name);
});
syncIVLE();
</script>

<style>
body {
background-color: #E9E9E9;
}
ul {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #141311;
}
li {
float: left;
}
li a {
font-family: 'Lato', serif;
font-size: 1.5vw;
color: #FFFFFF;
display: block;
padding: 10px;
text-align: center;
text-decoration: none;
}
li a:hover {
background-color: #B7B7B6;
}
h2 {
font-family: 'Lato', serif;
font-weight: bold;
font-size: 24px;
text-align: center;
color: #A2482E;
}
#logout {
cursor: pointer;
}
.avatarWardrobe {
text-align: center;
}
.moduleList {
text-align: center;
}
.col-md-12 {
margin-top: 3.5%;
height: 80vh;
}
</style>

0 comments on commit 573002a

Please sign in to comment.