Skip to content

Commit

Permalink
Fix room course empty parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Aug 28, 2020
1 parent bd0e0b5 commit ee8b157
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
25 changes: 13 additions & 12 deletions lib/api/parser/ap_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,20 @@ Map<String, dynamic> roomCourseTableQueryParser(dynamic html) {
//the second talbe.

//make timetable
var secondTable =
document.getElementsByTagName("table")[1].getElementsByTagName("tr");
try {
//remark:Best split is regex but... Chinese have some difficulty Q_Q
for (int i = 1; i < secondTable.length; i++) {
var _temptext =
secondTable[i].getElementsByTagName('td')[0].text.replaceAll(" ", "");
var secondTable = document.getElementsByTagName("table");
if (secondTable.length > 0)
try {
final td = secondTable[1].getElementsByTagName("tr");
//remark:Best split is regex but... Chinese have some difficulty Q_Q
for (int i = 1; i < td.length; i++) {
var _temptext =
td[i].getElementsByTagName('td')[0].text.replaceAll(" ", "");

data['coursetable']['timeCodes'].add(_temptext
.substring(0, _temptext.length - 10)
.replaceAll(String.fromCharCode(160), ""));
}
} on Exception catch (e) {}
data['coursetable']['timeCodes'].add(_temptext
.substring(0, _temptext.length - 10)
.replaceAll(String.fromCharCode(160), ""));
}
} on Exception catch (e) {}
//make each day.
List keyName = [
'Monday',
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/study/room_course_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ class _EmptyRoomPageState extends State<EmptyRoomPage> {
onSuccess: (CourseData data) {
courseData = data;
setState(() {
state = CourseState.finish;
if (courseData.courses.length != 0)
state = CourseState.finish;
else
state = CourseState.empty;
});
},
onFailure: (DioError e) async {
Expand Down

0 comments on commit ee8b157

Please sign in to comment.