<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<pre id="output-source" class="output"></pre>
<pre id="output-js" class="output"></pre>
</body>
</html>
var url = "https://raw.githubusercontent.com/freifunk-gluon/gluon/master/package/gluon-config-mode-hostname/i18n/de.po"
fetch(url)
.then(function(res) {
return res.body.getReader();
})
.then(function(reader) {
return reader.read();
})
.then(function(stream) {
var decoder = new TextDecoder();
var body = decoder.decode(stream.value || new Uint8Array);
return body
})
.then(function(body) {
var text = body.replace(/\\n/g, '');
var lines = text.split('\n');
console.log(text)
var arr = []
var obj = {}
for (var i = 0; i < lines.length; i++) {
// key:value pairs
if (lines[i].indexOf(':') !== -1) {
var line = lines[i].replace(/"/g, '');
var pair = line.split(':');
if (pair.length) {
obj[pair[0]] = pair[1].trim();
}
}
// msgid
if (lines[i].indexOf('msgid') !== -1) {
var msgobj = {};
var msgid = lines[i].split(' "')[1].replace(/\"/g, '');
msgobj.msgid = msgid;
// msgstr
if (lines[i+1].indexOf('msgstr') !== -1) {
var msgstr = lines[i+1].split(' "')[1].replace(/\"/g, '');
msgobj.msgstr = msgstr;
}
arr.push(msgobj);
}
}
arr.push(obj)
document.getElementById('output-source')
.innerHTML = body
document.getElementById('output-js')
.innerHTML = JSON.stringify(arr, null, 2);
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |