<commit_before> (function() {

    /* insert the MathJax script dynamically into the document */
    /* also insert a fix for Google+, until fixed upstream in MathJax */
  function insertScript(doc) {

        var googleFix = '.MathJax .mn {background: inherit;} .MathJax .mi {color: inherit;} .MathJax .mo {background: inherit;}';
        var style = doc.createElement('style');
        style.innerText = googleFix;
        try {
            style.textContent = googleFix;
        } catch(e) {}
        doc.getElementsByTagName('body')[0].appendChild(style);

        var script = doc.createElement('script'), config;

        /* see http://www.mathjax.org/resources/faqs/#problem-https */
        script.src = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML.js';
        script.type = 'text/javascript';

        /* see http://docs.mathjax.org/en/v1.1-latest/options/tex2jax.html */
        config = 'MathJax.Ajax.config.path[\'Contrib\']=\'//cdn.mathjax.org/mathjax/contrib\';MathJax.Hub.Config({extensions:[\'[Contrib]/xyjax/xypic.js\'], tex2jax:{inlineMath:[[\'$\',\'$\'],[\'$$\', \'$$\']],displayMath:[[\'\\\\[\',\'\\\\]\']],processEscapes:true},TeX:{extensions: [\'ypic.js\']}});MathJax.Hub.Startup.onload();';

        if (window.opera) script.innerHTML = config; else script.text = config;

        doc.getElementsByTagName('head')[0].appendChild(script);
    }

    /* execute MathJax for given window */
    function executeMathJax(win) {
        if (win.MathJax === undefined) {
            /* insert the script into document if MathJax global doesn't exist for given window */
            insertScript(win.document);
        } else {
            /* using win.Array instead of [] to get 'instanceof Array' check working inside iframe */
            /* see http://www.mathjax.org/docs/1.1/typeset.html */
            win.MathJax.Hub.Queue(new win.Array('Typeset', win.MathJax.Hub));
        }
    }

    var frames = document.getElementsByTagName('iframe'), index, win;

    /* execute MathJax on the window object */
    executeMathJax(window);

    /* try to execute MathJax on every iframe */
    for (index = 0; index < frames.length; index++) {
        /* find the iframe's window object */
        win = frames[index].contentWindow || frames[index].contentDocument;
        if (!win.document) win = win.parentNode;

        executeMathJax(win);
    }
})();
<commit_msg>Formatting<commit_after>(function() {

    /* insert the MathJax script dynamically into the document */
    /* also insert a fix for Google+, until fixed upstream in MathJax */
  function insertScript(doc) {

        var googleFix = '.MathJax .mn {background: inherit;} .MathJax .mi {color: inherit;} .MathJax .mo {background: inherit;}';
        var style = doc.createElement('style');
        style.innerText = googleFix;
        try {
            style.textContent = googleFix;
        } catch(e) {}
        doc.getElementsByTagName('body')[0].appendChild(style);

        var script = doc.createElement('script'), config;

        /* see http://www.mathjax.org/resources/faqs/#problem-https */
        script.src = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML.js';
        script.type = 'text/javascript';

        /* see http://docs.mathjax.org/en/v1.1-latest/options/tex2jax.html */
        config = 'MathJax.Ajax.config.path[\'Contrib\']=\'//cdn.mathjax.org/mathjax/contrib\';MathJax.Hub.Config({extensions:[\'[Contrib]/xyjax/xypic.js\'], tex2jax:{inlineMath:[[\'$\',\'$\'],[\'$$\', \'$$\']],displayMath:[[\'\\\\[\',\'\\\\]\']],processEscapes:true},TeX:{extensions: [\'ypic.js\']}});MathJax.Hub.Startup.onload();';

        if (window.opera) script.innerHTML = config; else script.text = config;

        doc.getElementsByTagName('head')[0].appendChild(script);
    }

    /* execute MathJax for given window */
    function executeMathJax(win) {
        if (win.MathJax === undefined) {
            /* insert the script into document if MathJax global doesn't exist for given window */
            insertScript(win.document);
        } else {
            /* using win.Array instead of [] to get 'instanceof Array' check working inside iframe */
            /* see http://www.mathjax.org/docs/1.1/typeset.html */
            win.MathJax.Hub.Queue(new win.Array('Typeset', win.MathJax.Hub));
        }
    }

    var frames = document.getElementsByTagName('iframe'), index, win;

    /* execute MathJax on the window object */
    executeMathJax(window);

    /* try to execute MathJax on every iframe */
    for (index = 0; index < frames.length; index++) {
        /* find the iframe's window object */
        win = frames[index].contentWindow || frames[index].contentDocument;
        if (!win.document) win = win.parentNode;

        executeMathJax(win);
    }
})();
<|endoftext|>


<commit_before>/*
IRA - Interactive Relational Algebra Tool
Copyright (C) 2010-2012 Henrik Mühe

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
var professoren = new DataRelation(
"Professoren",
["PersNr", "Name", "Rang", "Raum"],
[
[2125, "Sokrates", "C4", 226],
[2126, "Russel", "C4", 232],
[2127, "Kopernikus", "C3", 310],
[2133, "Popper", "C3", 52],
[2134, "Augustinus", "C3", 309],
[2136, "Curie", "C4", 36],
[2137, "Kant", "C4", 7]
]
);

var studenten = new DataRelation(
"Studenten",
["MatrNr", "Name", "Semester"],
[
[24002, 'Xenokrates', 18],
[25403, 'Jonas', 12],
[26120, 'Fichte', 10],
[26830, 'Aristoxenos', 8],
[27550, 'Schopenhauer', 6],
[28106, 'Carnap', 3],
[29120, 'Theophrastos', 2],
[29555, 'Feuerbach', 2]
]
);

var assistenten = new DataRelation(
"Assistenten",
["PersNr", "Name", "Fachgebiet", "Boss"],
[
[3002, 'Platon', 'Ideenlehre', 2125],
[3003, 'Aristoteles', 'Syllogistik', 2125],
[3004, 'Wittgenstein', 'Sprachtheorie', 2126],
[3005, 'Rhetikus', 'Planetenbewegung', 2127],
[3006, 'Newton', 'Keplersche Gesetze', 2127],
[3007, 'Spinoza', 'Gott und Natur', 2134]
]
);

var vorlesungen = new DataRelation(
"Vorlesungen",
["VorlNr", "Titel", "SWS", "gelesenVon"],
[
[5001, 'Grundzuege', 4, 2137],
[5041, 'Ethik', 4, 2125],
[5043, 'Erkenntnistheorie', 3, 2126],
[5049, 'Maeeutik', 2, 2125],
[4052, 'Logik', 4, 2125],
[5052, 'Wissenschaftstheorie', 3, 2126],
[5216, 'Bioethik', 2, 2126],
[5259, 'Der Wiener Kreis', 2, 2133],
[5022, 'Glaube und Wissen', 2, 2134],
[4630, 'Die 3 Kritiken', 4, 2137]
]
);

var hoeren = new DataRelation(
"hoeren",
["MatrNr", "VorlNr"],
[
[26120, 5001],
[27550, 5001],
[27550, 4052],
[28106, 5041],
[28106, 5052],
[28106, 5216],
[28106, 5259],
[29120, 5001],
[29120, 5041],
[29120, 5049],
[29555, 5022],
[25403, 5022],
//[29555, 5001]
]
);

var voraussetzen = new DataRelation(
"voraussetzen",
["Vorgaenger", "Nachfolger"],
[
[5001, 5041],
[5001, 5043],
[5001, 5049],
[5041, 5216],
[5043, 5052],
[5041, 5052],
[5052, 5259]
]
);

var pruefen = new DataRelation(
"pruefen",
["MatrNr", "VorlNr", "PersNr", "Note"],
[
[28106, 5001, 2126, 1.0],
[25403, 5041, 2125, 2.0],
[27550, 4630, 2137, 2.0]
]
);

var zehnkampf = new DataRelation(
"Zehnkampf",
["Name","Punkte"],
[
["Eaton",8869],
["Suarez",8523],
["Behrenbruch",8126],
["Hardee",8671],
["Sebrle",8869]
]
);
<commit_msg>Added missing tuple in relation 'hoeren'.<commit_after>/*
IRA - Interactive Relational Algebra Tool
Copyright (C) 2010-2012 Henrik Mühe

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
var professoren = new DataRelation(
"Professoren",
["PersNr", "Name", "Rang", "Raum"],
[
[2125, "Sokrates", "C4", 226],
[2126, "Russel", "C4", 232],
[2127, "Kopernikus", "C3", 310],
[2133, "Popper", "C3", 52],
[2134, "Augustinus", "C3", 309],
[2136, "Curie", "C4", 36],
[2137, "Kant", "C4", 7]
]
);

var studenten = new DataRelation(
"Studenten",
["MatrNr", "Name", "Semester"],
[
[24002, 'Xenokrates', 18],
[25403, 'Jonas', 12],
[26120, 'Fichte', 10],
[26830, 'Aristoxenos', 8],
[27550, 'Schopenhauer', 6],
[28106, 'Carnap', 3],
[29120, 'Theophrastos', 2],
[29555, 'Feuerbach', 2]
]
);

var assistenten = new DataRelation(
"Assistenten",
["PersNr", "Name", "Fachgebiet", "Boss"],
[
[3002, 'Platon', 'Ideenlehre', 2125],
[3003, 'Aristoteles', 'Syllogistik', 2125],
[3004, 'Wittgenstein', 'Sprachtheorie', 2126],
[3005, 'Rhetikus', 'Planetenbewegung', 2127],
[3006, 'Newton', 'Keplersche Gesetze', 2127],
[3007, 'Spinoza', 'Gott und Natur', 2134]
]
);

var vorlesungen = new DataRelation(
"Vorlesungen",
["VorlNr", "Titel", "SWS", "gelesenVon"],
[
[5001, 'Grundzuege', 4, 2137],
[5041, 'Ethik', 4, 2125],
[5043, 'Erkenntnistheorie', 3, 2126],
[5049, 'Maeeutik', 2, 2125],
[4052, 'Logik', 4, 2125],
[5052, 'Wissenschaftstheorie', 3, 2126],
[5216, 'Bioethik', 2, 2126],
[5259, 'Der Wiener Kreis', 2, 2133],
[5022, 'Glaube und Wissen', 2, 2134],
[4630, 'Die 3 Kritiken', 4, 2137]
]
);

var hoeren = new DataRelation(
"hoeren",
["MatrNr", "VorlNr"],
[
[26120, 5001],
[27550, 5001],
[27550, 4052],
[28106, 5041],
[28106, 5052],
[28106, 5216],
[28106, 5259],
[29120, 5001],
[29120, 5041],
[29120, 5049],
[29555, 5022],
[25403, 5022],
[29555, 5001]
]
);

var voraussetzen = new DataRelation(
"voraussetzen",
["Vorgaenger", "Nachfolger"],
[
[5001, 5041],
[5001, 5043],
[5001, 5049],
[5041, 5216],
[5043, 5052],
[5041, 5052],
[5052, 5259]
]
);

var pruefen = new DataRelation(
"pruefen",
["MatrNr", "VorlNr", "PersNr", "Note"],
[
[28106, 5001, 2126, 1.0],
[25403, 5041, 2125, 2.0],
[27550, 4630, 2137, 2.0]
]
);

var zehnkampf = new DataRelation(
"Zehnkampf",
["Name","Punkte"],
[
["Eaton",8869],
["Suarez",8523],
["Behrenbruch",8126],
["Hardee",8671],
["Sebrle",8869]
]
);
<|endoftext|>


<commit_before>
'use strict';

const _ = require('lodash');
const Script = require('smooch-bot').Script;

const scriptRules = require('./script.json');

var myDate = new Date();
var groet = '';

/* hour is before noon */
if ( myDate.getHours() < 12 )
{
groet = "Goeiemorgen";
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 12 && myDate.getHours() <= 17 )
{
groet = "Goedendag";
}
else  /* the hour is after 5pm, so it is between 6pm and midnight */
if ( myDate.getHours() > 17 && myDate.getHours() <= 24 )
{
groet = "Goedenavond";
}
else
if (myDate.getHours() <=8  || myDate.getHours() > 20 )
{
  groet = 'Goedenavond, bedankt voor je bezoek. Op dit moment is Independer echter gesloten. Uiteraard kun je met onze IndyBot praten maar er is helaas niemand die jouw vraag specifiek kan beantwoorden. Je kan je vraag ook doormailen naar info@independer. Dan komt het altijd goed.';
}
else  /* the hour is not between 0 and 24, so something is wrong */
{
groet = "Welkom";
}

