This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // sign up | |
| let emailTextBox = document.getElementById("emailTextBox") | |
| let passwordTextBox = document.getElementById("passwordTextBox") | |
| let btnSignUp = document.getElementById("btnSignUp") | |
| // login | |
| let loginEmailTextBox = document.getElementById("loginEmailTextBox") | |
| let loginPasswordTextBox = document.getElementById("loginPasswordTextBox") | |
| let btnLogin = document.getElementById("btnLogin") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let bookList = document.getElementById("bookList") | |
| // register the service worker | |
| if("serviceWorker" in navigator) { | |
| navigator.serviceWorker.register("/serviceWorker.js") | |
| .then((registration) => { | |
| console.log("Server worker has been registered with scope ",registration.scope) | |
| }).catch((error) => { | |
| console.log(error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if("serviceWorker" in navigator) { | |
| navigator.serviceWorker.register('/serviceWorker.js').then((registration) => { | |
| console.log('Server worker has been registered ',registration.scope) | |
| } ) | |
| } | |
| // register sync events | |
| navigator.serviceWorker.ready.then(function(registration) { | |
| return registration.sync.register('send-messages'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.get('/services/jwt',(req,res) => { | |
| const header = { | |
| "alg": "ES256", | |
| "typ": "JWT", | |
| "kid": "yourmapidkey" | |
| } | |
| const payload = { | |
| "iss": "yourteamid", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script> | |
| <style> | |
| #map { | |
| width: 100%; | |
| height: 600px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Article: Decodable { | |
| let title: String | |
| let description: String | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ArticleList: Decodable { | |
| let articles: [Article] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func getArticles(with url: URL, completion: @escaping ([Article]?) -> ()) { | |
| URLSession.shared.dataTask(with: url) { data, response, error in | |
| if let error = error { | |
| print(error.localizedDescription) | |
| completion(nil) | |
| } else if let data = data { | |
| let articlesList = try? JSONDecoder().decode(ArticleList.self, from: data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ArticleListViewModel { | |
| let articles: [Article] | |
| } | |
| extension ArticleListViewModel { | |
| var numberOfSections: Int { | |
| return 1 | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ArticleViewModel { | |
| private let article: Article | |
| } | |
| extension ArticleViewModel { | |
| init(_ article: Article) { | |
| self.article = article | |
| } | |
| } |