<!DOCTYPE html>
<html lang="en">
<head>
<link href="/static/css/app_new.css?v=1.559" rel="stylesheet" />
<link rel="shortcut icon" href="/static/img/favicon.ico?v=2">
<link href='//fonts.googleapis.com/css?family=Roboto:300,400,500,700|Oxygen:400,300|Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
<script src="//cdn.optimizely.com/js/3172500654.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="google-signin-client_id" content="559578500147.apps.googleusercontent.com">
<meta name="google-signin-requestvisibleactions" content="https://schema.org/AddAction" />
<meta name="google-signin-cookiepolicy" content="single_host_origin" />
<link rel="stylesheet" href="/static/new_ui/assets/vendor/asPieProgress/css/progress.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script>window.jQuery || document.write('<script src="/static/js/jquery.1.10.2.min.js">\x3C/script>')</script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" crossorigin="anonymous"></script>
<script>window.$.ui || document.write('<script src="/static/js/jquery.ui.1.10.3.min.js">\x3C/script>')</script>

<title>Interactive Video Learning</title>
</head>
<body>
<div id="navbar">
<div class="navbar" style="margin-bottom:1em;">
<nav>
<div class="nav-wrapper container2">
<a class="brand-logo hide-on-small-only" href="/dash"><img src="/static/img/logo_dog.png" height="64"><img class="hide-on-med-and-down" src="/static/img/logo_text.png" height="64"></a>

<ul style="position:absolute;right:0;z-index:99;">
<li class="modal-login-trigger">
<a href="javascript:void(0)" class="modal-login-trigger" id="link-0">Login</a>
<li class="">
<a href="/join" class="" id="link-1">Signup</a>
<li class="">
<a href="/curriculum/browse" class="" id="link-2">Browse</a>
<li class="">
<a href="http://blog.educanon.com" class="" id="link-3">Blog</a>
</ul>
</div>
</nav>
</div>
</div>
<main>
<script type="text/template" id="modal-login-template">
<div class="white-popup container" style="background:#fafafa;">
<div class="wrapper-signon">
<h5 class="header header-section">
Single sign-on
</h5>
<div class="row center-align">
<a class="col s12 m4 l4" href="https://api.edmodo.com/oauth/authorize?client_id=9c3a7aa55987ba46bebbd88d900e7dc2b744b88db189cf70b8fbb072e0331dcd&redirect_uri=https%3A%2F%2Feducanon.com%2Fedmodo&response_type=token"><img class="login-icon" src="/static/img/edmodo-button.png" alt="login with edmodo" style="width:139px;"/></a>
<a href="/clever" class="col s12 m4 l4"><img class="login-icon" src='/static/img/login-clever.png' alt="login with Clever" style="width:139px;"/></a>
<div class="g-signin2 col s12 m4 l4" data-scope="https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/classroom.courses.readonly https://www.googleapis.com/auth/classroom.profile.emails https://www.googleapis.com/auth/classroom.rosters.readonly" data-onsuccess="onSignIn" data-onfailure="onSignInFailure" data-theme="dark" data-width="139px"></div>
</div>
</div>
<div id="login-signup">
<h5 class="header header-section">
Login
</h5>
<div style="style=padding: 5px 20px 20px;">
<form action="/login" method="POST">
<div class="field input-field">
<i class="material-icons prefix">account_circle</i>
<input type="text" name="email" title="email" placeholder="email or username" autofocus required>
</div>
<div class="field input-field">
<i class="material-icons prefix">lock</i>
<input type="password" name="password" title="password" placeholder="password" required>
</div>
<div class="center-align col s12">
<button class="btn waves-effect waves-light" type="submit" name="submit">Submit<i class="material-icons right">send</i></button>
</div>
</form>
</div>
</div>
<br/>
<blockquote style="font-weight:200;">
<a href="http://educanon.uservoice.com/knowledgebase/articles/778704" target="_blank">Forgot your password?</a><br/>
No account yet? <a href="/join">Create an account here.</a>
</blockquote>
</script>

<!-- <script src="https://apis.google.com/js/platform.js" async defer></script> -->
<script type="text/javascript">
$(document).ready(function(){
$(".modal-login-trigger").click(function() {
$.magnificPopup.open({
items: {
src: _.template($("#modal-login-template").html(),{}),
type: "inline"
},
callbacks: {
open: function() {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://apis.google.com/js/platform.js";
$("head").append(s);

}
}
});
});
});
function onSignIn(googleUser) {
var isSignedIn = googleUser.isSignedIn();
if(isSignedIn){
var profile = googleUser.getBasicProfile();
var id_token = googleUser.getAuthResponse().id_token;
var email = profile.getEmail();
if(id_token){
googleUser.disconnect();
$.post( "/checkemail/"+email, function( data ) {
if( data ) {
app.listPopup('What best describes you?', [
{ title: 'STUDENT',
href: "/googleoauth2callback?id_token="+id_token+"&user=student" },
{ title: 'INSTRUCTOR',
href: "/googleoauth2callback?id_token="+id_token+"&user=teacher" }
]);
} else {
window.location.href = "/googleoauth2callback?id_token="+id_token;
}
});
}
}else{
error = "Google signedin failed.";
emailError(error);
window.location.href = "/" ;
}
}

function onSignInFailure(error) {
// Handle sign-in errors
console.log(error);
emailError(JSON.stringify(error, undefined, 2));
window.location.href = "/" ;
}
function emailError(error){
gtm("Google Lesson login error", "login fail", error);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/googlessoerror');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('error=' + error);
}

//Check if in Safari/iframe
var is_safari = navigator.userAgent.indexOf("Safari") > -1;
function inIframe () {
try { return window.self !== window.top; }
catch (e) { return true; }
}
// Popup to activate session, auto-closes
if(is_safari && inIframe()){
window.open("/appPopup", "loadingSession");
}
</script>