function wait(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

module.exports = new Script({

 processing: {
//prompt: (bot) => bot.say('...'),
 receive: () => 'processing'
 },

start: {
    receive: (bot,message) => {
        const opening = message.text.trim().toUpperCase();
        return bot.say(`${groet}... Wat voor soort hypotheek zoek je? `)
        .then(() => bot.say(`![]('http://www.bieg.nl/beeld/appartement.jpg')`))
        .then(() => bot.say(`%[Starters hypotheek](postback:hypotheektype_starter) %[Nieuwe hypotheek](postback:hypotheektype_nieuw) %[Hypotheek oversluiten](postback:hypotheektype_oversluiten)`))
        .then(() => 'selecteerHypotheek');
    }
},

selecteerHypotheek: {
    receive: (bot, message) => {
      switch(message.text) {
      case 'Hoi':
            return bot.say(`${groet} waar ben je naar op zoek? %[Starters hypotheek](postback:hypotheektype_starter) %[Nieuwe hypotheek](postback:hypotheektype_nieuw) %[Hypotheek oversluiten](postback:hypotheektype_oversluiten)`)
            .then(() => 'askName')
          break;
      case 'Starters hypotheek':
      //prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)

          return bot.say(`Wat voor type woning zoek je? `)
          .then(() => bot.say(`%[Appartement](postback:hypotheekkeuze_appartement) %[Huis](postback:hypotheekkeuze_huis) %[Vakantiewoning](postback:hypotheekkeuze_vakantiewoning)`))
          .then(() => 'hypotheek_starter')
              break;
        case 'Nieuwe hypotheek':
          return bot.say(`Helaas biedt Independer momenteel alleen Starters een hypotheek aan.`)
          .then(() => bot.say(`Via onderstaande link kun je de beste hypotheekadviseur voor jou vinden. %[Hypotheek Adviseur](https://www.independer.nl/hypotheekadviseur/intro.aspx)`))
            .then(() => 'finish')
          break;
        case 'Hypotheek oversluiten':
          return bot.say(`Het spijt me maar op dit moment biedt Independer alleen  Starters een hypotheek.`)
          .then(()=> bot.say(`Als het allemaal wel zo ver is, wil je dan een update ontvangen? %[Ja - graag](postback:update_ja) %[Nee,bedankt](postback:update_nee)`))
            .then(() => 'updateOntvangen')
          break;
        default:
          return bot.say(`...`)
            .then(() => 'processing')
          break;
      }
    }
},

updateOntvangen: {
    receive: (bot, message) => {
      switch(message.text) {
        case 'Ja - graag':
            return bot.say(`Leuk, dan houd ik  je op de hoogte zodra er weer nieuws is.`)
            .then(() => 'update_ja');
          break;
          case 'Nee, bedankt':
              receive: () => 'bye'
              break;
          default:
            return bot.say('...')
              .then(() => 'processing')
            break;
}
}
},

update_ja: {
  prompt: (bot) => bot.say('Wat is je email adres?'),
      receive: (bot, message) => {
          const emailVisitor=message.text.trim();
          return bot.setProp('emailVisitor', emailVisitor)
              .then(()  => bot.say(`Ok - dan hou ik je via ${emailVisitor} op de hoogte.`))
              .then(()  =>'lastCheck')
    }
},
update_nee: {
  receive: () => 'bye'
},

hypotheekkeuze_appartement: {
receive: (bot,message)  => {
    //  prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)
    receive: () => 'askName'
}
},
hypotheekkeuze_huis: {
//    prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)
  receive: () => 'askName'
},
hypotheekkeuze_vakantiewoning: {
//    prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)
    receive: () => 'askName'
},
hypotheektype_starter: {
    prompt: (bot) => bot.say('Pleasure meeting you - starter'),
    receive: () => 'processing'
},
hypotheektype_nieuw: {
    prompt: (bot) => bot.say('Independer biedt momenteel alleen voor Starters een hypotheek. Onderstaande link bied je meer informatie %[Hypotheek Adviseur](https://www.independer.nl/hypotheekadviseur/intro.aspx)'),
    receive: () => 'processing'
},

askName: {
  receive: (bot, message) => {
    switch(message.text) {
        case 'Appartement':
          return bot.say(`Nice!`)
          .then(() => 'vervolgVragen')
          break;
      case 'Huis':
          return bot.say(`Leuk :)`)
          .then(() => 'vervolgVragen')
          break;
      default:
        return bot.say(`...`)
          .then(() => 'processing')
        break;
        }
    }
},

vervolgVragen: {
  prompt: (bot) => bot.say('Hoe heet je eigelijk? Dat maakt het praten een stuk makkelijker...'),
  receive: (bot, message) => {
      const name = message.text;
      return bot.setProp('name', name)
          .then(() => bot.say(`Hoi ${name}. Ik heb nog wat vragen voor je om verder te kunnen.`))
          .then(() => 'lastCheck');
    }
},

lastCheck: {
    prompt: (bot) => bot.say('Is er nog iets waar ik  je bij kan helpen?  %[Ja](postback:speak) %[Nee](postback:bye)'),
          receive: (bot, message) => {
            switch(message.text) {
              case 'Nee hoor':
                  receive: ()  => 'bye'
                  break;
             case 'Ja':
                  receive: () => 'speak'
                  break;
            case 'Nee':
                  receive: () => 'bye'
                  break;
            default:
              return bot.say(`...`)
                .then(() => 'processing')
              break;
            }
        }
},

bye: {
    prompt: (bot) => bot.say('Fijn je gesproken te hebben. Bedankt voor je tijd'),
    receive: ()  => 'finish'
},

// error: {
// prompt: (bot) => bot.say('Sorry - kun je dat nog eens zeggen?  Er ging iets mis...'),
// receive: () => ''
// },

finish: {
receive: () => 'finish'
},

  speak: {
          receive: (bot, message) => {

              let upperText = message.text.trim().toUpperCase();

              function updateSilent() {
                  switch (upperText) {
                      case "CONNECT ME":
                          return bot.setProp("silent", true);
                      case "DISCONNECT":
                          return bot.setProp("silent", false);
                      default:
                          return Promise.resolve();
                  }
              }

              function getSilent() {
                  return bot.getProp("silent");
              }

              function processMessage(isSilent) {
                  if (isSilent) {
                      return Promise.resolve("speak");
                  }

                  if (!_.has(scriptRules, upperText)) {
                      return bot.say(`So, I'm good at structured conversations but stickers, emoji and sentences still confuse me. Say 'more' to chat about something else.`).then(() => 'speak');
                  }

                  var response = scriptRules[upperText];
                  var lines = response.split('\n');

                  var p = Promise.resolve();
                  _.each(lines, function(line) {
                      line = line.trim();
                      p = p.then(function() {
                          console.log(line);
                          return wait(50).then(function() {
                              return bot.say(line);
                          });
                      });
                  });

                  return p.then(() => 'speak');
              }

              return updateSilent()
                  .then(getSilent)
                  .then(processMessage);
          }
      }
});
<commit_msg>daw<commit_after>
'use strict';

const _ = require('lodash');
const Script = require('smooch-bot').Script;

const scriptRules = require('./script.json');

var myDate = new Date();
var groet = '';

/* hour is before noon */
if ( myDate.getHours() < 12 )
{
groet = "Goeiemorgen";
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 12 && myDate.getHours() <= 17 )
{
groet = "Goedendag";
}
else  /* the hour is after 5pm, so it is between 6pm and midnight */
if ( myDate.getHours() > 17 && myDate.getHours() <= 24 )
{
groet = "Goedenavond";
}
else
if (myDate.getHours() <=8  || myDate.getHours() > 20 )
{
  groet = 'Goedenavond, bedankt voor je bezoek. Op dit moment is Independer echter gesloten. Uiteraard kun je met onze IndyBot praten maar er is helaas niemand die jouw vraag specifiek kan beantwoorden. Je kan je vraag ook doormailen naar info@independer. Dan komt het altijd goed.';
}
else  /* the hour is not between 0 and 24, so something is wrong */
{
groet = "Welkom";
}

function wait(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

module.exports = new Script({

 processing: {
//prompt: (bot) => bot.say('...'),
 receive: () => 'processing'
 },

start: {
    receive: (bot,message) => {
        const opening = message.text.trim().toUpperCase();
        return bot.say(`${groet}... Wat voor soort hypotheek zoek je? `)
        .then(() => bot.say(`![]('http://www.bieg.nl/beeld/woningen.jpg')`))
        .then(() => bot.say(`%[Starters hypotheek](postback:hypotheektype_starter) %[Nieuwe hypotheek](postback:hypotheektype_nieuw) %[Hypotheek oversluiten](postback:hypotheektype_oversluiten)`))
        .then(() => 'selecteerHypotheek');
    }
},

selecteerHypotheek: {
    receive: (bot, message) => {
      switch(message.text) {
      case 'Hoi':
            return bot.say(`${groet} waar ben je naar op zoek? %[Starters hypotheek](postback:hypotheektype_starter) %[Nieuwe hypotheek](postback:hypotheektype_nieuw) %[Hypotheek oversluiten](postback:hypotheektype_oversluiten)`)
            .then(() => 'askName')
          break;
      case 'Starters hypotheek':
      //prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)

          return bot.say(`Wat voor type woning zoek je? `)
          .then(() => bot.say(`%[Appartement](postback:hypotheekkeuze_appartement) %[Huis](postback:hypotheekkeuze_huis) %[Vakantiewoning](postback:hypotheekkeuze_vakantiewoning)`))
          .then(() => 'hypotheek_starter')
              break;
        case 'Nieuwe hypotheek':
          return bot.say(`Helaas biedt Independer momenteel alleen Starters een hypotheek aan.`)
          .then(() => bot.say(`Via onderstaande link kun je de beste hypotheekadviseur voor jou vinden. %[Hypotheek Adviseur](https://www.independer.nl/hypotheekadviseur/intro.aspx)`))
            .then(() => 'finish')
          break;
        case 'Hypotheek oversluiten':
          return bot.say(`Het spijt me maar op dit moment biedt Independer alleen  Starters een hypotheek.`)
          .then(()=> bot.say(`Als het allemaal wel zo ver is, wil je dan een update ontvangen? %[Ja - graag](postback:update_ja) %[Nee,bedankt](postback:update_nee)`))
            .then(() => 'updateOntvangen')
          break;
        default:
          return bot.say(`...`)
            .then(() => 'processing')
          break;
      }
    }
},

updateOntvangen: {
    receive: (bot, message) => {
      switch(message.text) {
        case 'Ja - graag':
            return bot.say(`Leuk, dan houd ik  je op de hoogte zodra er weer nieuws is.`)
            .then(() => 'update_ja');
          break;
          case 'Nee, bedankt':
              receive: () => 'bye'
              break;
          default:
            return bot.say('...')
              .then(() => 'processing')
            break;
}
}
},

update_ja: {
  prompt: (bot) => bot.say('Wat is je email adres?'),
      receive: (bot, message) => {
          const emailVisitor=message.text.trim();
          return bot.setProp('emailVisitor', emailVisitor)
              .then(()  => bot.say(`Ok - dan hou ik je via ${emailVisitor} op de hoogte.`))
              .then(()  =>'lastCheck')
    }
},
update_nee: {
  receive: () => 'bye'
},

hypotheekkeuze_appartement: {
receive: (bot,message)  => {
    //  prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)
    receive: () => 'askName'
}
},
hypotheekkeuze_huis: {
//    prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)
  receive: () => 'askName'
},
hypotheekkeuze_vakantiewoning: {
//    prompt: (bot) => bot.say(`![](http:www.bieg.nl/beeld/appartement.jpg)`)
    receive: () => 'askName'
},
hypotheektype_starter: {
    prompt: (bot) => bot.say('Pleasure meeting you - starter'),
    receive: () => 'processing'
},
hypotheektype_nieuw: {
    prompt: (bot) => bot.say('Independer biedt momenteel alleen voor Starters een hypotheek. Onderstaande link bied je meer informatie %[Hypotheek Adviseur](https://www.independer.nl/hypotheekadviseur/intro.aspx)'),
    receive: () => 'processing'
},

askName: {
  receive: (bot, message) => {
    switch(message.text) {
        case 'Appartement':
          return bot.say(`Nice!`)
          .then(() => 'vervolgVragen')
          break;
      case 'Huis':
          return bot.say(`Leuk :)`)
          .then(() => 'vervolgVragen')
          break;
      default:
        return bot.say(`...`)
          .then(() => 'processing')
        break;
        }
    }
},

vervolgVragen: {
  prompt: (bot) => bot.say('Hoe heet je eigelijk? Dat maakt het praten een stuk makkelijker...'),
  receive: (bot, message) => {
      const name = message.text;
      return bot.setProp('name', name)
          .then(() => bot.say(`Hoi ${name}. Ik heb nog wat vragen voor je om verder te kunnen.`))
          .then(() => 'lastCheck');
    }
},

lastCheck: {
    prompt: (bot) => bot.say('Is er nog iets waar ik  je bij kan helpen?  %[Ja](postback:speak) %[Nee](postback:bye)'),
          receive: (bot, message) => {
            switch(message.text) {
              case 'Nee hoor':
                  receive: ()  => 'bye'
                  break;
             case 'Ja':
                  receive: () => 'speak'
                  break;
            case 'Nee':
                  receive: () => 'bye'
                  break;
            default:
              return bot.say(`...`)
                .then(() => 'processing')
              break;
            }
        }
},

bye: {
    prompt: (bot) => bot.say('Fijn je gesproken te hebben. Bedankt voor je tijd'),
    receive: ()  => 'finish'
},

// error: {
// prompt: (bot) => bot.say('Sorry - kun je dat nog eens zeggen?  Er ging iets mis...'),
// receive: () => ''
// },

finish: {
receive: () => 'finish'
},

  speak: {
          receive: (bot, message) => {

              let upperText = message.text.trim().toUpperCase();

              function updateSilent() {
                  switch (upperText) {
                      case "CONNECT ME":
                          return bot.setProp("silent", true);
                      case "DISCONNECT":
                          return bot.setProp("silent", false);
                      default:
                          return Promise.resolve();
                  }
              }

              function getSilent() {
                  return bot.getProp("silent");
              }

              function processMessage(isSilent) {
                  if (isSilent) {
                      return Promise.resolve("speak");
                  }

                  if (!_.has(scriptRules, upperText)) {
                      return bot.say(`So, I'm good at structured conversations but stickers, emoji and sentences still confuse me. Say 'more' to chat about something else.`).then(() => 'speak');
                  }

                  var response = scriptRules[upperText];
                  var lines = response.split('\n');

                  var p = Promise.resolve();
                  _.each(lines, function(line) {
                      line = line.trim();
                      p = p.then(function() {
                          console.log(line);
                          return wait(50).then(function() {
                              return bot.say(line);
                          });
                      });
                  });

                  return p.then(() => 'speak');
              }

              return updateSilent()
                  .then(getSilent)
                  .then(processMessage);
          }
      }
});
<|endoftext|>


<commit_before>"use strict";

$(document).ready(function() {
  var web3 = new Web3();
  web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
  web3.eth.defaultAccount = web3.eth.accounts[0];

  var runkeeperContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"hash","type":"bytes32"},{"name":"resultHex","type":"bytes32"},{"name":"v","type":"uint8"},{"name":"r","type":"bytes32"},{"name":"s","type":"bytes32"}],"name":"settle","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"hash","type":"bytes32"}],"name":"getCommitment","outputs":[{"name":"factId","type":"uint256"},{"name":"factHash","type":"bytes32"},{"name":"amount","type":"uint256"},{"name":"owner","type":"address"},{"name":"defaultAccount","type":"address"},{"name":"oracle","type":"address"},{"name":"threshold","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"getMyCommitmentCount","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"factId","type":"uint256"},{"name":"factHash","type":"bytes32"},{"name":"defaultAccount","type":"address"},{"name":"oracle","type":"address"},{"name":"threshold","type":"uint256"}],"name":"makeCommitment","outputs":[{"name":"hash","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"i","type":"uint256"}],"name":"getMyCommitmentHash","outputs":[{"name":"","type":"bytes32"}],"type":"function"}]);

  var runkeeper = runkeeperContract.at("0x5fdef2af54a909fa431f78cca795052e9fb1aba7");

  $("#create").submit(function(event) {

    // Stop form from submitting normally
    event.preventDefault();

    var data = {
      user_id: $("#user_id").val(),
      activity: "running",
      measurement: "total_distance",
      comparison: "ge",
      goal: $("#meters").val(),
      settlement_date: $("#end_date").val(),
      objection_period_secs: "604800",
      accept_terms_of_service: "current",
      use_existing: "1"
    };

    $.post("https://www.realitykeys.com/api/v1/runkeeper/new", data);
  });
});
<commit_msg>Record commitment in the blockchain.<commit_after>"use strict";

