<commit_before><!DOCTYPE html>
<!--
Possibilities:

1) Already logged in.
    - Activate acct
    - Redirect to index_new.html
    - Display message saying account has been activated.

2) Not logged in.
    - Show username
    - Ask for password
    - Then sign them in and redirect to index_new.html

3) Signed in as a different user:
    - Ask for password
    - Display message about how activating the account will switch who is
    signed in.
-->
<html>

<head>
    <title>Canopy - An Open Source Platform for the Internet of Things</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="canopy-js-client/canopy.js"></script>
    <script src="canopy_app_util.js"></script>
    <script src="nodes/cano.js"></script>
    <script src="nodes/cano_topbar.js"></script>
    <script src="nodes/cano_account_page.js"></script>
    <script src="nodes/cano_account_sidebar.js"></script>
    <script src="nodes/cano_device_list.js"></script>
    <script src="nodes/cano_device_details.js"></script>
    <script src="nodes/cano_device_details_details.js"></script>
    <script src="nodes/cano_device_details_vars.js"></script>
    <script src="nodes/cano_devices_page.js"></script>
    <script src="nodes/cano_devices_sidebar.js"></script>
    <script src="nodes/cano_devices_create.js"></script>
    <script src="nodes/cano_account_dropdown.js"></script>
    <script src="nodes/cano_device_no_devices_msg.js"></script>
    <script src="nodes/cano_editable.js"></script>
    <script src="nodes/cano_main_page.js"></script>
    <script src="nodes/cano_option.js"></script>
    <script src="nodes/cano_switcher.js"></script>
    <script src="canoweb_dispatcher.js"></script>
    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,700|ABeeZee|Titillium+Web:200,300,400,700' rel='stylesheet' type='text/css'>
    <link href='canoweb.css' rel='stylesheet' type='text/css'>
</head>

<body style='min-width: 800px; background:#ffffff'>

<div id=main></div>

</body>
<script>

var canopy = new CanopyClient({
    "cloud-host" : "dev02.canopy.link",
    "http-port" : 80
});

canopy.OnReady(function() {
    urlParams = CanopyUtil_GetURLParams();

    canopy.ActivateAccount({
        username: urlParams["username"],
        code: urlParams["code"],
        onSuccess: function() {
            window.location.replace("index_new.html?activated=true");
        },
        onError: function() {
            alert("Error activating account");
            //window.location.replace("login.html");
        }
    });
});
</script>
<commit_msg>More work on account activation flow<commit_after><!DOCTYPE html>
<!--
Possibilities:

1) Already logged in.
    - Activate acct
    - Redirect to index_new.html
    - Display message saying account has been activated.

2) Not logged in.
    - Show username
    - Ask for password
    - Then sign them in and redirect to index_new.html

3) Signed in as a different user:
    - Ask for password
    - Display message about how activating the account will switch who is
    signed in.
-->
<html>

<head>
    <title>Canopy - An Open Source Platform for the Internet of Things</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="canopy-js-client/canopy.js"></script>
    <script src="canopy_app_util.js"></script>
    <script src="nodes/cano.js"></script>
    <script src="nodes/cano_topbar.js"></script>
    <script src="nodes/cano_account_page.js"></script>
    <script src="nodes/cano_account_sidebar.js"></script>
    <script src="nodes/cano_device_list.js"></script>
    <script src="nodes/cano_device_details.js"></script>
    <script src="nodes/cano_device_details_details.js"></script>
    <script src="nodes/cano_device_details_vars.js"></script>
    <script src="nodes/cano_devices_page.js"></script>
    <script src="nodes/cano_devices_sidebar.js"></script>
    <script src="nodes/cano_devices_create.js"></script>
    <script src="nodes/cano_account_dropdown.js"></script>
    <script src="nodes/cano_device_no_devices_msg.js"></script>
    <script src="nodes/cano_editable.js"></script>
    <script src="nodes/cano_main_page.js"></script>
    <script src="nodes/cano_option.js"></script>
    <script src="nodes/cano_switcher.js"></script>
    <script src="canoweb_dispatcher.js"></script>
    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,700|ABeeZee|Titillium+Web:200,300,400,700' rel='stylesheet' type='text/css'>
    <link href='canoweb.css' rel='stylesheet' type='text/css'>
</head>

<body style='min-width: 800px; background:#ffffff'>

<div class='main-outer' id=main>
    <div class='topbar'>
        <div class='topbar-inner'>
            <div class='topbar-left-part noselect'>
                <a href='http://canopy.link'><div class='topbar-logo'>Canopy</div></a>
            </div>
            <div class='topbar-middle-part w400' style='color:#000000'>
                Device Manager for 172.16.31.10
            </div>
            <div class='topbar-right-part' style='width:200px;'>&nbsp;
            </div>
        </div>
    </div>
    <div style='height:58px;'>&nbsp;</div>
   
    <div class='centered' style='background:#f0f0f0; padding-top:30px'>
        <div style='display:inline-block; text-align:left'>
            <br><br><div class='l'>Activate Your Account</div>
            
            <div id=activate_current_username></div>

            <table cellpadding=16>
                <tr>
                    <td>Username: </td>
                    <td><b id=activate_username></b></td>
                </tr>
                <tr>
                    <td>Password: </td>
                    <td><input id=activate_password type=password></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type=submit id=activate_btn value='Activate'></td>
                </tr>
            </table>

            <br><br></input>
            <br>
            <br>
            <br>
            <br>
        </div>
    </div>
    

    <center class=bg-blue-gradient style='padding-top:00px; padding-bottom:30px' >
        <table width=800>
            <tr>
                <td valign=bottom>
                    <img style='position: relative; top:15px;' class=frontpage-cloudplug-img src=http://canopy.link/images/cloud_circuit_h256.png></img>
                </td>
                <td valign=center>
                    <div class='l' style=''>Canopy Device Manager</div>
                    <ul>
                        <li>Monitor, control and share your Canopy-enabled devices.</li>
                        <li>Advanced administrative tools for device makers.</li>
                        <li>100% open source.</li>
                    </ul>
                </td>
            </tr>
        </table>
        <div style='font-size: 16px'>
            Twitter:
            <a target=_blank style='color:#ffff80; font-weight:400;' href='http://twitter.com/CanopyIoT'>
                @CanopyIoT
            </a>
            <div style='display:inline-block; width:50px'></div>
            Email:
            <a target=_blank style='color:#ffff80; font-weight:400;' href='mailto:<EMAIL>'>
                <EMAIL>
            </a>
            <div style='display:inline-block; width:50px'></div>
            GitHub:
            <a target=_blank style='color:#ffff80; font-weight:400;' href='http://github.com/canopy-project'>
                github.com/canopy-project
            </a>
            <div style='display:inline-block; width:50px'></div>
            Forum
            <a target=_blank style='color:#ffff80; font-weight:400;' href='http://canopy.lefora.com'>
                canopy.lefora.com
            </a>
        </div>
    </center>

    <center>
            <br><div style='font-size:16px'>Copyright 2014 SimpleThings, Inc.</div>
    </center>
</div>

</body>
<script>

var canopy = new CanopyClient({
    "cloud-host" : "dev02.canopy.link",
    "http-port" : 80
});

canopy.OnReady(function() {
    urlParams = CanopyUtil_GetURLParams();
    $("#activate_username").html(urlParams["username"]);

    $("#activate_btn").off('click').on('click', function() {
        // sign in as new user
        canopy.Login({
            "username" : urlParams["username"],
            "password" : $("#activate_password").val(),
            onSuccess: function() {
                canopy.ActivateAccount({
                    "username" : urlParams["username"],
                    "code" : urlParams["code"],
                    onSuccess: function() {
                        window.location.replace("index_new.html?activated=true");
                    }
                });
            },
            onError: function() {
            }
        });
    });

    if (canopy.IsLoggedIn()) {
        if (canopy.me.Username().value != urlParams["username"]) {
            $("#activate_current_username").html("<div style='width:400px; font-size:14px;'>\
                <br>You are currently signed in as <b>" + canopy.me.Username().value + "</b>.\
                By clicking <b>Activate</b> you will be signed out and signed in as <b>" + urlParams['username'] + "</b>.<br></div>");
            return;
        }
    }

    canopy.ActivateAccount({
        username: urlParams["username"],
        code: urlParams["code"],
        onSuccess: function() {
            window.location.replace("index_new.html?activated=true");
        },
        onError: function() {
            //window.location.replace("login.html");
        }
    });
});
</script>

{'fraction_non_alphanumeric': 0.15945637514264965, 'fraction_numerical': 0.016599232285506794, 'mean_word_length': 2.386020372321742, 'pattern_counts': {'":': 0, '<': 229, '<?xml version=': 0, '>': 229, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1943757', 'n_tokens_mistral': 3125, 'n_tokens_neox': 2912, 'n_words': 542}