var osmosis = require('osmosis');
var assignment = require('../assignment');

// Western OWL cookie headers...
var COOKIE_SESSION_ID = 'JSESSIONID';
var COOKIE_ENCRYPYION = 'NSC_pxm.vxp.db--443';

let assignments = new Array();

function assignmentEntry(url, cookies) {
	return new Promise((resolve, reject) => {
		osmosis
		.get(url)
		.cookie(COOKIE_SESSION_ID, cookies[COOKIE_SESSION_ID])
		.cookie(COOKIE_ENCRYPYION, cookies[COOKIE_ENCRYPYION])
		.find('tr.internal, tr.external')
		.set({
				'title': 'td.left',
				'due_date': 'td.center[1]',
				'grade': 'td.center[2]',
				'comments': 'td.center[3]'
			})
		.data(function(data) {
			// TODO: Properly format the title, date, and grade.
			assignments.push(new assignment(data.title, data.due_date, data.grade, data.comments));
		})
		.done(function() {
			resolve(assignments);
		})
	})
}

// Export class assignmentEntry.
module.exports = assignmentEntry;
@@ -1,11 +1,13 @@
-var
+const
  osmosis
@@ -29,19 +29,21 @@
 osis');%0A
-var
+const
  assignm
@@ -109,14 +109,14 @@
 ers.
-..%0Avar
+%0Aconst
  COO
@@ -150,11 +150,13 @@
 D';%0A
-var
+const
  COO
@@ -200,11 +200,16 @@
 ';%0A%0A
-let
+function
  ass
@@ -219,68 +219,167 @@
 ment
-s = new Array();%0A%0Afunction assignmentEntry(url, cookies) %7B%0A%09
+Entry(url, cookies) %7B%0A    // Initialize an empty array to push assignments into.%0A    let assignments = %5B%5D;%0A%0A    // Return assignments array synchronously.%0A    
 retu
@@ -420,20 +420,32 @@
 %3E %7B%0A
-%09%09osmosis%0A%09%09
+        osmosis%0A        
 .get
@@ -450,18 +450,24 @@
 et(url)%0A
-%09%09
+        
 .cookie(
@@ -513,18 +513,24 @@
 ON_ID%5D)%0A
-%09%09
+        
 .cookie(
@@ -576,18 +576,83 @@
 PYION%5D)%0A
-%09%09
+        // Certain courses utilize different %3Ctr%3E classes.%0A        
 .find('t
@@ -681,21 +681,39 @@
 l')%0A
-%09%09.set(%7B%0A%09%09%09%09
+        .set(%7B%0A                
 'tit
@@ -728,20 +728,32 @@
 .left',%0A
-%09%09%09%09
+                
 'due_dat
@@ -772,20 +772,32 @@
 er%5B1%5D',%0A
-%09%09%09%09
+                
 'grade':
@@ -817,12 +817,24 @@
 %5D',%0A
-%09%09%09%09
+                
 'com
@@ -860,16 +860,31 @@
 3%5D'%0A
-%09%09%09%7D)%0A%09%09
+            %7D)%0A        
 .dat
@@ -902,19 +902,28 @@
 data) %7B%0A
-%09%09%09
+            
 // TODO:
@@ -967,19 +967,28 @@
  grade.%0A
-%09%09%09
+            
 assignme
@@ -1071,37 +1071,39 @@
 ));%0A
-%09%09%7D)%0A%09%09.done(function() %7B%0A%09%09%09
+        %7D)%0A        .done(() =%3E 
 reso
@@ -1122,16 +1122,14 @@
 nts)
-;%0A%09%09%7D)%0A%09
+)%0A    
 %7D)%0A%7D
@@ -1196,8 +1196,9 @@
 ntEntry;
+%0A

Update assignmentEntry.js