$(document).ready(function() {
  var web3 = new Web3();
  web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
  web3.eth.defaultAccount = web3.eth.accounts[0];

  var runkeeperContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"hash","type":"bytes32"},{"name":"resultHex","type":"bytes32"},{"name":"v","type":"uint8"},{"name":"r","type":"bytes32"},{"name":"s","type":"bytes32"}],"name":"settle","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"hash","type":"bytes32"}],"name":"getCommitment","outputs":[{"name":"factId","type":"uint256"},{"name":"factHash","type":"bytes32"},{"name":"amount","type":"uint256"},{"name":"owner","type":"address"},{"name":"defaultAccount","type":"address"},{"name":"oracle","type":"address"},{"name":"threshold","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"getMyCommitmentCount","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"factId","type":"uint256"},{"name":"factHash","type":"bytes32"},{"name":"defaultAccount","type":"address"},{"name":"oracle","type":"address"},{"name":"threshold","type":"uint256"}],"name":"makeCommitment","outputs":[{"name":"hash","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"i","type":"uint256"}],"name":"getMyCommitmentHash","outputs":[{"name":"","type":"bytes32"}],"type":"function"}]);

  var runkeeper = runkeeperContract.at("0x5fdef2af54a909fa431f78cca795052e9fb1aba7");

  $("#create").submit(function(event) {

    // Stop form from submitting normally
    event.preventDefault();

    var meters = $("#meters").val();
    var defaultAccount = $("#default_account").val();

    var data = {
      user_id: $("#user_id").val(),
      activity: "running",
      measurement: "total_distance",
      comparison: "ge",
      goal: meters,
      settlement_date: $("#end_date").val(),
      objection_period_secs: "604800",
      accept_terms_of_service: "current",
      use_existing: "1"
    };

    $.post("https://www.realitykeys.com/api/v1/runkeeper/new", data, function(data) {
      console.log(data);
      var tx = runkeeper.makeCommitment(data.id, "0x" + data.signature_v2.fact_hash, defaultAccount, "0x" + data.signature_v2.ethereum_address, meters, {gas: 250000});
      console.log(tx);
    });
  });
});
<|endoftext|>


