diff --git a/Classes/CalendarViewController.m b/Classes/CalendarViewController.m index a3d38f2..729ed61 100644 --- a/Classes/CalendarViewController.m +++ b/Classes/CalendarViewController.m @@ -50,11 +50,17 @@ - (void) configureView { //read in data from Model Logic + + SharedAppDataObject* theDataObject = [self theAppDataObject]; - NSMutableArray* defaultAnswer = [[ModelLogic modelLogic] getSelectedGroupsInfo]; - // add in imageview [scrollView addSubview:imageView]; theDataObject.image = self.imageView; + printf("active moudle %d\n",[[theDataObject activeModules]count]); + if([theDataObject activeModules]&&[[theDataObject activeModules]count]!=0) + { + NSMutableArray* defaultAnswer = [[ModelLogic modelLogic] getSelectedGroupsInfo]; + // add in imageview + for (NSDictionary* dict in defaultAnswer) { NSString* moduleCode = [dict objectForKey:@"moduleCode"]; @@ -154,6 +160,7 @@ - (void) configureView } } +} - (void) configureToolBar { diff --git a/Classes/IVLEWebViewController.m b/Classes/IVLEWebViewController.m index 45e7d20..36916f8 100644 --- a/Classes/IVLEWebViewController.m +++ b/Classes/IVLEWebViewController.m @@ -16,6 +16,9 @@ #define EXPORT_TO_IVLE_FAIL @"Sorry, can not connect server!" #define API_KEY @"K6vDt3tA51QC3gotLvPYf" +#define USERNAME @"u0602684" +#define PASSWORD @"tomrlq#04" + @implementation IVLEWebViewController @@ -108,7 +111,13 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView{ [acadYear release]; [semester release]; }else if ([requestURL.absoluteString isEqualToString:@"https://ivle.nus.edu.sg/api/login/?apikey=K6vDt3tA51QC3gotLvPYf"]) { - //do nothing + NSString *loadUsernameJS = [NSString stringWithFormat:@"document.forms['frm'].userid.value ='%@'", USERNAME]; + NSString *loadPasswordJS = [NSString stringWithFormat:@"document.forms['frm'].password.value ='%@'", PASSWORD]; + + + //autofill the form + [self.ivlePage stringByEvaluatingJavaScriptFromString: loadUsernameJS]; + [self.ivlePage stringByEvaluatingJavaScriptFromString: loadPasswordJS]; } /*else{ NSString *xml_file = [self.ivlePage stringByEvaluatingJavaScriptFromString:@"document.getElementById"]; diff --git a/Classes/ModuleListViewController.m b/Classes/ModuleListViewController.m index 19f5505..f619aaf 100644 --- a/Classes/ModuleListViewController.m +++ b/Classes/ModuleListViewController.m @@ -277,23 +277,26 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto if(alertView.message == SURE_TO_CHANGE_TO_CALENDAR) { ModelLogic* modelLogic = [ModelLogic modelLogic]; - [modelLogic syncModulesWithBasket:[theDataObject activeModules]]; - if ([[ModelLogic modelLogic] generateDefaultTimetableWithRequirements:[theDataObject requirements]]) + if([[theDataObject activeModules]count]!=0) { - //[[ModelLogic modelLogic]exportTimetableToiCalendar]; - UINavigationController *controller = [self.tabBarController.viewControllers objectAtIndex:0]; - [controller viewWillAppear:YES]; - self.tabBarController.selectedViewController = controller; - } - else - { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:NO_SOLUTION - delegate:self - cancelButtonTitle:@"Sure" otherButtonTitles:nil]; - - [alert show]; - [alert release]; - + [modelLogic syncModulesWithBasket:[theDataObject activeModules]]; + if ([[ModelLogic modelLogic] generateDefaultTimetableWithRequirements:[theDataObject requirements]]) + { + //[[ModelLogic modelLogic]exportTimetableToiCalendar]; + UINavigationController *controller = [self.tabBarController.viewControllers objectAtIndex:0]; + [controller viewWillAppear:YES]; + self.tabBarController.selectedViewController = controller; + } + else + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:NO_SOLUTION + delegate:self + cancelButtonTitle:@"Sure" otherButtonTitles:nil]; + + [alert show]; + [alert release]; + + } } theDataObject.continueToCalendar = NO; }else if (alertView.message == NO_SOLUTION) {