Skip to content

Commit

Permalink
[add] refs VG-Tech-Dojo#62 ユーザ名を投稿できるように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
larufa committed May 30, 2015
1 parent 97d1047 commit 53da067
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions missann/web-client/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<h4 class="modal-title" id="myModalLabel">投稿</h4>
</div>
<div class="modal-body">
ユーザ名
<p><input type="TEXT" class="form-control message-username" rows="3"></p>
コメント
<p><textarea class="form-control message-body" rows="3"></textarea></p>
</div>
Expand Down
9 changes: 5 additions & 4 deletions missann/web-client/web/js/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ function reloadMessages() {
/**
* メッセージの投稿
*/
function sendMessage(body) {
function sendMessage(username, body) {
var success = function() {
$(".message-username").val("");
$(".message-body").val("");
reloadMessages();
};
var error = function() { console.log("error") };
postMessage(body, success, error);
postMessage(username, body, success, error);
}

/**
Expand Down Expand Up @@ -70,12 +71,12 @@ function getMessages(success, error) {
/**
* APIリクエストコメント投稿
*/
function postMessage(body, success, error) {
function postMessage(username, body, success, error) {
var postMessageUri = "http://localhost:8888/messages";
return $.ajax({
type: "post",
url: postMessageUri,
data: JSON.stringify({"username":"名前はまだない", "body":body}),
data: JSON.stringify({"username":username,"body":body}),
dataType: "json",
})
.done(function(data) { success() })
Expand Down
3 changes: 2 additions & 1 deletion missann/web-client/web/js/web-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ $(document).ready(function () {
$(".post-message").bind("click", function() {
$("#myModal").modal("hide");
var body = $(".message-body").val();
sendMessage(body);
var username = $(".message-username").val();
sendMessage(username, body);
});

/**
Expand Down

0 comments on commit 53da067

Please sign in to comment.