mirror of
https://github.com/HackPlan/quark-shell-mac.git
synced 2026-01-13 07:01:18 +08:00
176 lines
4.9 KiB
JavaScript
176 lines
4.9 KiB
JavaScript
/*
|
||
$(function() {
|
||
quark.debug = true
|
||
|
||
$("#app-version").html(quark.appVersion)
|
||
$("#app-bundle-version").html("(" + quark.appBundleVersion + ")")
|
||
|
||
quark.addKeyboardShortcut({
|
||
keycode: 0x7A, // F1 key
|
||
modifierFlags: 0, // no modifier key
|
||
callback: function () {
|
||
console.log("wow")
|
||
quark.togglePopup()
|
||
}
|
||
})
|
||
|
||
quark.setClickAction(function () {
|
||
console.log("Don’t click me!")
|
||
})
|
||
quark.setSecondaryClickAction(function () {
|
||
console.log("What did I say?")
|
||
})
|
||
|
||
quark.setupPreferences([
|
||
{"label": "General", "identifier": "general", "icon": "NSPreferencesGeneral", "height": 192},
|
||
{"label": "Account", "identifier": "account", "icon": "NSUserAccounts", "height": 102},
|
||
{
|
||
"label": "Shortcut", "identifier": "shortcut", "icon": "NSAdvanced", "height": 80,
|
||
"nativeComponents": [{
|
||
type: "ShortcutRecorder",
|
||
options: {
|
||
x: 140,
|
||
y: 28,
|
||
keycode: 0x7A, // F1 key
|
||
modifierFlags: 0, // no modifier key
|
||
onChange: function (keycode, modifierFlags) {
|
||
console.log("New shortcut:", keycode, modifierFlags)
|
||
quark.clearKeyboardShortcut()
|
||
quark.addKeyboardShortcut({
|
||
keycode: keycode,
|
||
modifierFlags: modifierFlags,
|
||
callback: function () {
|
||
console.log("wow")
|
||
quark.togglePopup()
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}]
|
||
}
|
||
])
|
||
|
||
$("#toggle-pin").click(function() {
|
||
if ($(this).html() == "Pin") {
|
||
quark.pin()
|
||
$(this).html("Unpin")
|
||
}
|
||
else {
|
||
quark.unpin()
|
||
$(this).html("Pin")
|
||
}
|
||
})
|
||
|
||
$("#show-menu").click(function(event) {
|
||
quark.showMenu({
|
||
items: [
|
||
{label: "Test", click: function() { console.log("I am completely operational") } },
|
||
{type: "separator"},
|
||
{label: "Exit", click: function() { console.log("LIFE FUNCTION TERMINATED") } }
|
||
],
|
||
x: event.clientX,
|
||
y: event.clientY
|
||
})
|
||
})
|
||
|
||
var db = openDatabase('test', '1.0', 'Quark Shell supports WebSQL database', 5 * 1024 * 1024)
|
||
|
||
quark.on("TestMessage", function(message) {
|
||
console.log(message)
|
||
})
|
||
})
|
||
*/
|
||
|
||
$(function() {
|
||
$("#toggle-pin").click(function() {
|
||
if ($(this).html() == "Pin") {
|
||
quark.pin()
|
||
$(this).html("Unpin")
|
||
}
|
||
else {
|
||
quark.unpin()
|
||
$(this).html("Pin")
|
||
}
|
||
});
|
||
$("#show-menu").click(function(event) {
|
||
quark.showMenu({
|
||
items: [
|
||
{label: "Test", click: function() { console.log("I am completely operational") } },
|
||
{type: "separator"},
|
||
{label: "Exit", click: function() { console.log("LIFE FUNCTION TERMINATED") } }
|
||
],
|
||
x: event.clientX,
|
||
y: event.clientY
|
||
});
|
||
});
|
||
});
|
||
|
||
function setupPref(){
|
||
quark.setupPreferences([
|
||
{"label": "General", "identifier": "general", "icon": "NSPreferencesGeneral", "height": 192},
|
||
{"label": "Account", "identifier": "account", "icon": "NSUserAccounts", "height": 102},
|
||
{
|
||
"label": "Shortcut",
|
||
"identifier": "shortcut",
|
||
"icon": "NSAdvanced",
|
||
"height": 80,
|
||
"nativeComponents": [{
|
||
type: "ShortcutRecorder",
|
||
options: {
|
||
x: 140,
|
||
y: 28,
|
||
id: "start_pomo"
|
||
}
|
||
}]
|
||
}]
|
||
);
|
||
|
||
}
|
||
|
||
quark.ready(function () {
|
||
quark.notify({title: 'Quark Shell', content: 'Hello World', popupOnClick: true});
|
||
quark.pin();
|
||
quark.onShortcut('start_pomo', function(data) {
|
||
quark.notify({title: 'onQuarkShortcut', content: "start_pomo", popupOnClick: true});
|
||
})
|
||
})
|
||
|
||
function showConfirm() {
|
||
var content;
|
||
if (confirm('Quark Shell rocks!')){
|
||
content = "YES"
|
||
} else {
|
||
content = "NO"
|
||
}
|
||
quark.notify({title: 'Quark Shell', content: content, popupOnClick: true})
|
||
}
|
||
|
||
function showPrompt() {
|
||
var content = prompt('What do you say:');
|
||
quark.notify({title: 'Quark Shell', content: content, popupOnClick: true})
|
||
}
|
||
|
||
function setAutoStart(){
|
||
quark.setLaunchAtLogin(true)
|
||
}
|
||
|
||
function setIcon() {
|
||
var iconCanvas = document.getElementById('icon')
|
||
iconCanvas.width = 40
|
||
iconCanvas.height = 40
|
||
var iconCtx = iconCanvas.getContext('2d')
|
||
iconCtx.fillRect(6, 8, 28, 28)
|
||
iconCtx.clearRect(12, 14, 16, 16)
|
||
|
||
var highlightedIconCanvas = document.getElementById('highlighted-icon')
|
||
highlightedIconCanvas.width = 40
|
||
highlightedIconCanvas.height = 40
|
||
var highlightedIconCtx = highlightedIconCanvas.getContext('2d')
|
||
highlightedIconCtx.fillStyle = "white"
|
||
highlightedIconCtx.fillRect(6, 8, 28, 28)
|
||
highlightedIconCtx.clearRect(12, 14, 16, 16)
|
||
|
||
quark.changeIcon(iconCanvas.toDataURL())
|
||
quark.changeHighlightedIcon(highlightedIconCanvas.toDataURL())
|
||
}
|