Skip to content

Commit

Permalink
list clubs
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanSellas committed Sep 4, 2016
1 parent cf75143 commit 9564710
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 52 deletions.
6 changes: 4 additions & 2 deletions assets/html/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ <h2>About the App And Us</h2>
<div class="col-sm-6 col-sm-offset-3 text-left">
<div class="paragraph">

<p>Thank you for checking out mySchool. This app was created by me Dean Sellas, with the Help of Nick Horvat so that we could have a agenda for all of our classes. This webapp was built using HTML, CSS, Angular JS, Javascript, and the Google Calendar API. I have plans on porting it over to a native iOS and Android app if it becomes popular enough, but at the moment I am focusing on the web build by adding new features and killing bugs (if all that went over your head don't worry it was suppose to). If you are using this app and run into any problems, have a question, or if you just want to tell me about your experience feel free to tweet me <a href="https://twitter.com/TheSpaceCoder" target="_blank">@TheSpaceCoder</a> or send an email to <a href="mailto:contact@thespaceocoder.com">contact@thespacecoder.com</a>. I hope you have an enjoyable experience and find this app just as useful as we do.</p>

<p>Thank you for checking out mySchool. This app was created by me Dean Sellas, with the Help of Nick Horvat so that we could have a agenda for all of our classes. This webapp was built using HTML, CSS, Angular JS, Javascript, and the Google Calendar API. I have plans on porting it over to a native iOS and Android app if it becomes popular enough, but at the moment I am focusing on the web build by adding new features and killing bugs (if all that went over your head don't worry it was suppose to).</p>

<p>Want to help with development? Feel free to check out the <a href="https://github.com/TheSpaceCoder/mySchool" target="_blank">Github Repository</a> for up to date source code. What is that? Can't code but still want to help out? Well here are some other things you can do to help with development. You can check out the <a href="http://thespacecoder.com/myschool" target="_blank">Development Branch</a> and help search for bugs and test the app's stability (please understand that this branch is going to be unstable by nature and will not always be working, I break things a lot and this is where I test everything before the public sees it). If you are not adventurous enough to go into the development branch there is one more thing you can do. You can contact me if you run into any problems, have a question, or if you just want to tell me about your experience. So feel free to tweet me <a href="https://twitter.com/TheSpaceCoder" target="_blank">@TheSpaceCoder</a> or send an email to <a href="mailto:contact@thespaceocoder.com">contact@thespacecoder.com</a>. I hope you have an enjoyable experience and find this app just as useful as Nick and I do. </br></br> -Dean</p>

</div>


Expand Down
3 changes: 1 addition & 2 deletions assets/html/clubs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<h2>Clubs</h2>
<h4>PAGE UNDER CONSTRUCTION</h4>

<div class="container">
<div class="col-sm-6 col-sm-offset-3">
Expand Down Expand Up @@ -44,7 +43,7 @@ <h4>PAGE UNDER CONSTRUCTION</h4>
}

data = y + "-" + m + "-" + d;
console.log('Today is: ' + data);
console.log('CLUBS PAGE \nToday is: ' + data);
_dat.value = data;
}

Expand Down
3 changes: 1 addition & 2 deletions assets/html/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ <h3>Upcoming Homework</h3>
<div class="col-sm-4 clubs subsection">
<h3>Upcoming Club Meetings</h3>

<div id="clubs">
<p>No Upcoming Club Meetings.</p>
<div id="upcomingClubs">
</div>
</div>
2 changes: 1 addition & 1 deletion assets/html/homework.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2>Homework</h2>
}

data = y + "-" + m + "-" + d;
console.log('Today is: ' + data);
console.log('HOMEWORK PAGE \nToday is: ' + data);
_dat.value = data;
}

Expand Down
122 changes: 93 additions & 29 deletions assets/javascript/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ var checkWeekend = (new Date()).getDay();
// QUICK HOTFIX
var checkDay = 0;
var isHomework = 0;
var isClub = 0;