<commit_before>function github(path, method='GET', headers={}, body=null, respType='json') {
  var {token, user} = getData();
  sessionStorage.setItem('token', token);
  localStorage.setItem('github-username', user)
  return request('https://api.github.com/' + path, method, Object.assign(headers, {
    'Accept': 'application/vnd.github.v3+json',
    'Authorization': user + ':' + token
  }), body, respType);
}
function getData() {
  return {
    token: sessionStorage.getItem('token') || prompt('Please enter your github token'),
    user: localStorage.getItem('github-username') || prompt('Please enter you username')
  };
}
function request(url, method, headers, body, respType) {
  var xml = new XMLHttpRequest();
  return new Promise(function (resolve, reject) {
    xml.open(method.toUpperCase(), url);
    if (headers) {
      for (var i in headers) {
        var v = headers[i];
        xml.setRequestHeader(i, v);
      }
    }
    if (respType) {
      xml.responseType = respType;
    }
    xml.send(body);
    xml.onreadystatechange = function () {
      if (this.readyState == 4 && this.status == 200) {
        resolve(xml);
      }
    };
    xml.onerror = reject;
  });
}
<commit_msg>Delete script.js<commit_after><|endoftext|>


<commit_before>function Cube (element_id) {
	var DOM = document.getElementById(element_id);
	this.DOM = DOM;

	var sides = ['front','top','bottom','back','left','right'];

	for (i in sides) {this[sides[i]]=['z','-y','y','-z','-x','x'][i]}

	function fill () { // fill DOM cube sides with appropriate values
		for (i in sides) {
			var element = document.getElementById(sides[i]);
			var value = this[sides[i]];
			element.innerHTML=value;
			element.style.backgroundColor = get_random_color(value);
		}
	}
	this.fill = fill;

	function make (direction) {
	    rotate(direction)
	}
	this.make = make;

	function rotate (direction) {
		var t_angles = [0,0,0];
		switch (direction) {
	        case "top" : {
	            t_angles = convert_angles(1,0);
	        }; break;
	        case "bottom" : {
	            t_angles = convert_angles(-1,0);
	        }; break;
	        case "left" : {
	            t_angles = convert_angles(0,-1);
	        }; break;
	        case "right" : {
	            t_angles = convert_angles(0,1);
	        }; break;
	        default: throw new TypeError('direction must be "top", "bottom", "left" or "right", but not: "'+direction+'"');
	    };
		rotate3d(t_angles[0],t_angles[1],t_angles[2],90);
	}

	var coords = ['x','y','z']; // initial coord system

	function convert_angles (x,y) {
		var new_angles = [x,y,0];

		return new_angles;
	}

	function rotate3d(x,y,z,degree) {
		var matrix = new WebKitCSSMatrix(DOM.style.webkitTransform);
		matrix = matrix.rotateAxisAngle(x,y,z,degree);
		DOM.style.webkitTransform = matrix.toString();
	}
	rotate3d(-1,-1,0,30); // initial rotation

	return this;
}

var cube = new Cube('cube3d') // main cube object
cube.fill();

shortcut.add('up',function () {cube.make('top')});
shortcut.add('down',function () {cube.make('bottom')});
shortcut.add('left',function () {cube.make('left')});
shortcut.add('Right',function () {cube.make('right')});

