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('/service-workerw.js').then(function(registration) { | |
// register success | |
console.log('ServiceWorker registration successful with scope: ', registration.scope); | |
}).catch(function(err) { | |
// registration failed :( | |
console.log('ServiceWorker registration failed: ', err); | |
}); | |
} |
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
fileprivate extension NSTouchBarCustomizationIdentifier { | |
static let windowBar = NSTouchBarCustomizationIdentifier("com.n3tr.countertouchbar.touchbar") | |
} | |
fileprivate extension NSTouchBarItemIdentifier { | |
static let label = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.label") | |
} | |
class WindowController: NSWindowController { | |
// ... |
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
class WindowController: NSWindowController { | |
// .. | |
override func makeTouchBar() -> NSTouchBar? { | |
let touchBar = NSTouchBar() | |
touchBar.delegate = self | |
touchBar.customizationIdentifier = .touchBar | |
touchBar.defaultItemIdentifiers = [.label] | |
return touchBar | |
} | |
} |
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
extension WindowController: NSTouchBarDelegate { | |
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItemIdentifier) -> NSTouchBarItem? { | |
switch identifier { | |
case NSTouchBarItemIdentifier.label: | |
// Create custom touch bar Item | |
let custom = NSCustomTouchBarItem(identifier: identifier) | |
custom.customizationLabel = "Label Title" | |
// Create label as NSTextField | |
let label = NSTextField(labelWithString: "Hello, TouchBar") |
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
fileprivate extension NSTouchBarCustomizationIdentifier { | |
static let windowBar = NSTouchBarCustomizationIdentifier("com.n3tr.countertouchbar.touchbar") | |
} | |
fileprivate extension NSTouchBarItemIdentifier { | |
static let label = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.label") | |
} | |
class WindowController: NSWindowController { | |
// ... |
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
override func makeTouchBar() -> NSTouchBar? { | |
let touchBar = NSTouchBar() | |
touchBar.delegate = self | |
touchBar.customizationIdentifier = .touchBar | |
touchBar.defaultItemIdentifiers = [.label, .fixedSpaceSmall, .otherItemsProxy] | |
return touchBar | |
} |
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
// ViewController.swift | |
fileprivate extension NSTouchBarCustomizationIdentifier { | |
static let counterTouchBar = NSTouchBarCustomizationIdentifier("com.n3tr.countertouchbar.counter") | |
} | |
fileprivate extension NSTouchBarItemIdentifier { | |
static let increase = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.increase") | |
static let decrease = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.decrease") | |
static let counter = NSTouchBarItemIdentifier("com.n3tr.countertouchbar.counter") | |
} |
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
class ViewController: NSViewController { | |
// ... | |
override func makeTouchBar() -> NSTouchBar? { | |
let touchBar = NSTouchBar() | |
touchBar.delegate = self | |
touchBar.customizationIdentifier = .counterTouchBar | |
touchBar.defaultItemIdentifiers = [.increase, .counter, .decrease] | |
return touchBar | |
} | |
} |
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
// ViewController.swift | |
class ViewController: NSViewController { | |
// (1) | |
dynamic var currentCounter = 0 | |
// ... | |
// (2) | |
func increaseCounter() { | |
currentCounter += 1 |