Initial commit

master
informatic 2016-10-18 00:31:24 +02:00
commit f4bedcd612
5 changed files with 221 additions and 0 deletions

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

91
icon.svg Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 32 32.000001"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
inkscape:export-filename="/tmp/xD2"
inkscape:export-xdpi="174"
inkscape:export-ydpi="174"
sodipodi:docname="logo.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.6"
inkscape:cx="19.868022"
inkscape:cy="-16.038421"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1021"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1020.3622)">
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:9.85748005;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4136-3"
cx="16"
cy="1027.3187"
r="2.9303739" />
<circle
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:9.85748005;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4136-35"
cx="25.914766"
cy="1036.3622"
r="2.9303739" />
<circle
style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:9.85748005;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4136-7-6"
cx="6.0852337"
cy="1045.4058"
r="2.9303739" />
<circle
style="opacity:1;fill:#00ff00;fill-opacity:1;stroke:none;stroke-width:9.85748005;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4136-5-2"
cx="16"
cy="1045.4058"
r="2.9303739" />
<circle
style="opacity:1;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:9.85748005;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4136-35-9"
cx="25.914766"
cy="1045.4058"
r="2.9303739" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

20
manifest.json Normal file
View File

@ -0,0 +1,20 @@
{
"manifest_version": 2,
"name": "Share to q3kled",
"description": "This extension shares current URL to q3kled led matrix API",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"http://led.waw.hackerspace.pl/"
],
"icons": {
"128": "icon.png"
},
"author": "informatic"
}

56
popup.html Normal file
View File

@ -0,0 +1,56 @@
<!doctype html>
<html>
<head>
<title>Share to q3kled popup</title>
<style>
#targetURL {
font-weight: bold;
}
body {
min-width: 300px;
}
button {
font-weight: bold;
padding: 10px 20px;
font-size: 120%;
}
#status {
font-weight: bold;
font-size: 120%;
text-align: center;
}
#status.error {
color: red;
}
#status.success {
color: green;
}
#status.progress {
color black;
}
.buttons {
margin: 15px auto;
text-align: center;
}
</style>
<script src="popup.js"></script>
</head>
<body>
This is going to share following URL to q3kled:
<div id="targetURL"></div>
<div class="buttons">
<button id="append">Add to Queue</button>
<button id="now">Play now</button>
</div>
<div id="status"></div>
</body>
</html>

54
popup.js Normal file
View File

@ -0,0 +1,54 @@
function getCurrentTabUrl(callback) {
var queryInfo = {
active: true,
currentWindow: true
};
console.info('xD');
chrome.tabs.query(queryInfo, function(tabs) {
var tab = tabs[0];
var url = tab.url;
callback(url);
});
}
function updateStatus(text, status) {
document.getElementById('status').textContent = text;
document.getElementById('status').setAttribute('class', status);
}
function pushToQ3kled(action, targetURL, callback, errorCallback) {
var requestUrl = 'http://led.waw.hackerspace.pl/api/1/webled/playlist/play/' + action +
'?uri=' + encodeURIComponent(targetURL);
var x = new XMLHttpRequest();
x.open('GET', requestUrl);
x.responseType = 'json';
x.onload = function() {
// Parse and process the response from Google Image Search.
var response = x.response;
if(!response.okay)
updateStatus(response.error, 'error');
else
updateStatus('OK', 'success');
};
x.onerror = function() {
updateStatus('Network error.', 'error');
};
x.send();
updateStatus('Loading ...', 'progress');
}
document.addEventListener('DOMContentLoaded', function() {
getCurrentTabUrl(function(url) {
document.getElementById('targetURL').textContent = url;
document.getElementById('append').addEventListener('click', function() {
pushToQ3kled('append', url);
});
document.getElementById('now').addEventListener('click', function() {
pushToQ3kled('now', url);
});
});
});