44 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-10-23 10:07:45 +09:00
2024-10-23 17:06:27 +09:00
var currentLat = 0.0
var currentLon = 0.0
let baseData = {
'title': "",
'content': "",
'firstPostLat': "",
'firstPostLon': "",
'category' : "none",
'hashTags' : "#none",
}
2024-10-23 10:07:45 +09:00
function onclickWrite(type, keyword, html) {
let title_field = document.getElementById('title_field')
var hasValues = true
if (hasValues) {
2024-10-23 17:06:27 +09:00
baseData.title = encodeURIComponent(title_field.value)
baseData.content = encodeURIComponent(html)
baseData.firstPostLat = encodeURIComponent(currentLat)
baseData.firstPostLon = encodeURIComponent(currentLon)
}
let uploadUrl = getMainPath() + "/blog/post.ajax";
if(confirm(JSON.stringify(baseData) + "\n해당 내용으로\n유저 등록 하실??")) {
post(uploadUrl,type,JSON.stringify(baseData),keyword, function (resultData) {
alert(resultData)
})
} else {
}
}
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
2024-10-23 10:07:45 +09:00
}
2024-10-23 17:06:27 +09:00
}
function showPosition(position) {
currentLat = position.coords.latitude
currentLon = position.coords.longitude
baseData.firstPostLat = encodeURIComponent(currentLat)
baseData.firstPostLon = encodeURIComponent(currentLon)
document.getElementById('location_field').value = "Lat: " + position.coords.latitude + ", Lon: " + position.coords.longitude;
2024-10-23 10:07:45 +09:00
}