<commit_before>(function() {
    var mailEndpoint, mailRequest, SPClient, UPClient;

    // config params for UnifiedPush server
    var variantId = "<Your-Variant-ID";
    var variantSecret = "<Your-Variant-Secret>";
    var simplePushUrl = "<URL of the running SimplePush server>"
    var unifiedPushUrl = "<URL of the running UnifiedPush server>";

     // create the 'UnifiedPush' client object:
    var UPClient = AeroGear.UnifiedPushClient(variantId, variantSecret, unifiedPushUrl + "/rest/registry/device");

    // onConnect callback function called when SimplePush 
    // successfully establishes connection to the server
    function spConnect() {
        appendTextArea("Connection established with SimplePush server!");

        // use 'PushManager' to request a new PushServer URL endpoint for 'Mail' notifications:
        mailRequest = navigator.push.register();
         // the DOMRequest returns 'successfully':
        mailRequest.onsuccess = function( event ) {
            // extract the endpoint object from the event: 
            mailEndpoint = event.target.result;
            
            appendTextArea("Subscribed to 'Mail' messages on channel " + mailEndpoint.channelID);

            // if it is the first registration, need to register 
            // the 'pushEndpoint' with the UnifiedPush server.
            if ( mailEndpoint.pushEndpoint ) {
                // assemble the metadata for registration with the UnifiedPush server
                var metadata = {
                    deviceToken: mailEndpoint.channelID,
                    simplePushEndpoint: mailEndpoint.pushEndpoint,
                    alias: "john",
                    category: "email"
                };

                // register with the server
                UPClient.registerWithPushServer(metadata);

                appendTextArea("Registered 'Mail' endpoint with UnifiedPush server!")

            } else {
                appendTextArea("'Mail' was already registered!");
            }
        };

        // let's request another endpoint for 'broadcast' notifications

        // use 'PushManager' to request a new PushServer URL endpoint for 'broadcast' notifications:
        broadcastRequest = navigator.push.register();
         // the DOMRequest returns 'successfully':
        broadcastRequest.onsuccess = function( event ) {
            // extract the endpoint object from the event: 
            broadcastEndpoint = event.target.result;
            
            appendTextArea("Subscribed to 'broadcast' messages on channel " + broadcastEndpoint.channelID);

            // if it is the first registration, need to register 
            // the 'pushEndpoint' with the UnifiedPush server.
            if ( broadcastEndpoint.pushEndpoint ) {
                // assemble the metadata for registration with the UnifiedPush server
                var metadata = {
                    deviceToken: broadcastEndpoint.channelID,
                    simplePushEndpoint: broadcastEndpoint.pushEndpoint,
                    alias: "john",
                    category: "broadcast"
                };

                // register with the server
                UPClient.registerWithPushServer(metadata);

                appendTextArea("Registered 'broadcast' endpoint with UnifiedPush server!")

            } else {
                appendTextArea("'broadcast' was already registered!");
            }
        };        

        // set the notification handler:
        navigator.setMessageHandler( "push", function( message ) {
            if ( message.channelID === mailEndpoint.channelID ) {
                // let's react on the 'email' endpoint
                appendTextArea("Mail Notification - " + message.version);
            } else if ( message.channelID === broadcastEndpoint.channelID ) { 
                // let's react on the 'broadcast' endpoint
                appendTextArea("Broadcast Notification - " + message.version);            
            }
        });
    }

    function appendTextArea(newData) {
        var el = getTextAreaElement();
        el.value = el.value + '\n' + newData;
    }

    function getTextAreaElement() {
        return document.getElementById('responseText');
    }<commit_msg>use mail name for consistency<commit_after>(function() {
    var mailEndpoint, mailRequest, SPClient, UPClient;

    // config params for UnifiedPush server
    var variantId = "<Your-Variant-ID";
    var variantSecret = "<Your-Variant-Secret>";
    var simplePushUrl = "<URL of the running SimplePush server>"
    var unifiedPushUrl = "<URL of the running UnifiedPush server>";

     // create the 'UnifiedPush' client object:
    var UPClient = AeroGear.UnifiedPushClient(variantId, variantSecret, unifiedPushUrl + "/rest/registry/device");

    // onConnect callback function called when SimplePush 
    // successfully establishes connection to the server
    function spConnect() {
        appendTextArea("Connection established with SimplePush server!");

        // use 'PushManager' to request a new PushServer URL endpoint for 'Mail' notifications:
        mailRequest = navigator.push.register();
         // the DOMRequest returns 'successfully':
        mailRequest.onsuccess = function( event ) {
            // extract the endpoint object from the event: 
            mailEndpoint = event.target.result;
            
            appendTextArea("Subscribed to 'Mail' messages on channel " + mailEndpoint.channelID);

            // if it is the first registration, need to register 
            // the 'pushEndpoint' with the UnifiedPush server.
            if ( mailEndpoint.pushEndpoint ) {
                // assemble the metadata for registration with the UnifiedPush server
                var metadata = {
                    deviceToken: mailEndpoint.channelID,
                    simplePushEndpoint: mailEndpoint.pushEndpoint,
                    alias: "john",
                    category: "mail"
                };

                // register with the server
                UPClient.registerWithPushServer(metadata);

                appendTextArea("Registered 'Mail' endpoint with UnifiedPush server!")

            } else {
                appendTextArea("'Mail' was already registered!");
            }
        };

        // let's request another endpoint for 'broadcast' notifications

        // use 'PushManager' to request a new PushServer URL endpoint for 'broadcast' notifications:
        broadcastRequest = navigator.push.register();
         // the DOMRequest returns 'successfully':
        broadcastRequest.onsuccess = function( event ) {
            // extract the endpoint object from the event: 
            broadcastEndpoint = event.target.result;
            
            appendTextArea("Subscribed to 'broadcast' messages on channel " + broadcastEndpoint.channelID);

            // if it is the first registration, need to register 
            // the 'pushEndpoint' with the UnifiedPush server.
            if ( broadcastEndpoint.pushEndpoint ) {
                // assemble the metadata for registration with the UnifiedPush server
                var metadata = {
                    deviceToken: broadcastEndpoint.channelID,
                    simplePushEndpoint: broadcastEndpoint.pushEndpoint,
                    alias: "john",
                    category: "broadcast"
                };

                // register with the server
                UPClient.registerWithPushServer(metadata);

                appendTextArea("Registered 'broadcast' endpoint with UnifiedPush server!")

            } else {
                appendTextArea("'broadcast' was already registered!");
            }
        };        

        // set the notification handler:
        navigator.setMessageHandler( "push", function( message ) {
            if ( message.channelID === mailEndpoint.channelID ) {
                // let's react on the 'mail' endpoint
                appendTextArea("Mail Notification - " + message.version);
            } else if ( message.channelID === broadcastEndpoint.channelID ) { 
                // let's react on the 'broadcast' endpoint
                appendTextArea("Broadcast Notification - " + message.version);            
            }
        });
    }

    function appendTextArea(newData) {
        var el = getTextAreaElement();
        el.value = el.value + '\n' + newData;
    }

    function getTextAreaElement() {
        return document.getElementById('responseText');
    }
{'fraction_non_alphanumeric': 0.08298072402444757, 'fraction_numerical': 0.0, 'mean_word_length': 1.9741349178608878, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '1601315', 'n_tokens_mistral': 1985, 'n_tokens_neox': 1855, 'n_words': 592}