Last active
October 7, 2015 20:38
-
-
Save xl1/3222482 to your computer and use it in GitHub Desktop.
cui-about.me に日記を書く
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
cuiaboutme = 'http://cui-about.me/' | |
$ = (id) -> document.getElementById id | |
getData = -> | |
inputs = document.querySelectorAll('input, textarea') | |
res = [] | |
for input in inputs | |
id = input.id | |
if id isnt 'name' and id isnt 'submit' | |
res.push input.id + '=' + encodeURIComponent input.value | |
res.join('&') | |
submit = -> | |
url = cuiaboutme + $('name').value | |
xhr = new XMLHttpRequest | |
xhr.open 'PUT', url, true | |
xhr.setRequestHeader 'Content-Type', 'application/x-www-form-urlencoded' | |
xhr.onload = -> | |
alert xhr.responseText | |
if xhr.status is 200 | |
$('ifr').src = url | |
xhr.send getData() | |
document.addEventListener 'DOMContentLoaded', -> | |
$('submit').addEventListener 'click', submit, false | |
, false |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<title>日記を書く</title> | |
<script src="index.js"></script> | |
<style> | |
input { display: block; } | |
</style> | |
<input type="text" id="name" placeholder="name"> | |
<input type="password" id="password" placeholder="password"> | |
<textarea id="update" rows="10" cols="80"></textarea> | |
<input type="button" id="submit" value="submit"> | |
<iframe src="about:blank" id="ifr" width="500" height="300"></iframe> |
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
{ | |
"name": "\u65e5\u8a18\u3092\u66f8\u304f", | |
"version": "1.0", | |
"manifest_version": 2, | |
"app": { | |
"launch": { | |
"local_path": "index.html", | |
"container": "tab" | |
} | |
}, | |
"permissions": [ | |
"http://cui-about.me/*" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment