forked from OfficeDev/Outlook-Add-In-Contextual-Regex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginal-index.js
41 lines (37 loc) · 1.42 KB
/
original-index.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
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. see LICENSE in the project root for license information.
"use strict";
Office.initialize = function(reason) {
$(document).ready(function(){
loadEntities();
});
}
function loadEntities() {
// getSelectedRegExMatches is in preview, so need to test for it
if (Office.context.mailbox.item.getSelectedRegExMatches !== undefined) {
var selectedMatches = Office.context.mailbox.item.getSelectedRegExMatches();
if (selectedMatches) {
// Note that the use of selectedMatches.PartNumber, where
// PartNumber corresponds to the RegExName attribute of the Rule element
// in the manifest
$("#selected-match").text(JSON.stringify(selectedMatches.PartNumber, null, 2));
} else {
$("#selected-match").text("Selected matches was null");
}
} else {
$("#selected-match").text("Method not supported on your client");
}
// Get all matches
var allMatches = Office.context.mailbox.item.getRegExMatches();
if (allMatches) {
// Note that the use of selectedMatches.PartNumber, where
// PartNumber corresponds to the RegExName attribute of the Rule element
// in the manifest
$("#all-matches").text(JSON.stringify(allMatches.PartNumber, null, 2));
} else {
$("#all-matches").text("All matches was null");
}
}
function showError(message) {
$("#error-msg").text(message);
$("#error").show();
}