forked from pandao/editor.md
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_callback.html
More file actions
45 lines (39 loc) · 1.53 KB
/
upload_callback.html
File metadata and controls
45 lines (39 loc) · 1.53 KB
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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
</head>
<body>
<!--
这是同域下的callback页面,本页面在iframe内,所以只要通过window.parent就能操作父窗口的元素
-->
<script type="text/javascript">
var query = {};
var urlParams = window.location.search.split('?')[1];
urlParams = urlParams.split("&");
for (var i = 0; i< urlParams.length; i++)
{
var param = urlParams[i].split("=");
query[param[0]] = param[0] === "meta" ? JSON.parse(decodeURIComponent(param[1])) : param[1];
}
console.log('upload_callback: result =>', JSON.stringify(query, null, ' '));
var imageDialog = window.parent.document.getElementById(query['dialog_id']);
if (parseInt(query['success']) === 1)
{
imageDialog.querySelector("[data-url]").value = query['url'];
}
else
{
alert(decodeURIComponent(query['message']));
}
if (query['callback_handler']) {
try {
window.parent[query['callback_handler']](query, imageDialog);
} catch (e) {
console.error('upload_callback: callback_handler =>', e);
}
}
location.replace("about:blank");
</script>
</body>
</html>