Skip to content

Commit

Permalink
Merged branch develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
defaultcf committed Jan 15, 2017
2 parents 9d7d6a3 + 47ae3b8 commit 4ca61d2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
16 changes: 6 additions & 10 deletions web/docker_django/apps/smap/static/smap/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ $(".modal__open").click( function(){
return false ;
}
if(target == "seasma") {
console.log("タグ検索");
getTags();
}
nowModalSyncer = document.getElementById( target ) ;
Expand All @@ -67,9 +66,9 @@ $(".modal__open").click( function(){
$( nowModalSyncer ).fadeIn( "slow" ) ;

$("#inbtn").click(function() {
var message = document.getElementById("message").value;
var tags = document.getElementById("tags").value;
if(!message || !tags) {
var message = document.getElementById("message");
var tags = document.getElementById("tags");
if(!message.value || !tags.value) {
alert("messageとtagを入力してください");
return;
}
Expand All @@ -84,15 +83,14 @@ $(".modal__open").click( function(){
"lat": lat,
"lng": lng
},
"message": message,
"tags": tags
"message": message.value,
"tags": tags.value
}
),
contentType: 'application/JSON',
dataType : 'JSON'
}).done(function(res) {
console.log("success!");
message = "", tags = "";
message.value = "", tags.value = "";
closeModal();
}).fail(function(err) {
alert(err);
Expand All @@ -101,13 +99,11 @@ $(".modal__open").click( function(){
});

$("#seabtn").click(function() {
console.log("タグ検索");
var checks = document.getElementsByName("tags");
var checkTags = "";
for(var i = 0; i < checks.length; i++) {
if(checks[i].checked) checkTags += checks[i].value + ",";
}
console.log(checkTags);
window.checkTags = checkTags;
if(checkTags = "") {
alert("tagを入力してください");
Expand Down
24 changes: 21 additions & 3 deletions web/docker_django/apps/smap/static/smap/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ function grepTags(url, tags) {
/**
* マーカー作成
*/
function makeMarker(title, position, message) {
function makeMarker(title, position, message, good, id) {
return new google.maps.Marker({
map: map,
title: title,
position: position,
message: message,
good: good,
id: id,
animation: google.maps.Animation.DROP
});
}
Expand All @@ -93,21 +95,37 @@ function makeMarker(title, position, message) {
function getMarker() {
getData("/sumari/").then(function(data) {
for(var i = 0; i < data.length; i++) {
console.log(data[i]);
var name = data[i]["name"];
var lat = data[i]["position"]["lat"];
var lng = data[i]["position"]["lng"];
var message = data[i]["message"];
markers[i] = makeMarker(name, {lat: lat,lng: lng}, message);
var good = data[i]["good"];
var id = data[i]["id"];
markers[i] = makeMarker(name, {lat: lat,lng: lng}, message, good, id);
markers[i].addListener('click', function() {
infoWindow = new google.maps.InfoWindow({
content: "<b>" + this.title + "</b><br><p>" + this.message + "</br>"
content: "<b>" + this.title + "</b><br><p>" + this.message + "</br><button id='" + this.id + "' onclick='good(" + this.id + ")'>👍" + this.good + "</button>"
});
infoWindow.open(map, this);
});
}
});
};

/**
* good
*/
function good(id) {
console.log(id);
$.ajax({
url: "/sumari/" + id + "/good",
type: "POST"
}).done(function(res) {
$("#" + id).text("👍" + res.good);
});
}

/**
* マーカーを全て削除する
*/
Expand Down
1 change: 0 additions & 1 deletion web/docker_django/apps/smap/templates/smap/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<div id="seasma" class="sma">
<p class="sma__lead">タグ検索</p>
<div class="sma__message">
<!--<textarea id="seatag" cols="30" rows="15" placeholder="input one tag"></textarea>-->
<div id="findtags"></div>
</div>
<div class="sma__twoBtn">
Expand Down

0 comments on commit 4ca61d2

Please sign in to comment.