-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jkharrat
committed
Apr 17, 2021
0 parents
commit c0efd1f
Showing
16 changed files
with
1,894 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# streamDeck-weatherPlugin | ||
Plugin for StreamDeck to display weather info |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"Actions": [ | ||
{ | ||
"Icon": "resources/actionIcon", | ||
"Name": "Weather", | ||
"States": [ | ||
{ | ||
"Image": "resources/actionDefaultImage", | ||
"TitleAlignment": "bottom", | ||
"FontSize": "10" | ||
} | ||
], | ||
"SupportedInMultiActions": true, | ||
"Tooltip": "Get current weather", | ||
"UUID": "com.jk.weather.action" | ||
} | ||
], | ||
"SDKVersion": 2, | ||
"Author": "Jaouher", | ||
"CodePath": "plugin/main.html", | ||
"Description": "Easily get a preview about the weather", | ||
"Name": "Weather", | ||
"Icon": "resources/pluginIcon", | ||
"PropertyInspectorPath": "pi/main_pi.html", | ||
"URL": "https://jk.com", | ||
"Version": "2.0", | ||
"OS": [ | ||
{ | ||
"Platform": "mac", | ||
"MinimumVersion" : "10.11" | ||
}, | ||
{ | ||
"Platform": "windows", | ||
"MinimumVersion" : "10" | ||
} | ||
], | ||
"Software": | ||
{ | ||
"MinimumVersion" : "4.1" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<title>com.jk.weather.pi</title> | ||
<link rel="stylesheet" href="sdpi.css"> | ||
<script src="main_pi.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="sdpi-wrapper hidden"> | ||
<div class="sdpi-item"> | ||
<div class="sdpi-item-label">API Key</div> | ||
<input class="sdpi-item-value" id="apiKey" value="" onchange="updateApiKey()" placeholder="Enter your WeatherApi Key"> | ||
</div> | ||
<div class="sdpi-item"> | ||
<div class="sdpi-item-label">City Name</div> | ||
<input class="sdpi-item-value" id="cityName" value="" onchange="updateCityName()" placeholder="Enter the city for the current weather details"> | ||
</div> | ||
<div class="sdpi-item"> | ||
<button class="sdpi-item-value" onclick="openPage('weatherapi.com/my/')">Get my API key</button> | ||
<button class="sdpi-item-value" onclick="openPage('github.com/JaouherK/streamDeck-weatherPlugin')">GitHub</button> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
let websocket = null, | ||
uuid = null, | ||
actionInfo = {}; | ||
|
||
function connectElgatoStreamDeckSocket(inPort, inPropertyInspectorUUID, inRegisterEvent, inInfo, inActionInfo) { | ||
|
||
uuid = inPropertyInspectorUUID; | ||
actionInfo = JSON.parse(inActionInfo); | ||
|
||
websocket = new WebSocket('ws://localhost:' + inPort); | ||
|
||
websocket.onopen = function() | ||
{ | ||
// WebSocket is connected, register the Property Inspector | ||
let json = { | ||
"event": inRegisterEvent, | ||
"uuid": inPropertyInspectorUUID | ||
}; | ||
websocket.send(JSON.stringify(json)); | ||
|
||
json = { | ||
"event": "getSettings", | ||
"context": uuid, | ||
}; | ||
websocket.send(JSON.stringify(json)); | ||
|
||
json = { | ||
"event": "getGlobalSettings", | ||
"context": uuid, | ||
}; | ||
websocket.send(JSON.stringify(json)); | ||
}; | ||
|
||
websocket.onmessage = function (evt) { | ||
// Received message from Stream Deck | ||
const jsonObj = JSON.parse(evt.data); | ||
if (jsonObj.event === 'didReceiveSettings') { | ||
const payload = jsonObj.payload.settings; | ||
|
||
document.getElementById('cityName').value = payload.cityName; | ||
|
||
if(document.getElementById('cityName').value === "undefined") { | ||
document.getElementById('cityName').value = ""; | ||
} | ||
} | ||
if (jsonObj.event === 'didReceiveGlobalSettings') { | ||
const payload = jsonObj.payload.settings; | ||
|
||
document.getElementById('apiKey').value = payload.apiKey; | ||
|
||
if(document.getElementById('apiKey').value === "undefined") { | ||
document.getElementById('apiKey').value = ""; | ||
} | ||
|
||
const el = document.querySelector('.sdpi-wrapper'); | ||
el && el.classList.remove('hidden'); | ||
} | ||
}; | ||
|
||
} | ||
|
||
function updateCityName() { | ||
if (websocket && (websocket.readyState === 1)) { | ||
let payload = {}; | ||
payload.cityName = document.getElementById('cityName').value; | ||
const json = { | ||
"event": "setSettings", | ||
"context": uuid, | ||
"payload": payload | ||
}; | ||
websocket.send(JSON.stringify(json)); | ||
console.log(json) | ||
} | ||
} | ||
|
||
function updateApiKey() { | ||
if (websocket && (websocket.readyState === 1)) { | ||
let payload = {}; | ||
payload.apiKey = document.getElementById('apiKey').value; | ||
const json = { | ||
"event": "setGlobalSettings", | ||
"context": uuid, | ||
"payload": payload | ||
}; | ||
websocket.send(JSON.stringify(json)); | ||
console.log(json) | ||
} | ||
} | ||
|
||
function openPage(site) { | ||
if (websocket && (websocket.readyState === 1)) { | ||
const json = { | ||
'event': 'openUrl', | ||
'payload': { | ||
'url': 'https://' + site | ||
} | ||
}; | ||
websocket.send(JSON.stringify(json)); | ||
} | ||
} |
Oops, something went wrong.