<style>
.hover-opacity {
opacity: 0.35;
}
.hover-opacity:hover {
opacity:1.0;
}
</style>
<div class="section no-pad-bot" id="index-banner" style="position:absolute !important; top: 85px !important;">
<div class="container" style="background:rgba(1,1,1,0.4); border-radius:2px;">
<br><br>
<h1 class="header center white-text" style="font-weight:500;#background:rgba(1,1,1,0.6)">Unleash Interactive Video</h1>
<div class="row center">
<h5 class="header col s12 light white-text">Deeply engage learners and accountably measure understanding</h5>
</div>
<div class="row center">
<a href="javascript:void(0)" id="download-button" class="btn-large waves-effect waves-light green" style="margin-right:1em;" onClick="app.gtm('click-join-above-fold');location.href='/signup';">Join now (it's free)</a> <a id="request-form" href="javascript:void(0)" class="btn-large waves-effect waves-light orange" onClick="app.gtm('click-demo-above-fold');">Request Enterprise Demo</a>
</div>
<br><br>
</div>
</div>
<div id='videosplash' style="
margin-top: -78px;
width: 100%;
min-height: 100vh;
overflow:hidden;">
</div>
<div class="section hide-on-med-and-down">
<div class="row">
<div class="col s12 m2 l1 hover-opacity">
<a href="https://www.edsurge.com/n/2014-05-23-educanon-sweeps-edtech-biz-competitions-wins-115k" target="_blank">
<img style="width:100%;" src="/static/img/EBPCBadge.png" alt="penn recognition" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://www.edukwest.com/educanon-wins-100k-1776-challenge-cup-interview-benjamin-levy/" target="_blank">
<img style="width:100%;" src="/static/img/ChallengeCup.png" alt="challenge cup award" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="https://www.edsurge.com/n/2014-06-30-educanon-a-real-crowd-pleaser-at-iste2014-pitchfest" target="_blank">
<img style="width:100%;" src="/static/img/iste.png" alt="iste award" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://techcrunch.com/2013/06/17/bostons-learnlaunch-unveils-first-batch-as-edtech-accelerators-continue-to-proliferate/" target="_blank">
<img style="width:100%;" src="/static/img/llx.png" alt="learnlaunch logo" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://blog.educanon.com/posts/milkenchallenge" target="_blank">
<img style="width:100%;" src="/static/img/splash/mcgrawhill.png" alt="mcgraw hill logo" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://www.mit100k.org/launch/2013_semi_finalists/" target="_blank">
<img style="width:100%;" src="/static/img/mit.png" alt="mit 100K contest" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://www.digital.nyc/news/education-pitch-day-showcases-creative-startups" target="_blank">
<img style="width:100%;" src="/static/img/splash/dell.png" alt="dell contest" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="https://www.edsurge.com/n/2014-12-31-counting-down-the-top-ten-s-cool-tools-of-2014" target="_blank">
<img style="width:100%;" src="/static/img/splash/edsurge.png" alt="edsurge recognition" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://www.forbes.com/pictures/lmh45mfhd/benjamin-levy-27/" target="_blank">
<img style="width:100%;" src="/static/img/splash/forbes.png" alt="forbes 30 under 30" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://startx.stanford.edu/companies" target="_blank">
<img style="width:100%;" src="/static/img/splash/startx.png" alt="stanford university startx" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://dcinno.streetwise.co/2015/10/15/dc-tech-1776-startup-educanon-growing-customers-hiring-sf/" target="_blank">
<img style="width:100%;" src="/static/img/splash/att.png" alt="at&t aspire educational accelerator" />
</a>
</div>
<div class="col s12 m2 l1 hover-opacity">
<a href="http://www.venturecapitol.co/#!educanon/c5k6" target="_blank">
<img style="width:100%;" src="/static/img/splash/tfa.png" alt="teach for america social innovation award finalists" />
</a>
</div>
</div>
</div>
<div class="container">
<h1 class="header center blue-text hide-on-med-and-down">Join 1,000,000+ users</h1>
<div class="section">
<!-- Icon Section Search, Add Interactions, Share, Monitor-->
<div class="row">
<div class="col s12 m6">
<div class="card">
<div class="card-image">
<img src="/static/img/splash/videossources.png">
</div>
<div class="card-content">
<p style="padding:1em 2em;height:7em;">Easily find educational videos online or search our 300,000+ pre-made interactive videos.</p>
</div>
<div class="card-action">
<span class="card-title blue-text">SEARCH (MANY)</span>
</div>
</div>
</div>
<div class="col s12 m6">
<div class="card">
<div class="card-image">
<img src="/static/img/splash/builder.png">
</div>
<div class="card-content">
<p style="padding:1em 2em;height:7em;">Add any of seven interactive question types and rich media into the video's timeline to actively engage on mobile or web devices.</p>
</div>
<div class="card-action">
<span class="card-title blue-text">INTERACT (DEEPLY)</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col s12 m6">
<div class="card">
<div class="card-image">
<img src="/static/img/splash/integrations.png">
</div>
<div class="card-content">
<p style="padding:1em 2em;height:7em;">Share with students, copy from colleagues, and learn from administrators. Embed directly into your Learning Management System!</p>
</div>
<div class="card-action">
<span class="card-title blue-text">SHARE (URL or LMS)</span>
</div>
</div>
</div>
<div class="col s12 m6">
<div class="card">
<div class="card-image">
<img src="/static/img/splash/monitor.png">
</div>
<div class="card-content">
<p style="padding:1em 2em;height:7em;">Understand student learning as it happens in-class or better prepare when delivery is in a flipped environment.</p>
</div>
<div class="card-action">
<span class="card-title blue-text">MONITOR (ACCOUNTABLY)</span>
</div>
</div>
</div>
</div>
</div>
<br><br>
<div class="section">
<div class="row center">
<a href="javascript:void(0)" id="download-button" class="btn-large waves-effect waves-light green" style="margin-right:1em;" onClick="app.gtm('click-join-below-fold');location.href='/signup';">Join now (it's free)</a> <a id="request-form-below" href="javascript:void(0)" class="btn-large waves-effect waves-light orange" onClick="app.gtm('click-demo-below-fold');">Request Enterprise Demo</a>
</div>
<br><br>
</div>
</div>
</div>

</main>
<footer class="page-footer">
<div class="container">
<div class="row">
<div class="col l8 s12">
<h5 class="white-text">What we do</h5>
<p class="grey-text text-lighten-4">
Backed by AT&T and Stanford's startX, eduCanon is an online learning environment to create and share interactive video lessons. Teachers begin with any online video (screencasts, Khan Academy, TED, etc.) and transform what is traditionally passive content into an active experience for students, with time-embedded activities. <br/><br/>Awarded the "best open educational resource", eduCanon is designed for K-corporate, flipped, and blended environments.</p>
<a class="twitter-timeline" data-dnt="true" href="https://twitter.com/educanon123/favorites" data-widget-id="656515977790623744">Favorite Tweets by @educanon123</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<div class="col l3 offset-l1 s12">
<h5 class="white-text">Learn</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="https://educanon.uservoice.com/knowledgebase" target="_blank">FAQ</a></li>
<li><a class="grey-text text-lighten-3" href="http://blog.educanon.com/" target="_blank">Blog</a></li>
<li><a class="grey-text text-lighten-3" href="/school">School</a></li>
<li><a class="grey-text text-lighten-3" href="/premium">Premium</a></li>
<li><a class="grey-text text-lighten-3" href="https://docs.google.com/presentation/d/1o-rA3VFQx4Gwi1v1PYeetL6CvatqGXRcuwOXcFELylY/edit?usp=drivesdk" target="_blank">On-Boarding</a></li>
<li><a class="grey-text text-lighten-3" href="/terms">Terms of Use</a></li>
<li><a class="grey-text text-lighten-3" href="/privacy">Privacy Policy</a></li>
</ul>
<h5 class="white-text">Build</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="/panel/lessons">Bulbs</a></li>
<li><a class="grey-text text-lighten-3" href="/panel/lessons#premade">Search</a></li>
</ul>
<h5 class="white-text">Deliver</h5>
<ul>
<li><a class="grey-text text-lighten-3" href="/roster">Roster</a></li>
<li><a class="grey-text text-lighten-3" href="/monitor/grades#assign">Assign</a></li>
<li><a class="grey-text text-lighten-3" href="/monitor/grades">Monitor</a></li>
<br />
<div id="google_translate_element"></div>
</ul>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container">
&copy; 2015 <a class="grey-text text-lighten-4" href="https://www.educanon.com">EDUCANON, INC.</a>
<a class="grey-text text-lighten-4 right" href="https://educanon.uservoice.com/knowledgebase" target="_blank">Contact Us</a>
</div>
</div>
</footer>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, gaTrack: true, gaId: 'UA-42920959-1'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>
<script type="text/javascript" src="/min/b=static/js&amp;f=underscore.js,backbone.js,deep-model.js,moment.js,styling.js,magnific-popup.js,date.format.js,typeahead-0.9.3.js"></script>
<script>
Backbone.emulateJSON = true;
window.api_prefix = "/api/1.0";
try {
window.FromPHP = JSON.parse("{\"user\":\"\"}");
} catch(e) {
//console.log(JSON.stringify(e));
}
</script>
<script type="text/javascript" src="/static/js/parsley.min.js"></script>
<script type="text/javascript" src="/min/b=static&amp;f=js/fluidvids.min.js,js/hogan-2.0.0.js,js/snap.min.js,js/panel.js,js/youtube_setup.js,js/html5slider.js,js/userfeed.js,vendor/materialize/js/materialize.js,js/jquery.nicescroll.min.js,js/jquery-asPieProgress.js,js/app.js?v=1.559"></script>
<script type="text/javascript">
var ouruser_id = "",
ouruser_type = "none",
ouruser_new = false,
ouruser_subject = "",
ouruser_grade = "",
ouruser_role = "",
ouruser_school = "",
ouruser_school_id = "",
ouruser_premium = false,
ouruser_premium_date = false,
ouruser_students = "",
ouruser_email = "",
ouruser_name = "",
ouruser_signup = "",
ouruser_lessons = "",
ouruser_phone = "",
ouruser_questions = "";

if (typeof FromPHP != "undefined" && FromPHP != null) {
if (typeof FromPHP.student != "undefined" && FromPHP.student != null) {
ouruser_type = "student";
ouruser_id = FromPHP.student.id;
} else if (typeof FromPHP.user == "object") {
ouruser_id = FromPHP.user.id;
ouruser_type = "teacher";
ouruser_grade = FromPHP.user.grade_default;
ouruser_subject = FromPHP.user.subject_default;
ouruser_role = FromPHP.user.role;
ouruser_school = FromPHP.user.school_name;
ouruser_school_id = FromPHP.user.school_id;
ouruser_email = FromPHP.user.email;
ouruser_name = FromPHP.user.student_name;
ouruser_phone = FromPHP.user.school_zip;
ouruser_signup = new Date(FromPHP.user.timestamp).getTime() / 1000;
if (FromPHP.user.last_login.slice(-1) == ";") ouruser_new = "new_user";
} else if (typeof FromPHP.teacher == "object") {
ouruser_id = FromPHP.teacher.id;
ouruser_type = "teacher";
ouruser_grade = FromPHP.teacher.grade_default;
ouruser_subject = FromPHP.teacher.subject_default;
ouruser_role = FromPHP.teacher.role;
ouruser_school = FromPHP.teacher.school_name;
ouruser_school_id = FromPHP.teacher.school_id;
ouruser_email = FromPHP.teacher.email;
ouruser_name = FromPHP.teacher.student_name;
ouruser_phone = FromPHP.teacher.school_zip;
ouruser_signup = new Date(FromPHP.teacher.timestamp).getTime() / 1000;
if (FromPHP.teacher.last_login && FromPHP.teacher.last_login.slice(-1) == ";") ouruser_new = "new_user";
if (FromPHP.active_students) ouruser_students = FromPHP.active_students;
}
if (typeof FromPHP.features != "undefined" && FromPHP.features[0] != null) {
ouruser_premium_date = new Date(FromPHP.features[0].timstamp).getTime() / 1000;
ouruser_premium = true;
}
if (typeof FromPHP.dataLayer == "object") {
ouruser_lessons = FromPHP.dataLayer.lessons;
ouruser_questions = FromPHP.dataLayer.questions;
}
}
dataLayer = [{
'ouruser_id': ouruser_id,
'ouruser_type': ouruser_type,
'ouruser_new': ouruser_new,
'ouruser_subject': ouruser_subject,
'ouruser_grade': ouruser_grade,
'ouruser_role': ouruser_role,
'ouruser_school': ouruser_school,
'ouruser_school_id': ouruser_school_id,
'ouruser_premium': ouruser_premium,
'ouruser_premium_date': ouruser_premium_date,
'ouruser_students': ouruser_students,
'ouruser_email': ouruser_email,
'ouruser_name': ouruser_name,
'ouruser_signup': ouruser_signup,
'ouruser_lessons': ouruser_lessons,
'ouruser_questions': ouruser_questions,
'ouruser_phone': ouruser_phone
}];
//Blocking things on edmodo
var edmodo = FromPHP ?
(FromPHP.user ? (FromPHP.user.edmodoSesh) :
(FromPHP.student ? FromPHP.student.edmodoSesh :
(FromPHP.teacher ? FromPHP.teacher.edmodoSesh : false))) : false;
if(edmodo === true){
$(".Premium").css("display", "none"); //removing premium link
$(".premium-feature-promo").css("display", "none"); //Remove premium prompt signup
}
if(location.search.match(/cn=(.)/)) {
var campaign = location.search.match(/cn=(.)/)[1];
$.post( "/set_session/"+campaign, function (datum) {
//setting campaign type
});
}
window.onerror = function(){
"use strict";
var errors = Array.prototype.slice.apply(arguments);

var error_message = errors[0];
var error_url = errors[1];
var error_line = errors[2];
var error_column = errors[3]+1;

var line_string = isNaN(error_line) ? "" : " (line: " + error_line + "";
var column_string = isNaN(error_column) ? "" : ", column: " + error_column + ")";
var error_event = "[" + error_message + "][" + error_url + line_string + column_string + "]";
//error_event += ouruser_type + " " + ouruser_id;

if (typeof(dataLayer) != "undefined") {
dataLayer.push({'event': 'on-js-error','error-output': error_event + " v=1.559" });
}
return errors; //make true to hide errors
}
</script>

<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-M9KW84" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-M9KW84');</script>

<script>
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/apWCQwoLM4UCHPU1RfAg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();

UserVoice.push(['set', {
accent_color: '#ff9900',
trigger_color: 'white',
trigger_background_color: '#ff9900'
}]);
try {
UserVoice.push(['identify', {
//email: '[email protected]', // User’s email address
name: "name: "+ouruser_name, // User’s real name
//created_at: 1364406966, // Unix timestamp for the date the user signed up
id: "id: "+ouruser_id, // Optional: Unique id of the user (if set, this should not change)
type: ouruser_type+" & role:"+ouruser_role+" & school_id:"+ouruser_school_id+" & premium:"+ouruser_premium+" "+ouruser_email, // Optional: segment your users by type
account: {
id: "signup: "+ouruser_signup, // Optional: associate multiple users with a single account
name: "phone: "+ouruser_phone, // Account name
//created_at: ouruser_signup, // Unix timestamp for the date the account was created
//monthly_rate: ouruser_phone, // Decimal; monthly rate of the account
//ltv: ouruser_school_id, // Decimal; lifetime value of the account
plan: "L: "+ouruser_lessons+"; Q: "+ouruser_questions // Plan name for the account
}
}]);
} catch(e) {
UserVoice.push(['identify', {}]);
}
UserVoice.push(['addTrigger', {mode: 'satisfaction', trigger_position: 'bottom-right' }]);
UserVoice.push(['autoprompt', {}]);
if (ouruser_school_id || ouruser_new) {
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
$.src="//v2.zopim.com/?3IHl2NieckFh41wgb9bdCA40ST5sh1Xp";z.t=+new Date;$.
type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
$zopim(function() {
$zopim.livechat.button.setHideWhenOffline(true);
});
}
</script>
<script type="text/javascript" src="/static/js/jquery.vide.min.js?v=1.559"></script>
<script type="text/javascript">
var videourls = ["http://content.jwplatform.com/videos/w0b3pCUI-8cM2wyTG.mp4","https://embed-ssl.wistia.com/deliveries/39bfb08888a601fe700295d1485cc74c2f0c2f09/file.mp4", "https://embed-ssl.wistia.com/deliveries/c694e9b86fb567409e4966d8646a2679fb85fb3d/file.mp4","https://embed-ssl.wistia.com/deliveries/7e14c9a74046ad273c2609029544f02578695851/file.mp4"]; //"http://content.jwplatform.com/videos/w0b3pCUI-8cM2wyTG.mp4",
var videosplash = videourls[Math.floor(Math.random() * videourls.length)];
$('#videosplash').vide({
mp4: videosplash,
//webm: path/to/video2,
//ogv: path/to/video3,
poster: '/static/img/splash_curriculum.jpg' //'/static/img/survey_splash.jpg'
});
$("#request-form, #request-form-below").click(function() {
$.magnificPopup.open({
items: {
src: _.template($("#request-form-template").html(), {}),
type: 'inline' },
callbacks: {
open: function() {
$('#principal-interest').submit(function () {
if ($("#principal-interest").parsley().isValid()) {
var postData = {};
$.each($("#principal-interest input,#principal-interest select, #principal-interest textarea"), function() {
postData[this.id] = this.value;
});
//console.log(postData);
$.ajax({
url : "/school",
type: "POST",
data : postData,
success:function(data, textStatus, jqXHR) {
app.toast('We will be in touch shortly, '+data+'!', 4000, 'green accent-4');
$.magnificPopup.close();
},
error: function(jqXHR, textStatus, errorThrown) {
Materialize.toast('There has been an error. Feel free to contact us at 484-483-6449', 4000);
}
});
} else {
Materialize.toast('Missing/incomplete information!', 2000);
}
event.preventDefault();
});
}
}
});
});
$( document ).ready(function() {
if (window.location.href.match(/.requestdemo./)) { $("#request-form").click(); }
});
</script>
<script type="text/template" id="request-form-template">
<div class="container white-popup">
<div class="row">
<div class="col m10 offset-m1 s12">
<h5 class="center-align light">Admins: learn about our enterprise solution!</h5>
<div class="row">
<form id="principal-interest" class="col s12" method="post" action="/school" data-parsley-validate>
<div class="row">
<div class="input-field col m6 s12">
<input id="name" type="text" class="validate" autofocus required>
<label for="name" data-error="this field cannot be blank">Name</label>
</div>
<div class="input-field col m6 s12">
<input id="phone" type="text" class="validate" required>
<label for="phone" data-error="this field cannot be blank">Phone</label>
</div>
</div>
<div class="row">
<div class="input-field col m6 s12">
<input id="school" type="text" class="validate" required>
<label for="school" data-error="this field cannot be blank">Organization</label>
</div>
<div class="input-field col m6 s12">
<input id="email" type="email" class="validate" required>
<label for="email" data-error="please input a valid email">Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<select id="role" class="browser-default validate" required>
<option value="" disabled selected>Please choose your closest role</option>
<option value="School Administrator">School Administrator</option>
<option value="Curriculum Coordinator">Curriculum Coordinator</option>
<option value="Technology Director">Technology Director</option>
<option value="District Administrator">District Administrator</option>
<option value="Staff Development">Staff Development</option>
</select>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<select id="count" class="browser-default validate" required>
<option value="" disabled selected>Please choose a staff range</option>
<option value="Under 50">Under 50</option>
<option value="50-100">50-100</option>
<option value="100-150">100-150</option>
<option value="150+">150+</option>
</select>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<textarea id="message" class="materialize-textarea" class="validate" required></textarea>
<label for="message">Describe how your staff are or will be using video (1:1, flipping, blending, professional development, in-class, MOOC, etc.)</label>
</div>
</div>
<div class="row">
<div class="col m12">
<p class="right-align"><button id="school-submit" class="btn waves-effect waves-light" type="submit">Submit
<i class="material-icons right">send</i>
</button></p>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</script>

<script type="text/template" id="modal-create-lesson-template">
<form id="lesson-form" data-parsley-validate>
<div class="card modal-content teacher-view permanent-scroll" style="margin-bottom:0;">
<div class="card-heading row light-blue" style="">
<div class="col s3 m6">
<h3 class="card-title"><%= (prepop === true) ? "Edit" : "Create" %> Video Bulb</h3>
</div>
<% if (prepop !== true) { %>
<div class="col s9 m6" style="display:none">
<ul class="light-blue tabs" style="margin-top:10px;">
<li class="tab col s6 right"><a class="" href="#add-video">Add Video</a></li>
<li class="tab col s6 disabled" style="display:none"><a href="#lesson-criteria" style="min-height: 480px;">Details</a></li>
</ul>
</div>
<% } %>
</div>
<% if (prepop !== true) { %>
<div id="add-video">
<div class="section row" style="">
<h4 class="grey-text header text-darken-2">Know which video to use?</h4>
<div class="col m8">
<div class="input-field">
<input class="labeled" type="text" id="video_id" name="video_id" />
<label class=""
data-label="Accepts YouTube, Vimeo, TeacherTube, Shmoop, Google Drive, SchoolTube, and others
for school licenses!" data-error="Invalid video url" for="video_id">
Video URL
</label>
</div>
</div>
<div class="col m4">
<a id="add-video-continue" class="btn btn-raised btn-block disabled btn-large blue white-text">Continue</a>
<div id="video-loader" class="progress" style="display:none;">
<div class="indeterminate"></div>
</div>
</div>
</div>
<div class="section row">
<h4 class="grey-text header">Find the perfect video for your lesson</h4>
<br />
<div class="col s6">
<a href="/panel/lessons#premade" target="_blank"
class="btn btn-raised btn-large btn-block green accent-4 white-text">
Browse Premade Bulbs
</a>
</div>
<div class="col s6">
<a class="btn btn-raised btn-large btn-block disabled red accent-2 white-text">Educator Channels<br>(coming soon)</a>
</div>
</div>

</div>
<% } %>
<div id="lesson-criteria" class="section row">

<div class="section" style="clear:both;">
<% if (prepop !== true) { %>
<div class="col s4 center-align">
<div id="create-lesson-thumbnail"></div>
</div>
<% } else { %>
<div class="col m4">
<h6 style="margin:-20px 0 16px 0" class="blue-text">Bulb Details</h6>
<img class="responsive-img"
src="<%= (lesson.thumbnail) ? lesson.thumbnail : '/api/1.0/lesson/' + lesson.id + '/thumbnail.jpg' %>">
</div>
<% } %>


<div class="col s8">
<div class="input-field" style="margin-top:0;">
<% if (prepop === true) { %>
<input id="cl_video_id" name="video_id" value="<%= lesson.video_id %>" data-error="Invalid video url" type="text" required="">
<label class="<%= (lesson.title) ? 'active' : '' %>" for="cl_title">Change Video URL</label>
</div>

<div class="input-field">
<% } %>
<input id="cl_title" name="title" key="title" value="<%= lesson.title %>" data-error="A lesson title is required" type="text" required="">
<label class="<%= (lesson.title) ? 'active' : '' %>" for="cl_title">Lesson Title</label>
</div>
<div class="input-field">
<input id="learning_objective" name="learning_objective" key="learning_objective" data-error="A learning objective is required" value="<%= lesson.learning_objective %>" type="text" required />
<label for="learning_objective" class="<%= (lesson.learning_objective) ? 'active' : '' %>">Learning Objective</label>
</div>
</div>
</div>
<div class="section" style="clear:both;">
<div class="col m4">
<div class="input-field">
<label for="cl_grade" class="active">Grade Level</label>
<select id="cl_grade" name="grade" key="grade" required>
<option value="" class="grey-text" disabled <%= (teacher.grade_default == undefined) ? "selected" : "" %>>Choose Grade</option>
<% _.each(grades, function(item) { %>
<option value="<%= item %>" <%= (lesson.grade == item || (!lesson.grade && teacher.grade_default == item)) ? 'selected' : '' %>><%= item %></option>
<% }); %>
</select>
</div>
</div>
<div class="col m4">
<div class="input-field">
<label for="cl_topic" class="active">Subject</label>
<select id="cl_topic" name="topic" key="topic" onchange="injectTpl('cl-subtopic', { subtopics: FromPHP.subtopics[this.value]})" required>
<option value="" class="grey-text" <%= (teacher.subject_default == undefined) ? "selected" : "" %> disabled>Choose subject</option>
<% _.each(topics, function(item) { %>
<option value="<%= item %>" <%= (lesson.topic == item || (!lesson.topic && teacher.subject_default == item)) ? 'selected' : '' %>><%= item %></option>
<% }); %>
</select>
</div>
</div>
<div class="col m4">
<div class="input-field" id="cl-subtopic">
<label for="cl_subtopic" class="active">Subtopic</label>
<select id="cl_subtopic" name="subtopic" key="subtopic" required>
<option value="" class="grey-text" disabled <%= (lesson.subtopic) ? "" : "selected" %>>Choose Subtopic</option>
<% if (lesson.topic) {
_.each(FromPHP.subtopics[lesson.topic], function(item) { %>
<option value="<%= item.subtopic %>" <%= (lesson.subtopic == item.subtopic) ? "selected" : "" %>><%= item.subtopic %></option>
<% });
} else if (teacher.subject_default) {
_.each(FromPHP.subtopics[teacher.subject_default], function(item) { %>
<option value="<%= item.subtopic %>" <%= (lesson.subtopic == item.subtopic) ? "selected" : "" %>><%= item.subtopic %></option>
<% });
} %>
</select>
</div>
</div>
<div class="col m12">
<div class="input-field" id="ccss-field">
<input id="ccss" type="text" name="ccss" class="CCSS-typeahead" style="width:100%;" value="<%= lesson.ccss %>" />
<input type="hidden" class="ccss-identified <%= (lesson.video_id) ? 'active' : '' %>" name="ccss-identified" />
<p class="ccss-text"></p>
</div>
</div>
</div>
<div class="section" style="clear:both;">
<h6 class="blue-text">Settings</h6>
<div class="col m8">
<div style="margin:16px 0;">
<div class="switch" id="firewall-bypass" style="<%= ((!lesson.video_id || lesson.video_id.toString().indexOf('http://light.dog/proxy/?url=') < 0) && (lesson.source != 0 || !lesson.video_id)) ? 'display:none;' : '' %>">
<label>
<h6 class="grey-text text-darken-4" style="display:inline">Youtube Firewall Bypass (<a target="_blank" href="http://educanon.uservoice.com/knowledgebase/articles/772362">questions?</a>)</h6>
<input name="youtube_firewall" type="checkbox" <%= (lesson.video_id && lesson.video_id.toString().indexOf('http://light.dog/proxy/?url=') >= 0) ? "checked" : "" %> class="editable-checkbox" />
<span class="lever right"></span>
</label>
</div>
</div>
<div style="margin:16px 0;">
<div class="switch">
<label>
<h6 class="grey-text text-darken-4" style="display:inline">Rewind during Questions</h6>
<input type="checkbox" name="rewind_yes" class="editable-checkbox" <%= (lesson.rewind_yes) ? "checked" : "" %> id="rewind_yes" key="rewind_yes" />
<span class="lever right"></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<% if (prepop === true) { %>
<input type="submit" class="waves-effect blue-text waves-light btn-flat right" value="SAVE" />
<% } %>
<a href="javascript:void(0)" class="modal-action modal-close waves-effect waves-light btn-flat right">Cancel</a>
</div>
</form>
</script>

<div id="modal-create-lesson" class="modal modal-fixed-footer">
</div>
<script type="text/template" id="cl-subtopic-template">
<label for="cl_subtopic" class="active">Subtopic</label>
<select id="cl_subtopic" name="subtopic" key="subtopic" required>
<option value="" class="grey-text" selected disabled>Choose Subtopic</option>
<% _.each(subtopics, function(item) { %>
<option value="<%= item.subtopic %>"><%= item.subtopic %></option>
<% }); %>
</select>
</script>

<script type="text/javascript">
window.EditLesson = Backbone.Model.extend({
defaults: function () {
return {
title: '',
grade: '',
topic: '',
subtopic: '',
learning_objective: '',
video_id: "",
rewind_yes: null,
source: 2,
duration: null
};
},
initialize: function (attrs) {
if(FromPHP["slesson"]){
this.Student = attrs.Student;
} else {
this.Teacher = attrs.Teacher;
}
},
analytics: function() {
var questions = lessonView.questions.models,
data = {
"bloom":[0,0,0,0,0,0],
"types":[0,0,0,0], //MC, Check all, FR, SA
"media":[0,0,0],
"feedback_ratio":[0,0,0] // (applicable) questions, answers, feedback
};

// Perform analytics on each question and return the cumulative sum
for (var i in questions) {
var q = questions[i],
q_data = q.analyze(q);
for (var j in q_data) {
for (var k in q_data[j]) {
data[j][k] += q_data[j][k];
}
}
}
var dur = this.get("duration");
if (dur) {
dur = dur.split(',');
data['duration'] = parseInt(dur[1], 10) - parseInt(dur[0], 10);
} else {
data['duration'] = lessonView.videoView.player.getDuration();
}
return data;
},
score: function(analysis) {
var score = 2,
labels = ['Good', 'Very Good', 'Excellent'],
fbr = Math.round(analysis.feedback_ratio[2]*100/analysis.feedback_ratio[1]),
qr = ((analysis.types[0] + analysis.types[1] + analysis.types[2] + analysis.types[3]) * 60 / analysis.duration).toFixed(1),
cr = (analysis.feedback_ratio[1] / analysis.feedback_ratio[0]).toFixed(2);

function subThres(stat, range, min) {
for (var i=0; i<range; i++) {
if (stat[i] <= min) return true;
}
return false;
}
if (subThres(analysis.bloom, 6, 0) || subThres(analysis.types, 4, 1) ||
fbr <= 0 || qr <= 1 || cr < 3) {
score = 0;
} else if (subThres(analysis.bloom, 6, 2) || subThres(analysis.types, 4, 2) ||
fbr <= 50 || qr <= 2 || cr < 4) {
score = 1;
}
return [score, labels[score]];

},
urlRoot: function () {
//If slesson, student-made lesson; else teacher (regular) lesson
return api_prefix + "/teachers/" + FromPHP.teacher.id + "/lessons";
}
});

var lessonObj;

function firewallBypass(value) {
var videoUrl = lessonObj.get('video_id');
var proxyUrl = "http://light.dog/proxy/?url=";
if (value) {
if (!videoUrl.indexOf(proxyUrl) >= 0)
videoUrl = proxyUrl + videoUrl;
lessonObj.set('source', 2);
} else if (value === false) {
if (videoUrl.indexOf(proxyUrl) == 0)
videoUrl = videoUrl.replace(proxyUrl, '');
lessonObj.set('source', 0);
} else {
app.error("Invalid value passed for firewall bypass");
return
}
//console.log(videoUrl);
lessonObj.set('video_id', videoUrl);
lessonObj.save();
}

function renderTypeahead() {
if (typeof $('.CCSS-typeahead').typeahead != "undefined") {
$(".CCSS-typeahead").typeahead('destroy');
var gradeLevel, standardSubject,
grade = lessonObj.get('grade'),
topic = lessonObj.get('topic');
if (grade == "K-5th")
gradeLevel = "3rd-5th,Other";
gradeLevel = (grade == "3rd-5th" || grade=="6th-8th" || grade=="9th-12th" || grade=="Other") ? grade : gradeLevel;
standardSubject = (topic == "Math" || topic=="Science" || topic=="English") ? topic : false;
if (!gradeLevel || !standardSubject) {
$('#ccss-field').fadeOut(800);
lessonObj.set('ccss', '');
lessonObj.save();
} else {
$('#ccss-field').show();
$('#ccss').css('visibility', 'visible');
$('.ccss-text').html(function(i, html) {
return html.replace(/([^ ]+) /, '<span style="font-weight:bold">$1</span> ');
});

var url = '/ccss/topic/' + standardSubject + '/grade/' + gradeLevel;
$('.CCSS-typeahead').typeahead({
name: gradeLevel+"-and-"+topic,
valueKey: 'standard_title',
prefetch: {
url: url,
filter: function(parsedResponse) {
Standards = _.map(parsedResponse, function(standard) {
standard["tokens"] = standard["tokens"].replace(/,\s/g, ',').replace(/(\r\n|\n|\r)/gm,"").split(',');
return standard;
});
return Standards;
}
},
template: [
'<p class="tt-suggestion"><strong>{{identifier}}</strong> {{standard_title}}</p>'
].join(''),
engine: Hogan
});

$('.CCSS-typeahead').attr("placeholder", "Search Standards");
$('.CCSS-typeahead').on("typeahead:selected typeahead:autocompleted", function(e,datum) {
$(".ccss-identified").val(datum.identifier+": "+datum.standard_title);
});
$('.CCSS-typeahead').on("typeahead:selected typeahead:autocompleted", function(dat) {
var val = $('.ccss-identified').val();
//console.log(val);
lessonObj.set('ccss', val);
});
}
}
}
var saveOnly = false;
var editDeferred;
function prepopLesson(lesson) {
editDeferred = $.Deferred();
if (typeof lesson == "number")
lesson = app.getById(lesson, "lessons");

lessonObj = new EditLesson(lesson);
injectModal('modal-create-lesson', {
prepop: true,
lesson: lesson,
teacher: FromPHP.teacher,
grades: FromPHP.grades,
topics: FromPHP.topics,
subtopics: FromPHP.subtopics
});
saveOnly = true;
bindEvents(true);
renderTypeahead();
return editDeferred.promise();
}

function injectCreateLesson(){
lessonObj = {
title: '',
grade: FromPHP.teacher.grade_default,
topic: FromPHP.teacher.subject_default,
subtopic: '',
learning_objective: '',
source: 0,
rewind_yes: null,
duration: null
};
saveOnly = false;

injectTpl('modal-create-lesson', {
prepop: false,
lesson: lessonObj,
teacher: FromPHP.teacher,
grades: FromPHP.grades,
topics: FromPHP.topics,
subtopics: FromPHP.subtopics
});
$('#modal-create-lesson').find('ul.tabs').tabs();
bindEvents();
$('#modal-create-lesson').openModal({
dismissible: false,
// opacity: .5, // Opacity of modal background
// in_duration: 300, // Transition in duration
// out_duration: 200, // Transition out duration
ready: function() {
$("#modal-create-lesson form .permanent-scroll").niceScroll({autohidemode:false,cursorcolor:"rgba(0,0,0,0.3)",cursorborder: "0px solid transparent", cursorwidth:8});
}, // Callback for Modal open
complete: function() { } // Callback for Modal close
});

}

function bindEvents(preprop) {
$("#lesson-form").parsley();
$("#lesson-form").find(".parsley-errors-list").each(function() {
$(this).appendTo($(this).parent());
})
$("#lesson-form").on('submit', function(e) {
var form = $("#lesson-form").parsley();
if (form.isValid()) {
lessonObj.save().then(function() {
if (!saveOnly) {
window.location.href = "/panel/edit/" + lessonObj.get('id');
} else {
$('#modal-create-lesson').closeModal();
editDeferred.resolve(lessonObj.toJSON());
}
});
} else {
}
e.preventDefault();
return;
});
$('input[type=submit]').click(function() {
var form = $("#lesson-form").parsley();
if (!form.isValid())
app.error("A required field needs to be filled out before continuing");
});
var raceCondition = 0;
$("#cl_video_id").on("keyup change", _.debounce(function() {
youtubeSearch($(this).val()).then(function(videoId) {
lessonObj.set('video_id', videoId);
lessonObj.set('duration', '');
$("#cl_video_id").addClass("valid").removeClass('invalid');
}, function() {
$("#cl_video_id").removeClass("valid").addClass('invalid');
app.error('Invalid video id', '#cl_video_id');
});
}, 1000));

$('#video_id').on("keyup change", _.debounce(function() {
$("#video-loader").show();
youtubeSearch($(this).val()).then(function(videoId) {
$('#video_id').prop('disabled', true).removeClass('invalid').addClass('valid');

if (typeof lessonObj.get != "function") {
lessonObj.video_id = videoId;
//console.log('race condition: ' + raceCondition);
if (raceCondition === 0) {
raceCondition = 1;
} else {
return
}
$.ajax({
data: {
model: JSON.stringify(lessonObj)
},
url: "/api/1.0/teachers/" + FromPHP.teacher.id + "/lessons",
type: "POST",
success: function (data) {
lessonObj = new EditLesson(data);

$("#lean-overlay, #modal-create-lesson .modal-close").unbind('click').click(function() {
app.confirm(["Abandon progress on this lesson?", "Current progress on this lesson will be lost"],"ABANDON", "CANCEL").then(function(){
$("#modal-create-lesson").closeModal();
$.ajax('/api/1.0/teachers/'+FromPHP.teacher.id+'/lessons/'+lessonObj.get('id'), {
type: "DELETE"
});
});
});

$('#modal-create-lesson').find('li.disabled').show().removeClass('disabled');
$('#modal-create-lesson').find('li.right').removeClass('right');
renderTypeahead();
$('#add-video-continue').removeClass('disabled');
$("#video-loader").remove();
$('#add-video-continue').unbind('click');
$('#add-video-continue').click(function () {
$('#create-lesson-thumbnail').html('<img class="responsive-img" src="/api/1.0/lesson/' + lessonObj.get('id') + '/thumbnail.jpg' + '" />');
$('#modal-create-lesson').tabs('select_tab', 'lesson-criteria');
$('#modal-create-lesson').find('.modal-footer').prepend(
$('<input id="beginBuild" type="submit" class="waves-effect blue-text waves-light btn-flat right" value="Begin Building">').click(function() {
var form = $("#lesson-form").parsley();
if (!form.isValid()) {
gtm('create-bulb-begin-building-error', 'begin-building-error', lessonObj.get('id'));
app.error("A required field needs to be filled out before continuing");
}
else gtm('create-bulb-begin-building-success', 'begin-building-success', lessonObj.get('id'));
})
);
});
$("#beginBuild").remove();
}
});
} else {
lessonObj.set('video_id', videoId);
}
}, function() {
//console.log('id error');
app.error('Invalid video id', '#video_id');
$('#add-video-continue').unbind('click');
});
}, 1000));

$("#firewall-bypass").find('input[type=checkbox]').change(function(e) {
firewallBypass($(this).prop('checked'));

});

$("#lesson-criteria").find(".switch input[key]").change(function() {
var val = ($(this).prop('checked')) ? '1' : '0',
key = $(this).attr('key');
//console.log(val);

lessonObj.set(key, val);
});
app.bindToUI(function(target) {
$(target).find('*[key]:not([type=checkbox])').change(function() {
var key = $(this).attr('key');
lessonObj.set(key, jsonEscape($(this).val()));
//console.log({key:key, val:$(this).val()});
if (key == "grade" || key == "topic") {
renderTypeahead();
}
});
})

}

$(document).ready(function(){
app.requireVars(['teacher','grades', 'topics', 'subtopics']).then(function() {
$('.create-lesson-trigger').click(injectCreateLesson);
});
});

function youtubeSearch(q) {
window.isVimeo = false;
window.isTT = false;
var shmoopre = /shmoop\.com\/video\/(.+)/;
var archivere = /\.mp4$/;
var schooltubere = /schooltube\.com\/(?:embed|video|embed_force)\/([A-Za-z0-9]+)\//;
var wistiare = /wistia\.com\/medias\/([A-Za-z0-9]+)/;
var ytre = /^(?:https?:\/\/)?(?:(?:www|m)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
var drivere = /drive\.google\.com.*\/([-\w]{25,})/;
var urlre = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/;
var vimre = /^(?:https?:\/\/)?(?:player\.)?(?:www\.)?vimeo.com\/(?:video\/|channels\/|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/;
var teachertubere = /^(?:https?:\/\/)?(?:(?:www)\.)?(?:teachertube\.com\/(?:embed\/)?video)\/(?:.*-)?(\d+)(?!.*\d).*/;
var videoId = (q.match(ytre)) ? RegExp.$1 : false;
$('#firewall-bypass').hide();
var defer = $.Deferred();
if (videoId) {
isVimeo = false;
isTT = false;
console.log('yt');
if (typeof lessonObj.set == "function")
lessonObj.set("source", 0);
else
lessonObj.source = 0;
if (FromPHP.features || FromPHP.teacher.school_id)
$('#firewall-bypass').show();
defer.resolve(videoId);
} else if (q.match(vimre)) {
console.log('vim');
var vimId = q.match(vimre)[3];
isVimeo = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 1
}, {silent:true});
else
lessonObj.source = 1;
defer.resolve(vimId);
} else if (q.match(teachertubere)) {
var teacherTubeId = q.match(teachertubere)[1];
//var TTUrl = q.match(teachertubere).input;
var TTUrl = "http://www.teachertube.com/video/"+teacherTubeId;
isTT = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 2
}, {silent:true});
else { lessonObj.source = 2; }
$.ajax({
type: "POST",
url: "/teachertube",
data: {'TTUrl': TTUrl}
}).success( function( data ) {
TTObj = JSON.parse(data);
mp4File = TTObj['TTUrl'];
var mp4thumb = TTObj['TTThumbnail'];
if (typeof lessonObj.set == "function") {
lessonObj.set({
"thumbnail": mp4thumb
}, {silent:true});
} else { lessonObj.thumbnail = mp4thumb; }
defer.resolve(mp4File);
});
// defer.resolve(teacherTubeId);
} else if (q.match(drivere)) {
if ($( ".toast" ).length == 0) app.toast('Reminder: All Google Drive links must be set to "Public on the web", Instructions '+"&nbsp;"+' <a target="_blank" href="https://support.google.com/drive/answer/2494886"> here</a>', 8000, 'green accent-4');
isTT = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 2
}, {silent:true});
else
lessonObj.source = 2;
var driveId = q.match(drivere)[1];
defer.resolve(driveUrl = 'https://googledrive.com/host/'+driveId);
//defer.resolve(driveUrl = 'https%3a%2f%2fgoogledrive.com%2fhost%2f'+driveId);
} else if (q.match(wistiare)) {
var wistiaID = q.match(wistiare)[1];
isTT = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 2
}, {silent:true});
else
lessonObj.source = 2;
$.ajax({
type: "POST",
url: "/wistia/"+wistiaID,
data: {'wistiaId': wistiaID}
}).success( function( data ) {
WistiaObj = JSON.parse(data);
mp4File = WistiaObj['url'];
var mp4thumb = WistiaObj['thumbnail'];
if (typeof lessonObj.set == "function")
lessonObj.set({
"thumbnail": mp4thumb
}, {silent:true});
else
lessonObj.thumbnail = mp4thumb;

defer.resolve(mp4File);
});
} else if (q.match(shmoopre)) {
var shmoopUrl = q.match(shmoopre).input;
if (shmoopUrl.indexOf("www.shmoop.com") == -1) q = q.replace('shmoop.com','www.shmoop.com');
isTT = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 2
}, {silent:true});
else
lessonObj.source = 2;
var shmoopId = q.match(shmoopre)[1];
shmoopId = shmoopId.replace(/\/$/, "");
$.ajax({
type: "POST",
url: "/shmoop",
data: {'shmoopUrl': shmoopUrl, 'shmoopId': shmoopId}
}).success( function( data ) {
shmoopObj = $.parseJSON(JSON.parse(data));
shmoopUrl = "http://d395x7ewlfzo3v.cloudfront.net/"+shmoopObj["file"];

defer.resolve(shmoopUrl);
});
}
else if (q.match(schooltubere)) {
var schooltubeId = q.match(schooltubere)[1];
////console.log(schooltubeId);
//var schooltubeUrl = 'http://www.schooltube.com/embed_force/'+schooltubeId;
isTT = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 2
}, {silent:true});
else
lessonObj.source = 2;
$.ajax({
type: "POST",
url: "/schooltube",
data: {'schooltubeId': schooltubeId}
}).success( function( data ) {
var schooltubeObj = JSON.parse(data);
var schooltubeUrl = schooltubeObj["STurl"];
var mp4thumb = schooltubeObj['STthumb'];
if (typeof lessonObj.set == "function")
lessonObj.set({
"thumbnail": mp4thumb
}, {silent:true});
else
lessonObj['thumbnail'] = mp4thumb;
defer.resolve(schooltubeUrl);
}).error( function() {
alert("There has been a problem with schooltube. Please email [email protected] with the URL you used to solve.");
});
}
else if (q.match(archivere)) {
isTT = true;
if (typeof lessonObj.set == "function")
lessonObj.set({
"source": 2
}, {silent:true});
else
lessonObj.source = 2;
defer.resolve(archiveUrl = q.match(archivere).input);
}
else {
return defer.reject();
}
return defer.promise();
}
</script>
<script type="text/template" id="modal-confirm-template">
<div class="modal-content">
<% if (typeof message == "object") { %>
<h5 class="grey-text text-darken-3" style="margin-top:0;margin-bottom:1rem;"><%= message[0] %></h6>
<h6 class="grey-text"><%= message[1] %></h6>
<% } else { %>
<h6 class="grey-text"><%= message %></h6>
<% } %>
</div>
<div class="modal-footer">
<a href="javascript:void(0)" class="waves-effect blue-text btn-flat confirm-ok right"><%= confirm %></a>
<a href="javascript:void(0)" class="waves-effect blue-text btn-flat confirm-dismiss right"><%= cancel %></a>
</div>
</script>
<div id="modal-confirm" class="modal modal-fixed-fotter"></div>
<script type="text/template" id="modal-list-template">
<div class="modal-content collection section row" style="padding:0;margin-bottom:0">
<div class="collection-item">
<h5 style="padding:8px 0" class="card-title black-text"><%= title %></h5>
</div>
<% _.each(items, function(item) { %>

<a class="collection-item grey-text" href="<%= (item.href) ? item.href : 'javascript:void(0)' %>"
<% if (item.onclick) { %>onclick="<%= item.onclick %>" <% } %>
><%= item.title %>
</a>

<% }); %>
</div>
</script>
<div class="modal" id="modal-list" style="max-width:300px;"></div>
</body></html>