Added line break recognition to info table, added new card displayed when the general plan is empty

This commit is contained in:
Deniz Duezgoeren
2019-10-18 21:49:05 +02:00
parent ca760cbcc1
commit fc8349d30c
3 changed files with 11 additions and 2 deletions
+9 -2
View File
@@ -167,6 +167,7 @@ class DataFetcher {
foodUrl = "https://djd4rkn355.github.io/food_test.html"
}
var isPlanEmpty = true
var isPersonalEmpty = true
var personalPlanCount = 0
var mWebsitePriority = 0
@@ -188,6 +189,7 @@ class DataFetcher {
let coursePreference = prefs.string(forKey: "courses")
for i in (0..<rows.size()) {
isPlanEmpty = false
let cols = try rows.get(i).select("th")
let mGroup = try cols.get(0).text()
@@ -228,6 +230,11 @@ class DataFetcher {
prefs.set(personalPlanCount, forKey: "personalPlanCount")
if isPlanEmpty {
let emptySubstitution = SubstModel(group: "", course: NSLocalizedString("plan_empty", comment: ""), additional: "", date: "", time: "", room: "", teacher: "", type: "", groupPriority: 0, datePriority: 0, websitePriority: 0)
substitutionList.append(emptySubstitution)
}
if isPersonalEmpty {
let emptySubstitution = SubstModel(group: "", course: NSLocalizedString("personal_plan_empty", comment: ""), additional: "", date: "", time: "", room: "", teacher: "", type: "", groupPriority: 0, datePriority: 0, websitePriority: 0)
personalList.append(emptySubstitution)
@@ -238,10 +245,10 @@ class DataFetcher {
let lastUpdated = try substitutionsDocument.select("h1").get(0).text()
infoString = "\(NSLocalizedString("last_updated", comment: ""))\(lastUpdated)."
let informationTableElements = try substitutionsDocument.select("p")
let informationTableElements = try substitutionsDocument.select("h6")
for item in informationTableElements {
infoString += "\n\n\(try item.text())"
infoString += "\n\n\(try item.html().replacingOccurrences(of: "<br>", with: "\n"))"
}
// start food fetch