<commit_before>﻿
/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
*/

/// <reference path="../App.js" />

(function () {
    "use strict";

    // The Office initialize function must be run each time a new page is loaded
    Office.initialize = function (reason) {
        $(document).ready(function () {
            app.initialize();

            detectActionsForMe();
        });
    };

    function detectActionsForMe() {
        var item = Office.cast.item.toItemRead(Office.context.mailbox.item);
        

        if (item.itemType === Office.MailboxEnums.ItemType.Message) {
           
            var myInfo = Office.context.mailbox.userProfile;
            var nameParts = myInfo.displayName.split(" ");

            // Make an assumption that the displayName is in the form "firstName lastName"
            var myFirstName = nameParts[0];

            // Check whether I was cc'd on this email
            for (var i = 0; i < item.cc.length; i++) {
                if (item.cc[i].emailAddress == myInfo.emailAddress) {
                    $("#cc-result").text("yes");
                    break;
                }
            }

            // Check whether I am on the To line
            for (var i = 0; i < item.to.length; i++) {
                if (item.to[i].emailAddress == myInfo.emailAddress) {
                    $("#to-result").text("yes");
                    break;
                }
            }

            // Check whether I am mentioned in the body of the email by name
            Office.context.mailbox.item.body.getAsync(function (asyncResult) {
                var bodyText = asyncResult.value;
              

                // Create regular expression to find all matches of the first name
                // i => ignore case
                // g => global match, i.e., doesn't stop after first match
                var regex = new RegExp(myFirstName, 'gi'); 
                var matchingArray = new Array();
                while (regex.exec(bodyText)) {
                    matchingArray.push(regex.lastIndex);
                }

                var result = "Scan complete.";
                
                if (matchingArray.length > 0)
                {<commit_msg>Add link to related samlple (link will work when the target repo is made public).<commit_after>﻿
/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
*/

/// <reference path="../App.js" />

(function () {
    "use strict";

    // The Office initialize function must be run each time a new page is loaded
    Office.initialize = function (reason) {
        $(document).ready(function () {
            app.initialize();

            detectActionsForMe();
        });
    };

    function detectActionsForMe() {
        var item = Office.cast.item.toItemRead(Office.context.mailbox.item);
        

        if (item.itemType === Office.MailboxEnums.ItemType.Message) {
           
            var myInfo = Office.context.mailbox.userProfile;
            var nameParts = myInfo.displayName.split(" ");

            // Make an assumption that the displayName is in the form "firstName lastName"
            var myFirstName = nameParts[0];

            // Check whether I was cc'd on this email
            for (var i = 0; i < item.cc.length; i++) {
                if (item.cc[i].emailAddress == myInfo.emailAddress) {
                    $("#cc-result").text("yes");
                    break;
                }
            }

            // Check whether I am on the To line
            for (var i = 0; i < item.to.length; i++) {
                if (item.to[i].emailAddress == myInfo.emailAddress) {
                    $("#to-result").text("yes");
                    break;
                }
            }

            // Check whether I am mentioned in the body of the email by name
            // In this sample we scan the email body as plain text. You can also 
            // set the coercionType on the getAsync() method to retrieve the body as HTML.
            // For an example of retrieving the body as HTML and parsing the result, 
            // see https://github.com/OfficeDev/Outlook-Add-in-LinkRevealer/blob/master/LinkRevealerWeb/AppRead/Home/Home.js
            Office.context.mailbox.item.body.getAsync(function (asyncResult) {
                var bodyText = asyncResult.value;
              

                // Create regular expression to find all matches of the first name
                // i => ignore case
                // g => global match, i.e., doesn't stop after first match
                var regex = new RegExp(myFirstName, 'gi'); 
                var matchingArray = new Array();
                while (regex.exec(bodyText)) {
                    matchingArray.push(regex.lastIndex);
                }

                var result = "Scan complete.";
                
                if (matchingArray.length > 0)
                {
{'fraction_non_alphanumeric': 0.10457256461232604, 'fraction_numerical': 0.0015904572564612327, 'mean_word_length': 1.5218045112781955, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2122905', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1232, 'n_words': 406}