Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Lucksi
GitHub Repository: Lucksi/Mr.Holmes
Path: blob/master/GUI/Script/Maps/Builder.js
1071 views
1
/*ORIGINAL CREATOR: Luca Garofalo (Lucksi)
2
AUTHOR: Luca Garofalo (Lucksi)
3
Copyright (C) 2023 Lucksi <[email protected]>
4
License: GNU General Public License v3.0*/
5
6
var LocationList = [];
7
8
function CreateElement(){
9
var comment = document.getElementById("writeText").value;
10
var IsEntity = false;
11
if(document.getElementById("pe").checked == true ){
12
comment = "[Entity Used Person]:" + comment;
13
IsEntity = true;
14
}
15
else if (document.getElementById("ev").checked == true){
16
comment = "[Entity Used Event]:" + comment;
17
IsEntity = true;
18
}
19
else if (document.getElementById("place").checked == true){
20
comment = "[Entity Used Place]:" + comment;
21
IsEntity = true;
22
}
23
else{
24
IsEntity = false;
25
}
26
if (IsEntity == false){
27
alert("Entity not selected");
28
}
29
else{
30
var latidute = document.getElementById("Lat").value;
31
var longitude = document.getElementById("Lon").value;
32
L.marker([latidute ,longitude]).addTo(map).bindPopup(comment).openPopup().addEventListener("click",function(e){
33
map.panTo([latidute,longitude])});
34
var item = "L.marker([" + latidute + "," + longitude + "]).addTo(map).bindPopup('"+ comment + "').openPopup().addEventListener('click',function(e){map.panTo(["+ latidute +"," + longitude +"])})";
35
LocationList.push(item);
36
}
37
}
38
39
function DeleteAll(Message){
40
if(confirm(Message)){
41
window.location.reload();
42
}
43
else{
44
alert("Aborted");
45
}
46
}
47
48
function SaveGraph(filename){
49
var filename2 = filename + ".mh";
50
var text = " <div id = 'Content20' class = >'<div class ='map' id='map'></div>"+
51
"<script>"+
52
"var map = L.map('map').setView([0.0,0.0], 3);"+
53
"L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ attribution: '&copy; <a href= https://www.openstreetmap.org/copyright >OpenStreetMap</a> contributors'}).addTo(map);" +
54
"" + LocationList + "</script></div>";
55
var crypt = false;
56
var charset = "";
57
crypt = true
58
charset = "Encoded";
59
var cryfile = new Blob([charset], {type: "text/plain"});
60
var data = new FormData();
61
data.append("upFile",cryfile);
62
var req = new XMLHttpRequest();
63
req.open("POST","../Actions/Upload_MapFold.php");
64
req.onload=function(){
65
console.log(this.response);
66
};
67
req.send(data);
68
if(crypt == true){
69
var encode = window.btoa(text);
70
}
71
else if (crypt == false){
72
var encode = text;
73
}
74
var file = new Blob([encode], {type: "text/plain"});
75
var data = new FormData();
76
data.append("upFile",file);
77
var req = new XMLHttpRequest();
78
req.open("POST","../Actions/Upload_MapFile.php");
79
req.onload=function(){
80
console.log(this.response);
81
};
82
req.send(data);
83
alert("Download Complete: " + filename2);
84
}
85