-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdetails.html
301 lines (265 loc) · 11.6 KB
/
details.html
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello simpleMDE</title>
<script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script>
<script src="https://cdn.wilddog.com/sdk/js/2.5.8/wilddog.js"></script>
<link rel="stylesheet" href="./libs/angular/angular-material.min.css"/>
<link rel="stylesheet" href="./libs/mdl/material-icons.css"/>
<link rel="stylesheet" href="./styles/index.css"/>
</head>
<body onload="return_fromwilddog()">
<div id="MDE-wrapper" style="display: block;">
<!--textarea id="simpleMDE"></textarea>
<p><input type="button" value="edit" onclick="togglePreview(simplemde);"/>
<input type="button" value="save" onclick="save(simplemde);"/>
</p-->
</div>
<div>
<input type="button" value="save" onclick="save(simplemde)"/>
<div class="container" ng-controller="PostCtrl">
<!--<div class="login-form" ng-show="!login">
<md-content>
<md-card>
<md-card-content>
<h1 class="md-title">请先登录</h1>
<p layout="row">
<!–<md-button ng-click="authWithQQ()" class="md-raised md-primary" flex>
<img src="styles/qq.png" class="btn-icon"/>
用QQ登录
</md-button>–>
<img style="display: block;margin: 0 auto;" ng-click="authWithQQ()" src="http://7xlotq.com1.z0.glb.clouddn.com/o_19vn79qlr19n1rjfgg91t1v11da9.png"/>
</p>
</md-card-content>
</md-card>
</md-content>
</div>-->
<div class="main-content">
<ng-form layout="column"
style="padding: 10px; background: rgba(255,255,255,.8);border-radius: 5px;margin-bottom: 10px;">
<!--<div layout="row">
<p flex>您好,QQ用户</p>
<md-button class="md-mini md-raised" ng-click="logout()">退出</md-button>
</div>-->
<md-input-container>
<label for="desc">add pictures to your details here</label>
<input type="text" id="desc" ng-model="text"/>
</md-input-container>
<div layout id="uploader">
<md-input-container flex>
<label for="img">Image</label>
<input type="text" id="img" ng-model="img"/>
</md-input-container>
<md-button id="uploaderBtn" class="md-raised md-primary" ng-disabled="uploading">
{{uploading?'uploading...':'choose files'}}
</md-button>
</div>
<div class="align-right">
<md-button ng-click="addPost()" class="md-raised md-primary">add</md-button>
</div>
</ng-form>
<md-content>
<md-card ng-repeat="post in posts">
<div class="i-card-cover" card-cover="{{post.img}}?imageView2/2/w/800/q/60"
ng-if="post.img && post.img != 'null' && post.img !='' && post.img.indexOf('http') == 0"></div>
<md-card-content>
<p>{{post.text}}</p>
<p class="timestamp">{{post.time | date:'yyyy-MM-dd H:mm:ss'}}</p>
</md-card-content>
</md-card>
</md-content>
<!--<ul>
<li ng-repeat="post in posts">
[<span class="timestamp">{{post.time | date:'yyyy-MM-dd H:mm:ss'}}</span>] {{post.text}}
<div class="media-holder"
ng-if="post.img && post.img!=null && post.img != 'null' && post.img !='' && post.img.indexOf('http') == 0">
<img width="100" ng-src="{{post.img}}"/>
</div>
</li>
<div ng-show="loading" class="mdl-spinner mdl-js-spinner is-active"></div>
</ul>-->
</div>
</div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<script type="text/javascript">
var url = location.search;
console.log(url)
var uid = url.slice(5,33);
console.log(uid)
var titlesec = url.match(/\&(.*?)\&/)[1];
var title = titlesec.slice(6);
console.log(title)
var id = url.slice(40+title.length+4);
console.log(id)
var config = {
syncURL: "https://athandiajsmind.wilddogio.com" //输入节点 URL
};
wilddog.initializeApp(config);
var ref = wilddog.sync().ref(uid).child('jsmind');
//var ref = new Wilddog('https://athandiajsmind.wilddogio.com').sync().ref('/jsmind');
var de = "";
function return_fromwilddog(){
ref.child('details').child(title).child(id).on("value", function(snapshot){
console.log(snapshot.val())
de = snapshot.val().details;
loadMDE(de,de);
})
}
//var simplemde = new SimpleMDE({ element: document.getElementById("simpleMDE") });
/*
var simplemde = new SimpleMDE({
autosave: {
enabled: true,
uniqueId: "MyUniqueID",
delay: 1000,
},
element: document.getElementById("simpleMDE"),
initialValue: "Hello world!",
placeholder: "Type here...",
shortcuts: {
drawTable: "Cmd-Alt-T"
},
showIcons: ["code", "table"],
spellChecker: false,
toolbar: false
});
*/
var simplemde = null;
var loadMDE = function (title, content, onChangeCallBack) {
console.log(title, content, onChangeCallBack);
if (simplemde != null) {
simplemde.toTextArea(); simplemde = null;
};
var initVal = null;
if (content == null) {
initVal = "# " + title;
}
else {
initVal = content;
}
simplemde = new SimpleMDE({
autosave: {
enabled: true,
uniqueId: "MyUniqueID",
delay: 1000,
},
element: document.getElementById("simpleMDE"),
initialValue: initVal,
placeholder: "# 为你伟大的想法 " + title + " 码字",
shortcuts: {
drawTable: "Cmd-Alt-T"
},
showIcons: ["code", "table"],
spellChecker: false,
toolbar: false
});
simplemde.codemirror.on("change", function () {
console.log(simplemde.value());
if (onChangeCallBack != null) { onChangeCallBack(); }
});
};
function initMDE(id, loadCb){
if (simplemde!=null) {return;}
var e = document.getElementById(id);
e.innerHTML = '<textarea id="simpleMDE"></textarea><p><input type="button" value="edit" onclick="togglePreview(simplemde);"/></p>'
/* load twice to clear the autosave on page refresh */
if (loadCb!=null){
loadCb();
//loadCb(); //more customize-able.
}
else{
loadMDE(de);
loadMDE(de);
}
togglePreview(simplemde);
}
function destructMDE(id){
if (simplemde==null) {return;}
simplemde.toTextArea(); simplemde = null;
var e = document.getElementById(id);
e.innerHTML = "";
}
function save(editor){
var content = editor.value();
var details = {"details":content}
ref.child('details').child(title).child(id).set(details, function (error) {
if (error == null) {
console.info("Saved to Wilddog");
console.log(details);;
}
else {
alert(error);
}
});
}
function togglePreview(editor) {
var cm = editor.codemirror;
var wrapper = cm.getWrapperElement();
var toolbar_div = wrapper.previousSibling;
var toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false;
var preview = wrapper.lastChild;
if (!preview || !/editor-preview/.test(preview.className)) {
preview = document.createElement("div");
preview.className = "editor-preview";
wrapper.appendChild(preview);
}
if (/editor-preview-active/.test(preview.className)) {
preview.className = preview.className.replace(
/\s*editor-preview-active\s*/g, ""
);
if (toolbar) {
toolbar.className = toolbar.className.replace(/\s*active\s*/g, "");
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
}
} else {
// When the preview button is clicked for the first time,
// give some time for the transition from editor.css to fire and the view to slide from right to left,
// instead of just appearing.
setTimeout(function () {
preview.className += " editor-preview-active";
}, 1);
if (toolbar) {
toolbar.className += " active";
toolbar_div.className += " disabled-for-preview";
}
}
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
// Turn off side by side if needed
//var sidebyside = cm.getWrapperElement().nextSibling;
//if (/editor-preview-active-side/.test(sidebyside.className))
//toggleSideBySide(editor);
}
/* load twice to clear the autosave on page refresh */
//loadMDE("超牛逼的想法");
//loadMDE("超牛逼的想法");
//togglePreview(simplemde);
/* use initMDE("MDE-wrapper") instead */
initMDE("MDE-wrapper",function(){
loadMDE(de,de);
});
/* show / hide function. Ref: http://stackoverflow.com/questions/16308779/how-can-i-hide-show-a-div-when-a-button-is-clicked */
/*
function showhide(id) {
var e = document.getElementById(id);
e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}*/
//showhide("MDE-wrapper"); // wrapper要在loadMDE()之后设置为 display: none, 否则第一次edit会出现 白板&滚动条
//warning!! 不能在wrapper为display:none的状态下,loadMDE()
//todo: init_MDE() 函数 //visual improvement! //done!
//fixed. 使用initMDE 和 destructMDE 来代替
</script>
<script src="./libs/CryptoJS.js"></script>
<script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script>
<script src="./libs/plupload.full.min.js"></script>
<script src="./libs/qiniu.js"></script>
<script src="./libs/angular/angular.min.js"></script>
<script src="./libs/angular/angular-aria.min.js"></script>
<script src="./libs/angular/angular-animate.min.js"></script>
<script src="./libs/angular/angular-material.min.js"></script>
<script src="./scripts/index.js"></script>
<script src="./scripts/controllers/index.js?v=20160201"></script>
<script src="./scripts/services/index.js"></script>
<script src="./scripts/directives/index.js"></script>
</body>