function get_random_color (value) {
	Math.seedrandom(value);
    var color = 'rgba('+(Math.round(Math.random()*150)+55)+','+(Math.round(Math.random()*250)+5)+','+(Math.round(Math.random()*250)+5)+','+'.5)';
    Math.seedrandom();
    return color;
}<commit_msg>add console logs<commit_after>function Cube (element_id) {
	var DOM = document.getElementById(element_id);
	this.DOM = DOM;

	var sides = ['front','top','bottom','back','left','right'];

	for (i in sides) {this[sides[i]]=['z','-y','y','-z','-x','x'][i]}

	function fill () { // fill DOM cube sides with appropriate values
		for (i in sides) {
			var element = document.getElementById(sides[i]);
			var value = this[sides[i]];
			element.innerHTML=value;
			element.style.backgroundColor = get_random_color(value);
		}
	}
	this.fill = fill;

	function make (direction) {
	    rotate(direction)
	}
	this.make = make;

	function rotate (direction) {
		var t_angles = [0,0,0];
		console.group(direction);
		switch (direction) {
	        case "top" : {
	            t_angles = convert_angles(1,0);
	        }; break;
	        case "bottom" : {
	            t_angles = convert_angles(-1,0);
	        }; break;
	        case "left" : {
	            t_angles = convert_angles(0,-1);
	        }; break;
	        case "right" : {
	            t_angles = convert_angles(0,1);
	        }; break;
	        default: throw new TypeError('direction must be "top", "bottom", "left" or "right", but not: "'+direction+'"');
	    };
		rotate3d(t_angles[0],t_angles[1],t_angles[2],90);
	}

	var coords = ['x','y','z']; // initial coord system

	function convert_angles (x,y) {
		var new_angles = [x,y,0];
		console.log(x,y);
			console.log('coords before',coords);

			console.log('coords after',coords);
		console.groupEnd();
		return new_angles;
	}

	function rotate3d(x,y,z,degree) {
		var matrix = new WebKitCSSMatrix(DOM.style.webkitTransform);
		matrix = matrix.rotateAxisAngle(x,y,z,degree);
		DOM.style.webkitTransform = matrix.toString();
	}
	rotate3d(-1,-1,0,30); // initial rotation

	return this;
}

var cube = new Cube('cube3d') // main cube object
cube.fill();

shortcut.add('up',function () {cube.make('top')});
shortcut.add('down',function () {cube.make('bottom')});
shortcut.add('left',function () {cube.make('left')});
shortcut.add('Right',function () {cube.make('right')});

function get_random_color (value) {
	Math.seedrandom(value);
    var color = 'rgba('+(Math.round(Math.random()*150)+55)+','+(Math.round(Math.random()*250)+5)+','+(Math.round(Math.random()*250)+5)+','+'.5)';
    Math.seedrandom();
    return color;
}<|endoftext|>


<commit_before>function getSlide(id) {
   var displayValue =  document.getElementById(id).style.display;

   if( displayValue=='none') {

      Ext.get(id).slideIn('t',
      {
         duration: .5,
         remove: false,
         useDisplay: true,
      });

   } else{

         Ext.get(id).slideOut('t',
         {
            duration: .5,
            remove: false,
            useDisplay: true,
         });

   }

}
<commit_msg>[tracker] Correction JS<commit_after>function getSlide(id) {
   var displayValue =  document.getElementById(id).style.display;

   if( displayValue=='none') {

      Ext.get(id).slideIn('t',
      {
         duration: .5,
         remove: false,
         useDisplay: true
      });

   } else{

         Ext.get(id).slideOut('t',
         {
            duration: .5,
            remove: false,
            useDisplay: true
         });

   }

}
<|endoftext|>


<commit_before>alert("The point of this game is to get through life without failing.");
alert("*The alarm rings*");
var morning1 = prompt("Would you like to [sleep in] or [wake up]?").toLowerCase();
if (morning1 === "wake up") {
	alert("You wake up and slowly walk to the washroom, to brush your teeth and get ready.");
	alert("You walk downstairs.");
	var breakfast1 = prompt("What do you eat for breakfast?").toLowerCase();
	alert("You finish breakfast and go back upstairs to brush again.");
	alert("You walk outside and wait about 5 minutes.");
	alert("The bus arrives.");
	alert("You are at school. It was a boring bus ride but you smelt a cow take a poop on the way.");
	alert("You put your stuff in a shared locker with your best friend. You walk inside to see the first two periods ar math! Your favourie subject.");
	alert("You easily finish the math and do some work on your laptop.");
	alert("RING RING RING!");
	alert("Second period, gym!");
	alert("You walk inside the boys changeroom and quickly get dressed for gym.");
	alert("\"LET'S GET INTO A LINE ON THE WALL! WER'E DOING OUR WARMUP!\" says the gym teacher.");
	alert("During the warmup, do you...");
	var cheat1 = prompt("[Skip a few laps] or [do it all]?").toLowerCase();
	if (cheat1 === "do it all") {
		alert("You do all of the warmup");
		alert("HUFF PUFF HUFF PUFF HUFF PUFF");
		alert("The class plays a game of volleyball and you were the top player!");
		alert("You go back and put your normal clothes back on.");
		alert("RING RING RING!");
		alert("Ah, lunch time.");
		alert("You eat your food and play outside.");
		alert("The rest of the day goes on as usual, until you noticed the most hilarious thing.");
		alert("A girl called Ameeta steals tries taking a chair from Kulshan.");
		alert("Kulshan fails to save his chair, so he takes a chair from a boy named Tejas.");
		alert("Tejas pushes Kulshan off the chair, and gets his chair back.");
		alert("At that moment, Kulshan knew, he was chairless.");
		alert("When I went home, the day went normal. I watched some TV and played outside a bit.");
		alert("You go to sleep after eating dinner, do you...");
		var night1 = prompt("[Stay up] or [go to sleep]?").toLowerCase();
		if (night1 === "go to sleep") {
			alert("You wake up the next day.");
			alert("It's Halloween. You put on your brilliant costume, a fedora and call yourself Winston Churchill.");
			var classmates = prompt("As you walk to school, you see some of your classmates. [Cameron] the Demon, [Daman] the Schoolkid, [Connor] the Leprechaun, and [Harshan] the Zombie.\nDo you greet them or [ignore] them? If you did greet them, which one do you greet?").toLowerCase();
			switch (classmates) {
				case "daman":
					alert("You say, \"Hey Daman. Nice costume.\"");
					alert("He responds, \"I'm not wearing a costume, retard.\" He proceeds to lightly tap your shoulder in a joking way. Being Arshneet, this kills you.");
					alert("THE END");
					break;
				case "connor":
					alert("You say, \"Hey Connor. Nice costume.\"");
					alert("Connor responds \"WOW. OF COURSE YOU THINK THE LEPRECHAUN COSTUME IS GOOD. BECAUSE LEPRECHAUNS ARE SHORT AND I'M SHORT.\"");
					alert("In his fit of height-insecure induced rage, Connor kills you.");
					alert("THE END");
					break;
				case "cameron":
					alert("You say, \"Hey Cameron. Nice costume.\"");
					alert("Cameron responds, \"Thanks arshneet, what are you supposed to...be...\"");
					alert("He then has an asthma attack on the spot.");
					alert("The stress of Cameron's death kills you.");
					alert("GAME OVER");
					break;
				case "harshan":
					alert("You say, \"Hey Harshan. Wow, cool costume.\"");
					alert("He responds, \"Thanks fam. What are you going as when you trick or tre-\"");
					alert("He faints on the spot.");
					alert("The stress kills you.");
					alert("GAME OVER");
					break;
				case "ignore":
					alert("You ignore them. Good, since you're a loner anyway.");
					alert("You continue on your merry way to school.");
					break;
			}
		} else {
			alert("Your mom hears you making noises so she walks in your room.");
			alert("Your mom sees what you are doing so she makes you sleep in her room.");
			alert("GAME OVER");
		}
	} else if (cheat1 === "skip a few laps") {
		alert("Your teacher notices and yells at you for cheating. You now have to do 700 more laps.");
		alert("GAME OVER");
	} else {
		alert("Your teacher notices and yells at you for cheating. You now have to do 700 more laps.");
		alert("GAME OVER");
	}
} else if (morning1 === "sleep in") {
	alert("Your dad comes and wakes you up.");
	alert("RUN RUN RUN");
	alert("You quickly brush your teeth and get ready.");
	alert("You run downstairs to scarf on your breakfast.");
	alert("You run back upstairs to brush your teeth again and run back downstairs. You run out the door.");
	alert("The bus has long gone.");
	alert("You come back inside and explain to your mom what happened.");
	alert("Your mom gives you a beating.");
	alert("GAME OVER");
}<commit_msg>nope<commit_after>alert("The point of this game is to get through life without failing.");
    alert("*The alarm rings*");
    var morning1 = prompt("Would you like to [sleep in] or [wake up]?").toLowerCase();
    if (morning1 === "wake up") {
        alert("You wake up and slowly walk to the washroom, to brush your teeth and get ready.");
        alert("You walk downstairs.");
        var breakfast1 = prompt("What do you eat for breakfast?").toLowerCase();
        alert("You finish breakfast and go back upstairs to brush again.");
        alert("You walk outside and wait about 5 minutes.");
        alert("The bus arrives.");
        alert("You are at school. It was a boring bus ride but you smelt a cow take a poop on the way.");
        alert("You put your stuff in a shared locker with your best friend. You walk inside to see the first two periods ar math! Your favourie subject.");
        alert("You easily finish the math and do some work on your laptop.");
        alert("RING RING RING!");
        alert("Second period, gym!");
        alert("You walk inside the boys changeroom and quickly get dressed for gym.");
        alert("\"LET'S GET INTO A LINE ON THE WALL! WER'E DOING OUR WARMUP!\" says the gym teacher.");
        alert("During the warmup, do you...");
        var cheat1 = prompt("[Skip a few laps] or [do it all]?").toLowerCase();
        if (cheat1 === "do it all") {
            alert("You do all of the warmup");
            alert("HUFF PUFF HUFF PUFF HUFF PUFF");
            alert("The class plays a game of volleyball and you were the top player!");
            alert("You go back and put your normal clothes back on.");
            alert("RING RING RING!");
            alert("Ah, lunch time.");
            alert("You eat your food and play outside.");
            alert("The rest of the day goes on as usual, until you noticed the most hilarious thing.");
            alert("A girl called Ameeta steals tries taking a chair from Kulshan.");
            alert("Kulshan fails to save his chair, so he takes a chair from a boy named Tejas.");
            alert("Tejas pushes Kulshan off the chair, and gets his chair back.");
            alert("At that moment, Kulshan knew, he was chairless.");
            alert("When I went home, the day went normal. I watched some TV and played outside a bit.");
            alert("You go to sleep after eating dinner, do you...");
            var night1 = prompt("[Stay up] or [go to sleep]?").toLowerCase();
            if (night1 === "go to sleep") {
                alert("You wake up the next day.");
                alert("It's Halloween. You put on your brilliant costume, a fedora and call yourself Winston Churchill.");
                var classmates = prompt("As you walk to school, you see some of your classmates. [Cameron] the Demon, [Daman] the Schoolkid, [Connor] the Leprechaun, and [Harshan] the Zombie.\nDo you greet them or [ignore] them? If you did greet them, which one do you greet?").toLowerCase();
                switch (classmates) {
                    case "daman":
                        alert("You say, \"Hey Daman. Nice costume.\"");
                        alert("He responds, \"I'm not wearing a costume, retard.\" He proceeds to lightly tap your shoulder in a joking way. Being Arshneet, this kills you.");
                        alert("THE END");
                        break;
                    case "connor":
                        alert("You say, \"Hey Connor. Nice costume.\"");
                        alert("Connor responds \"WOW. OF COURSE YOU THINK THE LEPRECHAUN COSTUME IS GOOD. BECAUSE LEPRECHAUNS ARE SHORT AND IM SHORT.\"");
                        alert("In his fit of height-insecure induced rage, Connor kills you.");
                        alert("THE END");
                        break;
                    case "cameron":
                        alert("You say, \"Hey Cameron. Nice costume.\"");
                        alert("Cameron responds, \"Thanks arshneet, what are you supposed to...be...\"");
                        alert("He then has an asthma attack on the spot.");
                        alert("The stress of Cameron's death kills you.");
                        alert("GAME OVER");
                        break;
                    case "harshan":
                        alert("You say, \"Hey Harshan. Wow, cool costume.\"");
                        alert("He responds, \"Thanks fam. What are you going as when you trick or tre-\"");
                        alert("He faints on the spot.");
                        alert("The stress kills you.");
                        alert("GAME OVER");
                        break;
                    case "ignore":
                        alert("You ignore them. Good, since you're a loner anyway.");
                        alert("You continue on your merry way to school.");
                        alert("As you get to school, the bell rings. Made it just in time!");
                        alert("Walking into homeroom, you look around at the assortment of colors and unique costumes.");
                        alert("Regardless, you think your costume is the best. Good on you.");
                        prompt("In homeroom, for the next tow periods, do you...")
                }
            } else {
                alert("Your mom hears you making noises so she walks in your room.");
                alert("Your mom sees what you are doing so she makes you sleep in her room.");
                alert("GAME OVER");
            }
        } else if (cheat1 === "skip a few laps") {
            alert("Your teacher notices and yells at you for cheating. You now have to do 700 more laps.");
            alert("GAME OVER");
        } else {
            alert("Your teacher notices and yells at you for cheating. You now have to do 700 more laps.");
            alert("GAME OVER");
        }
    } else if (morning1 === "sleep in") {
            alert("Your dad comes and wakes you up.");
            alert("RUN RUN RUN");
            alert("You quickly brush your teeth and get ready.");
            alert("You run downstairs to scarf on your breakfast.");
            alert("You run back upstairs to brush your teeth again and run back downstairs. You run out the door.");
            alert("The bus has long gone.");
            alert("You come back inside and explain to your mom what happened.");
            alert("Your mom gives you a beating.");
            alert("GAME OVER");
    }<|endoftext|>


