Permalink
Browse files

manifest_version2対応

  • Loading branch information...
dameninngenn committed Aug 9, 2012
1 parent 7f2922c commit 845cf0c3749862088a4d8024f78b7322a968ced0
Showing with 114 additions and 96 deletions.
  1. +3 −2 src/manifest.json
  2. +3 −34 src/options.html
  3. +37 −0 src/options.js
  4. +4 −60 src/popup.html
  5. +67 −0 src/popup.js
View
@@ -1,10 +1,11 @@
{
"manifest_version": 2,
"name": "Ikachan Post",
"version": "0.1.0",
"version": "0.1.1",
"description": "send url to ikachan",
"browser_action": {
"default_icon": "ika128.png",
"popup": "popup.html"
"default_popup": "popup.html"
},
"icons": {
"128": "ika128.png",
View
@@ -1,42 +1,11 @@
<html>
<head><title>Options</title></head>
<script type="text/javascript">
function save_options() {
var channel = document.getElementById("channel");
var ikachan_url = document.getElementById("ikachan_url");
if( channel.value ) {
localStorage["channel"] = channel.value;
}
if( ikachan_url.value ) {
localStorage["ikachan_url"] = ikachan_url.value;
}
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 750);
}
function restore_options() {
var strage_channel = localStorage["channel"];
var strage_ikachan_url = localStorage["ikachan_url"];
if( strage_channel ){
var channel = document.getElementById("channel");
channel.value = strage_channel;
}
if( strage_ikachan_url ){
var ikachan_url = document.getElementById("ikachan_url");
ikachan_url.value = strage_ikachan_url;
}
}
</script>
<body onload="restore_options()">
<body>
channel: <input id="channel" type="text" /><br />
ikachan url: <input id="ikachan_url" type="text" />
<br>
<button onclick="save_options()">Save</button>
<button id="save_btn">Save</button>
<div id="status"></div>
<script type="text/javascript" src="options.js"></script>
</body>
</html>
View
@@ -0,0 +1,37 @@
restore_options();
var btn = document.getElementById("save_btn");
var btn_listener = function(e){
save_options();
};
btn.addEventListener('click', btn_listener, false);
function save_options() {
var channel = document.getElementById("channel");
var ikachan_url = document.getElementById("ikachan_url");
if( channel.value ) {
localStorage["channel"] = channel.value;
}
if( ikachan_url.value ) {
localStorage["ikachan_url"] = ikachan_url.value;
}
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 750);
}
function restore_options() {
var strage_channel = localStorage["channel"];
var strage_ikachan_url = localStorage["ikachan_url"];
if( strage_channel ){
var channel = document.getElementById("channel");
channel.value = strage_channel;
}
if( strage_ikachan_url ){
var ikachan_url = document.getElementById("ikachan_url");
ikachan_url.value = strage_ikachan_url;
}
}
View
@@ -9,71 +9,15 @@
overflow-x:hidden;
}
</style>
<script>
chrome.tabs.getSelected(null, function(tab) {
setUrl(tab.url);
setTitle(tab.title);
setOptions();
});
function setUrl(tablink) {
var url = document.getElementById("url");
url.innerHTML = tablink;
}
function setTitle(tabtitle) {
var title = document.getElementById("title");
title.innerHTML = tabtitle;
}
function setOptions() {
var strage_channel = localStorage["channel"];
if( strage_channel ){
var channel = document.getElementById("channel");
channel.value = strage_channel;
}
}
function showErrorMsg(msg) {
var error = document.getElementById("error_msg");
error_msg.innerHTML = msg;
}
function postIkachan(){
var url = document.getElementById("url");
var channel = document.getElementById("channel");
var ikachan_url = localStorage["ikachan_url"];
// XXX
if( !url.innerHTML || !channel.value || !ikachan_url ) {
showErrorMsg('何か足りないよ');
return;
}
var message = encodeURIComponent(url.innerHTML);
var param = 'channel=' + channel.value + '&message=' + message;
var req = new XMLHttpRequest();
req.open(
"POST",
ikachan_url,
true
);
req.onload = showResults();
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(param);
}
function showResults(){
//alert('done');
}
</script>
<h1>見てるページのURLをIkachanにpostするやつ</h1>
<p id="title"></p>
<p id="url"></p>
channel: <input id="channel" type="text" /><br />
<p id="error_msg"></p>
<input id="submit_btn" type="button" onclick="javascript:postIkachan();" value="post" />
<input id="submit_btn" type="button" value="post" />
<p id="status"></p>
<p>チャンネル名のデフォルトとかpost先のikachanのURLはオプションで設定してね。</p>
<script type="text/javascript" src="popup.js"></script>
</html>
View
@@ -0,0 +1,67 @@
var btn = document.getElementById("submit_btn");
var btn_listener = function(e){
postIkachan();
};
btn.addEventListener('click', btn_listener, false);
chrome.tabs.getSelected(null, function(tab) {
setUrl(tab.url);
setTitle(tab.title);
setOptions();
});
function setUrl(tablink) {
var url = document.getElementById("url");
url.innerHTML = tablink;
}
function setTitle(tabtitle) {
var title = document.getElementById("title");
title.innerHTML = tabtitle;
}
function setOptions() {
var strage_channel = localStorage["channel"];
if( strage_channel ){
var channel = document.getElementById("channel");
channel.value = strage_channel;
}
}
function showErrorMsg(msg) {
var error = document.getElementById("error_msg");
error_msg.innerHTML = msg;
}
function postIkachan(){
var url = document.getElementById("url");
var channel = document.getElementById("channel");
var ikachan_url = localStorage["ikachan_url"];
// XXX
if( !url.innerHTML || !channel.value || !ikachan_url ) {
showErrorMsg('何か足りないよ');
return;
}
var message = encodeURIComponent(url.innerHTML);
var param = 'channel=' + channel.value + '&message=' + message;
var req = new XMLHttpRequest();
req.open(
"POST",
ikachan_url,
true
);
req.onload = showResults();
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(param);
}
function showResults(){
var status = document.getElementById("status");
status.innerHTML = "送信したよ";
setTimeout(function() {
status.innerHTML = "";
}, 750);
}

0 comments on commit 845cf0c

Please sign in to comment.