/**
* Check if current user has authorized this application.
*/
function checkAuth() {
function checkAuth() {
gapi.auth.authorize({
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
Expand All @@ -41,7 +42,7 @@ var isHomework = 0;
*
* @param {Object} authResult Authorization result.
*/
function handleAuthResult(authResult) {
function handleAuthResult(authResult) {
var authorizeDiv = document.getElementById('authorize-div');

if (authResult && !authResult.error) {
Expand All @@ -64,13 +65,13 @@ var isHomework = 0;
*
* @param {Event} event Button click event.
*/
function handleAuthClick(event) {
function handleAuthClick(event) {
gapi.auth.authorize({
client_id: CLIENT_ID,
scope: SCOPES,
immediate: false
},
handleAuthResult);
handleAuthResult);
return false;
}

Expand All @@ -79,16 +80,17 @@ var isHomework = 0;
* Load Google Calendar client library. List upcoming events
* once client library is loaded.
*/
function loadCalendarApi() {
function loadCalendarApi() {
gapi.client.load('calendar', 'v3', blueGold);
gapi.client.load('calendar', 'v3', listUpcomingHomework);
gapi.client.load('calendar', 'v3', listUpcomingClubs);
}


/**
* Displays if its a Blue or Gold Day
*/
function blueGold() {
function blueGold() {
//Gets events from google calendar
var request = gapi.client.calendar.events.list({
'calendarId': calendar,
Expand All @@ -100,7 +102,7 @@ var isHomework = 0;
'orderBy': 'startTime'
});

request.execute(function(resp) {
request.execute(function (resp) {
var events = resp.items;

if (events.length > 0) {
Expand Down Expand Up @@ -137,9 +139,9 @@ var isHomework = 0;

// CHECKS FOR NO SCHOOL EVENT
if (event.summary.indexOf("NO SCHOOL") !== -1 && checkDay === 0) {
document.title("mySchool | No School")
document.title("mySchool | No School");
writeDay("No School Today, Have a Good Day off");
console.log("no school")
console.log("no school");
checkDay = 1;
}

Expand All @@ -149,7 +151,7 @@ var isHomework = 0;
console.log("Finals Exams");
checkDay = 1;
}

// CHECKS FOR FIRST DAY OF SCHOOL
if (event.summary.indexOf("FIRST DAY OF SCHOOL") !== -1) {
alert("First Day of School Good Luck!");
Expand Down Expand Up @@ -177,17 +179,17 @@ var isHomework = 0;


/**
* Print the summary and start date of the next ten homework events in
* Print the summary and start date of the next twenty homework events in
* the authorized user's calendar. If no events are found an
* appropriate message is printed.
*/
function listUpcomingHomework() {
function listUpcomingHomework() {

// GETS TODAY'S DATE
var todayDate = new Date(),
d = todayDate.getDate(),
m = todayDate.getMonth() + 1,
today;
d = todayDate.getDate(),
m = todayDate.getMonth() + 1,
today;

if (d < 10) {
d = "0" + d;
Expand All @@ -209,9 +211,9 @@ var isHomework = 0;
'orderBy': 'startTime'
});

request.execute(function(resp) {
request.execute(function (resp) {
var events = resp.items;

if (events.length > 0) {
for (i = 0; i < events.length; i++) {

Expand All @@ -220,18 +222,18 @@ var isHomework = 0;
if (!when) {
when = event.start.date;
}

// EVENT NAME
var str = event.summary;
var strLength = str.length;

// IF CATCHES HOMEWORK EVENT
if (str.indexOf('HOMEWORK') > -1) {
console.log(str.substring(11, strLength) + '\nDue on ' + when.substring(5, 10));
writeHomework(str.substring(11, strLength)+ ' Due on ' + when.substring(5, 10));
console.log("HOMEWORK CALENDAR \n" + str.substring(11, strLength) + ' Due On ' + when.substring(5, 10));
writeHomework(str.substring(11, strLength) + ' Due On ' + when.substring(5, 10));

// ALERT IF HOMEWORK IS DUE TODAY
if(when.substring(5,10) == today && isHomework != 1){
if (when.substring(5, 10) == today && isHomework != 1) {
alert("You Have Homework due today!");
}

Expand All @@ -245,7 +247,59 @@ var isHomework = 0;
console.log("no homework found");
writeHomework('No upcoming homework found!');
}


});
}


/**
* Print the summary and start date of the next ten club events in
* the authorized user's calendar. If no events are found an
* appropriate message is printed.
*/
function listUpcomingClubs() {

var request = gapi.client.calendar.events.list({
'calendarId': 'primary',
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'maxResults': 10,
'orderBy': 'startTime'
});

request.execute(function (resp) {
var events = resp.items;

if (events.length > 0) {
for (i = 0; i < events.length; i++) {

var event = events[i];
var when = event.start.dateTime;
if (!when) {
when = event.start.date;
}

// EVENT NAME
var str = event.summary;
var strLength = str.length;

// IF CATCHES HOMEWORK EVENT
if (str.indexOf('CLUB') > -1) {
console.log("CLUB CALENDAR \n" + str.substring(7, strLength) + " Meeting On " + when.substring(5, 10));
writeClub(str.substring(7, strLength) + " Meeting On " + when.substring(5, 10));

isClub = 1;
}
}
}

// IF NO HOMEWORK EVENT IS FOUND
if (isClub != 1) {
console.log("no clubs found");
writeClub('No upcoming clubs found!');
}

});
}

Expand All @@ -256,18 +310,28 @@ var isHomework = 0;


/*
* WRITES THE DAY OF WEEK (BLUE OR GOLD) AND WRITES THE HOMEWORK
* WRITES THE DAY OF WEEK (BLUE OR GOLD)
* WRITES HOMEWORK
* WRITES CLUB
*/
function writeDay(message){
function writeDay(message) {
// DISPLAYS MESSAGE
$('#output').text(message);
checkDay = 0;
}
function writeHomework(homeworkList){
function writeHomework(homeworkList) {
// FIXES REPEATING HOMEWORK BUG
if ($('#' + i).text() != homeworkList) {

// DISPLAYS MESSAGE
$('#upcomingHomework').append('<p id="' + i + '">' + homeworkList + '</p>' + '\n');
}
}
function writeClub(clubList) {
// FIXES REPEATING HOMEWORK BUG
if($('#'+i).text() != homeworkList){
if ($('#' + i).text() != clubList) {

// DISPLAYS MESSAGE
$('#upcomingHomework').append('<p id="'+i+'">' + homeworkList + '</p>' + '\n');
$('#upcomingClubs').append('<p id="' + i + '">' + clubList + '</p>' + '\n');
}
}
16 changes: 15 additions & 1 deletion assets/javascript/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ function setActive() {
}, 50);
}

// ADDS DEVELOPMENT BRANCH TEXT TO PAGE
function testingBranch() {
if (window.location.href.indexOf("localhost") > -1){
console.log("DEVELOPMENT BRANCH");
$(".title").append('<h4>Development Branch</h4>');
}

if (window.location.href.indexOf("http://thespacecoder.com/myschool/") > -1){
console.log("DEVELOPMENT BRANCH");
$(".title").append('<h4>Development Branch</h4>');
}
}

// SETS DATE
function setDay() {
$('#date').text(month + '/' + day);
Expand All @@ -73,4 +86,5 @@ function setDay() {
// LOAD FUNTIONS
$('body').ready(resize);
$('body').ready(setDay);
$('body').ready(setActive);
$('body').ready(setActive);
$('body').ready(testingBranch);
18 changes: 10 additions & 8 deletions assets/javascript/controllers/angularControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module('mySchoolApp')
*/
self.addClub = function () {

var clubDate = $('#clubMeeting').val()
var clubDate = $('#clubMeeting').val();
var clubMeeting = new Date(clubDate);

// +1 TO DATE, WHY? JAVASCRIPT IS WEIRD
Expand All @@ -39,7 +39,9 @@ angular.module('mySchoolApp')
},
};

console.log(clubEvent);
// LOG
// console.log(clubEvent);
console.log("CLUB DETAILS \nClub " + self.clubName + "\nDescription " + self.clubDescription + "\nMeeting " + clubMeeting);

// ADDS EVENT
var request = gapi.client.calendar.events.insert({
Expand All @@ -53,7 +55,7 @@ angular.module('mySchoolApp')
alert("Club Added To Calendar");
});

// RESETS TEXT BOX
// CLEARS INPUT BOX
self.clubName = "";
self.clubDescription = "";

Expand All @@ -74,7 +76,7 @@ angular.module('mySchoolApp')
* and adds it to the authorized user's calendar.
*/
self.addAssignment = function () {
var homeworkDate = $('#dueDate').val()
var homeworkDate = $('#dueDate').val();
var dueDate = new Date(homeworkDate);

// +1 TO DATE, WHY? JAVASCRIPT IS WEIRD
Expand All @@ -87,7 +89,7 @@ angular.module('mySchoolApp')
// EVENT INFO
var homeworkEvent = {

"summary": "HOMEWORK - " + self.homeworkName + " for " + self.className,
"summary": "HOMEWORK - " + self.homeworkName + " For " + self.className,
'description': 'Homework for ' + self.className + '. It is due on ' + dueDate.toLocaleDateString() + '\nDescription: ' + self.homeworkDescription,

"start": {
Expand All @@ -100,8 +102,8 @@ angular.module('mySchoolApp')
};

// LOG
console.log(homeworkEvent);
console.log("Homework:" + self.homeworkName + '\nClass: ' + self.className + '\nDue Date: ' + dueDate + '\nHomework Description: ' + self.homeworkDescription);
//console.log(homeworkEvent);
console.log("HOMEWORK DETAILS \nHomework:" + self.homeworkName + '\nClass: ' + self.className + '\nHomework Description: ' + self.homeworkDescription + '\nDue Date: ' + dueDate);

// ADDS EVENT
var request = gapi.client.calendar.events.insert({
Expand All @@ -111,11 +113,11 @@ angular.module('mySchoolApp')

//IF EVENT CREATED
request.execute(function (homeworkEvent) {

console.log('Event created: ' + homeworkEvent.htmlLink);
alert("Homework Added To Calendar");
});

// CLEARS INPUT BOX
self.homeworkName = "";
self.className = "";
self.homeworkDescription = "";
Expand Down
Loading

0 comments on commit 9564710

Please sign in to comment.