<commit_before>/*
 * Websensor video stabilization project
 * https://github.com/jessenie-intel/websensor-video
 *
 * Copyright (c) 2017 Jesse Nieminen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

'use strict';

var constraints = {audio: true,video: {  width: { min: 640, ideal: 640, max: 640 },  height: { min: 480, ideal: 480, max: 480 }}};
var mediaRecorder = null;
var chunks = [];
var videoData = null;
var interval = null;

var accel_sensor = null;
var orientation_sensor = null;
var sensorfreq = 60;

//var roll = null;
//var pitch = null;
//var yaw = null;
var accel = {"x": null, "y": null, "z": null};
var ori = {"roll": null, "pitch": null, "yaw": null, "time": null};
var oriInitial = {"roll": null, "pitch": null, "yaw": null, "time": null};
var initialoriobtained = false;
var orientationData = [];       //array to store all the orientation data
var frameData = {"data": null, "time": null, "ori": null};
var dataArray = [];     //array to store all the combined data
var dataArray2 = [];     //array to store all the combined data

var time = null;
var timestamps = [];
var nFrame = 0; //frame number with which we can combine timestamp and frame data

//canvas
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');

//video element
var videoElement = document.querySelector('video');
videoElement.controls = false;

var ref = null;
var extraFrames = 0;

class AbsOriSensor {
        constructor() {
        const sensor = new AbsoluteOrientationSensor({ frequency: sensorfreq });
        const mat4 = new Float32Array(16);
        const euler = new Float32Array(3);
        sensor.onreading = () => {
                sensor.populateMatrix(mat4);
                toEulerianAngle(sensor.quaternion, euler);      //From quaternion to Eulerian angles
                this.roll = euler[0];
                this.pitch = euler[1];
                this.yaw = euler[2];
                this.timestamp = sensor.timestamp;
                if (this.onreading) this.onreading();
        };
        sensor.onactivate = () => {
                if (this.onactivate) this.onactivate();
        };
        const start = () => sensor.start();
        Object.assign(this, { start });
        }
}

function update_debug()
{
                        document.getElementById("ori").textContent = `${ori.roll} ${ori.pitch} ${ori.yaw}`;
}

//WINDOWS 10 HAS DIFFERENT CONVENTION: Yaw z, pitch x, roll y
function toEulerianAngle(quat, out)
{
        const ysqr = quat[1] ** 2;

        // Roll (x-axis rotation).
        const t0 = 2 * (quat[3] * quat[0] + quat[1] * quat[2]);
        const t1 = 1 - 2 * (ysqr + quat[0] ** 2);
        out[0] = Math.atan2(t0, t1);
        // Pitch (y-axis rotation).
        let t2 = 2 * (quat[3] * quat[1] - quat[2] * quat[0]);
        t2 = t2 > 1 ? 1 : t2;
        t2 = t2 < -1 ? -1 : t2;
        out[1] = Math.asin(t2);
        // Yaw (z-axis rotation).
        const t3 = 2 * (quat[3] * quat[2] + quat[0] * quat[1]);
        const t4 = 1 - 2 * (ysqr + quat[2] ** 2);
        out[2] = Math.atan2(t3, t4);
        return out;
}

function errorCallback(error){
	console.log("error: ", error);
}

function startDemo () {
		navigator.getUserMedia(constraints, startRecording, errorCallback);
}

function startRecording(stream) {

                try {
                //Initialize sensors
                /*accel_sensor = new Accelerometer();
                accel_sensor.onreading = () => {
                        accel = {"x": accel_sensor.x, "y": accel_sensor.y, "z": accel_sensor.z};
                };
                accel_sensor.onactivate = () => {
                };
                accel_sensor.start();*/
                orientation_sensor = new AbsOriSensor();
                orientation_sensor.onreading = () => {
                        let roll = orientation_sensor.roll;
                        let pitch = orientation_sensor.pitch;
                        let yaw = orientation_sensor.yaw;
                        time = orientation_sensor.timestamp;
                        if(!initialoriobtained) //obtain initial orientation
                        {
                                oriInitial = {"roll": orientation_sensor.roll, "pitch": orientation_sensor.pitch, "yaw": orientation_sensor.yaw, "time": orientation_sensor.timestamp};
                                initialoriobtained = true;
                        }
                        ori = {"roll": orientation_sensor.roll, "pitch": orientation_sensor.pitch, "yaw": orientation_sensor.yaw, "time": orientation_sensor.timestamp};
                };
                orientation_sensor.onactivate = () => {
                };
                orientation_sensor.start();
                }
                catch(err) {
                        console.log(err.message);
                        console.log("Your browser doesn't seem to support generic sensors. If you are running Chrome, please enable it in about:flags.");
                        //this.innerHTML = "Your browser doesn't seem to support generic sensors. If you are running Chrome, please enable it in about:flags";
                }
	        //var options = {mimeType: 'video/webm;codecs=vp9'};
		//mediaRecorder = new MediaRecorder(stream, options);
		mediaRecorder = new MediaRecorder(stream);

	        mediaRecorder.start(10);

	        var url = window.URL;
	        videoElement.src = url ? url.createObjectURL(stream) : stream;
                //videoElement.play();

	        mediaRecorder.ondataavailable = function(e) {
                        //console.log("Data available", e);
                        //console.log(time);
                        timestamps.push(time);
                        frameData.time = time;
		        chunks.push(e.data);
                        frameData.data = e.data;
                        orientationData.push(ori);
                        frameData.ori = ori;
                        var b = new Object;     //need to push by value
                        Object.assign(b, frameData);
                        dataArray.push(b);
	        };

	        mediaRecorder.onerror = function(e){
		        console.log('Error: ', e);
	        };

	        mediaRecorder.onstart = function(){
                        console.log("Recording started", mediaRecorder.state);
	        };

	        mediaRecorder.onstop = function(){
		        var blob = new Blob(chunks, {type: "video/webm"});
		        chunks = [];

		        var videoURL = window.URL.createObjectURL(blob);

		        videoElement.src = videoURL;
                        //videoElement.load();

                        //resize canvas
videoElement.addEventListener('loadedmetadata', function() {
  canvas.width = videoElement.videoWidth;
  canvas.height = videoElement.videoHeight;
});

                        /*//Read blob data so we can stabilize the video
                        var reader = new FileReader();
                         reader.onload = function(event){
                                let text = reader.result;
                                console.log(text);
                          };
                        reader.readAsText(blob, "video/webm");*/
                        //console.log(orientationData);
                        //console.log(timestamps);
                        //console.log(dataArray);
/*
var blobUrl = URL.createObjectURL(blob);
var x = new XMLHttpRequest();
// set x.responseType = 'blob' if you want to get a Blob object:
// x.responseType = 'blob';
x.onload = function() {
    alert(x.responseText);
};
console.log(x.open('get', blobUrl));*/
                        readFrameData(blob, orientationData);    //reads the video into dataArray2
                        /*videoElement.onended = function() {
                                alert("The video has ended");
                                cancelAnimationFrame(ref);
                        };*/
                        //ctx.clearRect(0, 0, canvas.width, canvas.height);
                        //stabilize(dataArray2);        //now we can operate on it
                        interval=window.setInterval(update_debug,100);
	        };

	        mediaRecorder.onpause = function(){
	        }

	        mediaRecorder.onresume = function(){
	        }

	        mediaRecorder.onwarning = function(e){
	        };
}

