From b75bc14a055279bdc5420047226dc8dded45d5e0 Mon Sep 17 00:00:00 2001 From: nandenjin Date: Sat, 12 Jul 2014 08:48:12 +0900 Subject: [PATCH 1/1] =?utf8?q?=E3=83=95=E3=82=A1=E3=83=BC=E3=82=B9?= =?utf8?q?=E3=83=88=E3=82=B3=E3=83=9F=E3=83=83=E3=83=88=EF=BC=9A=E5=90=8C?= =?utf8?q?=E6=9C=9F=E7=94=A8=E3=82=B3=E3=83=B3=E3=83=88=E3=83=AD=E3=83=BC?= =?utf8?q?=E3=83=A9=E3=82=B9=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88=E3=82=92?= =?utf8?q?=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands.json | 1 + index.html | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugin.js | 23 +++++++++++++++++++++++ receiver.php | 8 ++++++++ server.php | 23 +++++++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 commands.json create mode 100644 index.html create mode 100644 plugin.js create mode 100644 receiver.php create mode 100644 server.php diff --git a/commands.json b/commands.json new file mode 100644 index 0000000..40d5d48 --- /dev/null +++ b/commands.json @@ -0,0 +1 @@ +[{"id":"dummy","time":0,"action":"none","data":""}] \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..f919fe0 --- /dev/null +++ b/index.html @@ -0,0 +1,56 @@ + + + + + + Controller + + + + + + +
+ + \ No newline at end of file diff --git a/plugin.js b/plugin.js new file mode 100644 index 0000000..5017c29 --- /dev/null +++ b/plugin.js @@ -0,0 +1,23 @@ +//プログラム リモート コントローラー +//プログラムの作成中に複数台の端末を一斉に制御し、更新やページ移動を簡単にできるようにしています。 +//plugin.js - 実際に制御されるプログラムに埋め込んでおきます。他のスクリプトには影響を与えません。 +window.addEventListener('load',function(){ + //イベントストリームでserver.phpに接続 + var stream=new EventSource('http://'+location.hostname+'/control/server.php'); + //再読み込み + stream.addEventListener('reload',function(e){ + if(localStorage.sshCtrlCmdId==JSON.parse(e.data).id){ + return false; + } + localStorage.sshCtrlCmdId=JSON.parse(e.data).id; + location.reload(); + }); + //ページジャンプ + stream.addEventListener('jump',function(e){ + if(localStorage.sshCtrlCmdId==JSON.parse(e.data).id){ + return false; + } + localStorage.sshCtrlCmdId=JSON.parse(e.data).id; + location.href=JSON.parse(e.data).data; + }); +}); \ No newline at end of file diff --git a/receiver.php b/receiver.php new file mode 100644 index 0000000..b81f7c4 --- /dev/null +++ b/receiver.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/server.php b/server.php new file mode 100644 index 0000000..847f9f1 --- /dev/null +++ b/server.php @@ -0,0 +1,23 @@ +=time()-30){ + echo 'event:'.$current_cmd['action']."\n"; + echo 'data:'.json_encode($current_cmd)."\n\n"; + $last_id=$current_cmd['id']; + }else if($current_cmd['id']!='dummy'&&$current_cmd['time'] \ No newline at end of file -- 2.11.0