-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuAction.js
160 lines (140 loc) · 4.17 KB
/
menuAction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
function onMenuJoinus(){
var elJoinus = document.getElementById("popupJoinus");
elJoinus.style.visibility = "visible";
}
function onMenuNew(){
return false;
}
function onMenuLoad(){
if( MapModified ){
var elPopup = document.getElementById("popupLoadConfirm");
elPopup.style.visibility = "visible";
popupPosisionCenter(elPopup);
return;
}
else
onLoadListPopup();
}
function onLoadConfirmYes(){
document.getElementById("popupLoadConfirm").style.visibility = "hidden";
onMMSave();
// TODO. save의 결과를 보고 load를 해야 하는데. 방법이 없다.
onLoadListPopup();
}
function onLoadConfirmNo(){
document.getElementById("popupLoadConfirm").style.visibility = "hidden";
onLoadListPopup();
}
function onLoadConfirmCancel(){
document.getElementById("popupLoadConfirm").style.visibility = "hidden";
}
function onLoadListPopup(){
var elPopupLoad = document.getElementById("popupLoad");
elPopupLoad.style.visibility = "visible";
// position to center
popupPosisionCenter(elPopupLoad);
// xml request call
var mmapi = new MindmapAPI();
mmapi.maplistRsp = function( strJson ){
if( strJson == null ){
console.log("map list fail");
return;
}
var jsMapList = eval( strJson);
var elListBox = document.getElementById("mmList");
var htmlMapList = "";
for( var i in jsMapList ){
htmlMapList += "<div class=\"mapName\" onClick=\"onMMLoad(" + jsMapList[i].mapid + ");\">";
htmlMapList += jsMapList[i].name;
htmlMapList += "</div>";
}
elListBox.innerHTML = htmlMapList;
}
mmapi.maplist();
return false;
}
function onMMLoad( mapid ){
var mmapi = new MindmapAPI();
mmapi.MMLoadRsp = function( strJson, mapid ) {
if( strJson == null ){
console.log("map data fail");
return;
}
MapId = mapid;
RootNode = eval( "(" + strJson + ")" );
Mapid = mapid;
// close popup
var elPopupLoad = document.getElementById("popupLoad");
elPopupLoad.style.visibility = "hidden";
// go to center
DrawPosX = canvas.width/2 - (RootNode.area[2] - RootNode.area[0]);
DrawPosY = canvas.height/2;
draw();
popupOkOpen("load", "");
}
mmapi.MMLoad( mapid );
}
function onMMLoadCancel(){
document.getElementById("popupLoad").style.visibility = "hidden";
}
function onMenuSave(){
if( !MapModified )
return false;
if( Mapid == -1 ){
var elPopup = document.getElementById("popupSaveNewConfirm");
elPopup.style.visibility = "visible";
popupPosisionCenter(elPopup);
}
else{
onMMSave();
popupOkOpen("Save", "complete");
}
return false;
}
function onSaveNewYes() {
document.getElementById("popupSaveNewConfirm").style.visibility = "hidden";
onMMSaveNew();
}
function onSaveNewNo() {
document.getElementById("popupSaveNewConfirm").style.visibility = "hidden";
}
function popupOkOpen(title, text){
var elPopup = document.getElementById("popupOk");
elPopup.style.visibility = "visible";
var elTitle = document.getElementById("popupOkTitle");
elTitle.innerHTML = title;
var elContent = document.getElementById("popupOkContent");
elContent.innerHTML = text;
popupPosisionCenter(elPopup);
}
function popupOkClose(){
document.getElementById("popupOk").style.visibility = "hidden";
}
function onMMSave(){
var mmaip = new MindmapAPI();
mmaip.MMSaveRsp = function( state ){
if( !state ){
Alert("save new fail");
}
else {
MapModified = false;
popupOkOpen("save", "");
}
}
mmaip.MMSave( JSON.stringify(RootNode), Mapid, RootNode.text );
}
function onMMSaveNew(){
var mmaip = new MindmapAPI();
mmaip.MMSaveNewRsp = function( state ){
if( !state ){
Alert("save new fail");
}
else {
MapModified = false;
popupOkOpen("save", "");
}
}
mmaip.MMSaveNew( JSON.stringify(RootNode), RootNode.text );
}
function saveAsNewMap(){
}