<commit_before>var Web3Utility = require('./js/Web3Utility.js');
var Config = require('./js/Config.js');
var Buffer = Web3Utility.Buffer;
var async = require('async');
var CookieUtility = require("./js/CookieUtility.js");
var Crypto = require("./js/Crypto.js");


//** Globals ** //

var web3 = Web3Utility.initWeb3(window.web3);
var ipfs = Web3Utility.initIpfs();
var registryContract;
var userAccount;
var scanner;

//**  ** //

main();

function main() {
    initUi();

    initClickListeners();

    initUserInfo();

    loadData();
}

function mockAuthorize() {
    var data = {
        publicKey: "",
        name: "<NAME>",
        permissions: [
            "name", "city"
        ]

    };
    showAuthorizationDialog(data);
}

function initUi() {
    initScanner();
    loadTemplate(Config.baseUrl + '/html/' + 'profile.ejs', 'profileContainer', {});
}

function initScanner() {
    loadTemplate(Config.baseUrl + '/html/' + 'scanner.ejs', 'scannerContainer', {});

    beginScanner();
}

function beginScanner() {
    var opts = {
        continuous: true,
        video: document.getElementById('preview'),
        mirror: true,
        captureImage: false,
        backgroundScan: false,
        refractoryPeriod: 5000,
        scanPeriod: 1
    };

    scanner = new Instascan.Scanner(opts);
    scanner.addListener('scan', function (content) {
        console.log(content);
        try {
            var data = JSON.parse(content);
            showAuthorizationDialog(data);
        } catch(e) {
            console.log(e);
        }
    });

    Instascan.Camera.getCameras().then(function (cameras) {
        if (cameras.length > 0) {
            console.log(cameras.length + ' cameras found.');
            scanner.start(cameras[0]);
        } else {
            console.error('No cameras found.');
        }
    }).catch(function (e) {
        console.error(e);
    });<commit_msg>camera<commit_after>var Web3Utility = require('./js/Web3Utility.js');
var Config = require('./js/Config.js');
var Buffer = Web3Utility.Buffer;
var async = require('async');
var CookieUtility = require("./js/CookieUtility.js");
var Crypto = require("./js/Crypto.js");


//** Globals ** //

var web3 = Web3Utility.initWeb3(window.web3);
var ipfs = Web3Utility.initIpfs();
var registryContract;
var userAccount;
var scanner;

//**  ** //

main();

function main() {
    initUi();

    initClickListeners();

    initUserInfo();

    loadData();
}

function mockAuthorize() {
    var data = {
        publicKey: "",
        name: "<NAME>",
        permissions: [
            "name", "city"
        ]

    };
    showAuthorizationDialog(data);
}

function initUi() {
    initScanner();
    loadTemplate(Config.baseUrl + '/html/' + 'profile.ejs', 'profileContainer', {});
}

function initScanner() {
    loadTemplate(Config.baseUrl + '/html/' + 'scanner.ejs', 'scannerContainer', {});

    beginScanner();
}

function beginScanner() {
    // var opts = {
    //     continuous: true,
    //     video: document.getElementById('preview'),
    //     mirror: true,
    //     captureImage: false,
    //     backgroundScan: false,
    //     refractoryPeriod: 5000,
    //     scanPeriod: 1
    // };
    //
    // scanner = new Instascan.Scanner(opts);
    // scanner.addListener('scan', function (content) {
    //     console.log(content);
    //     try {
    //         var data = JSON.parse(content);
    //         showAuthorizationDialog(data);
    //     } catch(e) {
    //         console.log(e);
    //     }
    // });
    //
    // Instascan.Camera.getCameras().then(function (cameras) {
    //     if (cameras.length > 0) {
    //         console.log(cameras.length + ' cameras found.');
    //         scanner.start(cameras[0]);
    //     } else {
    //         console.error('No cameras found.');
    //     }
    // }).catch(function (e) {
    //     console.error(e);
    // });

    var video = document.getElementById('preview');

    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
        // Not adding `{ audio: true }` since we only want video now
        navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
            video.src = window.URL.createObjectURL(stream);
            video.play();
        });
    }
{'fraction_non_alphanumeric': 0.16538011695906432, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 2.2691131498470947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3028333', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1324, 'n_words': 245}