initial commit and add statusbar icon

This commit is contained in:
Felix Förtsch
2018-10-08 16:53:31 +02:00
parent 87c2956eb4
commit 3c528e2f58
38 changed files with 3603 additions and 20 deletions
+44
View File
@@ -0,0 +1,44 @@
//
// StatusBarController.swift
// LiquipediaMenu
//
// Created by Felix Förtsch on 08.10.18.
// Copyright © 2018 Felix Förtsch. All rights reserved.
//
import Cocoa
import SwiftyJSON
class StatusBarController: NSObject {
let baseURL = "https://liquipedia.net/"
let game = "dota2"
let query = "/api.php?action=parse&page=Liquipedia:Upcoming_and_ongoing_matches&format=json&prop=text"
var html = ""
func constructURL(baseURL: String, game: String, query: String) -> String {
return baseURL + game + query
}
func fetch(url: String) {
DispatchQueue.global().async {
[unowned self] in
if let url = URL(string: url) {
if let data = try? String(contentsOf: url) {
let json = JSON(parseJSON: data)
self.html = self.extractHTML(json: json)
return
}
}
}
}
func extractHTML(json: JSON) -> String {
return json["parse"]["text"].stringValue
}
}