Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suport reactjs, add superagent.js and change to .html from .php
- Loading branch information
Showing
8 changed files
with
270 additions
and
53 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<?php | ||
namespace HttpTester; | ||
|
||
use HttpTester; | ||
|
||
class HttpSendProvider | ||
{ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
if(!empty($_POST["url"])){ | ||
$url = htmlspecialchars($_POST["url"]); | ||
}else{ | ||
$url=""; | ||
} | ||
if(!empty($_POST["text"])){ | ||
$text = htmlspecialchars($_POST["text"]); | ||
}else{ | ||
$text=""; | ||
} | ||
$responseData = [ | ||
"data"=>"ok", | ||
"status"=>"true", | ||
"sendData"=>[ | ||
"url"=>$url, | ||
"text"=>$text, | ||
], | ||
]; | ||
echo json_encode($responseData); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>HttpTester</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<meta http-equiv="Content-Script-Type" content="text/javascript"> | ||
<meta http-equiv="Content-Style-Type" content="text/css"> | ||
<link rel='stylesheet' type='text/css' href='design.css?id=4'> | ||
<script src="https://fb.me/react-0.13.3.js"></script> | ||
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script> | ||
<script src="./js/superagent.js"></script> | ||
<script type="text/jsx"> | ||
var request = window.superagent; | ||
var serverUrl = "https://tomo.syo.tokyo/httptester/httptester.php"; | ||
|
||
var NewAppButton = React.createClass({ | ||
onClick(e) { | ||
alert("addNewAPP"); | ||
}, | ||
render: function(){ | ||
return ( | ||
<div onClick={this.onClick} className="header-newapp-button">New App</div> | ||
); | ||
} | ||
}); | ||
|
||
var Header = React.createClass({ | ||
render: function() { | ||
return ( | ||
<header id="header"> | ||
<h1 className="header-title">HTTPTESTER</h1> | ||
<NewAppButton /> | ||
</header> | ||
); | ||
} | ||
}); | ||
|
||
var SideBar = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div id="sidebar"> | ||
<div className="sidebar-tag sidebar-tag-on">Default</div> | ||
<div className="sidebar-tag-title">RequestList</div> | ||
<div className="sidebar-tag sidebar-tag-on">Empty</div> | ||
<div className="sidebar-tag sidebar-tag-off">test</div> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var SideBarRight = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div id="sidebar-right">user's Log and image</div> | ||
); | ||
} | ||
}); | ||
|
||
var SendPostButton = React.createClass({ | ||
onClick(e) { | ||
sendHttpRequest("POST", serverUrl); | ||
}, | ||
render: function(){ | ||
return ( | ||
<p><button onClick={this.onClick} className="contens-input-sendbutton">POST</button></p> | ||
); | ||
} | ||
}); | ||
|
||
var SendGetButton = React.createClass({ | ||
onClick(e) { | ||
sendHttpRequest("GET", serverUrl); | ||
}, | ||
render: function(){ | ||
return ( | ||
<p><button onClick={this.onClick} className="contens-input-sendbutton contens-input-sendbutton-marginleft">GET</button></p> | ||
); | ||
} | ||
}); | ||
|
||
var Content = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div id="contens"> | ||
<div className="contens-in"> | ||
<div className="contens-sendarea-padding"> | ||
<div className="contens-sendarea"> | ||
<p><input type="text" name="url" className="contens-input-text" placeholder="URL" /></p> | ||
<p><textarea type="text" name="text" className="contens-input-textarea" placeholder="name=tomo&age=23"></textarea></p> | ||
<div className="contens-input-area"> | ||
<SendPostButton /> | ||
<SendGetButton /> | ||
<p><button className="contens-input-savebutton">SAVE</button></p> | ||
<p><input type="text" placeholder="save RequestName" className="contens-input-saveinput" /></p> | ||
<div className="clear-fix"></div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div id="contens-logarea"> | ||
<textarea type="text" name="text" id="contens-logarea-textarea"></textarea> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Page = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div id="page"> | ||
<Header /> | ||
<SideBar /> | ||
<Content /> | ||
<SideBarRight /> | ||
</div> | ||
); | ||
} | ||
}); | ||
React.render(<Page />, document.getElementById('react-httptester')); | ||
|
||
function sendHttpRequest(type, serverUrl){ | ||
if(type == "POST"){ | ||
request | ||
.post(serverUrl) | ||
.end(function(err, res){ | ||
console.log(res); | ||
var elements = document.getElementById("contens-logarea-textarea"); | ||
elements.innerHTML = res.text; | ||
}); | ||
}else if(type == "GET"){ | ||
request | ||
.get(serverUrl) | ||
.end(function(err, res){ | ||
console.log(res); | ||
var elements = document.getElementById("contens-logarea-textarea"); | ||
elements.innerHTML = res.text; | ||
}); | ||
}else{ | ||
alert("miss sendType") | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<div id="react-httptester"></div> | ||
</body> | ||
</html> |
Oops, something went wrong.