66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
|
|
var currentLat = 0.0
|
|
var currentLon = 0.0
|
|
|
|
let baseData = {
|
|
'id' : "",
|
|
'title': "",
|
|
'content': "",
|
|
'firstPostLat': 0.0,
|
|
'firstPostLon': 0.0,
|
|
'category' : "none",
|
|
'hashTags' : "#none",
|
|
'modifyLat' : 0.0,
|
|
'modifyLon' : 0.0,
|
|
'originId' : "",
|
|
'writeTime' : 0,
|
|
}
|
|
|
|
function goToEditor(id) {
|
|
location.href = getMainPath() + '/blog/editor/' + id;
|
|
}
|
|
|
|
|
|
|
|
function onclickWrite(type, keyword, html) {
|
|
let title_field = document.getElementById('title_field')
|
|
var hasValues = true
|
|
if (hasValues) {
|
|
baseData.title = encodeURIComponent(title_field.value)
|
|
baseData.content = encodeURIComponent(html)
|
|
baseData.firstPostLat = encodeURIComponent(currentLat)
|
|
baseData.firstPostLon = encodeURIComponent(currentLon)
|
|
}
|
|
let uploadUrl = getMainPath() + "/blog/post.bjx";
|
|
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.";
|
|
}
|
|
}
|
|
function showPosition(position) {
|
|
currentLat = position.coords.latitude
|
|
currentLon = position.coords.longitude
|
|
if(baseData.firstPostLat !== 0.0) {
|
|
baseData.modifyLat = encodeURIComponent(currentLat)
|
|
} else {
|
|
baseData.firstPostLat = encodeURIComponent(currentLat)
|
|
}
|
|
if(baseData.firstPostLon !== 0.0 ) {
|
|
baseData.modifyLon = encodeURIComponent(currentLon)
|
|
} else {
|
|
baseData.firstPostLon = encodeURIComponent(currentLon)
|
|
}
|
|
|
|
|
|
document.getElementById('location_field').textContent = "Lat: " + position.coords.latitude + ", Lon: " + position.coords.longitude;
|
|
} |