forked from madhavagrawal17/DialogApi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDialogTaskpane.html
89 lines (81 loc) · 2.78 KB
/
DialogTaskpane.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
<!DOCTYPE html>
<html>
<head>
<title>DialogApp</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/beta/hosted/office.debug.js"></script>
</head>
<script type="text/javascript">
var _dialog;
function launchDialogCallback(asyncResult){
if(asyncResult.status=="succeeded"){
_dialog = asyncResult.value;
_dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, addStatus);
_dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogEventReceived, addCloseStatus);
}else{
text.value = asyncResult.error.message;
}
}
function LaunchDialog(event) {
Office.context.ui.displayDialogAsync("https://madhavagrawal17.github.io/DialogApi/Dialog.html",
{height:80, width:50, requireHTTPS: true, promptBeforeOpen:false},
launchDialogCallback);
}
function LaunchInframeDialog(event) {
Office.context.ui.displayDialogAsync("https://madhavagrawal17.github.io/DialogApi/Dialog.html",
{height:80, width:50, requireHTTPS: true, promptBeforeOpen:false, displayInIframe:true},
launchDialogCallback);
}
function BtnSetData() {
var value = document.getElementById("TxtData").value;
if (!value) {
value = "Hello";
}
_dialog.messageChild(value);
}
function addStatus(arg){
text.value = text.value + arg.message;
var w = window;
console.log(w.location.href);
}
function onMessage(message, dialog){
text.value = text.value + message;
}
function addCloseStatus(arg){
text.value = text.value + " " + arg.error;
text.value = text.value + "dialog closed";
}
</script>
<script>
// Perform Step 2 of an initialization that -- in a real developer scenario (non-test-agave), would have
// been included inside the "excel-web-16.00.js"/"excel-win32-16.01.js"/etc files
Office.onReady(function(info) {
// do something
});
</script>
<body>
<div>
Message
<div>
<button id="BtnSetData" onclick="BtnSetData()">SendMessageToChild</button>: <input id="TxtData" type="text" />
</div>
</div>
<div>
<br><br>
<textarea id="text" cols="20" rows="10"></textarea>
<input type="button" onclick="LaunchDialog()" value="LaunchDialog" id="LaunchDialog"/>
<input type="button" onclick="LaunchInframeDialog()" value="LaunchInframeDialog" id="LaunchInframeDialog"/>
</div>
<div>
<div>
<button id="BtnRun" onclick="BtnRun()">Run</button> the following code:
</div>
<div>
<textarea id="TxtCode" cols="40" rows="20" spellcheck="false"></textarea>
</div>
</div>
<div>Logs:</div>
<div id="DivLog">
</div>
</body>
</html>