Commit cc1de22e by Piotr Mitros

Initial commit

parents
syntax: glob
*.pyc
*~
database.sqlite
from django.db import models
from django.contrib.auth.models import User
import uuid
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True, db_index=True)
name = models.TextField(blank=True)
language = models.TextField(blank=True)
location = models.TextField(blank=True)
meta = models.TextField(blank=True) # JSON dictionary for future expansion
class Registration(models.Model):
''' Allows us to wait for e-mail before user is registered. A
registration profile is created when the user creates an
account, but that account is inactive. Once the user clicks
on the activation key, it becomes active. '''
user = models.ForeignKey(User, unique=True)
activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True)
def register(self, user):
# MINOR TODO: Switch to crypto-secure key
self.activation_key=uuid.uuid4().hex
self.user=user
self.save()
def activate(self):
self.user.is_active = True
self.user.save()
self.delete()
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
from djangomako.shortcuts import render_to_response, render_to_string
from django.contrib.auth.models import User
from django.shortcuts import redirect
from django.contrib.auth import logout, authenticate, login
from django.contrib.auth.models import User
from django.http import HttpResponse
import json
from models import Registration, UserProfile
from django.conf import settings
from django.core.context_processors import csrf
from django.core.validators import validate_email, validate_slug
def csrf_token(context):
csrf_token = context.get('csrf_token', '')
if csrf_token == 'NOTPROVIDED':
return ''
return u'<div style="display:none"><input type="hidden" name="csrfmiddlewaretoken" value="%s" /></div>' % (csrf_token)
def index(request):
if request.user.is_authenticated():
return redirect('/courseware')
else:
return render_to_response('index.html', {'error':'', 'csrf':csrf(request)['csrf_token']}) # Clean up how error is done.
def login_user(request, error=""):
if 'email' not in request.GET or 'password' not in request.GET:
return render_to_response('login.html', {'error':error.replace('+',' ')})
email = request.GET['email']
password = request.GET['password']
try:
user=User.objects.get(email=email)
except User.DoesNotExist:
return HttpResponse(json.dumps({'success':False, 'error': 'Invalid login'})) # TODO: User error message
username=user.username
user=authenticate(username=username, password=password)
if user is None:
return HttpResponse(json.dumps({'success':False, 'error': 'Invalid login'}))
if user is not None and user.is_active:
login(request, user)
return HttpResponse(json.dumps({'success':True}))
return HttpResponse(json.dumps({'success':False, 'error': 'Account not active. Check your e-mail.'}))
def logout_user(request):
logout(request)
return redirect('/')
def create_account(request):
js={'success':False}
# Confirm we have a properly formed request
for a in ['username', 'email', 'password', 'location', 'language', 'name']:
if a not in request.GET:
js['value']="Error (401 {field}). E-mail us.".format(field=a)
return HttpResponse(json.dumps(js))
if request.GET['honor_code']!=u'true':
js['value']="To enroll, you must follow the honor code.".format(field=a)
return HttpResponse(json.dumps(js))
if request.GET['terms_of_service']!=u'true':
js['value']="You must accept the terms of service.".format(field=a)
return HttpResponse(json.dumps(js))
# Confirm appropriate fields are there.
# TODO: Check e-mail format is correct.
# TODO: Confirm e-mail is not from a generic domain (mailinator, etc.)? Not sure if
# this is a good idea
# TODO: Check password is sane
for a in ['username', 'email', 'password', 'terms_of_service', 'honor_code']:
if len(request.GET[a])<2:
js['value']="{field} is required.".format(field=a)
return HttpResponse(json.dumps(js))
try:
validate_email(request.GET['email'])
except:
js['value']="Valid e-mail is required.".format(field=a)
return HttpResponse(json.dumps(js))
try:
validate_slug(request.GET['username'])
except:
js['value']="Username should only consist of A-Z and 0-9.".format(field=a)
return HttpResponse(json.dumps(js))
# Confirm username and e-mail are unique. TODO: This should be in a transaction
if len(User.objects.filter(username=request.GET['username']))>0:
js['value']="An account with this username already exists."
return HttpResponse(json.dumps(js))
if len(User.objects.filter(email=request.GET['email']))>0:
js['value']="An account with this e-mail already exists."
return HttpResponse(json.dumps(js))
u=User(username=request.GET['username'],
email=request.GET['email'],
is_active=False)
u.set_password(request.GET['password'])
r=Registration()
# TODO: Rearrange so that if part of the process fails, the whole process fails.
# Right now, we can have e.g. no registration e-mail sent out and a zombie account
u.save()
r.register(u)
up=UserProfile(user=u)
up.name=request.GET['name']
up.language=request.GET['language']
up.location=request.GET['location']
up.save()
d={'name':request.GET['name'],
'key':r.activation_key,
'site':settings.SITE_NAME}
subject = render_to_string('activation_email_subject.txt',d)
# Email subject *must not* contain newlines
subject = ''.join(subject.splitlines())
message = render_to_string('activation_email.txt',d)
try:
res=u.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
except:
js['value']=str(sys.exc_info())
return HttpResponse(json.dumps(js))
js={'success':True,
'value':render_to_string('registration/reg_complete.html', {'email':request.GET['email']})}
return HttpResponse(json.dumps(js), mimetype="application/json")
def activate_account(request, key):
r=Registration.objects.filter(activation_key=key)
if len(r)==1:
r[0].activate()
return render_to_response("activation_complete.html",{})
if len(r)==0:
return render_to_response("activation_invalid.html",{})
return HttpResponse("Unknown error. Please e-mail us to let us know how it happened.")
# For calculator:
# http://pyparsing.wikispaces.com/file/view/fourFn.py
import random, numpy, math, scipy, sys, StringIO, os, struct, json
from x_module import XModule
from xml.dom.minidom import parse, parseString
class LoncapaProblem(XModule):
def get_state(self):
def get_score(self):
def max_score(self):
def get_html(self):
def handle_ajax(self, json):
def __init__(self, filename, id=None, state=None):
if __name__=='__main__':
p=LoncapaProblem('<problem name="Problem 1: Resistive Divider" filename="resistor" />')
print p.getHtml()
print p.getContext()
print p.getSeed()
# Chef and puppot
# For calculator:
# http://pyparsing.wikispaces.com/file/view/fourFn.py
import random, numpy, math, scipy, sys, StringIO, os, struct, json
from xml.dom.minidom import parse, parseString
class LoncapaProblem():
def get_state(self):
''' Stored per-user session data neeeded to:
1) Recreate the problem
2) Populate any student answers. '''
return json.dumps({'seed':self.seed,
'answers':self.answers,
'correct_map':self.correct_map})
def get_score(self):
correct=0
for key in self.correct_map:
if self.correct_map[key] == u'correct':
correct += 1
if len(self.answers)==0:
return {'score':0,
'total':len(self.questions)}
else:
return {'score':correct,
'total':len(self.questions)}
def max_score(self):
pass
def get_html(self):
''' Return the HTML of the question '''
return self.text
def handle_ajax(self, json):
pass
def __init__(self, filename, id=None, state=None):
''' Create a new problem of the type defined in filename.
By default, this will generate a random problem. Passing
seed will provide the random seed. Alternatively, passing
context will bypass all script execution, and use the
given execution context. '''
if state!=None:
state=json.loads(state)
else:
state={}
self.gid=id
if 'seed' in state:
self.seed=state['seed']
else:
# TODO: Check performance of urandom -- depending on
# implementation, it may slow down to the point of causing
# performance issues if we deplete the kernel entropy
# pool.
self.seed=struct.unpack('i', os.urandom(4))[0]
if 'answers' in state:
self.answers=state['answers']
if 'correct_map' in state:
self.correct_map=state['correct_map']
random.seed(self.seed)
dom=parse(filename).childNodes[0]
g={'random':random,'numpy':numpy,'math':math,'scipy':scipy}
buf=StringIO.StringIO()
ot=False ## Are we in an outtext context?
for e in dom.childNodes:
if e.localName=='script' and context==None:
exec e.childNodes[0].data in g,self.context
if e.localName=='endouttext':
ot=False
if ot:
e.writexml(buf)
if e.localName=='startouttext':
ot=True
if e.localName in self.handlers:
problem=self.handlers[e.localName](self,e)
buf.write(problem)
self.text=buf.getvalue()
self.text=self.contextualize_text(self.text)
text=""
context={} # Execution context from loncapa/python
questions={} # Detailed info about questions in problem instance. TODO: Should be by id and not lid.
answers={} # Student answers
correct_map={}
seed=None
gid="" # ID of the problem
lid=-1 # ID of the field within the problem
def get_context(self):
''' Return the execution context '''
return self.context
def get_seed(self):
''' Return the random seed used to generate the problem '''
return self.seed
def get_correct_map(self):
return self.correct_map
def set_answers(self, answers):
self.answers=answers
def grade_answers(self, answers):
''' Takes a map of IDs to answers. Return which ones are correct '''
self.answers=answers
correct_map={}
for key in self.questions:
id=self.questions[key]['id']
if id not in answers:
correct_map[id]='incorrect' # Should always be there
else:
correct_map[id]=self.grade_nr(self.questions[key],
self.answers[id])
self.correct_map=correct_map
return correct_map
## Internal methods
def number(self,text):
''' Convert a number to a float, understanding suffixes '''
try:
text.strip()
suffixes={'%':0.01,'k':1e3,'M':1e6,'G':1e9,'T':1e12,'P':1e15,
'E':1e18,'Z':1e21,'Y':1e24,'c':1e-2,'m':1e-3,'u':1e-6,
'n':1e-9,'p':1e-12,'f':1e-15,'a':1e-18,'z':1e-21,'y':1e-24}
if text[-1] in suffixes:
return float(text[:-1])*suffixes[text[-1]]
else:
return float(text)
except:
return 0 # TODO: Better error handling?
def grade_nr(self, question, answer):
error = abs(self.number(answer) - question['answer'])
allowed_error = abs(question['answer']*question['tolerance'])
if error <= allowed_error:
return 'correct'
else:
return 'incorrect'
def handle_nr(self, element):
answer=element.getAttribute('answer')
for e in element.childNodes:
if e.nodeType==1 and e.getAttribute('type')=="tolerance":
tolerance=e.getAttribute('default')
self.lid+=1
id=str(self.gid)+'_'+str(self.lid)
problem={"answer":self.number(self.contextualize_text(answer)),
"type":"numericalresponse",
"tolerance":self.number(self.contextualize_text(tolerance)),
"id":id,
"lid":self.lid,
}
self.questions[self.lid]=problem
if id in self.answers:
value=self.answers[id]
else:
value=""
icon='bullet'
if id in self.correct_map and self.correct_map[id]=='correct':
icon='check'
if id in self.correct_map and self.correct_map[id]=='incorrect':
icon='close'
html='<input type="text" name="input_{id}" id="input_{id}" value="{value}"><span class="ui-icon ui-icon-{icon}" style="display:inline-block;" id="status_{id}"></span> '.format(id=id,value=value,icon=icon)
return html
graders={'numericalresponse':grade_nr}
handlers={'numericalresponse':handle_nr}
def contextualize_text(self, text):
''' Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context '''
for key in sorted(self.context, lambda x,y:cmp(len(y),len(x))):
text=text.replace('$'+key, str(self.context[key]))
return text
if __name__=='__main__':
p=LoncapaProblem('resistor.xml', seed=-1601461296)
print p.getHtml()
print p.getContext()
print p.getSeed()
from django.db import models
from django.contrib.auth.models import User
# class Organization(models.Model):
# # Tree structure implemented such that child node has left ID
# # greater than all parents, and right ID less than all parents
# left_tree_id = models.IntegerField(unique=True, db_index=True)
# right_tree_id = models.IntegerField(unique=True, db_index=True)
# # This is a duplicate, but we keep this to enforce unique name
# # constraint
# parent = models.ForeignKey('self', null=True, blank=True)
# name = models.CharField(max_length=200)
# ORG_TYPES= (('course','course'),
# ('chapter','chapter'),
# ('section','section'),)
# org_type = models.CharField(max_length=32, choices=ORG_TYPES)
# available = models.DateField(null=True, blank=True)
# due = models.DateField(null=True, blank=True)
# # JSON dictionary of metadata:
# # Time for a video, format of a section, etc.
# metadata = models.TextField(null=True, blank=True)
# class Modules(models.Model):
# MOD_TYPES = (('hw','homework'),
# ('vid','video_clip'),
# ('lay','layout'),
# (),)
# module_type = models.CharField(max_length=100)
# left_tree_id = models.IntegerField(unique=True, db_index=True)
# right_tree_id = models.IntegerField(unique=True, db_index=True)
# LAYOUT_TYPES = (('leaf','leaf'),
# ('tab','tab'),
# ('seq','sequential'),
# ('sim','simultaneous'),)
# layout_type = models.CharField(max_length=32, choices=LAYOUT_TYPES)
# data = models.TextField(null=True, blank=True)
#class HomeworkProblems(models.Model):
class StudentModule(models.Model):
# For a homework problem, contains a JSON
# object consisting of state
state = models.TextField(null=True, blank=True)
grade = models.FloatField(null=True, blank=True)
student = models.ForeignKey(User)
MODULE_TYPES = (('hw','homework'),)
module_type = models.CharField(max_length=32, choices=MODULE_TYPES, default='hw')
module_id = models.CharField(max_length=255) # Filename
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
class Meta:
unique_together = (('student', 'module_id'),)
%!PS-Adobe-3.0 EPSF-3.0
%%Title: divider
%%Creator: XCircuit v3.6 rev135
%%CreationDate: Thu Dec 1 09:49:39 2011
%%Pages: 1
%%BoundingBox: 68 68 202 174
%%DocumentNeededResources: font Helvetica Times-Roman
%%EndComments
%%BeginProlog
%
% PostScript prolog for output from xcircuit
% Version: 3.3
%
% Electrical circuit (and otherwise general) drawing program
%
% Written by Tim Edwards 8/5/93--7/13/05 (tim.edwards@multigig.com)
% The Johns Hopkins University (1993-2004)
% MultiGiG, Inc. (2004-present)
%
%%BeginResource: procset XCIRCproc 3.3 0
%
% supporting definitions --- these are the primary xcircuit types.
/XCIRCsave save def
/topmat matrix currentmatrix def
/fontslant { /slant exch def [1 0 slant 1 0 0]
exch findfont exch makefont dup length dict /ndict exch def
{ 1 index /FID ne { ndict 3 1 roll put } { pop pop } ifelse } forall
ndict definefont pop} def
/ul { dup type /stringtype eq showflag 1 eq and { gsave
currentpoint topmat setmatrix 0 0 moveto 2 index stringwidth pop (_)
false charpath flattenpath pathbbox grestore exch pop 1 index
sub setlinewidth exch pop currentpoint 3 -1 roll add moveto 0
rlineto stroke moveto } if } def
/ol { dup type /stringtype eq showflag 1 eq and { gsave gsave
currentpoint topmat setmatrix 2 index stringwidth pop 3 index
true charpath flattenpath pathbbox grestore exch pop
exch pop topmat setmatrix (_) true charpath pathbbox grestore
exch pop 1 index sub setlinewidth exch pop currentpoint
exch 4 1 roll exch sub add moveto pop 0 rlineto stroke
moveto } if } def
/stW { gsave currentpoint newpath moveto true charpath flattenpath
pathbbox pop exch pop sub grestore } def
/Ts {mark Tabs aload pop counttomark 1 add array astore /Tabs exch def Tabs
0 currentpoint pop put} def
/Tbn {mark Tabs aload pop counttomark dup 2 add 1 roll cleartomark 1 sub} def
/Tb { 0 1 Tbn {Tabs exch get dup currentpoint pop lt
{currentpoint exch pop moveto exit} {pop} ifelse } for } def
/Tf { Tbn -1 0 {Tabs exch get dup currentpoint pop gt
{currentpoint exch pop moveto exit} {pop} ifelse } for } def
/qS { (aa) stW (a a) stW sub 4 div 0 Kn } def
/hS { qS qS } def
/pspc 0 def
/cf0 { scalefont setfont } bind def
/Kn { dup kY add /kY exch def rmoveto } bind def
/ss { /fscale fscale 0.67 mul def currentfont 0.67 cf0 0 fscale0 fscale mul
0.33 mul neg Kn} def
/Ss { /fscale fscale 0.67 mul def currentfont 0.67 cf0 0 fscale0 fscale mul
0.67 mul Kn } def
/ns { 0 kY neg Kn /kY 0 def /fscale 1.0 def xfont0 1.0 cf0 } def
/CR { ns 0 /Bline Bline fscale0 neg add def Bline moveto } def
/cf { dup type /realtype ne {1.0} if exch findfont exch kY 0 eq
{ 40 mul dup /fscale0 exch def cf0 /xfont0 currentfont def}
{fscale0 mul fscale mul cf0} ifelse } def
/ctmk { counttomark dup 2 add -1 roll pop } bind def
/label { gsave translate 0 0 moveto dup scale neg /rotval exch def
/just exch def just 384 and 0 gt {/mshow {pop} def} {/mshow {show}
def} ifelse just 16 and 0 gt {gsave rotval rotate 0 1 dtransform
gsave pagemat setmatrix idtransform exch grestore 1 0 dtransform
gsave pagemat setmatrix idtransform exch grestore dup abs 1e-9 lt
{pop mul 0 gt} {3 1 roll pop pop 0 lt} ifelse grestore {-1 /rotval
rotval neg def /just just dup 3 and 1 ne {3 xor} if def} {1} ifelse
exch -1e-9 lt {-1 /rotval rotval neg def /just just dup 12 and
4 ne {12 xor} if def} {1} ifelse scale } if /showflag 0 def
/fspc pspc def /Bline 0 def /Tabs 0 array def /fscale 1.0 def
/kY 0 def gsave dup 1 add copy 0 exch 1 0 dtransform exch atan rotate
{exch dup type /stringtype eq {true charpath flattenpath} {dup type
/arraytype eq {exec} {12 string cvs true charpath flattenpath} ifelse}
ifelse} repeat pop pathbbox grestore 3 -1 roll pop 3 1 roll just
1 and 0 gt {just 2 and 0 gt {exch pop neg fspc sub} {exch sub 0.5
mul neg} ifelse} {pop neg fspc add} ifelse exch Bline exch just 4
and 0 gt {just 8 and 0 gt {exch pop neg fspc sub} {add 0.5 mul neg}
ifelse} {pop neg fspc add} ifelse rotval rotate Kn currentpoint
translate /showflag 1 def /Bline 0 def /Tabs 0 array def /fscale
1.0 def /kY 0 def {dup type /stringtype eq {mshow} {dup type
/arraytype eq {exec} {12 string cvs mshow} ifelse} ifelse} repeat
grestore } def
/pinlabel { 4 index 32 and 0 ne hlevel 0 eq or { /pspc 10 def label
/pspc 0 def } { pop pop pop pop pop {pop} repeat } ifelse } def
/pinglobal { pinlabel } def
/infolabel { pinlabel } def
/graphic { gsave 4 index cvx exec /DataSource get resetfile translate
0 0 moveto neg rotate dup scale cvx exec image grestore } def
/scb { setrgbcolor } bind def /sce { defColor aload pop scb } bind def
/cRedef {/defColor currentcolor 3 array astore def} def
/begingate {dup type /dicttype ne {1 dict} if begin % default params
dup type /dicttype ne {1 dict} if begin % instanced params
/hlevel hlevel 1 add def /defColor currentcolor sce 3 array
astore def gsave sce translate 0 0 moveto neg rotate dup abs scale
} bind def
/endgate { /hlevel hlevel 1 sub def grestore defColor aload pop cRedef
scb end end} bind def
/hlevel 0 def
/tmpa [1 0 0 1 0 0] def
/gar {8 8 true tmpa {<c0 c0 00 00 0c 0c 00 00>} imagemask} bind
{8 8 true tmpa {<30 70 60 02 03 07 06 20>} imagemask} bind
{8 8 true tmpa {<0c 1e 1e 0c c0 e1 e1 c0>} imagemask} bind
{8 8 true tmpa {<0f 0f 0f 0f f0 f0 f0 f0>} imagemask} bind
{8 8 true tmpa {<3f f3 e1 e1 f3 3f 1e 1e>} imagemask} bind
{8 8 true tmpa {<df cf 8f 9f fd fc f8 f9>} imagemask} bind
{8 8 true tmpa {<ff 3f 3f ff ff f3 f3 ff>} imagemask} bind 7 array astore def
/ppaint { gsave clip tmpa dup setmatrix pathbbox neg exch neg 4 2 roll
neg 4 -1 roll 2 copy gt {exch} if 8 div ceiling 8 mul 4 2 roll neg 2 copy
gt {exch} if 8 div ceiling 8 mul 3 -1 roll -8 5 -1 roll
{ 3 index exch 5 exch put dup -8 3 index { 3 index
exch 4 exch put 3 index exec } for } for pop pop pop pop grestore } bind def
/setstyles {
currentlinewidth mul setlinewidth /style exch def
style 1 and 0 gt not {closepath} if
style 1024 and 0 gt {2 setlinecap} if
style 2 and 0 gt {currentlinewidth 4 mul dup 2 array astore 0 setdash} if
style 4 and 0 gt {0.5 currentlinewidth 4 mul 2 array astore 0 setdash} if
gsave style 16 and 0 gt { style 224 and -5 bitshift style 256 and 0 gt {
7 exch sub 8 div dup 1 exch sub currentrgbcolor 3 array astore
{3 copy mul add 4 1 roll pop} forall pop pop setrgbcolor eofill}
{dup 7 lt {gar exch get ppaint} {pop eofill} ifelse} ifelse}
{style 256 and 0 gt {1 setgray eofill} if} ifelse grestore style 8 and 0 gt
style 512 eq or {newpath} {stroke} ifelse grestore} def
/polygon { gsave /num exch def moveto num 1 sub {lineto} repeat setstyles } def
/xcarc { gsave newpath arc setstyles } def
/elb { matrix currentmatrix 7 -1 roll 7 -1 roll translate 5 1 roll 4 -1 roll
3 index div 1 scale } def
/ele { 0 4 1 roll 0 4 1 roll } bind def
/ellipse { gsave elb newpath ele arc setmatrix setstyles } def
/pellip { elb ele arc setmatrix } def
/nellip { elb ele arcn setmatrix } def
/spline { gsave moveto curveto setstyles } def
/polyc { {lineto} repeat } bind def
/beginpath { gsave moveto } bind def
/endpath { setstyles } bind def
/bop { 1 setlinecap 0 setlinejoin 6 setmiterlimit 0 0 0 scb cRedef } def
/psinsertion {/PSobj save def /showpage {} def /setpagedevice {pop} def bop
rotate translate dup scale} def
/end_insert {PSobj restore} def
/setpagemat {/pagemat matrix currentmatrix def} def
/inchscale {setpagemat 0.375 mul dup scale} def
/cmscale {setpagemat 0.35433071 mul dup scale} def
%%EndResource
%%EndProlog
% XCircuit output starts here.
%%BeginSetup
/analog::resistor {
begingate
1 1.000 0 64 0 36 2 polygon
1 1.000 0 -64 0 -36 2 polygon
1 1.000 0 -36 14 -30 -14 -18 14 -6 -14 6 14 18 -14 30 0 36 8 polygon
1.000 0.000 0.000 scb
(r.1) {/Times-Roman cf} 2 9 0 1.000 0 64 pinlabel
(r.2) {/Times-Roman cf} 2 13 0 1.000 0 -64 pinlabel
0.180 0.545 0.341 scb
(spice:R%i %pr.1 %pr.2 1.0K) {/Times-Roman cf} 2 0 0 1.000 -208 -160 infolabel
(sim:r %pr.1 %pr.2) {/Times-Roman cf} 2 0 0 1.000 -208 -208 infolabel
endgate
} def
/analog::gnd {
% trivial
begingate
1 1.000 0 0 0 -32 2 polygon
1 1.000 -32 -32 32 -32 2 polygon
1 1.000 -18 -46 18 -46 2 polygon
1 1.000 -4 -60 4 -60 2 polygon
0.933 0.604 0.000 scb
(GND) {/Times-Roman cf} 2 1 0 1.000 0 0 pinglobal
endgate
} def
/generic::circle {
% trivial
begingate
1 1.000 16 0 6 0.000 360.000 xcarc
1 1.000 0 0 10 0 2 polygon
1.000 0.000 0.000 scb
(out) {/Times-Roman cf} 2 4 0 1.000 16 0 pinlabel
(out) {/Times-Roman cf} 2 7 0 1.000 0 0 pinlabel
endgate
} def
%%EndSetup
%%Page: 1 1
%%PageOrientation: Portrait
/pgsave save def bop
1.0000 inchscale
2.6000 setlinewidth 864 -132 translate
1.000 90 -528 528 analog::resistor
1.000 0 -448 448 analog::resistor
1.000 0 -448 384 analog::gnd
1.000 0 -432 528 generic::circle
1 1.000 -480 528 -448 528 -448 512 3 polygon
1 1.000 -432 528 -448 528 2 polygon
-1.000 0 -592 528 generic::circle
(in) {ss} (V) {/Helvetica cf} 4 16 0 1.000 -672 512 label
(out) {ss} (V) {/Helvetica cf} 4 16 0 1.000 -400 512 label
(1) {ss} (R) {/Helvetica cf} 4 16 0 1.000 -560 560 label
(2) {ss} (R) {/Helvetica cf} 4 16 0 1.000 -432 432 label
pgsave restore showpage
%%Trailer
XCIRCsave restore
%%EOF
%!PS-Adobe-3.0 EPSF-3.0
%%Title: thevenin
%%Creator: XCircuit v3.6 rev135
%%CreationDate: Thu Dec 1 09:57:24 2011
%%Pages: 1
%%BoundingBox: 68 68 241 172
%%DocumentNeededResources: font Helvetica Times-Roman
%%EndComments
%%BeginProlog
%
% PostScript prolog for output from xcircuit
% Version: 3.3
%
% Electrical circuit (and otherwise general) drawing program
%
% Written by Tim Edwards 8/5/93--7/13/05 (tim.edwards@multigig.com)
% The Johns Hopkins University (1993-2004)
% MultiGiG, Inc. (2004-present)
%
%%BeginResource: procset XCIRCproc 3.3 0
%
% supporting definitions --- these are the primary xcircuit types.
/XCIRCsave save def
/topmat matrix currentmatrix def
/fontslant { /slant exch def [1 0 slant 1 0 0]
exch findfont exch makefont dup length dict /ndict exch def
{ 1 index /FID ne { ndict 3 1 roll put } { pop pop } ifelse } forall
ndict definefont pop} def
/ul { dup type /stringtype eq showflag 1 eq and { gsave
currentpoint topmat setmatrix 0 0 moveto 2 index stringwidth pop (_)
false charpath flattenpath pathbbox grestore exch pop 1 index
sub setlinewidth exch pop currentpoint 3 -1 roll add moveto 0
rlineto stroke moveto } if } def
/ol { dup type /stringtype eq showflag 1 eq and { gsave gsave
currentpoint topmat setmatrix 2 index stringwidth pop 3 index
true charpath flattenpath pathbbox grestore exch pop
exch pop topmat setmatrix (_) true charpath pathbbox grestore
exch pop 1 index sub setlinewidth exch pop currentpoint
exch 4 1 roll exch sub add moveto pop 0 rlineto stroke
moveto } if } def
/stW { gsave currentpoint newpath moveto true charpath flattenpath
pathbbox pop exch pop sub grestore } def
/Ts {mark Tabs aload pop counttomark 1 add array astore /Tabs exch def Tabs
0 currentpoint pop put} def
/Tbn {mark Tabs aload pop counttomark dup 2 add 1 roll cleartomark 1 sub} def
/Tb { 0 1 Tbn {Tabs exch get dup currentpoint pop lt
{currentpoint exch pop moveto exit} {pop} ifelse } for } def
/Tf { Tbn -1 0 {Tabs exch get dup currentpoint pop gt
{currentpoint exch pop moveto exit} {pop} ifelse } for } def
/qS { (aa) stW (a a) stW sub 4 div 0 Kn } def
/hS { qS qS } def
/pspc 0 def
/cf0 { scalefont setfont } bind def
/Kn { dup kY add /kY exch def rmoveto } bind def
/ss { /fscale fscale 0.67 mul def currentfont 0.67 cf0 0 fscale0 fscale mul
0.33 mul neg Kn} def
/Ss { /fscale fscale 0.67 mul def currentfont 0.67 cf0 0 fscale0 fscale mul
0.67 mul Kn } def
/ns { 0 kY neg Kn /kY 0 def /fscale 1.0 def xfont0 1.0 cf0 } def
/CR { ns 0 /Bline Bline fscale0 neg add def Bline moveto } def
/cf { dup type /realtype ne {1.0} if exch findfont exch kY 0 eq
{ 40 mul dup /fscale0 exch def cf0 /xfont0 currentfont def}
{fscale0 mul fscale mul cf0} ifelse } def
/ctmk { counttomark dup 2 add -1 roll pop } bind def
/label { gsave translate 0 0 moveto dup scale neg /rotval exch def
/just exch def just 384 and 0 gt {/mshow {pop} def} {/mshow {show}
def} ifelse just 16 and 0 gt {gsave rotval rotate 0 1 dtransform
gsave pagemat setmatrix idtransform exch grestore 1 0 dtransform
gsave pagemat setmatrix idtransform exch grestore dup abs 1e-9 lt
{pop mul 0 gt} {3 1 roll pop pop 0 lt} ifelse grestore {-1 /rotval
rotval neg def /just just dup 3 and 1 ne {3 xor} if def} {1} ifelse
exch -1e-9 lt {-1 /rotval rotval neg def /just just dup 12 and
4 ne {12 xor} if def} {1} ifelse scale } if /showflag 0 def
/fspc pspc def /Bline 0 def /Tabs 0 array def /fscale 1.0 def
/kY 0 def gsave dup 1 add copy 0 exch 1 0 dtransform exch atan rotate
{exch dup type /stringtype eq {true charpath flattenpath} {dup type
/arraytype eq {exec} {12 string cvs true charpath flattenpath} ifelse}
ifelse} repeat pop pathbbox grestore 3 -1 roll pop 3 1 roll just
1 and 0 gt {just 2 and 0 gt {exch pop neg fspc sub} {exch sub 0.5
mul neg} ifelse} {pop neg fspc add} ifelse exch Bline exch just 4
and 0 gt {just 8 and 0 gt {exch pop neg fspc sub} {add 0.5 mul neg}
ifelse} {pop neg fspc add} ifelse rotval rotate Kn currentpoint
translate /showflag 1 def /Bline 0 def /Tabs 0 array def /fscale
1.0 def /kY 0 def {dup type /stringtype eq {mshow} {dup type
/arraytype eq {exec} {12 string cvs mshow} ifelse} ifelse} repeat
grestore } def
/pinlabel { 4 index 32 and 0 ne hlevel 0 eq or { /pspc 10 def label
/pspc 0 def } { pop pop pop pop pop {pop} repeat } ifelse } def
/pinglobal { pinlabel } def
/infolabel { pinlabel } def
/graphic { gsave 4 index cvx exec /DataSource get resetfile translate
0 0 moveto neg rotate dup scale cvx exec image grestore } def
/scb { setrgbcolor } bind def /sce { defColor aload pop scb } bind def
/cRedef {/defColor currentcolor 3 array astore def} def
/begingate {dup type /dicttype ne {1 dict} if begin % default params
dup type /dicttype ne {1 dict} if begin % instanced params
/hlevel hlevel 1 add def /defColor currentcolor sce 3 array
astore def gsave sce translate 0 0 moveto neg rotate dup abs scale
} bind def
/endgate { /hlevel hlevel 1 sub def grestore defColor aload pop cRedef
scb end end} bind def
/hlevel 0 def
/tmpa [1 0 0 1 0 0] def
/gar {8 8 true tmpa {<c0 c0 00 00 0c 0c 00 00>} imagemask} bind
{8 8 true tmpa {<30 70 60 02 03 07 06 20>} imagemask} bind
{8 8 true tmpa {<0c 1e 1e 0c c0 e1 e1 c0>} imagemask} bind
{8 8 true tmpa {<0f 0f 0f 0f f0 f0 f0 f0>} imagemask} bind
{8 8 true tmpa {<3f f3 e1 e1 f3 3f 1e 1e>} imagemask} bind
{8 8 true tmpa {<df cf 8f 9f fd fc f8 f9>} imagemask} bind
{8 8 true tmpa {<ff 3f 3f ff ff f3 f3 ff>} imagemask} bind 7 array astore def
/ppaint { gsave clip tmpa dup setmatrix pathbbox neg exch neg 4 2 roll
neg 4 -1 roll 2 copy gt {exch} if 8 div ceiling 8 mul 4 2 roll neg 2 copy
gt {exch} if 8 div ceiling 8 mul 3 -1 roll -8 5 -1 roll
{ 3 index exch 5 exch put dup -8 3 index { 3 index
exch 4 exch put 3 index exec } for } for pop pop pop pop grestore } bind def
/setstyles {
currentlinewidth mul setlinewidth /style exch def
style 1 and 0 gt not {closepath} if
style 1024 and 0 gt {2 setlinecap} if
style 2 and 0 gt {currentlinewidth 4 mul dup 2 array astore 0 setdash} if
style 4 and 0 gt {0.5 currentlinewidth 4 mul 2 array astore 0 setdash} if
gsave style 16 and 0 gt { style 224 and -5 bitshift style 256 and 0 gt {
7 exch sub 8 div dup 1 exch sub currentrgbcolor 3 array astore
{3 copy mul add 4 1 roll pop} forall pop pop setrgbcolor eofill}
{dup 7 lt {gar exch get ppaint} {pop eofill} ifelse} ifelse}
{style 256 and 0 gt {1 setgray eofill} if} ifelse grestore style 8 and 0 gt
style 512 eq or {newpath} {stroke} ifelse grestore} def
/polygon { gsave /num exch def moveto num 1 sub {lineto} repeat setstyles } def
/xcarc { gsave newpath arc setstyles } def
/elb { matrix currentmatrix 7 -1 roll 7 -1 roll translate 5 1 roll 4 -1 roll
3 index div 1 scale } def
/ele { 0 4 1 roll 0 4 1 roll } bind def
/ellipse { gsave elb newpath ele arc setmatrix setstyles } def
/pellip { elb ele arc setmatrix } def
/nellip { elb ele arcn setmatrix } def
/spline { gsave moveto curveto setstyles } def
/polyc { {lineto} repeat } bind def
/beginpath { gsave moveto } bind def
/endpath { setstyles } bind def
/bop { 1 setlinecap 0 setlinejoin 6 setmiterlimit 0 0 0 scb cRedef } def
/psinsertion {/PSobj save def /showpage {} def /setpagedevice {pop} def bop
rotate translate dup scale} def
/end_insert {PSobj restore} def
/setpagemat {/pagemat matrix currentmatrix def} def
/inchscale {setpagemat 0.375 mul dup scale} def
/cmscale {setpagemat 0.35433071 mul dup scale} def
%%EndResource
%%EndProlog
% XCircuit output starts here.
%%BeginSetup
/analog::resistor {
begingate
1 1.000 0 64 0 36 2 polygon
1 1.000 0 -64 0 -36 2 polygon
1 1.000 0 -36 14 -30 -14 -18 14 -6 -14 6 14 18 -14 30 0 36 8 polygon
1.000 0.000 0.000 scb
(r.1) {/Times-Roman cf} 2 9 0 1.000 0 64 pinlabel
(r.2) {/Times-Roman cf} 2 13 0 1.000 0 -64 pinlabel
0.180 0.545 0.341 scb
(spice:R%i %pr.1 %pr.2 1.0K) {/Times-Roman cf} 2 0 0 1.000 -208 -160 infolabel
(sim:r %pr.1 %pr.2) {/Times-Roman cf} 2 0 0 1.000 -208 -208 infolabel
endgate
} def
/analog::source {
% hidden
begingate
1 1.000 0 0 32 0.000 360.000 xcarc
1 1.000 0 32 0 64 2 polygon
1 1.000 0 -32 0 -64 2 polygon
endgate
} def
/generic::arrowhead {
% nonetwork
begingate
8 -28 beginpath
3 -18 3 -15 0 0 curveto
-3 -15 -3 -18 -8 -28 curveto
-2 -26 2 -26 8 -28 curveto
249
1.000 endpath
endgate
} def
/analog::isource {
begingate
1.000 0 0 0 analog::source
1 0.750 0 20 0 -8 2 polygon
0.800 180 0 -20 generic::arrowhead
1.000 0.000 0.000 scb
(i.p) {/Times-Roman cf} 2 9 0 1.000 0 64 pinlabel
(i.m) {/Times-Roman cf} 2 13 0 1.000 0 -64 pinlabel
endgate
} def
/generic::circle {
% trivial
begingate
1 1.000 16 0 6 0.000 360.000 xcarc
1 1.000 0 0 10 0 2 polygon
1.000 0.000 0.000 scb
(out) {/Times-Roman cf} 2 4 0 1.000 16 0 pinlabel
(out) {/Times-Roman cf} 2 7 0 1.000 0 0 pinlabel
endgate
} def
%%EndSetup
%%Page: 1 1
%%PageOrientation: Portrait
/pgsave save def bop
1.0000 inchscale
2.6000 setlinewidth 896 -218 translate
1.000 90 -416 608 analog::resistor
1.000 0 -640 512 analog::isource
1.000 180 -512 512 analog::resistor
1.000 180 -320 512 analog::resistor
1 1.000 -640 448 -640 416 2 polygon
1 1.000 -512 448 -512 416 2 polygon
1 1.000 -320 448 -320 416 2 polygon
1 1.000 -320 416 -640 416 2 polygon
1 1.000 -640 576 -640 608 2 polygon
1 1.000 -512 576 -512 608 2 polygon
1 1.000 -320 576 -320 608 2 polygon
1 1.000 -320 608 -352 608 2 polygon
1 1.000 -480 608 -640 608 2 polygon
1.000 0 -288 608 generic::circle
1 1.000 -288 608 -320 608 2 polygon
1.000 0 -288 416 generic::circle
1 1.000 -288 416 -320 416 2 polygon
(1) {ss} (R) {/Helvetica cf} 4 16 0 1.000 -432 640 label
(2) {ss} (R) {/Helvetica cf} 4 16 0 1.000 -496 512 label
(3) {ss} (R) {/Helvetica cf} 4 16 0 1.000 -304 512 label
(I) {/Helvetica cf} 2 16 0 1.000 -704 512 label
pgsave restore showpage
%%Trailer
XCIRCsave restore
%%EOF
/*
----------------------------------------------------------------------------------------
Copyright 2010 - Thierry Ruiz - www.dotemplate.com - All rights reserved.
THIS TEMPLATE IS FREE AS LONG AS YOU KEEP THE LINK TO WWW.DOTEMPLATE.COM IN THE FOOTER
TO REMOVE THE LINK, PLEASE MAKE A 10 DOLLARS DONATION at www.dotemplate.com/#donate
----------------------------------------------------------------------------------------
*/
html {
background: $bottomWrapper.bg.color;
margin:0 0 0 -1px;
padding:0;
overflow-Y: scroll;
}
body {
padding:0;
margin :0;
display:table;
width:100%;
}
body {
color:#023063;
font-family: Helvetica, Arial, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
text-transform: normal;
}
p {
letter-spacing: normal;
line-height: 20px;
}
h1 {
color:#adcc80;
font-size:24px;
margin:25px 0 10px 0;
clear:both;
}
h2 {
color:#adcc80;
font-size:18px;
margin:20px 0 10px 0;
clear:both;
}
h3 {
color:#adcc80;
font-size:16px;
margin:20px 0 5px 0;
clear:both;
}
a:link, a:visited {
color:#adcc80;
text-decoration:none;
}
a:hover {
color:#fa720a;
text-decoration:underline;
}
#sectiondesc {
font-size:8px;
}
#wrapper {
background: transparent url( images/css/page-vbg.jpg ) repeat-y scroll 50% 0px;
margin:0 auto ;
width:100%;
}
body {
background-color:#FFFFFF;
}
#wrapper {
border-top: 1px solid #ffffff;
}
#topWrapper {
width:100%;
height:100px;
background-color:${topWrapper.bg.color};
background-image:url(images/css/topWrapper-bg.jpg);
background-position:center top ;
background-repeat:repeat-x;
}
#topBanner {
width:800px;
margin:0 auto;
height:100px;
background-image:url(images/css/topBanner.jpg);
background-repeat:no-repeat;
}
#topnav {
background:transparent url('images/css/hmenu.jpg') repeat-x top left;
}
#topnav {
height:20px;
margin:0 auto ;
text-align:center;
}
#topnav ul {
display:table;
margin:0 auto;
padding:0;
list-style-type:none;
position:relative;
height:20px;
text-transform:uppercase;
font-size:12px;
font-family:Arial,sans-serif;
}
#topnav ul li {
display:block;
float:left;
margin:0;
padding:0;
background:transparent url('images/css/hmenu.jpg') repeat-x top left;
}
#topnav ul li a {
display:block;
float:left;
color:#031634;
text-decoration:none;
padding:0px 50px ;
line-height:20px;
font-weight:bold;
}
#topnav ul li a:hover, #topnav li#current a {
color:#7a994c;
background:transparent url('images/css/hmenu-sel.jpg') repeat-x top left;
}
#topnav ul {
width:800px;
}
body {
background-position : center 120px;
}
#bg {
margin:0 auto;
padding:0;
background:transparent ;
background-image:url(images/css/hat.jpg);
background-repeat:no-repeat;
background-position: center top ;
}
#header {
margin: 0 auto;
min-height:0px;
height: 0px;
width: 800px;
}
#page {
background: transparent url( images/css/page-bg.jpg ) no-repeat center top;
}
#container {
margin:0 auto;
width:800px;
}
#content {
width:780px;
margin:0 auto ;
text-align:left;
min-height:800px;
}
#content p {
text-align:justify;
}
#footerWrapper {
margin:0 auto;
height:10px;
padding:0;
background:transparent url( images/css/footerWrapper-bg.jpg ) no-repeat scroll center top;
}
#footer {
margin:0 auto;
padding:0;
width:800px;
height:10px;
}
#right {
width:200px;
padding:10px 20px 20px 20px;
float:left;
}
#center {
width:500px;
padding:10px 20px 20px 20px;
float:left;
}
#content p {
margin-top:10px;
text-align:justify;
}
#sidebar ul.vmenu {
list-style: none;
text-align: left;
margin: 7px 0px 8px 0px;
padding: 0;
text-decoration: none;
border-top: 1px solid #eeeeee;
}
#sidebar ul.vmenu li {
list-style: none;
padding: 4px 0 4px 0px;
margin: 0 2px;
border-bottom: 1px solid #eeeeee;
}
#sidebar ul.vmenu li a {
text-decoration: none;
color:#023063;
}
#sidebar ul.vmenu li a:hover {
color:#adcc80;
}
#sidebar ul.vmenu ul { margin: 0 0 0 5px; padding: 0; }
#sidebar ul.vmenu ul li { border: none; }
#bottomWrapper {
height:140px;
background-color:#031634;
background-image:url(images/css/bottomWrapper-bg.jpg);
background-position:center top ;
background-repeat:repeat-x;
text-align:center;
color:#adcc80;
text-align:center;
}
#bottomWrapper a:link, #footer a:visited {
color:#dae5c9;
}
#bottomWrapper a:hover{
color:#adcc80;
text-decoration:none;
}
a img {
border:none;
}
.clear {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
*
* Open source under the BSD License.
*
* Copyright © 2008 George McGinley Smith
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
// t: current time, b: begInnIng value, c: change In value, d: duration
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))
/*
*
* TERMS OF USE - EASING EQUATIONS
*
* Open source under the BSD License.
*
* Copyright © 2001 Robert Penner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
#fancybox-loading {
position: fixed;
top: 50%;
left: 50%;
width: 40px;
height: 40px;
margin-top: -20px;
margin-left: -20px;
cursor: pointer;
overflow: hidden;
z-index: 1104;
display: none;
}
#fancybox-loading div {
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 480px;
background-image: url('fancybox.png');
}
#fancybox-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 1100;
display: none;
}
#fancybox-tmp {
padding: 0;
margin: 0;
border: 0;
overflow: auto;
display: none;
}
#fancybox-wrap {
position: absolute;
top: 0;
left: 0;
padding: 20px;
z-index: 1101;
outline: none;
display: none;
}
#fancybox-outer {
position: relative;
width: 100%;
height: 100%;
background: #fff;
}
#fancybox-content {
width: 0;
height: 0;
padding: 0;
outline: none;
position: relative;
overflow: hidden;
z-index: 1102;
border: 0px solid #fff;
}
#fancybox-hide-sel-frame {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: 1101;
}
#fancybox-close {
position: absolute;
top: -15px;
right: -15px;
width: 30px;
height: 30px;
background: transparent url('fancybox.png') -40px 0px;
cursor: pointer;
z-index: 1103;
display: none;
}
#fancybox-error {
color: #444;
font: normal 12px/20px Arial;
padding: 14px;
margin: 0;
}
#fancybox-img {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
border: none;
outline: none;
line-height: 0;
vertical-align: top;
}
#fancybox-frame {
width: 100%;
height: 100%;
border: none;
display: block;
}
#fancybox-left, #fancybox-right {
position: absolute;
bottom: 0px;
height: 100%;
width: 35%;
cursor: pointer;
outline: none;
background: transparent url('blank.gif');
z-index: 1102;
display: none;
}
#fancybox-left {
left: 0px;
}
#fancybox-right {
right: 0px;
}
#fancybox-left-ico, #fancybox-right-ico {
position: absolute;
top: 50%;
left: -9999px;
width: 30px;
height: 30px;
margin-top: -15px;
cursor: pointer;
z-index: 1102;
display: block;
}
#fancybox-left-ico {
background-image: url('fancybox.png');
background-position: -40px -30px;
}
#fancybox-right-ico {
background-image: url('fancybox.png');
background-position: -40px -60px;
}
#fancybox-left:hover, #fancybox-right:hover {
visibility: visible; /* IE6 */
}
#fancybox-left:hover span {
left: 20px;
}
#fancybox-right:hover span {
left: auto;
right: 20px;
}
.fancybox-bg {
position: absolute;
padding: 0;
margin: 0;
border: 0;
width: 20px;
height: 20px;
z-index: 1001;
}
#fancybox-bg-n {
top: -20px;
left: 0;
width: 100%;
background-image: url('fancybox-x.png');
}
#fancybox-bg-ne {
top: -20px;
right: -20px;
background-image: url('fancybox.png');
background-position: -40px -162px;
}
#fancybox-bg-e {
top: 0;
right: -20px;
height: 100%;
background-image: url('fancybox-y.png');
background-position: -20px 0px;
}
#fancybox-bg-se {
bottom: -20px;
right: -20px;
background-image: url('fancybox.png');
background-position: -40px -182px;
}
#fancybox-bg-s {
bottom: -20px;
left: 0;
width: 100%;
background-image: url('fancybox-x.png');
background-position: 0px -20px;
}
#fancybox-bg-sw {
bottom: -20px;
left: -20px;
background-image: url('fancybox.png');
background-position: -40px -142px;
}
#fancybox-bg-w {
top: 0;
left: -20px;
height: 100%;
background-image: url('fancybox-y.png');
}
#fancybox-bg-nw {
top: -20px;
left: -20px;
background-image: url('fancybox.png');
background-position: -40px -122px;
}
#fancybox-title {
font-family: Helvetica;
font-size: 12px;
z-index: 1102;
}
.fancybox-title-inside {
padding-bottom: 10px;
text-align: center;
color: #333;
background: #fff;
position: relative;
}
.fancybox-title-outside {
padding-top: 10px;
color: #fff;
}
.fancybox-title-over {
position: absolute;
bottom: 0;
left: 0;
color: #FFF;
text-align: left;
}
#fancybox-title-over {
padding: 10px;
background-image: url('fancy_title_over.png');
display: block;
}
.fancybox-title-float {
position: absolute;
left: 0;
bottom: -20px;
height: 32px;
}
#fancybox-title-float-wrap {
border: none;
border-collapse: collapse;
width: auto;
}
#fancybox-title-float-wrap td {
border: none;
white-space: nowrap;
}
#fancybox-title-float-left {
padding: 0 0 0 15px;
background: url('fancybox.png') -40px -90px no-repeat;
}
#fancybox-title-float-main {
color: #FFF;
line-height: 29px;
font-weight: bold;
padding: 0 0 3px 0;
background: url('fancybox-x.png') 0px -40px;
}
#fancybox-title-float-right {
padding: 0 0 0 15px;
background: url('fancybox.png') -55px -90px no-repeat;
}
/* IE6 */
.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_close.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_left.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_right.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_left.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_main.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_right.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame {
height: expression(this.parentNode.clientHeight + "px");
}
#fancybox-loading.fancybox-ie6 {
position: absolute; margin-top: 0;
top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px');
}
#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_loading.png', sizingMethod='scale'); }
/* IE6, IE7, IE8 */
.fancybox-ie .fancybox-bg { background: transparent !important; }
.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }
\ No newline at end of file
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
*
* Requires: 1.2.2+
*/
(function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=
f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
var load_id;
function caption_at(index) {
if (captions==0)
return "&nbsp;";
text_array=captions.text
if ((index>=text_array.length) || (index < 0))
return "&nbsp;";
return text_array[index];
}
function caption_time_at(index) {
if (captions==0)
return 0;
time_array=captions.start;
if (index < 0)
return 0;
if (index>=time_array.length)
return ytplayer.getDuration();
return time_array[index]/1000.0;
}
function caption_index(now) {
// Returns the index of the current caption, given a time
if (captions==0)
return 0;
time_array=captions.start
// TODO: Bisection would be better, or something incremental
var i;
for(i=0;i<captions.start.length; i++) {
if(time_array[i]>(now*1000)) {
return i-1;
}
}
return i-1;
}
function update_captions(t) {
var i=caption_index(t);
$("#std_n5").html(caption_at(i-5));
$("#std_n4").html(caption_at(i-4));
$("#std_n3").html(caption_at(i-3));
$("#std_n2").html(caption_at(i-2));
$("#std_n1").html(caption_at(i-1));
$("#std_0").html(caption_at(i));
$("#std_p1").html(caption_at(i+1));
$("#std_p2").html(caption_at(i+2));
$("#std_p3").html(caption_at(i+3));
$("#std_p4").html(caption_at(i+4));
$("#std_p5").html(caption_at(i+5));
$("#std_p6").html(caption_at(i+6));
}
function title_seek(i) {
// Seek video forwards or backwards by i subtitles
current=caption_index(getCurrentTime());
new_time=caption_time_at(current+i);
ytplayer.seekTo(new_time, true);
}
function updateHTML(elmId, value) {
document.getElementById(elmId).innerHTML = value;
}
function setytplayerState(newState) {
updateHTML("playerstate", newState);
}
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
setInterval(updateytplayerInfo, 1000);
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
ytplayer.addEventListener("onError", "onPlayerError");
if((typeof load_id != "undefined") && (load_id != null)) {
var id=load_id;
load_id = null;
loadNewVideo(id);
}
}
function log_event(e) {
//$("#eventlog").append("<br>");
//$("#eventlog").append(JSON.stringify(e));
window['console'].log(JSON.stringify(e));
}
function seek_slide(type,oe,value) {
//log_event([type, value]);
if(type=='slide') {
// HACK/TODO: Youtube recommends this be false for slide and true for stop.
// Works better on my system with true/true.
// We should test both configurations on low/high bandwidth
// connections, and different browsers
// One issue is that we query the Youtube window every 250ms for position/state
// With false, it returns the old one (ignoring the new seek), and moves the
// scroll bar to the wrong spot.
ytplayer.seekTo(value, true);
} else if (type=='stop') {
ytplayer.seekTo(value, true);
log_event([type, value]);
}
update_captions(value);
}
function get_state() {
if (ytplayer)
return [ytplayer.getPlayerState(),
ytplayer.getVideoUrl(),
ytplayer.getDuration(), ytplayer.getCurrentTime(),
ytplayer.getVideoBytesLoaded(), ytplayer.getVideoBytesTotal(),
ytplayer.getVideoStartBytes(),
ytplayer.getVolume(),ytplayer.isMuted(),
ytplayer.getPlaybackQuality(),
ytplayer.getAvailableQualityLevels()];
return [];
}
function onytplayerStateChange(newState) {
setytplayerState(newState);
log_event(['State Change',newState, get_state()]);
}
function onPlayerError(errorCode) {
alert("An error occured: " + errorCode);
}
function updateytplayerInfo() {
if(ytplayer.getPlayerState()!=3) {
$("#slider").slider("option","max",ytplayer.getDuration());
$("#slider").slider("option","value",ytplayer.getCurrentTime());
}
if (getPlayerState() == 1){
update_captions(getCurrentTime());
}
updateHTML("videoduration", getDuration());
updateHTML("videotime", getCurrentTime());
updateHTML("startbytes", getStartBytes());
updateHTML("volume", getVolume());
}
// functions for the api calls
function loadNewVideo(id, startSeconds) {
if (typeof ytplayer != "undefined") {
ytplayer.loadVideoById(id, parseInt(startSeconds));
} else {
load_id = id;
}
$.getJSON("/static/subs/"+id+".srt.sjson", function(data) {
captions=data;
});
}
function cueNewVideo(id, startSeconds) {
if (ytplayer) {
ytplayer.cueVideoById(id, startSeconds);
}
}
function play() {
if (ytplayer) {
ytplayer.playVideo();
}
}
function pause() {
if (ytplayer) {
ytplayer.pauseVideo();
}
}
function stop() {
if (ytplayer) {
ytplayer.stopVideo();
}
}
function getPlayerState() {
if (ytplayer) {
return ytplayer.getPlayerState();
}
}
function seekTo(seconds) {
if (ytplayer) {
ytplayer.seekTo(seconds, true);
}
}
function getBytesTotal() {
if (ytplayer) {
return ytplayer.getVideoBytesTotal();
}
}
function getCurrentTime() {
if (ytplayer) {
return ytplayer.getCurrentTime();
}
}
function getDuration() {
if (ytplayer) {
return ytplayer.getDuration();
}
}
function getStartBytes() {
if (ytplayer) {
return ytplayer.getVideoStartBytes();
}
}
function mute() {
if (ytplayer) {
ytplayer.mute();
}
}
function unMute() {
if (ytplayer) {
ytplayer.unMute();
}
}
function getEmbedCode() {
alert(ytplayer.getVideoEmbedCode());
}
function getVideoUrl() {
alert(ytplayer.getVideoUrl());
}
function setVolume(newVolume) {
if (ytplayer) {
ytplayer.setVolume(newVolume);
}
}
function getVolume() {
if (ytplayer) {
return ytplayer.getVolume();
}
}
function clearVideo() {
if (ytplayer) {
ytplayer.clearVideo();
}
}
\ No newline at end of file
var load_id;
function caption_at(index) {
if (captions==0)
return "&nbsp;";
text_array=captions.text
if ((index>=text_array.length) || (index < 0))
return "&nbsp;";
return text_array[index];
}
function caption_time_at(index) {
if (captions==0)
return 0;
time_array=captions.start;
if (index < 0)
return 0;
if (index>=time_array.length)
return ytplayer.getDuration();
return time_array[index]/1000.0;
}
function caption_index(now) {
// Returns the index of the current caption, given a time
if (captions==0)
return 0;
time_array=captions.start
// TODO: Bisection would be better, or something incremental
var i;
for(i=0;i<captions.start.length; i++) {
if(time_array[i]>(now*1000)) {
return i-1;
}
}
return i-1;
}
function update_captions(t) {
var i=caption_index(t);
$("#std_n5").html(caption_at(i-5));
$("#std_n4").html(caption_at(i-4));
$("#std_n3").html(caption_at(i-3));
$("#std_n2").html(caption_at(i-2));
$("#std_n1").html(caption_at(i-1));
$("#std_0").html(caption_at(i));
$("#std_p1").html(caption_at(i+1));
$("#std_p2").html(caption_at(i+2));
$("#std_p3").html(caption_at(i+3));
$("#std_p4").html(caption_at(i+4));
$("#std_p5").html(caption_at(i+5));
$("#std_p6").html(caption_at(i+6));
}
function title_seek(i) {
// Seek video forwards or backwards by i subtitles
current=caption_index(getCurrentTime());
new_time=caption_time_at(current+i);
ytplayer.seekTo(new_time, true);
}
function updateHTML(elmId, value) {
document.getElementById(elmId).innerHTML = value;
}
function setytplayerState(newState) {
updateHTML("playerstate", newState);
}
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
setInterval(updateytplayerInfo, 250);
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
ytplayer.addEventListener("onError", "onPlayerError");
if((typeof load_id != "undefined") && (load_id != null)) {
var id=load_id;
load_id = null;
loadNewVideo(id);
}
}
function log_event(e) {
//$("#eventlog").append("<br>");
//$("#eventlog").append(JSON.stringify(e));
window['console'].log(JSON.stringify(e));
}
function seek_slide(type,oe,value) {
//log_event([type, value]);
if(type=='slide') {
// HACK/TODO: Youtube recommends this be false for slide and true for stop.
// Works better on my system with true/true.
// We should test both configurations on low/high bandwidth
// connections, and different browsers
// One issue is that we query the Youtube window every 250ms for position/state
// With false, it returns the old one (ignoring the new seek), and moves the
// scroll bar to the wrong spot.
ytplayer.seekTo(value, true);
} else if (type=='stop') {
ytplayer.seekTo(value, true);
log_event([type, value]);
}
update_captions(value);
}
function get_state() {
if (ytplayer)
return [ytplayer.getPlayerState(),
ytplayer.getVideoUrl(),
ytplayer.getDuration(), ytplayer.getCurrentTime(),
ytplayer.getVideoBytesLoaded(), ytplayer.getVideoBytesTotal(),
ytplayer.getVideoStartBytes(),
ytplayer.getVolume(),ytplayer.isMuted(),
ytplayer.getPlaybackQuality(),
ytplayer.getAvailableQualityLevels()];
return [];
}
function onytplayerStateChange(newState) {
setytplayerState(newState);
log_event(['State Change',newState, get_state()]);
}
function onPlayerError(errorCode) {
alert("An error occured: " + errorCode);
}
function updateytplayerInfo() {
if(ytplayer.getPlayerState()!=3) {
$("#slider").slider("option","max",ytplayer.getDuration());
$("#slider").slider("option","value",ytplayer.getCurrentTime());
}
update_captions(getCurrentTime());
updateHTML("videoduration", getDuration());
updateHTML("videotime", getCurrentTime());
updateHTML("startbytes", getStartBytes());
updateHTML("volume", getVolume());
}
// functions for the api calls
function loadNewVideo(id, startSeconds) {
if (typeof ytplayer != "undefined") {
ytplayer.loadVideoById(id, parseInt(startSeconds));
} else {
load_id = id;
}
$.getJSON("/static/subs/"+id+".srt.sjson", function(data) {
captions=data;
});
}
function cueNewVideo(id, startSeconds) {
if (ytplayer) {
ytplayer.cueVideoById(id, startSeconds);
}
}
function play() {
if (ytplayer) {
ytplayer.playVideo();
}
}
function pause() {
if (ytplayer) {
ytplayer.pauseVideo();
}
}
function stop() {
if (ytplayer) {
ytplayer.stopVideo();
}
}
function getPlayerState() {
if (ytplayer) {
return ytplayer.getPlayerState();
}
}
function seekTo(seconds) {
if (ytplayer) {
ytplayer.seekTo(seconds, true);
}
}
function getBytesTotal() {
if (ytplayer) {
return ytplayer.getVideoBytesTotal();
}
}
function getCurrentTime() {
if (ytplayer) {
return ytplayer.getCurrentTime();
}
}
function getDuration() {
if (ytplayer) {
return ytplayer.getDuration();
}
}
function getStartBytes() {
if (ytplayer) {
return ytplayer.getVideoStartBytes();
}
}
function mute() {
if (ytplayer) {
ytplayer.mute();
}
}
function unMute() {
if (ytplayer) {
ytplayer.unMute();
}
}
function getEmbedCode() {
alert(ytplayer.getVideoEmbedCode());
}
function getVideoUrl() {
alert(ytplayer.getVideoUrl());
}
function setVolume(newVolume) {
if (ytplayer) {
ytplayer.setVolume(newVolume);
}
}
function getVolume() {
if (ytplayer) {
return ytplayer.getVolume();
}
}
function clearVideo() {
if (ytplayer) {
ytplayer.clearVideo();
}
}
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment