<commit_before>﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Poll_Demo.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Beebotte Poll Demo</title>
       <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <link href="Content/bootstrap.css" rel="stylesheet" />
    
    <script src="Scripts/bootstrap.js"></script>
      <script src="http://cdn.socket.io/socket.io-1.1.0.js"></script>
  <script src="Scripts//bbt.js"></script>
    <script>
        var bbt;
        var optionsTotal = [0, 0, 0, 0];
        $(document).ready(function () {
            bbt = new BBT('502b09f9113252ba91d0fa24b2e69c1e', { ws_host: 'beebotte.com', auth_endpoint: '/api/authentications/bbt' });
            bbt.subscribe({ channel: 'Poll', resource: 'Q2', read: true, write: true }, function (message) {
                optionsTotal[message.data -1] += 1;
                updateResults();
            });
            GetResults();
        });

        function GetResults() {
            bbt.read({ owner: 'beebotte', channel: 'Poll', resource: 'Q2', limit: 10000 }, function (err, msg) {
                $(jQuery.parseJSON(JSON.stringify(msg))).each(function () {
                    optionsTotal[this.data - 1] += 1;
                });
                updateResults();
            });
        }

        function updateResults() {
            var total = 0;
            $(optionsTotal).each(function () {
                total += this;
            });
            if (total > 0) {
                $("#option1Perc").html(optionsTotal[0] + " votes");
                $("#option2Perc").html(optionsTotal[1] + " votes");
                $("#option3Perc").html(optionsTotal[2] + " votes");
                $("#option4Perc").html(optionsTotal[3] + " votes");

                $("#option1bar").html((optionsTotal[0] * 100 / total).toFixed(2) + "%");
                $("#option2bar").html((optionsTotal[1] * 100 / total).toFixed(2) + "%");
                $("#option3bar").html((optionsTotal[2] * 100 / total).toFixed(2) + "%");
                $("#option4bar").html((optionsTotal[3] * 100 / total).toFixed(2) + "%");

                $("#option1bar").width((optionsTotal[0] * 100 / total).toFixed(2) + "%");
                $("#option2bar").width((optionsTotal[1] * 100 / total).toFixed(2) + "%");
                $("#option3bar").width((optionsTotal[2] * 100 / total).toFixed(2) + "%");
                $("#option4bar").width((optionsTotal[3] * 100 / total).toFixed(2) + "%");
            }
        }
<commit_msg>Update Default.aspx<commit_after>﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Poll_Demo.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Beebotte Poll Demo</title>
       <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <link href="Content/bootstrap.css" rel="stylesheet" />
    
    <script src="Scripts/bootstrap.js"></script>
      <script src="http://cdn.socket.io/socket.io-1.1.0.js"></script>
  <script src="Scripts//bbt.js"></script>
    <script>
        var bbt;
        var optionsTotal = [0, 0, 0, 0];
        $(document).ready(function () {
            bbt = new BBT('502b09f9113252ba91d0fa24b2e69c1e', { ws_host: 'beebotte.com', auth_endpoint: '/api/authentications/bbt' });
            bbt.subscribe({ channel: 'Poll', resource: 'Q2', read: true, write: true }, function (message) {
                optionsTotal[message.data -1] += 1;
                updateResults();
            });
            GetResults();
        });

        function GetResults() {
            bbt.read({ owner: 'beebotte', channel: 'Poll', resource: 'Q2', limit: 750 }, function (err, msg) {
                $(jQuery.parseJSON(JSON.stringify(msg))).each(function () {
                    optionsTotal[this.data - 1] += 1;
                });
                updateResults();
            });
        }

        function updateResults() {
            var total = 0;
            $(optionsTotal).each(function () {
                total += this;
            });
            if (total > 0) {
                $("#option1Perc").html(optionsTotal[0] + " votes");
                $("#option2Perc").html(optionsTotal[1] + " votes");
                $("#option3Perc").html(optionsTotal[2] + " votes");
                $("#option4Perc").html(optionsTotal[3] + " votes");

                $("#option1bar").html((optionsTotal[0] * 100 / total).toFixed(2) + "%");
                $("#option2bar").html((optionsTotal[1] * 100 / total).toFixed(2) + "%");
                $("#option3bar").html((optionsTotal[2] * 100 / total).toFixed(2) + "%");
                $("#option4bar").html((optionsTotal[3] * 100 / total).toFixed(2) + "%");

                $("#option1bar").width((optionsTotal[0] * 100 / total).toFixed(2) + "%");
                $("#option2bar").width((optionsTotal[1] * 100 / total).toFixed(2) + "%");
                $("#option3bar").width((optionsTotal[2] * 100 / total).toFixed(2) + "%");
                $("#option4bar").width((optionsTotal[3] * 100 / total).toFixed(2) + "%");
            }
        }

{'fraction_non_alphanumeric': 0.19996158278908951, 'fraction_numerical': 0.039953899346907414, 'mean_word_length': 2.1538461538461537, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '2448249', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1597, 'n_words': 243}