function stopRecording(){
	mediaRecorder.stop();
        //Now stabilize
	videoElement.controls = true;
}
//Idea: copy video to canvas, operate on the video, and then use the canvas with the stabilized video as source for the video element
function readFrameData(blob, oriArray) {     //Read video data from blob to object form with pixel data we can operate on
        //console.log("frame");

        nFrame = videoElement.webkitDecodedFrameCount - extraFrames;
        //console.log(videoElement.webkitDecodedFrameCount);      //only works in webkit browsers
        //console.log(timestamps[nFrame] - timestamps[0], videoElement.currentTime);
        //while(!videoElement.ended)
        //{
        let dx = 0;
        let dy = 0;
        let oriDiff = null;
                //videoElement.playbackRate = 0.5;        //fix playback being too fast
                let ori = orientationData[nFrame];
                if(ori !== undefined)
                {
                        oriDiff = {"roll": ori.roll-oriInitial.roll, "pitch": ori.pitch-oriInitial.pitch, "yaw": ori.yaw-oriInitial.yaw};
                        dx = videoElement.videoWidth*(oriDiff.yaw/(2*Math.PI));
                        //x = 100*oriDiff.yaw;
                        dy = -videoElement.videoHeight*(oriDiff.roll/(2*Math.PI));     //each 2pi means 1 video height
                        //y = 100*oriDiff.roll;
                }
                else
                {
                        dx = 0;
                        dy = 0;
                }
                //console.log(x, y);
                let widthR = 0.8*canvas.width;
                let heightR = 0.8*canvas.height;
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.drawImage(videoElement,0,0, videoElement.videoWidth, videoElement.videoHeight);
                ctx.beginPath();
                ctx.rect(dx+0.1*canvas.width,dy+0.1*canvas.height,widthR,heightR);
                ctx.stroke();

                //ctx.drawImage(videoElement, 0, 0);
                //let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
                /*let pixeldataArray = [];
                //loop through every pixel
                for(let i=0; i<imageData.data.length; i = i+4)
                {
                        let pixeldata = {"red": imageData.data[i], "green":imageData.data[i+1], "blue": imageData.data[i+2], "alpha":imageData.data[i+3]};
                        //pixeldataArray.push(pixeldata);
                }
                //pixeldataArray.push(imageData);*/
                if(ori !== undefined) {
                        //let timestamp = dataArray[nFrame].time;
                        //let frameData2 = {"imagedata": imageData, "time": timestamp, "oridiff": oriDiff};
                        //dataArray2.push(frameData2);
                        //console.log(pixeldataArray);
                        //newImageData.data = data;
                    // Draw the pixels onto the visible canvas
                    //ctx.putImageData(newImageData,0,0);
                        //ctx.putImageData(imageData, 0, 0)
                        //xD
                }
        //}
                //nFrame = nFrame + 1;
                ref = requestAnimationFrame(readFrameData);
        /*
        if(dataArray2.length === timestamps.length)     //now we have read the whole blob - should use callback here instead of if condition
        {
                console.log("ended");
                cancelAnimationFrame(ref);
                console.log(dataArray2);
                stabilize(dataArray2);
        } */
        if(videoElement.ended)
        {
                console.log("ended");
        }
        if(nFrame >= orientationData.length-1)
        {
                extraFrames = extraFrames + nFrame;
                nFrame = 0;
                //cancelAnimationFrame(ref);
        }
}

function stabilize(dataArrayArg) { //Create a stabilized video from the pixel data given as input
        let frame = dataArrayArg[0];      //first frame
        console.log(frame);
        //ctx.drawImage(frame.imagedata,0,0, videoElement.videoWidth, videoElement.videoHeight);
        //ctx.putImageData(frame.imagedata, 0, 0);
}
<commit_msg>Added gyroscope and accelerometer<commit_after>/*
 * Websensor video stabilization project
 * https://github.com/jessenie-intel/websensor-video
 *
 * Copyright (c) 2017 Jesse Nieminen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

'use strict';

var constraints = {audio: true,video: {  width: { min: 640, ideal: 640, max: 640 },  height: { min: 480, ideal: 480, max: 480 }}};
var mediaRecorder = null;
var chunks = [];
var videoData = null;
var interval = null;

var accel_sensor = null;
var orientation_sensor = null;
var sensorfreq = 60;

//var roll = null;
//var pitch = null;
//var yaw = null;
var accel = {"x": null, "y": null, "z": null};
var ori = {"roll": null, "pitch": null, "yaw": null, "time": null};
var oriInitial = {"roll": null, "pitch": null, "yaw": null, "time": null};
var initialoriobtained = false;
var orientationData = [];       //array to store all the orientation data
var frameData = {"data": null, "time": null, "ori": null};
var dataArray = [];     //array to store all the combined data
var dataArray2 = [];     //array to store all the combined data

var time = null;
var timestamps = [];
var nFrame = 0; //frame number with which we can combine timestamp and frame data

//canvas
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');

//video element
var videoElement = document.querySelector('video');
videoElement.controls = false;

var ref = null;
var extraFrames = 0;

class AbsOriSensor {
        constructor() {
        const sensor = new AbsoluteOrientationSensor({ frequency: sensorfreq });
        const mat4 = new Float32Array(16);
        const euler = new Float32Array(3);
        sensor.onreading = () => {
                sensor.populateMatrix(mat4);
                toEulerianAngle(sensor.quaternion, euler);      //From quaternion to Eulerian angles
                this.roll = euler[0];
                this.pitch = euler[1];
                this.yaw = euler[2];
                this.timestamp = sensor.timestamp;
                if (this.onreading) this.onreading();
        };
        sensor.onactivate = () => {
                if (this.onactivate) this.onactivate();
        };
        const start = () => sensor.start();
        Object.assign(this, { start });
        }
}

function update_debug()
{
                        document.getElementById("ori").textContent = `${ori.roll} ${ori.pitch} ${ori.yaw}`;
}

//WINDOWS 10 HAS DIFFERENT CONVENTION: Yaw z, pitch x, roll y
function toEulerianAngle(quat, out)
{
        const ysqr = quat[1] ** 2;

        // Roll (x-axis rotation).
        const t0 = 2 * (quat[3] * quat[0] + quat[1] * quat[2]);
        const t1 = 1 - 2 * (ysqr + quat[0] ** 2);
        out[0] = Math.atan2(t0, t1);
        // Pitch (y-axis rotation).
        let t2 = 2 * (quat[3] * quat[1] - quat[2] * quat[0]);
        t2 = t2 > 1 ? 1 : t2;
        t2 = t2 < -1 ? -1 : t2;
        out[1] = Math.asin(t2);
        // Yaw (z-axis rotation).
        const t3 = 2 * (quat[3] * quat[2] + quat[0] * quat[1]);
        const t4 = 1 - 2 * (ysqr + quat[2] ** 2);
        out[2] = Math.atan2(t3, t4);
        return out;
}

function errorCallback(error){
	console.log("error: ", error);
}

function startDemo () {
		navigator.getUserMedia(constraints, startRecording, errorCallback);
}

function startRecording(stream) {

                try {
                //Initialize sensors
                accel_sensor = new Accelerometer();
                accel_sensor.onreading = () => {
                        accel = {"x": accel_sensor.x, "y": accel_sensor.y, "z": accel_sensor.z};
                };
                accel_sensor.onactivate = () => {
                };
                accel_sensor.start();
                gyroscope = new Gyroscope();
                gyroscope.onreading = () => {
                        //accel = {"x": accel_sensor.x, "y": accel_sensor.y, "z": accel_sensor.z};
                };
                gyroscope.onactivate = () => {
                };
                gyroscope.start();
                orientation_sensor = new AbsOriSensor();
                orientation_sensor.onreading = () => {
                        let roll = orientation_sensor.roll;
                        let pitch = orientation_sensor.pitch;
                        let yaw = orientation_sensor.yaw;
                        time = orientation_sensor.timestamp;
                        if(!initialoriobtained) //obtain initial orientation
                        {
                                oriInitial = {"roll": orientation_sensor.roll, "pitch": orientation_sensor.pitch, "yaw": orientation_sensor.yaw, "time": orientation_sensor.timestamp};
                                initialoriobtained = true;
                        }
                        ori = {"roll": orientation_sensor.roll, "pitch": orientation_sensor.pitch, "yaw": orientation_sensor.yaw, "time": orientation_sensor.timestamp};
                };
                orientation_sensor.onactivate = () => {
                };
                orientation_sensor.start();
                }
                catch(err) {
                        console.log(err.message);
                        console.log("Your browser doesn't seem to support generic sensors. If you are running Chrome, please enable it in about:flags.");
                        //this.innerHTML = "Your browser doesn't seem to support generic sensors. If you are running Chrome, please enable it in about:flags";
                }
	        //var options = {mimeType: 'video/webm;codecs=vp9'};
		//mediaRecorder = new MediaRecorder(stream, options);
		mediaRecorder = new MediaRecorder(stream);

	        mediaRecorder.start(10);

	        var url = window.URL;
	        videoElement.src = url ? url.createObjectURL(stream) : stream;
                //videoElement.play();

	        mediaRecorder.ondataavailable = function(e) {
                        //console.log("Data available", e);
                        //console.log(time);
                        timestamps.push(time);
                        frameData.time = time;
		        chunks.push(e.data);
                        frameData.data = e.data;
                        orientationData.push(ori);
                        frameData.ori = ori;
                        var b = new Object;     //need to push by value
                        Object.assign(b, frameData);
                        dataArray.push(b);
	        };

	        mediaRecorder.onerror = function(e){
		        console.log('Error: ', e);
	        };

	        mediaRecorder.onstart = function(){
                        console.log("Recording started", mediaRecorder.state);
	        };

	        mediaRecorder.onstop = function(){
		        var blob = new Blob(chunks, {type: "video/webm"});
		        chunks = [];

		        var videoURL = window.URL.createObjectURL(blob);

		        videoElement.src = videoURL;
                        //videoElement.load();

                        //resize canvas
videoElement.addEventListener('loadedmetadata', function() {
  canvas.width = videoElement.videoWidth;
  canvas.height = videoElement.videoHeight;
});

                        /*//Read blob data so we can stabilize the video
                        var reader = new FileReader();
                         reader.onload = function(event){
                                let text = reader.result;
                                console.log(text);
                          };
                        reader.readAsText(blob, "video/webm");*/
                        //console.log(orientationData);
                        //console.log(timestamps);
                        //console.log(dataArray);
/*
var blobUrl = URL.createObjectURL(blob);
var x = new XMLHttpRequest();
// set x.responseType = 'blob' if you want to get a Blob object:
// x.responseType = 'blob';
x.onload = function() {
    alert(x.responseText);
};
console.log(x.open('get', blobUrl));*/
                        readFrameData(blob, orientationData);    //reads the video into dataArray2
                        /*videoElement.onended = function() {
                                alert("The video has ended");
                                cancelAnimationFrame(ref);
                        };*/
                        //ctx.clearRect(0, 0, canvas.width, canvas.height);
                        //stabilize(dataArray2);        //now we can operate on it
                        interval=window.setInterval(update_debug,100);
	        };

	        mediaRecorder.onpause = function(){
	        }

	        mediaRecorder.onresume = function(){
	        }

	        mediaRecorder.onwarning = function(e){
	        };
}

function stopRecording(){
	mediaRecorder.stop();
        //Now stabilize
	videoElement.controls = true;
}
//Idea: copy video to canvas, operate on the video, and then use the canvas with the stabilized video as source for the video element
function readFrameData(blob, oriArray) {     //Read video data from blob to object form with pixel data we can operate on
        //console.log("frame");

        nFrame = videoElement.webkitDecodedFrameCount - extraFrames;
        //console.log(videoElement.webkitDecodedFrameCount);      //only works in webkit browsers
        //console.log(timestamps[nFrame] - timestamps[0], videoElement.currentTime);
        //while(!videoElement.ended)
        //{
        let dx = 0;
        let dy = 0;
        let oriDiff = null;
                //videoElement.playbackRate = 0.5;        //fix playback being too fast
                let ori = orientationData[nFrame];
                if(ori !== undefined)
                {
                        oriDiff = {"roll": ori.roll-oriInitial.roll, "pitch": ori.pitch-oriInitial.pitch, "yaw": ori.yaw-oriInitial.yaw};
                        dx = videoElement.videoWidth*(oriDiff.yaw/(2*Math.PI));
                        //x = 100*oriDiff.yaw;
                        dy = -videoElement.videoHeight*(oriDiff.roll/(2*Math.PI));     //each 2pi means 1 video height
                        //y = 100*oriDiff.roll;
                }
                else
                {
                        dx = 0;
                        dy = 0;
                }
                //console.log(x, y);
                let widthR = 0.8*canvas.width;
                let heightR = 0.8*canvas.height;
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.drawImage(videoElement,0,0, videoElement.videoWidth, videoElement.videoHeight);
                ctx.beginPath();
                ctx.rect(dx+0.1*canvas.width,dy+0.1*canvas.height,widthR,heightR);
                ctx.stroke();

                //ctx.drawImage(videoElement, 0, 0);
                //let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
                /*let pixeldataArray = [];
                //loop through every pixel
                for(let i=0; i<imageData.data.length; i = i+4)
                {
                        let pixeldata = {"red": imageData.data[i], "green":imageData.data[i+1], "blue": imageData.data[i+2], "alpha":imageData.data[i+3]};
                        //pixeldataArray.push(pixeldata);
                }
                //pixeldataArray.push(imageData);*/
                if(ori !== undefined) {
                        //let timestamp = dataArray[nFrame].time;
                        //let frameData2 = {"imagedata": imageData, "time": timestamp, "oridiff": oriDiff};
                        //dataArray2.push(frameData2);
                        //console.log(pixeldataArray);
                        //newImageData.data = data;
                    // Draw the pixels onto the visible canvas
                    //ctx.putImageData(newImageData,0,0);
                        //ctx.putImageData(imageData, 0, 0)
                        //xD
                }
        //}
                //nFrame = nFrame + 1;
                ref = requestAnimationFrame(readFrameData);
        /*
        if(dataArray2.length === timestamps.length)     //now we have read the whole blob - should use callback here instead of if condition
        {
                console.log("ended");
                cancelAnimationFrame(ref);
                console.log(dataArray2);
                stabilize(dataArray2);
        } */
        if(videoElement.ended)
        {
                console.log("ended");
        }
        if(nFrame >= orientationData.length-1)
        {
                extraFrames = extraFrames + nFrame;
                nFrame = 0;
                //cancelAnimationFrame(ref);
        }
}

function stabilize(dataArrayArg) { //Create a stabilized video from the pixel data given as input
        let frame = dataArrayArg[0];      //first frame
        console.log(frame);
        //ctx.drawImage(frame.imagedata,0,0, videoElement.videoWidth, videoElement.videoHeight);
        //ctx.putImageData(frame.imagedata, 0, 0);
}
<|endoftext|>