Commit 1eacc561 by Gregory Martin

update templates

parent 4bde58bd
......@@ -8,7 +8,7 @@ install: pip install pep8
# build tests
script:
- python VEDA/tests/test_build.py
- python common/tests/test_build.py
- pep8
- cd control/tests nosetests
......@@ -12,7 +12,7 @@ if project_path not in sys.path:
from control.celeryapp import maintainer_healer
from control.veda_heal import VedaHeal
from VEDA_OS01.models import Video
from pipeline.models import Video
"""
Deliver
......
"""
edx-video-pipeline's Django Secrets
NEVER SHARE ANYTHING IN HERE, like, EVER
--assume unchanged in git--
"""
import os
DJANGO_SECRET_KEY = ""
DJANGO_DB_USER = ""
DJANGO_DB_PASS = ""
DJANGO_ADMIN = ('', '')
SANDBOX_TOKEN = None
if SANDBOX_TOKEN is not None and SANDBOX_TOKEN in os.path.dirname(__file__):
DEBUG = True
DBHOST = ''
pipeline_dbname = ""
else:
DEBUG = False
DBHOST = ''
pipeline_dbname = ""
"""
Settings
"""
DATABASES = None
import os
from django_secrets import *
ROOT_DIR = os.path.dirname(os.path.dirname((__file__)))
ADMINS = (
DJANGO_ADMIN,
)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Port the warnings to the backend
MANAGERS = ADMINS
if DATABASES is None:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': pipeline_dbname,
'USER': DJANGO_DB_USER,
'PASSWORD': DJANGO_DB_PASS,
'HOST': DBHOST,
'PORT': '3306',
}
}
# Make this unique, and don't share it with anybody.
SECRET_KEY = DJANGO_SECRET_KEY
ALLOWED_HOSTS = ['*']
TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "static")
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(ROOT_DIR, 'templates', 'admin'),
os.path.join(ROOT_DIR, 'templates'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(ROOT_DIR, 'templates')
],
'OPTIONS': {
'context_processors': [
"django.contrib.auth.context_processors.auth",
],
'debug': DEBUG,
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
]
}
},
]
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Oauth2
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
)
AUTHENTICATION_BACKENDS = (
# Oauth2
'django.contrib.auth.backends.ModelBackend',
'oauth2_provider.backends.OAuth2Backend',
)
OAUTH2_PROVIDER = {
# this is the list of available scopes
'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'}
}
X_FRAME_OPTIONS = 'DENY'
SECURE_SSL_REDIRECT = False
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
ROOT_URLCONF = 'common.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'common.wsgi.application'
REST_FRAMEWORK = {
'PAGE_SIZE': 10,
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_FILTER_BACKENDS': (
'rest_framework.filters.DjangoFilterBackend',
),
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'rest_framework.authtoken',
'oauth2_provider',
'rest_framework',
'corsheaders',
'frontend',
'pipeline',
)
CORS_ORIGIN_ALLOW_ALL = True
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
"""
build test
"""
import sys
import unittest
class BuildTest(unittest.TestCase):
def setUp(self):
self.assertTrue(True)
def test_defaults(self):
self.assertTrue(True)
def main():
unittest.main()
if __name__ == '__main__':
sys.exit(main())
import sys
import os
sys.path.append(os.path.abspath(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.conf import settings
from rest_framework.routers import DefaultRouter
from django.conf.urls import patterns, include, url
from django.contrib import admin
from pipeline import views
router = DefaultRouter()
admin.autodiscover()
router.register(r'courses', views.CourseViewSet)
router.register(r'videos', views.VideoViewSet)
router.register(r'encodes', views.EncodeViewSet)
router.register(r'urls', views.URLViewSet)
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
# Front End
url(r'^', include('frontend.urls')),
# API
url(r'^login/', views.user_login),
url(r'^accounts/login/$', 'django.contrib.auth.views.login', ),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
# Cheap auth server
url(r'^veda_auth/', views.token_auth)
]
"""
"""
import os
from django.core.wsgi import get_wsgi_application
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.environ.setdefault("PYTHON_EGG_CACHE", BASE_DIR + "/egg_cache")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "common.settings")
application = get_wsgi_application()
......@@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VEDA.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "common.settings")
from django.core.management import execute_from_command_line
......
from django.contrib import admin
from pipeline.models import Course
from pipeline.models import Video
from pipeline.models import Encode
from pipeline.models import URL
from pipeline.models import Destination
from pipeline.models import Institution
from pipeline.models import VedaUpload
class CourseAdmin(admin.ModelAdmin):
ordering = ['institution']
list_display = [
'course_name',
'course_hold',
'institution',
'edx_classid',
'last_vid_number',
'previous_statechange'
]
list_filter = ['institution']
search_fields = [
'course_name',
'edx_classid',
'institution',
'studio_hex'
]
save_as = True
class VideoAdmin(admin.ModelAdmin):
model = Video
list_display = [
'edx_id',
'client_title',
'studio_id',
'video_trans_start',
'video_trans_status',
'video_active'
]
list_filter = ['inst_class__institution']
search_fields = ['edx_id', 'client_title', 'studio_id']
class EncodeAdmin(admin.ModelAdmin):
model = Encode
ordering = ['encode_name']
list_display = [
'encode_name',
'profile_active',
'encode_filetype',
'get_destination',
'encode_suffix',
'encode_bitdepth',
'product_spec'
]
def get_destination(self, obj):
return obj.encode_destination.destination_name
get_destination.short_description = 'Destination'
save_as = True
class URLAdmin(admin.ModelAdmin):
model = URL
list_display = [
'videoID',
'encode_get',
'encode_url',
'url_date',
'val_input',
'xuetang_input'
]
list_filter = ['videoID__inst_class__institution']
def encode_get(self, obj):
return obj.encode_profile.encode_name
search_fields = [
'videoID__edx_id',
'videoID__client_title',
'encode_url'
]
class DestinationAdmin(admin.ModelAdmin):
model = Destination
list_display = ['destination_name', 'destination_active']
class InstitutionAdmin(admin.ModelAdmin):
model = Institution
list_display = ['institution_name', 'institution_code']
class VideoUploadAdmin(admin.ModelAdmin):
model = VedaUpload
list_display = [
'client_information',
'upload_filename',
'status_email',
'file_complete',
'youtube_id'
]
admin.site.register(Course, CourseAdmin)
admin.site.register(Video, VideoAdmin)
admin.site.register(Encode, EncodeAdmin)
admin.site.register(URL, URLAdmin)
admin.site.register(Destination, DestinationAdmin)
admin.site.register(Institution, InstitutionAdmin)
admin.site.register(VedaUpload, VideoUploadAdmin)
"""
Pipeline API METHODS
1. cheap-o token authorizer
This is a super hacky way to finish the Oauth2 Flow, but I need to move on
will get the token id from a url view, auth it, then push forward with a success bool
"""
import os
import sys
import oauth2_provider
from oauth2_provider import models
from rest_framework.authtoken.models import Token
from django.contrib.auth.models import User
from pipeline_env import *
primary_directory = os.path.dirname(__file__)
sys.path.append(primary_directory)
def token_finisher(token_id):
try:
d = oauth2_provider.models.AccessToken.objects.get(token=token_id)
except:
return False
d.user = User.objects.get(pk=1)
d.save()
try:
token = Token.objects.create(user=d.user)
except:
token = Token.objects.get(user=d.user)
return token.key
if __name__ == '__main__':
pass
#!/usr/bin/env python
import os
import sys
import django
"""
VEDA Environment variables
"""
"""
Import Django Shit
"""
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_path not in sys.path:
sys.path.append(project_path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'common.settings'
django.setup()
from pipeline.models import Institution
from pipeline.models import Course
from pipeline.models import Video
from pipeline.models import URL
from pipeline.models import VedaUpload
#! usr/bin/env python
from rest_framework import serializers
from pipeline.models import Course, Video, URL, Encode
class CourseSerializer(serializers.ModelSerializer):
class Meta:
model = Course
fields = (
'id',
'course_hold',
'review_proc',
'yt_proc',
's3_proc',
'mobile_override',
'course_name',
'institution',
'edx_classid',
'semesterid',
'last_vid_number',
'previous_statechange',
'studio_hex',
'proc_loc',
'sg_projID'
)
def create(self, validated_data, partial=True):
return Course.objects.create(**validated_data)
def update(self, instance, validated_data, partial=True):
instance.course_name = validated_data.get(
'course_name',
instance.course_name
)
instance.course_hold = validated_data.get(
'course_hold',
instance.course_hold
)
instance.last_vid_number = validated_data.get(
'last_vid_number',
instance.last_vid_number
)
instance.previous_statechange = validated_data.get(
'previous_statechange',
instance.previous_statechange
)
instance.save()
return instance
class VideoSerializer(serializers.ModelSerializer):
class Meta:
model = Video
fields = (
'id',
'inst_class',
'edx_id',
'studio_id',
'video_active',
'client_title',
'video_orig_duration',
'video_orig_filesize',
'video_orig_bitrate',
'video_orig_extension',
'video_orig_resolution',
'video_trans_start',
'video_trans_end',
'video_trans_status',
'video_glacierid'
)
def create(self, validated_data):
return Video.objects.create(**validated_data)
def update(self, instance, validated_data):
"""Might be able to pare this down"""
instance.inst_class = validated_data.get(
'inst_class',
instance.inst_class
)
instance.edx_id = validated_data.get(
'edx_id',
instance.edx_id
)
instance.studio_id = validated_data.get(
'studio_id',
instance.studio_id
)
instance.video_active = validated_data.get(
'video_active',
instance.video_active
)
instance.client_title = validated_data.get(
'client_title',
instance.client_title
)
instance.video_orig_duration = validated_data.get(
'video_orig_duration',
instance.video_orig_duration
)
instance.video_orig_extension = validated_data.get(
'video_orig_extension',
instance.video_orig_extension
)
instance.video_trans_start = validated_data.get(
'video_trans_start',
instance.video_trans_start
)
instance.video_trans_end = validated_data.get(
'video_trans_end',
instance.video_trans_end
)
instance.video_trans_status = validated_data.get(
'video_trans_status',
instance.video_trans_status
)
instance.video_glacierid = validated_data.get(
'video_glacierid',
instance.video_glacierid
)
instance.save()
return instance
class EncodeSerializer(serializers.ModelSerializer):
"""
View only Field
"""
class Meta:
model = Encode
fields = (
'id',
'profile_active',
'encode_suffix',
'encode_filetype',
'encode_bitdepth',
'encode_resolution',
'product_spec',
'xuetang_proc',
)
class URLSerializer(serializers.ModelSerializer):
class Meta:
model = URL
fields = (
'id',
'encode_profile',
'videoID',
'encode_url',
'url_date',
'encode_duration',
'encode_bitdepth',
'encode_size',
'val_input',
'xuetang_input',
'md5_sum',
)
def create(self, validated_data):
return URL.objects.create(**validated_data)
"""views"""
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.views.decorators.csrf import csrf_exempt
from rest_framework import renderers
from rest_framework import viewsets
from rest_framework.decorators import detail_route
from rest_framework import filters
from api import token_finisher
from pipeline.models import Course, Video, URL, Encode
from pipeline.serializers import CourseSerializer
from pipeline.serializers import VideoSerializer
from pipeline.serializers import EncodeSerializer
from pipeline.serializers import URLSerializer
class CourseViewSet(viewsets.ModelViewSet):
queryset = Course.objects.all()
serializer_class = CourseSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = (
'institution',
'edx_classid',
'proc_loc',
'course_hold',
'sg_projID'
)
@detail_route(renderer_classes=[renderers.StaticHTMLRenderer])
def highlight(self, request, *args, **kwargs):
course = self.get_object()
return Response(course.highlighted)
@csrf_exempt
def perform_create(self, serializer):
serializer.save()
class VideoViewSet(viewsets.ModelViewSet):
queryset = Video.objects.all()
serializer_class = VideoSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('inst_class', 'edx_id')
@detail_route(renderer_classes=[renderers.StaticHTMLRenderer])
def highlight(self, request, *args, **kwargs):
video = self.get_object()
return Response(video.highlighted)
@csrf_exempt
def perform_create(self, serializer):
serializer.save()
class EncodeViewSet(viewsets.ModelViewSet):
queryset = Encode.objects.all()
serializer_class = EncodeSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('encode_filetype', 'encode_suffix', 'product_spec')
@detail_route(renderer_classes=[renderers.StaticHTMLRenderer])
def highlight(self, request, *args, **kwargs):
encode = self.get_object()
return Response(encode.highlighted)
@csrf_exempt
def perform_create(self, serializer):
serializer.save()
class URLViewSet(viewsets.ModelViewSet):
queryset = URL.objects.all()
serializer_class = URLSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = (
'videoID__edx_id',
'encode_profile__encode_suffix',
'encode_profile__encode_filetype'
)
@detail_route(renderer_classes=[renderers.StaticHTMLRenderer])
def highlight(self, request, *args, **kwargs):
url = self.get_object()
return Response(url.highlighted)
@csrf_exempt
def perform_create(self, serializer):
serializer.save()
@csrf_exempt
def token_auth(request):
"""
This is a hack to override the "Authorize" step in token generation
"""
if request.method == 'POST':
complete = token_finisher(request.POST['data'])
return HttpResponse(complete)
else:
return HttpResponse(status=404)
def user_login(request):
if request.user.is_authenticated():
return HttpResponseRedirect(request.path)
else:
return HttpResponseRedirect('../admin') # settings.LOGIN_REDIRECT_URL)
if __name__ == "__main__":
course_view()
import os
import sys
from celery.task.control import revoke
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_path not in sys.path:
sys.path.append(project_path)
import control.celeryapp
tasks_to_cancel = [
'1386bfc2-ccb5-46e4-8971-33e7092f3cd2',
'980b763a-6531-4a25-970c-5b3b5cbf6361'
]
for t in tasks_to_cancel:
revoke(t, terminate=True)
\ No newline at end of file
import os
import sys
import datetime
from datetime import timedelta
from django.utils.timezone import utc
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_path not in sys.path:
sys.path.append(project_path)
from control.celeryapp import deliverable_route
from control.veda_heal import VedaHeal
from pipeline.models import Video
def get_videos():
video_query = Video.objects.filter(
video_trans_start__lt=(datetime.datetime.now().replace(tzinfo=utc)) - timedelta(days=7)
)
for v in video_query:
print v.edx_id
VH = VedaHeal()
encode_list = VH.determine_fault(video_object=v)
# if len(encode_list) > 0:
# for e in encode_list:
# deliverable_route(veda_id=v.edx_id, encode_profile=e)
# print encode_list
break
if __name__ == '__main__':
get_videos()
import os
import sys
import datetime
import time
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_path not in sys.path:
sys.path.append(project_path)
from control.veda_heal import VedaHeal
from pipeline.models import URL, Encode, Video
"""
Set your globals here
"""
CRAWL_SUFFIX = 'HLS'
CRAWL_START = datetime.datetime.strptime('Feb 1 2017 00:01', '%b %d %Y %H:%M')
CRAWL_EPOCH = datetime.datetime.strptime('Apr 12 2017 00:01', '%b %d %Y %H:%M')
BATCH_SIZE = 10
SLEEP_TIME = 1200
# NOTE: MSXSBVCP2017-V002600_100
class ReEncodeCrawler:
def __init__(self):
self.crawl_start = CRAWL_START
self.crawl_end = CRAWL_EPOCH
self.crawl_suffix = CRAWL_SUFFIX
self.url_query = None
def crawl(self):
self._url_query()
# self._run_reencode()
def _url_query(self):
self.url_query = URL.objects.filter(
url_date__gt=self.crawl_start,
url_date__lt=self.crawl_end,
encode_profile=Encode.objects.get(
encode_suffix=self.crawl_suffix
)
)
print len(self.url_query)
def _run_reencode(self):
batching = 0
for u in self.url_query:
print u.encode_url
if batching >= BATCH_SIZE:
print "%s :: %s" % (
"Sleeping",
"BatchSize"
)
time.sleep(SLEEP_TIME)
batching = 0
print "%s : %s" % (u.encode_url, u.url_date)
URL.objects.filter(pk=u.pk).delete()
"""Must be sent to heal as iterable"""
video_query = Video.objects.filter(pk=u.videoID.pk)
VH = VedaHeal(
video_query=video_query
)
VH.send_encodes()
batching += 1
def main():
REEC = ReEncodeCrawler()
REEC.crawl()
if __name__ == '__main__':
sys.exit(main())
'''
Manual HEAL IDs
GEOB3DAE2017-V006300
'''
"""
Fix resolution 'progressive)' bug
"""
import os
import sys
import django
from django.utils.timezone import utc
import datetime
from datetime import timedelta
sys.path.append(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
# import abvid_reporting
from pipeline_env import *
from veda_heal import VedaHeal
sick_list = [
'EDXABVID2014-V148900',
'MCHCFPXX2016-V006200',
'PRIMGWXXT315-V011000',
'PRIMGWXXT315-V011100',
'MIT143102016-V032100',
'MIT143102016-V032200',
'MIT143102016-V032300',
'MIT15662T115-V014900',
'MIT15662T115-V015000',
'MIT15662T115-V015100',
'MIT15662T115-V015200',
'HKUHKCGL2016-V017700',
'HKUHKCGL2016-V017800',
'HKUHKCGL2016-V017900',
'MIT21W78T114-V006000',
'MIT21W78T114-V006100',
'MIT21W78T114-V006200',
'MIT21W78T114-V006300',
'MIT21W78T114-V006400',
'MIT21W78T114-V006500',
'MIT21W78T114-V006600',
'MIT21W78T114-V006700',
'MIT15662T115-V015300',
'MIT15662T115-V015400',
'MIT15662T115-V015600',
'MIT15662T115-V015900',
'MIT15662T115-V016200',
'MIT15662T115-V016500',
'HKUDEXXX2016-V031200',
'HKUDEXXX2016-V031300',
'MIT21W78T114-V006800',
'MITSCTSX2016-V006000',
'HKUDEXXX2016-V031400',
'MIT15662T115-V016600',
'HKUDEXXX2016-V031500',
'HARCHEM12016-V006900',
'HARCHEM12016-V007000',
'HARCHEM12016-V007100',
'HARCHEM12016-V007200',
'HARCHEM12016-V007300',
'HARCHEM12016-V007400',
'HARCHEM12016-V007500',
'HARCHEM12016-V007600',
'HARCHEM12016-V007700',
'HARCHEM12016-V007800',
'HARCHEM12016-V007900',
'HARCHEM12016-V008000',
'HARCHEM12016-V008100',
'HARCHEM12016-V008200',
'HARCHEM12016-V008300',
'HARCHEM12016-V008400',
'HARCHEM12016-V008500',
'HARCHEM12016-V008600',
'HARCHEM12016-V008700',
'HARCHEM12016-V008800',
'HARCHEM12016-V008900',
'HARCHEM12016-V009000',
'HARCHEM12016-V009100',
'HARCHEM12016-V009200',
'HARCHEM12016-V009300',
'HARCHEM12016-V009400',
'HARCHEM12016-V009500',
'HARCHEM12016-V009600',
'HARCHEM12016-V009700',
'HARCHEM12016-V009800',
'HARCHEM12016-V009900',
'MCHLCGBG2016-V004100',
'MCHLCGBG2016-V004200',
'MCHLCGBG2016-V004300',
'MITSCTSX2016-V006200',
]
def get_videos():
video_q = Video.objects.filter(
video_trans_start__gt=datetime.datetime.utcnow() - timedelta(days=7)
# video_orig_resolution='progressive)'
)
# video_query = Video.objects.filter(
# edx_id='EDXABVID2014-V148900'
# )
for v in video_q:
if ')' in v.video_orig_resolution:
print v.edx_id
# Video.objects.filter(pk=v.pk).update(video_orig_resolution='1920x1080')
# print '***'
# VH = VedaHeal(
# video_query=Video.objects.filter(
# pk=v.pk
# )
# )
# VH.send_encodes()
# break
if __name__ == '__main__':
get_videos()
/* CHANGELISTS */
#changelist {
position: relative;
width: 100%;
}
#changelist table {
width: 100%;
}
.change-list .hiddenfields { display:none; }
.change-list .filtered table {
border-right: 1px solid #ddd;
}
.change-list .filtered {
min-height: 400px;
}
.change-list .filtered {
background: white url(../img/changelist-bg.gif) top right repeat-y !important;
}
.change-list .filtered .results, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull {
margin-right: 160px !important;
width: auto !important;
}
.change-list .filtered table tbody th {
padding-right: 1em;
}
#changelist .toplinks {
border-bottom: 1px solid #ccc !important;
}
#changelist .paginator {
color: #666;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
background: white url(../img/nav-bg.gif) 0 180% repeat-x;
overflow: hidden;
}
.change-list .filtered .paginator {
border-right: 1px solid #ddd;
}
/* CHANGELIST TABLES */
#changelist table thead th {
padding: 0;
white-space: nowrap;
vertical-align: middle;
}
#changelist table thead th.action-checkbox-column {
width: 1.5em;
text-align: center;
}
#changelist table tbody td, #changelist table tbody th {
border-left: 1px solid #ddd;
}
#changelist table tbody td:first-child, #changelist table tbody th:first-child {
border-left: 0;
border-right: 1px solid #ddd;
}
#changelist table tbody td.action-checkbox {
text-align:center;
}
#changelist table tfoot {
color: #666;
}
/* TOOLBAR */
#changelist #toolbar {
padding: 3px;
border-bottom: 1px solid #ddd;
background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x;
color: #666;
}
#changelist #toolbar form input {
font-size: 11px;
padding: 1px 2px;
}
#changelist #toolbar form #searchbar {
padding: 2px;
}
#changelist #changelist-search img {
vertical-align: middle;
}
/* FILTER COLUMN */
#changelist-filter {
position: absolute;
top: 0;
right: 0;
z-index: 1000;
width: 160px;
border-left: 1px solid #ddd;
background: #efefef;
margin: 0;
}
#changelist-filter h2 {
font-size: 11px;
padding: 2px 5px;
border-bottom: 1px solid #ddd;
}
#changelist-filter h3 {
font-size: 12px;
margin-bottom: 0;
}
#changelist-filter ul {
padding-left: 0;
margin-left: 10px;
}
#changelist-filter li {
list-style-type: none;
margin-left: 0;
padding-left: 0;
}
#changelist-filter a {
color: #999;
}
#changelist-filter a:hover {
color: #036;
}
#changelist-filter li.selected {
border-left: 5px solid #ccc;
padding-left: 5px;
margin-left: -10px;
}
#changelist-filter li.selected a {
color: #5b80b2 !important;
}
/* DATE DRILLDOWN */
.change-list ul.toplinks {
display: block;
background: white url(../img/nav-bg-reverse.gif) 0 -10px repeat-x;
border-top: 1px solid white;
float: left;
padding: 0 !important;
margin: 0 !important;
width: 100%;
}
.change-list ul.toplinks li {
padding: 3px 6px;
font-weight: bold;
list-style-type: none;
display: inline-block;
}
.change-list ul.toplinks .date-back a {
color: #999;
}
.change-list ul.toplinks .date-back a:hover {
color: #036;
}
/* PAGINATOR */
.paginator {
font-size: 11px;
padding-top: 10px;
padding-bottom: 10px;
line-height: 22px;
margin: 0;
border-top: 1px solid #ddd;
}
.paginator a:link, .paginator a:visited {
padding: 2px 6px;
border: solid 1px #ccc;
background: white;
text-decoration: none;
}
.paginator a.showall {
padding: 0 !important;
border: none !important;
}
.paginator a.showall:hover {
color: #036 !important;
background: transparent !important;
}
.paginator .end {
border-width: 2px !important;
margin-right: 6px;
}
.paginator .this-page {
padding: 2px 6px;
font-weight: bold;
font-size: 13px;
vertical-align: top;
}
.paginator a:hover {
color: white;
background: #5b80b2;
border-color: #036;
}
/* ACTIONS */
.filtered .actions {
margin-right: 160px !important;
border-right: 1px solid #ddd;
}
#changelist table input {
margin: 0;
}
#changelist table tbody tr.selected {
background-color: #FFFFCC;
}
#changelist .actions {
color: #999;
padding: 3px;
border-top: 1px solid #fff;
border-bottom: 1px solid #ddd;
background: white url(../img/nav-bg-reverse.gif) 0 -10px repeat-x;
}
#changelist .actions.selected {
background: #fffccf;
border-top: 1px solid #fffee8;
border-bottom: 1px solid #edecd6;
}
#changelist .actions span.all,
#changelist .actions span.action-counter,
#changelist .actions span.clear,
#changelist .actions span.question {
font-size: 11px;
margin: 0 0.5em;
display: none;
}
#changelist .actions:last-child {
border-bottom: none;
}
#changelist .actions select {
border: 1px solid #aaa;
margin-left: 0.5em;
padding: 1px 2px;
}
#changelist .actions label {
font-size: 11px;
margin-left: 0.5em;
}
#changelist #action-toggle {
display: none;
}
#changelist .actions .button {
font-size: 11px;
padding: 1px 2px;
}
/* DASHBOARD */
.dashboard .module table th {
width: 100%;
}
.dashboard .module table td {
white-space: nowrap;
}
.dashboard .module table td a {
display: block;
padding-right: .6em;
}
/* RECENT ACTIONS MODULE */
.module ul.actionlist {
margin-left: 0;
}
ul.actionlist li {
list-style-type: none;
}
ul.actionlist li.changelink {
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
}
\ No newline at end of file
@import url('widgets.css');
/* FORM ROWS */
.form-row {
overflow: hidden;
padding: 8px 12px;
padding-left: 15px;
font-size: 12px;
border-bottom: 1px solid #eee;
}
.form-row img, .form-row input {
vertical-align: middle;
}
form .form-row p {
padding-left: 15px;
font-size: 11px;
}
/* FORM LABELS */
form h4 {
margin: 0 !important;
padding: 0 !important;
border: none !important;
}
label {
font-weight: normal !important;
color: #666;
font-size: 14px;
}
.required label, label.required {
font-weight: bold !important;
color: #333 !important;
}
/* RADIO BUTTONS */
form ul.radiolist li {
list-style-type: none;
}
form ul.radiolist label {
float: none;
display: inline;
}
form ul.inline {
margin-left: 0;
padding: 0;
}
form ul.inline li {
float: left;
padding-right: 7px;
}
/* ALIGNED FIELDSETS */
.aligned label {
display: block;
text-align: left;
padding: 3px 10px 0 0;
float: left;
width: 12em;
}
.aligned ul label {
display: inline;
float: none;
width: auto;
}
.colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField {
width: 350px;
}
form .aligned p, form .aligned ul {
margin-left: 7em;
padding-left: 100px;
}
form .aligned table p {
margin-left: 0;
padding-left: 0;
}
form .aligned p.help {
padding-left: 38px;
}
.aligned .vCheckboxLabel {
float: none !important;
display: inline;
padding-left: 4px;
}
.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField {
width: 610px;
}
.checkbox-row p.help {
margin-left: 0;
padding-left: 0 !important;
}
fieldset .field-box {
float: left;
margin-right: 20px;
}
/* WIDE FIELDSETS */
.wide label {
width: 15em !important;
}
form .wide p {
margin-left: 15em;
}
form .wide p.help {
padding-left: 38px;
}
.colM fieldset.wide .vLargeTextField, .colM fieldset.wide .vXMLLargeTextField {
width: 450px;
}
/* COLLAPSED FIELDSETS */
fieldset.collapsed * {
display: none;
}
fieldset.collapsed h2, fieldset.collapsed {
display: block !important;
}
fieldset.collapsed h2 {
background-image: url(../img/nav-bg.gif);
background-position: bottom left;
color: #999;
}
fieldset.collapsed .collapse-toggle {
background: transparent;
display: inline !important;
}
/* MONOSPACE TEXTAREAS */
fieldset.monospace textarea {
font-family: "Bitstream Vera Sans Mono",Monaco,"Courier New",Courier,monospace;
}
/* SUBMIT ROW */
.submit-row {
padding: 5px 7px;
text-align: right;
background: white url(../img/nav-bg.gif) 0 100% repeat-x;
border: 1px solid #ccc;
margin: 5px 0;
overflow: hidden;
}
body.popup .submit-row {
overflow: auto;
}
.submit-row input {
margin: 0 0 0 5px;
}
.submit-row p {
margin: 0.3em;
}
.submit-row p.deletelink-box {
float: left;
}
.submit-row .deletelink {
background: url(../img/icon_deletelink.gif) 0 50% no-repeat;
padding-left: 14px;
}
/* CUSTOM FORM FIELDS */
.vSelectMultipleField {
vertical-align: top !important;
}
.vCheckboxField {
border: none;
}
.vDateField, .vTimeField {
margin-right: 2px;
}
.vURLField {
width: 30em;
}
.vLargeTextField, .vXMLLargeTextField {
width: 48em;
}
.flatpages-flatpage #id_content {
height: 40.2em;
}
.module table .vPositiveSmallIntegerField {
width: 2.2em;
}
.vTextField {
width: 18em;
}
.vIntegerField {
width: 5em;
}
.vBigIntegerField {
width: 10em;
}
.vForeignKeyRawIdAdminField {
width: 5em;
}
/* INLINES */
.inline-group {
padding: 0;
border: 1px solid #ccc;
margin: 10px 0;
}
.inline-group .aligned label {
width: 8em;
}
.inline-related {
position: relative;
}
.inline-related h3 {
margin: 0;
color: #666;
padding: 3px 5px;
font-size: 11px;
background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x;
border-bottom: 1px solid #ddd;
}
.inline-related h3 span.delete {
float: right;
}
.inline-related h3 span.delete label {
margin-left: 2px;
font-size: 11px;
}
.inline-related fieldset {
margin: 0;
background: #fff;
border: none;
width: 100%;
}
.inline-related fieldset.module h3 {
margin: 0;
padding: 2px 5px 3px 5px;
font-size: 11px;
text-align: left;
font-weight: bold;
background: #bcd;
color: #fff;
}
.inline-group .tabular fieldset.module {
border: none;
border-bottom: 1px solid #ddd;
}
.inline-related.tabular fieldset.module table {
width: 100%;
}
.last-related fieldset {
border: none;
}
.inline-group .tabular tr.has_original td {
padding-top: 2em;
}
.inline-group .tabular tr td.original {
padding: 2px 0 0 0;
width: 0;
_position: relative;
}
.inline-group .tabular th.original {
width: 0px;
padding: 0;
}
.inline-group .tabular td.original p {
position: absolute;
left: 0;
height: 1.1em;
padding: 2px 7px;
overflow: hidden;
font-size: 9px;
font-weight: bold;
color: #666;
_width: 700px;
}
.inline-group ul.tools {
padding: 0;
margin: 0;
list-style: none;
}
.inline-group ul.tools li {
display: inline;
padding: 0 5px;
}
.inline-group div.add-row,
.inline-group .tabular tr.add-row td {
color: #666;
padding: 3px 5px;
border-bottom: 1px solid #ddd;
background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x;
}
.inline-group .tabular tr.add-row td {
padding: 4px 5px 3px;
border-bottom: none;
}
.inline-group ul.tools a.add,
.inline-group div.add-row a,
.inline-group .tabular tr.add-row td a {
background: url(../img/icon_addlink.gif) 0 50% no-repeat;
padding-left: 14px;
font-size: 11px;
outline: 0; /* Remove dotted border around link */
}
.empty-form {
display: none;
}
/* IE 6 & 7 */
/* Proper fixed width for dashboard in IE6 */
.dashboard #content {
*width: 768px;
}
.dashboard #content-main {
*width: 535px;
}
/* IE 6 ONLY */
/* Keep header from flowing off the page */
#container {
_position: static;
}
/* Put the right sidebars back on the page */
.colMS #content-related {
_margin-right: 0;
_margin-left: 10px;
_position: static;
}
/* Put the left sidebars back on the page */
.colSM #content-related {
_margin-right: 10px;
_margin-left: -115px;
_position: static;
}
.form-row {
_height: 1%;
}
/* Fix right margin for changelist filters in IE6 */
#changelist-filter ul {
_margin-right: -10px;
}
/* IE ignores min-height, but treats height as if it were min-height */
.change-list .filtered {
_height: 400px;
}
/* IE doesn't know alpha transparency in PNGs */
.inline-deletelink {
background: transparent url(../img/inline-delete-8bit.png) no-repeat;
}
/* IE7 doesn't support inline-block */
.change-list ul.toplinks li {
zoom: 1;
*display: inline;
}
\ No newline at end of file
/* LOGIN FORM */
body.login {
background: #4B4B4B url(../img/background-pattern-1.jpg);
}
.login #container {
background: white;
border: 1px solid #ccc;
width: 28em;
min-width: 300px;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
}
.login #content-main {
width: 100%;
}
.login form {
margin-top: 1em;
}
.login .form-row {
padding: 4px 0;
float: left;
width: 100%;
}
.login .form-row label {
float: left;
width: 9em;
padding-right: 0.5em;
line-height: 2em;
text-align: right;
font-size: 1em;
color: #000;
}
.login .form-row #id_username, .login .form-row #id_password {
width: 14em;
}
.login span.help {
font-size: 10px;
display: block;
}
.login .submit-row {
clear: both;
padding: 1em 0 0 9.4em;
}
.login .password-reset-link {
text-align: center;
}
body {
direction: rtl;
}
/* LOGIN */
.login .form-row {
float: right;
}
.login .form-row label {
float: right;
padding-left: 0.5em;
padding-right: 0;
text-align: left;
}
.login .submit-row {
clear: both;
padding: 1em 9.4em 0 0;
}
/* GLOBAL */
th {
text-align: right;
}
.module h2, .module caption {
text-align: right;
}
.addlink, .changelink {
padding-left: 0px;
padding-right: 12px;
background-position: 100% 0.2em;
}
.deletelink {
padding-left: 0px;
padding-right: 12px;
background-position: 100% 0.25em;
}
.object-tools {
float: left;
}
thead th:first-child,
tfoot td:first-child {
border-left: 1px solid #ddd !important;
}
/* LAYOUT */
#user-tools {
right: auto;
left: 0;
text-align: left;
}
div.breadcrumbs {
text-align: right;
}
#content-main {
float: right;
}
#content-related {
float: left;
margin-left: -19em;
margin-right: auto;
}
.colMS {
margin-left: 20em !important;
margin-right: 10px !important;
}
/* SORTABLE TABLES */
table thead th.sorted .sortoptions {
float: left;
}
thead th.sorted .text {
padding-right: 0;
padding-left: 42px;
}
/* dashboard styles */
.dashboard .module table td a {
padding-left: .6em;
padding-right: 12px;
}
/* changelists styles */
.change-list .filtered {
background: white url(../img/changelist-bg_rtl.gif) top left repeat-y !important;
}
.change-list .filtered table {
border-left: 1px solid #ddd;
border-right: 0px none;
}
#changelist-filter {
right: auto;
left: 0;
border-left: 0px none;
border-right: 1px solid #ddd;
}
.change-list .filtered .results, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull {
margin-right: 0px !important;
margin-left: 160px !important;
}
#changelist-filter li.selected {
border-left: 0px none;
padding-left: 0px;
margin-left: 0;
border-right: 5px solid #ccc;
padding-right: 5px;
margin-right: -10px;
}
.filtered .actions {
border-left:1px solid #DDDDDD;
margin-left:160px !important;
border-right: 0 none;
margin-right:0 !important;
}
#changelist table tbody td:first-child, #changelist table tbody th:first-child {
border-right: 0;
border-left: 1px solid #ddd;
}
/* FORMS */
.aligned label {
padding: 0 0 3px 1em;
float: right;
}
.submit-row {
text-align: left
}
.submit-row p.deletelink-box {
float: right;
}
.submit-row .deletelink {
background: url(../img/icon_deletelink.gif) 0 50% no-repeat;
padding-right: 14px;
}
.vDateField, .vTimeField {
margin-left: 2px;
}
form ul.inline li {
float: right;
padding-right: 0;
padding-left: 7px;
}
input[type=submit].default, .submit-row input.default {
float: left;
}
fieldset .field-box {
float: right;
margin-left: 20px;
margin-right: 0;
}
.errorlist li {
background-position: 100% .3em;
padding: 4px 25px 4px 5px;
}
.errornote {
background-position: 100% .3em;
padding: 4px 25px 4px 5px;
}
/* WIDGETS */
.calendarnav-previous {
top: 0;
left: auto;
right: 0;
}
.calendarnav-next {
top: 0;
right: auto;
left: 0;
}
.calendar caption, .calendarbox h2 {
text-align: center;
}
.selector {
float: right;
}
.selector .selector-filter {
text-align: right;
}
.inline-deletelink {
float: left;
}
/* MISC */
.inline-related h2, .inline-group h2 {
text-align: right
}
.inline-related h3 span.delete {
padding-right: 20px;
padding-left: inherit;
left: 10px;
right: inherit;
float:left;
}
.inline-related h3 span.delete label {
margin-left: inherit;
margin-right: 2px;
}
/* IE7 specific bug fixes */
div.colM {
position: relative;
}
.submit-row input {
float: left;
}
\ No newline at end of file
Copyright (c) 2010 John Resig, http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
(function() {
'use strict';
var SelectBox = {
cache: {},
init: function(id) {
var box = document.getElementById(id);
var node;
SelectBox.cache[id] = [];
var cache = SelectBox.cache[id];
for (var i = 0, j = box.options.length; i < j; i++) {
node = box.options[i];
cache.push({value: node.value, text: node.text, displayed: 1});
}
},
redisplay: function(id) {
// Repopulate HTML select box from cache
var box = document.getElementById(id);
var node;
box.options.length = 0; // clear all options
var cache = SelectBox.cache[id];
for (var i = 0, j = cache.length; i < j; i++) {
node = cache[i];
if (node.displayed) {
var new_option = new Option(node.text, node.value, false, false);
// Shows a tooltip when hovering over the option
new_option.setAttribute("title", node.text);
box.options[box.options.length] = new_option;
}
}
},
filter: function(id, text) {
// Redisplay the HTML select box, displaying only the choices containing ALL
// the words in text. (It's an AND search.)
var tokens = text.toLowerCase().split(/\s+/);
var node, token;
var cache = SelectBox.cache[id];
for (var i = 0, j = cache.length; i < j; i++) {
node = cache[i];
node.displayed = 1;
var numTokens = tokens.length;
for (var k = 0; k < numTokens; k++) {
token = tokens[k];
if (node.text.toLowerCase().indexOf(token) === -1) {
node.displayed = 0;
}
}
}
SelectBox.redisplay(id);
},
delete_from_cache: function(id, value) {
var node, delete_index = null;
var cache = SelectBox.cache[id];
for (var i = 0, j = cache.length; i < j; i++) {
node = cache[i];
if (node.value === value) {
delete_index = i;
break;
}
}
var k = cache.length - 1;
for (i = delete_index; i < k; i++) {
cache[i] = cache[i + 1];
}
cache.length--;
},
add_to_cache: function(id, option) {
SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
},
cache_contains: function(id, value) {
// Check if an item is contained in the cache
var node;
var cache = SelectBox.cache[id];
for (var i = 0, j = cache.length; i < j; i++) {
node = cache[i];
if (node.value === value) {
return true;
}
}
return false;
},
move: function(from, to) {
var from_box = document.getElementById(from);
var option;
var boxOptions = from_box.options;
for (var i = 0, j = boxOptions.length; i < j; i++) {
option = boxOptions[i];
if (option.selected && SelectBox.cache_contains(from, option.value)) {
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
SelectBox.delete_from_cache(from, option.value);
}
}
SelectBox.redisplay(from);
SelectBox.redisplay(to);
},
move_all: function(from, to) {
var from_box = document.getElementById(from);
var option;
var boxOptions = from_box.options;
for (var i = 0, j = boxOptions.length; i < j; i++) {
option = boxOptions[i];
if (SelectBox.cache_contains(from, option.value)) {
SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
SelectBox.delete_from_cache(from, option.value);
}
}
SelectBox.redisplay(from);
SelectBox.redisplay(to);
},
sort: function(id) {
SelectBox.cache[id].sort(function(a, b) {
a = a.text.toLowerCase();
b = b.text.toLowerCase();
try {
if (a > b) {
return 1;
}
if (a < b) {
return -1;
}
}
catch (e) {
// silently fail on IE 'unknown' exception
}
return 0;
} );
},
select_all: function(id) {
var box = document.getElementById(id);
for (var i = 0; i < box.options.length; i++) {
box.options[i].selected = 'selected';
}
}
};
window.SelectBox = SelectBox;
})();
/*global _actions_icnt, gettext, interpolate, ngettext*/
(function($) {
'use strict';
var lastChecked;
$.fn.actions = function(opts) {
var options = $.extend({}, $.fn.actions.defaults, opts);
var actionCheckboxes = $(this);
var list_editable_changed = false;
var showQuestion = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).show();
$(options.allContainer).hide();
},
showClear = function() {
$(options.acrossClears).show();
$(options.acrossQuestions).hide();
$(options.actionContainer).toggleClass(options.selectedClass);
$(options.allContainer).show();
$(options.counterContainer).hide();
},
reset = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).hide();
$(options.allContainer).hide();
$(options.counterContainer).show();
},
clearAcross = function() {
reset();
$(options.acrossInput).val(0);
$(options.actionContainer).removeClass(options.selectedClass);
},
checker = function(checked) {
if (checked) {
showQuestion();
} else {
reset();
}
$(actionCheckboxes).prop("checked", checked)
.parent().parent().toggleClass(options.selectedClass, checked);
},
updateCounter = function() {
var sel = $(actionCheckboxes).filter(":checked").length;
// _actions_icnt is defined in the generated HTML
// and contains the total amount of objects in the queryset
$(options.counterContainer).html(interpolate(
ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {
sel: sel,
cnt: _actions_icnt
}, true));
$(options.allToggle).prop("checked", function() {
var value;
if (sel === actionCheckboxes.length) {
value = true;
showQuestion();
} else {
value = false;
clearAcross();
}
return value;
});
};
// Show counter by default
$(options.counterContainer).show();
// Check state of checkboxes and reinit state if needed
$(this).filter(":checked").each(function(i) {
$(this).parent().parent().toggleClass(options.selectedClass);
updateCounter();
if ($(options.acrossInput).val() === 1) {
showClear();
}
});
$(options.allToggle).show().click(function() {
checker($(this).prop("checked"));
updateCounter();
});
$("a", options.acrossQuestions).click(function(event) {
event.preventDefault();
$(options.acrossInput).val(1);
showClear();
});
$("a", options.acrossClears).click(function(event) {
event.preventDefault();
$(options.allToggle).prop("checked", false);
clearAcross();
checker(0);
updateCounter();
});
lastChecked = null;
$(actionCheckboxes).click(function(event) {
if (!event) { event = window.event; }
var target = event.target ? event.target : event.srcElement;
if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) {
var inrange = false;
$(lastChecked).prop("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
$(actionCheckboxes).each(function() {
if ($.data(this) === $.data(lastChecked) || $.data(this) === $.data(target)) {
inrange = (inrange) ? false : true;
}
if (inrange) {
$(this).prop("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
}
});
}
$(target).parent().parent().toggleClass(options.selectedClass, target.checked);
lastChecked = target;
updateCounter();
});
$('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() {
list_editable_changed = true;
});
$('form#changelist-form button[name="index"]').click(function(event) {
if (list_editable_changed) {
return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
}
});
$('form#changelist-form input[name="_save"]').click(function(event) {
var action_changed = false;
$('select option:selected', options.actionContainer).each(function() {
if ($(this).val()) {
action_changed = true;
}
});
if (action_changed) {
if (list_editable_changed) {
return confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action."));
} else {
return confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."));
}
}
});
};
/* Setup plugin defaults */
$.fn.actions.defaults = {
actionContainer: "div.actions",
counterContainer: "span.action-counter",
allContainer: "div.actions span.all",
acrossInput: "div.actions input.select-across",
acrossQuestions: "div.actions span.question",
acrossClears: "div.actions span.clear",
allToggle: "#action-toggle",
selectedClass: "selected"
};
})(django.jQuery);
(function(a){var f;a.fn.actions=function(q){var b=a.extend({},a.fn.actions.defaults,q),g=a(this),e=!1,k=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},l=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},m=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},n=function(){m();
a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},p=function(c){c?k():m();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},!0));a(b.allToggle).prop("checked",function(){var a;c===g.length?(a=!0,k()):(a=!1,n());return a})};a(b.counterContainer).show();a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);
h();1===a(b.acrossInput).val()&&l()});a(b.allToggle).show().click(function(){p(a(this).prop("checked"));h()});a("a",b.acrossQuestions).click(function(c){c.preventDefault();a(b.acrossInput).val(1);l()});a("a",b.acrossClears).click(function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);n();p(0);h()});f=null;a(g).click(function(c){c||(c=window.event);var d=c.target?c.target:c.srcElement;if(f&&a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,
d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){e=!0});a('form#changelist-form button[name="index"]').click(function(a){if(e)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});
a('form#changelist-form input[name="_save"]').click(function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return e?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};
a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery);
/*global SelectBox, interpolate*/
// Handles related-objects functionality: lookup link for raw_id_fields
// and Add Another links.
(function() {
'use strict';
function html_unescape(text) {
// Unescape a string that was escaped using django.utils.html.escape.
text = text.replace(/&lt;/g, '<');
text = text.replace(/&gt;/g, '>');
text = text.replace(/&quot;/g, '"');
text = text.replace(/&#39;/g, "'");
text = text.replace(/&amp;/g, '&');
return text;
}
// IE doesn't accept periods or dashes in the window name, but the element IDs
// we use to generate popup window names may contain them, therefore we map them
// to allowed characters in a reversible way so that we can locate the correct
// element when the popup window is dismissed.
function id_to_windowname(text) {
text = text.replace(/\./g, '__dot__');
text = text.replace(/\-/g, '__dash__');
return text;
}
function windowname_to_id(text) {
text = text.replace(/__dot__/g, '.');
text = text.replace(/__dash__/g, '-');
return text;
}
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
var name = triggeringLink.id.replace(name_regexp, '');
name = id_to_windowname(name);
var href = triggeringLink.href;
if (add_popup) {
if (href.indexOf('?') === -1) {
href += '?_popup=1';
} else {
href += '&_popup=1';
}
}
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
win.focus();
return false;
}
function showRelatedObjectLookupPopup(triggeringLink) {
return showAdminPopup(triggeringLink, /^lookup_/, true);
}
function dismissRelatedLookupPopup(win, chosenId) {
var name = windowname_to_id(win.name);
var elem = document.getElementById(name);
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
elem.value += ',' + chosenId;
} else {
document.getElementById(name).value = chosenId;
}
win.close();
}
function showRelatedObjectPopup(triggeringLink) {
return showAdminPopup(triggeringLink, /^(change|add|delete)_/, false);
}
function updateRelatedObjectLinks(triggeringLink) {
var $this = django.jQuery(triggeringLink);
var siblings = $this.nextAll('.change-related, .delete-related');
if (!siblings.length) {
return;
}
var value = $this.val();
if (value) {
siblings.each(function() {
var elm = django.jQuery(this);
elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
});
} else {
siblings.removeAttr('href');
}
}
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
// newId and newRepr are expected to have previously been escaped by
// django.utils.html.escape.
newId = html_unescape(newId);
newRepr = html_unescape(newRepr);
var name = windowname_to_id(win.name);
var elem = document.getElementById(name);
if (elem) {
var elemName = elem.nodeName.toUpperCase();
if (elemName === 'SELECT') {
elem.options[elem.options.length] = new Option(newRepr, newId, true, true);
} else if (elemName === 'INPUT') {
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
elem.value += ',' + newId;
} else {
elem.value = newId;
}
}
// Trigger a change event to update related links if required.
django.jQuery(elem).trigger('change');
} else {
var toId = name + "_to";
var o = new Option(newRepr, newId);
SelectBox.add_to_cache(toId, o);
SelectBox.redisplay(toId);
}
win.close();
}
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
objId = html_unescape(objId);
newRepr = html_unescape(newRepr);
var id = windowname_to_id(win.name).replace(/^edit_/, '');
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
var selects = django.jQuery(selectsSelector);
selects.find('option').each(function() {
if (this.value === objId) {
this.innerHTML = newRepr;
this.value = newId;
}
});
win.close();
}
function dismissDeleteRelatedObjectPopup(win, objId) {
objId = html_unescape(objId);
var id = windowname_to_id(win.name).replace(/^delete_/, '');
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
var selects = django.jQuery(selectsSelector);
selects.find('option').each(function() {
if (this.value === objId) {
django.jQuery(this).remove();
}
}).trigger('change');
win.close();
}
// Global for testing purposes
window.html_unescape = html_unescape;
window.id_to_windowname = id_to_windowname;
window.windowname_to_id = windowname_to_id;
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
window.showRelatedObjectPopup = showRelatedObjectPopup;
window.updateRelatedObjectLinks = updateRelatedObjectLinks;
window.dismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup;
window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup;
window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup;
// Kept for backward compatibility
window.showAddAnotherPopup = showRelatedObjectPopup;
window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
})();
/*global gettext, get_format, quickElement, removeChildren*/
/*
calendar.js - Calendar functions by Adrian Holovaty
depends on core.js for utility functions like removeChildren or quickElement
*/
(function() {
'use strict';
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
var CalendarNamespace = {
monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
daysOfWeek: gettext('S M T W T F S').split(' '),
firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')),
isLeapYear: function(year) {
return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0));
},
getDaysInMonth: function(month, year) {
var days;
if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) {
days = 31;
}
else if (month === 4 || month === 6 || month === 9 || month === 11) {
days = 30;
}
else if (month === 2 && CalendarNamespace.isLeapYear(year)) {
days = 29;
}
else {
days = 28;
}
return days;
},
draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999
var today = new Date();
var todayDay = today.getDate();
var todayMonth = today.getMonth() + 1;
var todayYear = today.getFullYear();
var todayClass = '';
// Use UTC functions here because the date field does not contain time
// and using the UTC function variants prevent the local time offset
// from altering the date, specifically the day field. For example:
//
// ```
// var x = new Date('2013-10-02');
// var day = x.getDate();
// ```
//
// The day variable above will be 1 instead of 2 in, say, US Pacific time
// zone.
var isSelectedMonth = false;
if (typeof selected !== 'undefined') {
isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month);
}
month = parseInt(month);
year = parseInt(year);
var calDiv = document.getElementById(div_id);
removeChildren(calDiv);
var calTable = document.createElement('table');
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year);
var tableBody = quickElement('tbody', calTable);
// Draw days-of-week header
var tableRow = quickElement('tr', tableBody);
for (var i = 0; i < 7; i++) {
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
}
var startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
var days = CalendarNamespace.getDaysInMonth(month, year);
var nonDayCell;
// Draw blanks before first of month
tableRow = quickElement('tr', tableBody);
for (i = 0; i < startingPos; i++) {
nonDayCell = quickElement('td', tableRow, ' ');
nonDayCell.className = "nonday";
}
// Draw days of month
var currentDay = 1;
for (i = startingPos; currentDay <= days; i++) {
if (i % 7 === 0 && currentDay !== 1) {
tableRow = quickElement('tr', tableBody);
}
if ((currentDay === todayDay) && (month === todayMonth) && (year === todayYear)) {
todayClass = 'today';
} else {
todayClass = '';
}
// use UTC function; see above for explanation.
if (isSelectedMonth && currentDay === selected.getUTCDate()) {
if (todayClass !== '') {
todayClass += " ";
}
todayClass += "selected";
}
var cell = quickElement('td', tableRow, '', 'class', todayClass);
quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '(' + year + ',' + month + ',' + currentDay + '));');
currentDay++;
}
// Draw blanks after end of month (optional, but makes for valid code)
while (tableRow.childNodes.length < 7) {
nonDayCell = quickElement('td', tableRow, ' ');
nonDayCell.className = "nonday";
}
calDiv.appendChild(calTable);
}
};
// Calendar -- A calendar instance
function Calendar(div_id, callback, selected) {
// div_id (string) is the ID of the element in which the calendar will
// be displayed
// callback (string) is the name of a JavaScript function that will be
// called with the parameters (year, month, day) when a day in the
// calendar is clicked
this.div_id = div_id;
this.callback = callback;
this.today = new Date();
this.currentMonth = this.today.getMonth() + 1;
this.currentYear = this.today.getFullYear();
if (typeof selected !== 'undefined') {
this.selected = selected;
}
}
Calendar.prototype = {
drawCurrent: function() {
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback, this.selected);
},
drawDate: function(month, year, selected) {
this.currentMonth = month;
this.currentYear = year;
if(selected) {
this.selected = selected;
}
this.drawCurrent();
},
drawPreviousMonth: function() {
if (this.currentMonth === 1) {
this.currentMonth = 12;
this.currentYear--;
}
else {
this.currentMonth--;
}
this.drawCurrent();
},
drawNextMonth: function() {
if (this.currentMonth === 12) {
this.currentMonth = 1;
this.currentYear++;
}
else {
this.currentMonth++;
}
this.drawCurrent();
},
drawPreviousYear: function() {
this.currentYear--;
this.drawCurrent();
},
drawNextYear: function() {
this.currentYear++;
this.drawCurrent();
}
};
window.Calendar = Calendar;
})();
/*global gettext*/
(function($) {
'use strict';
$(document).ready(function() {
// Add anchor tag for Show/Hide link
$("fieldset.collapse").each(function(i, elem) {
// Don't hide if fields in this fieldset have errors
if ($(elem).find("div.errors").length === 0) {
$(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
i + '" class="collapse-toggle" href="#">' + gettext("Show") +
'</a>)');
}
});
// Add toggle to anchor tag
$("fieldset.collapse a.collapse-toggle").click(function(ev) {
if ($(this).closest("fieldset").hasClass("collapsed")) {
// Show
$(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
} else {
// Hide
$(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);
}
return false;
});
});
})(django.jQuery);
(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(b,c){0===a(c).find("div.errors").length&&a(c).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser'+b+'" class="collapse-toggle" href="#">'+gettext("Show")+"</a>)")});a("fieldset.collapse a.collapse-toggle").click(function(b){a(this).closest("fieldset").hasClass("collapsed")?a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]):a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset",
[a(this).attr("id")]);return!1})})})(django.jQuery);
// Core javascript helper functions
// basic browser identification & version
var isOpera = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion);
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
// Cross-browser event handlers.
function addEvent(obj, evType, fn) {
'use strict';
if (obj.addEventListener) {
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent) {
var r = obj.attachEvent("on" + evType, fn);
return r;
} else {
return false;
}
}
function removeEvent(obj, evType, fn) {
'use strict';
if (obj.removeEventListener) {
obj.removeEventListener(evType, fn, false);
return true;
} else if (obj.detachEvent) {
obj.detachEvent("on" + evType, fn);
return true;
} else {
return false;
}
}
function cancelEventPropagation(e) {
'use strict';
if (!e) {
e = window.event;
}
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
}
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
function quickElement() {
'use strict';
var obj = document.createElement(arguments[0]);
if (arguments[2]) {
var textNode = document.createTextNode(arguments[2]);
obj.appendChild(textNode);
}
var len = arguments.length;
for (var i = 3; i < len; i += 2) {
obj.setAttribute(arguments[i], arguments[i + 1]);
}
arguments[1].appendChild(obj);
return obj;
}
// "a" is reference to an object
function removeChildren(a) {
'use strict';
while (a.hasChildNodes()) {
a.removeChild(a.lastChild);
}
}
// ----------------------------------------------------------------------------
// Cross-browser xmlhttp object
// from http://jibbering.com/2002/4/httprequest.html
// ----------------------------------------------------------------------------
var xmlhttp;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest !== 'undefined') {
xmlhttp = new XMLHttpRequest();
}
// ----------------------------------------------------------------------------
// Find-position functions by PPK
// See http://www.quirksmode.org/js/findpos.html
// ----------------------------------------------------------------------------
function findPosX(obj) {
'use strict';
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
obj = obj.offsetParent;
}
// IE offsetParent does not include the top-level
if (isIE && obj.parentElement) {
curleft += obj.offsetLeft - obj.scrollLeft;
}
} else if (obj.x) {
curleft += obj.x;
}
return curleft;
}
function findPosY(obj) {
'use strict';
var curtop = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
obj = obj.offsetParent;
}
// IE offsetParent does not include the top-level
if (isIE && obj.parentElement) {
curtop += obj.offsetTop - obj.scrollTop;
}
} else if (obj.y) {
curtop += obj.y;
}
return curtop;
}
//-----------------------------------------------------------------------------
// Date object extensions
// ----------------------------------------------------------------------------
(function() {
'use strict';
Date.prototype.getTwelveHours = function() {
var hours = this.getHours();
if (hours === 0) {
return 12;
}
else {
return hours <= 12 ? hours : hours - 12;
}
};
Date.prototype.getTwoDigitMonth = function() {
return (this.getMonth() < 9) ? '0' + (this.getMonth() + 1) : (this.getMonth() + 1);
};
Date.prototype.getTwoDigitDate = function() {
return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
};
Date.prototype.getTwoDigitTwelveHour = function() {
return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours();
};
Date.prototype.getTwoDigitHour = function() {
return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
};
Date.prototype.getTwoDigitMinute = function() {
return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
};
Date.prototype.getTwoDigitSecond = function() {
return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
};
Date.prototype.getHourMinute = function() {
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
};
Date.prototype.getHourMinuteSecond = function() {
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
};
Date.prototype.strftime = function(format) {
var fields = {
c: this.toString(),
d: this.getTwoDigitDate(),
H: this.getTwoDigitHour(),
I: this.getTwoDigitTwelveHour(),
m: this.getTwoDigitMonth(),
M: this.getTwoDigitMinute(),
p: (this.getHours() >= 12) ? 'PM' : 'AM',
S: this.getTwoDigitSecond(),
w: '0' + this.getDay(),
x: this.toLocaleDateString(),
X: this.toLocaleTimeString(),
y: ('' + this.getFullYear()).substr(2, 4),
Y: '' + this.getFullYear(),
'%': '%'
};
var result = '', i = 0;
while (i < format.length) {
if (format.charAt(i) === '%') {
result = result + fields[format.charAt(i + 1)];
++i;
}
else {
result = result + format.charAt(i);
}
++i;
}
return result;
};
// ----------------------------------------------------------------------------
// String object extensions
// ----------------------------------------------------------------------------
String.prototype.pad_left = function(pad_length, pad_string) {
var new_string = this;
for (var i = 0; new_string.length < pad_length; i++) {
new_string = pad_string + new_string;
}
return new_string;
};
String.prototype.strptime = function(format) {
var split_format = format.split(/[.\-/]/);
var date = this.split(/[.\-/]/);
var i = 0;
var day, month, year;
while (i < split_format.length) {
switch (split_format[i]) {
case "%d":
day = date[i];
break;
case "%m":
month = date[i] - 1;
break;
case "%Y":
year = date[i];
break;
case "%y":
year = date[i];
break;
}
++i;
}
return new Date(year, month, day);
};
})();
// ----------------------------------------------------------------------------
// Get the computed style for and element
// ----------------------------------------------------------------------------
function getStyle(oElm, strCssRule) {
'use strict';
var strValue = "";
if(document.defaultView && document.defaultView.getComputedStyle) {
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
}
else if(oElm.currentStyle) {
strCssRule = strCssRule.replace(/\-(\w)/g, function(strMatch, p1) {
return p1.toUpperCase();
});
strValue = oElm.currentStyle[strCssRule];
}
return strValue;
}
(function(b){b.fn.formset=function(d){var a=b.extend({},b.fn.formset.defaults,d),e=b(this);d=e.parent();var k=function(a,f,l){var c=new RegExp("("+f+"-(\\d+|__prefix__))");f=f+"-"+l;b(a).prop("for")&&b(a).prop("for",b(a).prop("for").replace(c,f));a.id&&(a.id=a.id.replace(c,f));a.name&&(a.name=a.name.replace(c,f))},h=b("#id_"+a.prefix+"-TOTAL_FORMS").prop("autocomplete","off"),l=parseInt(h.val(),10),f=b("#id_"+a.prefix+"-MAX_NUM_FORMS").prop("autocomplete","off"),c=""===f.val()||0<f.val()-h.val();
e.each(function(f){b(this).not("."+a.emptyCssClass).addClass(a.formCssClass)});if(e.length&&c){var m;"TR"===e.prop("tagName")?(e=this.eq(-1).children().length,d.append('<tr class="'+a.addCssClass+'"><td colspan="'+e+'"><a href="javascript:void(0)">'+a.addText+"</a></tr>"),m=d.find("tr:last a")):(e.filter(":last").after('<div class="'+a.addCssClass+'"><a href="javascript:void(0)">'+a.addText+"</a></div>"),m=e.filter(":last").next().find("a"));m.click(function(c){c.preventDefault();c=b("#"+a.prefix+
"-empty");var g=c.clone(!0);g.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+l);g.is("tr")?g.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></div>"):g.is("ul")||g.is("ol")?g.append('<li><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></li>"):g.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></span>");g.find("*").each(function(){k(this,
a.prefix,h.val())});g.insertBefore(b(c));b(h).val(parseInt(h.val(),10)+1);l+=1;""!==f.val()&&0>=f.val()-h.val()&&m.parent().hide();g.find("a."+a.deleteCssClass).click(function(c){c.preventDefault();g.remove();--l;a.removed&&a.removed(g);b(document).trigger("formset:removed",[g,a.prefix]);c=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(c.length);(""===f.val()||0<f.val()-c.length)&&m.parent().show();var d,e,h=function(){k(this,a.prefix,d)};d=0;for(e=c.length;d<e;d++)k(b(c).get(d),a.prefix,
d),b(c.get(d)).find("*").each(h)});a.added&&a.added(g);b(document).trigger("formset:added",[g,a.prefix])})}return this};b.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null};b.fn.tabularFormset=function(d){var a=b(this),e=function(l){b(a.selector).not(".add-row").removeClass("row1 row2").filter(":even").addClass("row1").end().filter(":odd").addClass("row2")},
k=function(){"undefined"!==typeof SelectFilter&&(b(".selectfilter").each(function(a,b){var c=b.name.split("-");SelectFilter.init(b.id,c[c.length-1],!1)}),b(".selectfilterstacked").each(function(a,b){var c=b.name.split("-");SelectFilter.init(b.id,c[c.length-1],!0)}))},h=function(a){a.find(".prepopulated_field").each(function(){var f=b(this).find("input, select, textarea"),c=f.data("dependency_list")||[],d=[];b.each(c,function(b,c){d.push("#"+a.find(".field-"+c).find("input, select, textarea").attr("id"))});
d.length&&f.prepopulate(d,f.attr("maxlength"))})};a.formset({prefix:d.prefix,addText:d.addText,formCssClass:"dynamic-"+d.prefix,deleteCssClass:"inline-deletelink",deleteText:d.deleteText,emptyCssClass:"empty-form",removed:e,added:function(a){h(a);"undefined"!==typeof DateTimeShortcuts&&(b(".datetimeshortcuts").remove(),DateTimeShortcuts.init());k();e(a)}});return a};b.fn.stackedFormset=function(d){var a=b(this),e=function(d){b(a.selector).find(".inline_label").each(function(a){a+=1;b(this).html(b(this).html().replace(/(#\d+)/g,
"#"+a))})},k=function(){"undefined"!==typeof SelectFilter&&(b(".selectfilter").each(function(a,b){var c=b.name.split("-");SelectFilter.init(b.id,c[c.length-1],!1)}),b(".selectfilterstacked").each(function(a,b){var c=b.name.split("-");SelectFilter.init(b.id,c[c.length-1],!0)}))},h=function(a){a.find(".prepopulated_field").each(function(){var d=b(this).find("input, select, textarea"),c=d.data("dependency_list")||[],e=[];b.each(c,function(b,c){e.push("#"+a.find(".form-row .field-"+c).find("input, select, textarea").attr("id"))});
e.length&&d.prepopulate(e,d.attr("maxlength"))})};a.formset({prefix:d.prefix,addText:d.addText,formCssClass:"dynamic-"+d.prefix,deleteCssClass:"inline-deletelink",deleteText:d.deleteText,emptyCssClass:"empty-form",removed:e,added:function(a){h(a);"undefined"!==typeof DateTimeShortcuts&&(b(".datetimeshortcuts").remove(),DateTimeShortcuts.init());k();e(a)}});return a}})(django.jQuery);
/*global django:true, jQuery:false*/
/* Puts the included jQuery into our own namespace using noConflict and passing
* it 'true'. This ensures that the included jQuery doesn't pollute the global
* namespace (i.e. this preserves pre-existing values for both window.$ and
* window.jQuery).
*/
var django = django || {};
django.jQuery = jQuery.noConflict(true);
This source diff could not be displayed because it is too large. You can view the blob instead.
/*global URLify*/
(function($) {
'use strict';
$.fn.prepopulate = function(dependencies, maxLength, allowUnicode) {
/*
Depends on urlify.js
Populates a selected field with the values of the dependent fields,
URLifies and shortens the string.
dependencies - array of dependent fields ids
maxLength - maximum length of the URLify'd string
allowUnicode - Unicode support of the URLify'd string
*/
return this.each(function() {
var prepopulatedField = $(this);
var populate = function() {
// Bail if the field's value has been changed by the user
if (prepopulatedField.data('_changed')) {
return;
}
var values = [];
$.each(dependencies, function(i, field) {
field = $(field);
if (field.val().length > 0) {
values.push(field.val());
}
});
prepopulatedField.val(URLify(values.join(' '), maxLength, allowUnicode));
};
prepopulatedField.data('_changed', false);
prepopulatedField.change(function() {
prepopulatedField.data('_changed', true);
});
if (!prepopulatedField.val()) {
$(dependencies.join(',')).keyup(populate).change(populate).focus(populate);
}
});
};
})(django.jQuery);
(function(c){c.fn.prepopulate=function(e,f,g){return this.each(function(){var a=c(this),b=function(){if(!a.data("_changed")){var b=[];c.each(e,function(a,d){d=c(d);0<d.val().length&&b.push(d.val())});a.val(URLify(b.join(" "),f,g))}};a.data("_changed",!1);a.change(function(){a.data("_changed",!0)});a.val()||c(e.join(",")).keyup(b).change(b).focus(b)})}})(django.jQuery);
django.jQuery(function($){
function updateLinks() {
var $this = $(this);
var siblings = $this.nextAll('.change-related, .delete-related');
if (!siblings.length) return;
var value = $this.val();
if (value) {
siblings.each(function(){
var elm = $(this);
elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
});
} else siblings.removeAttr('href');
}
var container = $(document);
container.on('change', '.related-widget-wrapper select', updateLinks);
container.find('.related-widget-wrapper select').each(updateLinks);
container.on('click', '.related-widget-wrapper-link', function(event){
if (this.href) {
showRelatedObjectPopup(this);
}
event.preventDefault();
});
});
(function() {
'use strict';
var timeParsePatterns = [
// 9
{
re: /^\d{1,2}$/i,
handler: function(bits) {
if (bits[0].length === 1) {
return '0' + bits[0] + ':00';
} else {
return bits[0] + ':00';
}
}
},
// 13:00
{
re: /^\d{2}[:.]\d{2}$/i,
handler: function(bits) {
return bits[0].replace('.', ':');
}
},
// 9:00
{
re: /^\d[:.]\d{2}$/i,
handler: function(bits) {
return '0' + bits[0].replace('.', ':');
}
},
// 3 am / 3 a.m. / 3am
{
re: /^(\d+)\s*([ap])(?:.?m.?)?$/i,
handler: function(bits) {
var hour = parseInt(bits[1]);
if (hour === 12) {
hour = 0;
}
if (bits[2].toLowerCase() === 'p') {
if (hour === 12) {
hour = 0;
}
return (hour + 12) + ':00';
} else {
if (hour < 10) {
return '0' + hour + ':00';
} else {
return hour + ':00';
}
}
}
},
// 3.30 am / 3:15 a.m. / 3.00am
{
re: /^(\d+)[.:](\d{2})\s*([ap]).?m.?$/i,
handler: function(bits) {
var hour = parseInt(bits[1]);
var mins = parseInt(bits[2]);
if (mins < 10) {
mins = '0' + mins;
}
if (hour === 12) {
hour = 0;
}
if (bits[3].toLowerCase() === 'p') {
if (hour === 12) {
hour = 0;
}
return (hour + 12) + ':' + mins;
} else {
if (hour < 10) {
return '0' + hour + ':' + mins;
} else {
return hour + ':' + mins;
}
}
}
},
// noon
{
re: /^no/i,
handler: function(bits) {
return '12:00';
}
},
// midnight
{
re: /^mid/i,
handler: function(bits) {
return '00:00';
}
}
];
function parseTimeString(s) {
for (var i = 0; i < timeParsePatterns.length; i++) {
var re = timeParsePatterns[i].re;
var handler = timeParsePatterns[i].handler;
var bits = re.exec(s);
if (bits) {
return handler(bits);
}
}
return s;
}
window.parseTimeString = parseTimeString;
})();
/*global XRegExp*/
(function() {
'use strict';
var LATIN_MAP = {
'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',
'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',
'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O',
'Õ': 'O', 'Ö': 'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U',
'Ü': 'U', 'Ű': 'U', 'Ý': 'Y', 'Þ': 'TH', 'Ÿ': 'Y', 'ß': 'ss', 'à': 'a',
'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c',
'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i',
'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o',
'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u',
'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y'
};
var LATIN_SYMBOLS_MAP = {
'©': '(c)'
};
var GREEK_MAP = {
'α': 'a', 'β': 'b', 'γ': 'g', 'δ': 'd', 'ε': 'e', 'ζ': 'z', 'η': 'h',
'θ': '8', 'ι': 'i', 'κ': 'k', 'λ': 'l', 'μ': 'm', 'ν': 'n', 'ξ': '3',
'ο': 'o', 'π': 'p', 'ρ': 'r', 'σ': 's', 'τ': 't', 'υ': 'y', 'φ': 'f',
'χ': 'x', 'ψ': 'ps', 'ω': 'w', 'ά': 'a', 'έ': 'e', 'ί': 'i', 'ό': 'o',
'ύ': 'y', 'ή': 'h', 'ώ': 'w', 'ς': 's', 'ϊ': 'i', 'ΰ': 'y', 'ϋ': 'y',
'ΐ': 'i', 'Α': 'A', 'Β': 'B', 'Γ': 'G', 'Δ': 'D', 'Ε': 'E', 'Ζ': 'Z',
'Η': 'H', 'Θ': '8', 'Ι': 'I', 'Κ': 'K', 'Λ': 'L', 'Μ': 'M', 'Ν': 'N',
'Ξ': '3', 'Ο': 'O', 'Π': 'P', 'Ρ': 'R', 'Σ': 'S', 'Τ': 'T', 'Υ': 'Y',
'Φ': 'F', 'Χ': 'X', 'Ψ': 'PS', 'Ω': 'W', 'Ά': 'A', 'Έ': 'E', 'Ί': 'I',
'Ό': 'O', 'Ύ': 'Y', 'Ή': 'H', 'Ώ': 'W', 'Ϊ': 'I', 'Ϋ': 'Y'
};
var TURKISH_MAP = {
'ş': 's', 'Ş': 'S', 'ı': 'i', 'İ': 'I', 'ç': 'c', 'Ç': 'C', 'ü': 'u',
'Ü': 'U', 'ö': 'o', 'Ö': 'O', 'ğ': 'g', 'Ğ': 'G'
};
var ROMANIAN_MAP = {
'ă': 'a', 'î': 'i', 'ș': 's', 'ț': 't', 'â': 'a',
'Ă': 'A', 'Î': 'I', 'Ș': 'S', 'Ț': 'T', 'Â': 'A'
};
var RUSSIAN_MAP = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo',
'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm',
'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh', 'щ': 'sh', 'ъ': '',
'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya',
'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'Yo',
'Ж': 'Zh', 'З': 'Z', 'И': 'I', 'Й': 'J', 'К': 'K', 'Л': 'L', 'М': 'M',
'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U',
'Ф': 'F', 'Х': 'H', 'Ц': 'C', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Sh', 'Ъ': '',
'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya'
};
var UKRAINIAN_MAP = {
'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i',
'ї': 'yi', 'ґ': 'g'
};
var CZECH_MAP = {
'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't',
'ů': 'u', 'ž': 'z', 'Č': 'C', 'Ď': 'D', 'Ě': 'E', 'Ň': 'N', 'Ř': 'R',
'Š': 'S', 'Ť': 'T', 'Ů': 'U', 'Ž': 'Z'
};
var POLISH_MAP = {
'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ó': 'o', 'ś': 's',
'ź': 'z', 'ż': 'z',
'Ą': 'A', 'Ć': 'C', 'Ę': 'E', 'Ł': 'L', 'Ń': 'N', 'Ó': 'O', 'Ś': 'S',
'Ź': 'Z', 'Ż': 'Z'
};
var LATVIAN_MAP = {
'ā': 'a', 'č': 'c', 'ē': 'e', 'ģ': 'g', 'ī': 'i', 'ķ': 'k', 'ļ': 'l',
'ņ': 'n', 'š': 's', 'ū': 'u', 'ž': 'z',
'Ā': 'A', 'Č': 'C', 'Ē': 'E', 'Ģ': 'G', 'Ī': 'I', 'Ķ': 'K', 'Ļ': 'L',
'Ņ': 'N', 'Š': 'S', 'Ū': 'U', 'Ž': 'Z'
};
var ARABIC_MAP = {
'أ': 'a', 'ب': 'b', 'ت': 't', 'ث': 'th', 'ج': 'g', 'ح': 'h', 'خ': 'kh', 'د': 'd',
'ذ': 'th', 'ر': 'r', 'ز': 'z', 'س': 's', 'ش': 'sh', 'ص': 's', 'ض': 'd', 'ط': 't',
'ظ': 'th', 'ع': 'aa', 'غ': 'gh', 'ف': 'f', 'ق': 'k', 'ك': 'k', 'ل': 'l', 'م': 'm',
'ن': 'n', 'ه': 'h', 'و': 'o', 'ي': 'y'
};
var LITHUANIAN_MAP = {
'ą': 'a', 'č': 'c', 'ę': 'e', 'ė': 'e', 'į': 'i', 'š': 's', 'ų': 'u',
'ū': 'u', 'ž': 'z',
'Ą': 'A', 'Č': 'C', 'Ę': 'E', 'Ė': 'E', 'Į': 'I', 'Š': 'S', 'Ų': 'U',
'Ū': 'U', 'Ž': 'Z'
};
var SERBIAN_MAP = {
'ђ': 'dj', 'ј': 'j', 'љ': 'lj', 'њ': 'nj', 'ћ': 'c', 'џ': 'dz',
'đ': 'dj', 'Ђ': 'Dj', 'Ј': 'j', 'Љ': 'Lj', 'Њ': 'Nj', 'Ћ': 'C',
'Џ': 'Dz', 'Đ': 'Dj'
};
var AZERBAIJANI_MAP = {
'ç': 'c', 'ə': 'e', 'ğ': 'g', 'ı': 'i', 'ö': 'o', 'ş': 's', 'ü': 'u',
'Ç': 'C', 'Ə': 'E', 'Ğ': 'G', 'İ': 'I', 'Ö': 'O', 'Ş': 'S', 'Ü': 'U'
};
var ALL_DOWNCODE_MAPS = [
LATIN_MAP,
LATIN_SYMBOLS_MAP,
GREEK_MAP,
TURKISH_MAP,
ROMANIAN_MAP,
RUSSIAN_MAP,
UKRAINIAN_MAP,
CZECH_MAP,
POLISH_MAP,
LATVIAN_MAP,
ARABIC_MAP,
LITHUANIAN_MAP,
SERBIAN_MAP,
AZERBAIJANI_MAP
];
var Downcoder = {
'Initialize': function() {
if (Downcoder.map) { // already made
return;
}
Downcoder.map = {};
Downcoder.chars = [];
for (var i = 0; i < ALL_DOWNCODE_MAPS.length; i++) {
var lookup = ALL_DOWNCODE_MAPS[i];
for (var c in lookup) {
if (lookup.hasOwnProperty(c)) {
Downcoder.map[c] = lookup[c];
}
}
}
for (var k in Downcoder.map) {
if (Downcoder.map.hasOwnProperty(k)) {
Downcoder.chars.push(k);
}
}
Downcoder.regex = new RegExp(Downcoder.chars.join('|'), 'g');
}
};
function downcode(slug) {
Downcoder.Initialize();
return slug.replace(Downcoder.regex, function(m) {
return Downcoder.map[m];
});
}
function URLify(s, num_chars, allowUnicode) {
// changes, e.g., "Petty theft" to "petty-theft"
// remove all these words from the string before urlifying
if (!allowUnicode) {
s = downcode(s);
}
var removelist = [
"a", "an", "as", "at", "before", "but", "by", "for", "from", "is",
"in", "into", "like", "of", "off", "on", "onto", "per", "since",
"than", "the", "this", "that", "to", "up", "via", "with"
];
var r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi');
s = s.replace(r, '');
// if downcode doesn't hit, the char will be stripped here
if (allowUnicode) {
// Keep Unicode letters including both lowercase and uppercase
// characters, whitespace, and dash; remove other characters.
s = XRegExp.replace(s, XRegExp('[^-_\\p{L}\\p{N}\\s]', 'g'), '');
} else {
s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars
}
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
s = s.toLowerCase(); // convert to lowercase
return s.substring(0, num_chars); // trim to first num_chars chars
}
window.URLify = URLify;
})();
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>edX Video Pipeline New Course Input</title>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
<link rel="icon" type="image/ico" href="https://s3.amazonaws.com/mediateam.edx.org/favicon.ico"/>
<link rel="shortcut icon" type="image/ico" href="https://s3.amazonaws.com/mediateam.edx.org/favicon.ico"/>
{% load staticfiles %}
<link rel="stylesheet" href="{% static "css/fe_style.css" %}">
<script>
$loading = '<span>...loading...</span>'
</script>
<script>
var institution_list = {{ institution_list|safe }}
</script>
</head>
<body>
<div id="total_input">
<div id="institutional"></div>
<br>
<form id="course-edit" action="" method="post" >
<div id="course_edit">
<!--Add organizational Table-->
<div id="course_edit_main"></div>
<hr>
<div id="course_edit_encode"></div>
<hr>
<div id="course_edit_transcribe"></div>
<hr>
</div>
</form>
<br>
<div id="data"></div>
</div>
<div id="initial_title">
<span>edX Video Pipeline Course Addition Tool</span>
</div>
<div id="forminput" class="course_input">
<!-- <span>VEDA Course Add</span><br> -->
<form id="course-form" action="" method="post" >
{% csrf_token %}
<!-- <input class="submit_button" type="submit" value="Submit"/> -->
<input type="text" placeholder="Institute Lookup" name="input_text" id="input_text" size="60">
</form>
<div id="inst_lookup"></div>
<div id="new_buttons">
<form id="reset-form" action="" method="post" >
<input id="rstb" class="reset_button" type="reset" value="Reset"/>
</form>
<form id="submit-form" action="" method="post" >
<input id="sbmt" class="submit_button" type="submit" value="Submit"/>
</form>
<div class="rebox" id="advanced">
<input type="checkbox" name="advanced_toggle" id="advanced_toggle" onclick="adv_toggle()" value="None" class="box">
<label for="advanced_toggle" >Advanced</label>
</div>
</div>
</div>
<div id="return">
</div>
<div id="results"></div>
<div id="form_button">
<form id="new-form" action="" method="post" >
<input id="nwfm" class="new_button" type="submit" value="New Inst."/>
</form>
</div>
<div class="footer">
edx-video-pipeline i/o version 1.0.0
</p>
<a href="../admin/logout/">logout</a>
</div>
<script src="{% static "js/course_form.js" %}" type="text/javascript"></script>
</body>
\ No newline at end of file
/*VEDA Interfaces*/
@import url(https://fonts.googleapis.com/css?family=Raleway:400,100);
*, *::before, *::after {
box-sizing: border-box;
}
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-webkit-keyframes fadeOut { from { opacity:1; } to { opacity:0; } }
@-moz-keyframes fadeOut { from { opacity:1; } to { opacity:0; } }
@keyframes fadeOut { from { opacity:1; } to { opacity:0; } }
html {
min-height: 100%;
}
body {
background: radial-gradient(#B1D8FB, #72B7F5);
font: 1em/1 'Raleway', sans-serif;
overflow: scroll;
}
/*A11y changes, per M. Sadecki*/
.sr {
background: #fff;
color: #000;
clip: rect(1px 1px 1px 1px);
clip: rect(1px, 1px, 1px, 1px);
position: absolute;
margin: -1px;
height: 1px;
width: 1px;
border: 0;
padding: 0;
overflow: hidden;
word-wrap: normal;
}
/********************************/
ul {
display: block;
list-style-type: none;
width: 33%;
font: 0.5em/1 'Raleway', sans-serif;
margin-right: auto;
margin-left: auto;
}
a {
color: #FFFFFF;
text-decoration: none;
}
li {
display: block; */
margin: auto;
margin-top: 10px;
margin-left: -10%;
white-space: nowrap;
padding: 10px;
padding-left: 15px;
padding-right: 15px;
font: 1em/1 'Raleway', sans-serif;
border-radius: 3px;
color: #FFFFFF;
background-color: #0A0A0A;
}
.veda_title {
opacity: 0.6;
color: #FFFFFF;
text-align: center;
width: 65%;
font: 3.4em/1 'Raleway', sans-serif;
margin-right: auto;
margin-left: auto;
margin-top: 100px;
border: 1px solid #FFFFFF;
}
hr {
display: none;
width: 75%;
height: 15px;
border: 0;
border-bottom: 1px solid #fff;
}
/* Step One */
#initial_title {
text-align: center;
margin-bottom: 25px;
margin-top: 150px;
font: 2.6em/1 'Raleway', sans-serif;
opacity: 0.8;
}
#input_text {
float: none !important;
margin-left: auto;
margin-right: auto;
}
#inst_lookup, .advisory {
color: #001152;;
}
#inst_lookup{
margin-top: 20px;
width: 60%;
margin-left: auto;
margin-right: auto;
border: 2px solid #fff;
font: 1.2em/1 'Raleway', sans-serif;
padding-left: 15px;
padding-right: 15px;
}
#inst_lookup:hover {
cursor:pointer;
}
.new_button {
display: block;
float: none !important;
margin-left: auto;
margin-right: auto;
background-color: #019696;
font: 1em/1 'Raleway', sans-serif;
color: #FFFFFF;
border: 1px solid #fff;
float: left;
margin-top: 25px
}
/* Step Two */
#course_edit_encode, #course_edit_main, #course_edit_transcribe {
margin-bottom: 15px;
}
#advanced {
margin-left: 25px;
}
#results {
bottom: 20px;
float: left;
font: 2.4em/1 'Raleway', sans-serif;
color: #FF0000;
position: absolute;
}
.data {
display: block;
float:left;
font: 1.4em/1 'Raleway', sans-serif;
color: #000000;
padding: 14px 30px 18px 30px;
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:0.5s;
-moz-animation-duration:0.5s;
animation-duration:0.5s;
}
.final_data {
display: block;
float:left;
color: #000000;
margin-left: 20px;
padding: 14px 30px 18px 30px;
border: 3px solid #fff;
width: 100%;
margin-bottom: 30px;
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:0.5s;
-moz-animation-duration:0.5s;
animation-duration:0.5s;
}
#return_data {
font: 0.7em/1 'Raleway', sans-serif;
color: #FFFFFF;
border: 2px solid #fff;
padding: 14px 30px 18px 30px;
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:0.5s;
-moz-animation-duration:0.5s;
animation-duration:0.5s;
}
#advst {
background-color: #000000;
}
#data {
float: left;
display: block;
color: #000000;
padding: 14px 30px 18px 30px;
}
h3 {
color: #019696;
font: 3.5em/0 'Raleway', sans-serif;
}
#return {
margin-left: auto;
margin-right: auto;
margin-top: 50px;
display: block;
color: #000000;
padding: 14px 30px 18px 30px;
width: 80%;
}
#form_edit {
border: 2px solid #fff;
float: none;
}
#course_edit {
display: block;
padding: 14px 30px 18px 30px;
margin-top: 50px;
display: none;
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:0.3s;
-moz-animation-duration:0.3s;
animation-duration:0.3s;
}
#institution_name {
float: left;
}
.loading {
display: block;
float:left;
font: 1.4em/1 'Raleway', sans-serif;
color: #fff;
background-image: url("../img/plimsol_oledit.gif");
background-size: 150px;
background-repeat: no-repeat;
background-position: center;
margin-left: 20px;
padding: 14px 30px 18px 30px;
border: 2px solid #fff;
opacity:0;
-webkit-animation:fadeIn ease-in 0.7;
-moz-animation:fadeIn ease-in 0.7;
animation:fadeIn ease-in 0.7;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:0.3s;
-moz-animation-duration:0.3s;
animation-duration:0.3s;
}
.warning {
display: block;
float: left;
font: 1.5em/1 'Raleway', sans-serif;
color: #FF0000;
margin-left: 9px;
padding: 13px 5px 18px 5px;
border: 1px solid #FF0000;
opacity: 0;
-webkit-animation: fadeIn ease-in 1;
-moz-animation: fadeIn ease-in 1;
animation: fadeIn ease-in 1;
-webkit-animation-fill-mode: forwards;
-moz-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-webkit-animation-duration: 0.3s;
-moz-animation-duration: 0.3s;
animation-duration: 0.3s;
}
input {
display: block;
float:left;
font: 1.4em/1 'Raleway', sans-serif;
padding: 14px 30px 14px 30px;
border: 3px solid #fff;
border-radius: 0px;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: text;
}
.box {
position: absolute;
left: -9999px;
}
label {
position: relative;
font: 1.4em/1 'Raleway', sans-serif;
margin-right: 20px;
padding: 15px 30px 15px 62px;
border: 3px solid #fff;
border-radius: 0px;
color: #FFFFFF;
background-color: #C3C3C3;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: pointer;
user-select: none;
transition: background-color .2s, box-shadow .2s, width .3s;
}
label::before {
content: '';
display: block;
position: absolute;
top: 10px;
bottom: 10px;
left: 10px;
width: 1.5em;
border: 3px solid #fff;
border-radius: 100px;
transition: background-color .2s;
}
label:hover, input:focus + label {
box-shadow: 0 0 20px rgba(0, 0, 0, .6);
}
input:checked + label {
background-color: #8FCE00;
color: #000;
}
input:checked + label::before {
background-color: #7DFF00;
}
button {
padding: 5px;
font: 1.2em/1 'Raleway', sans-serif;
border-radius: 0px;
color: #FFFFFF;
background-color: #019696;
margin-left: 10px;
border: 1px solid #fff;
margin-bottom: 5px;
margin-right: 5px;
}
select {
display: block;
height: 59px;
width: 240px;
font: 1.4em/1 'Roboto+Slab', sans-serif;
border-radius: 0px;
color: #fff;
background-color: #019696;
white-space: nowrap;
cursor: pointer;
user-select: none;
transition: background-color .2s, box-shadow .2s, width .3s /*font: 32px Cursive;*/
}
.rebox{
margin-top:20px;
width: 100%;
display: inline-flex;
float: left;
}
.text_label {
font: 1.4em/1 'Raleway', sans-serif;
padding: 18px 30px 15px 30px;
border: 3px solid #fff;
border-radius: 0px;
float: left;
}
.tiny_titles {
color: #000000;
font: 0.7em/1 'Raleway', sans-serif;
}
.advisory {
font: 1em/1 'Raleway', sans-serif;
padding: 15px 15px 15px 15px;
margin-top: 5px;
margin-right: 15px;
border-radius: 0px;
float: left;
}
.data_input {
float: left;
width: 100%;
margin-top: 20px;
}
.submit_button {
display: block;
margin-left: 20px;
padding-bottom: 18px;
background-color: #8A8A8A;
}
.reset_button {
display: block;
margin-left: 25px;
padding-bottom: 18px;
background-color: #019696;
color: #FFFFFF;
}
#rstb {
margin-top: 35px;
opacity: 0.8;
cursor: pointer;
}
#sbmt {
margin-top: 35px;
opacity: 0.8;
cursor: pointer;
}
.course_input {
/* FADE */
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:0.5s;
-moz-animation-duration:0.5s;
animation-duration:0.5s;
}
/* UPLOAD STYLES */
.help {
opacity: 0.8;
font: 25px 'Raleway', sans-serif;
}
.footer {
float: right;
bottom : 0px;
height : 20px;
margin-top : 250px;
font: 0.1em/1 'Raleway', sans-serif;
margin-left: 20px;
padding: 15px 30px 15px 30px;
}
/* Input Styles */
@import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,100);
@import url(http://fonts.googleapis.com/css?family=Noto+Sans);
*, *::before, *::after {
box-sizing: border-box;
}
html {
min-height: 100%;
}
body {
color: #000000;
background: radial-gradient(#fff, #737373);
font: 1em/1 'Roboto+Slab', sans-serif;
overflow: scroll;
}
.submit_button {
display: block;
margin-left: 20px;
margin-top: 20px;
}
#course_information {
border: 3px solid #fff;
background: rgba(255, 0, 0, 0.09);;
width: 45%;
margin-left: 20px;
float: left;
}
#transcribe_information {
border: 3px solid #fff;
background: rgba(255, 0, 0, 0.09);;
width: 45%;
margin-top: 20px;
margin-left: 20px;
float: left;
}
.minidiv {
float: left;
}
#destination_information {
border: 3px solid #fff;
background: rgba(255, 0, 0, 0.09);;
width: 45%;
margin-left: 20px;
float: left;
}
.info_container {
display: block;
margin-right: 0px;
margin-bottom: 20px;
width: 100%;
float: left;
}
select {
display: block;
height: 50px;
width: 200px;
font: 1em/1 'Roboto+Slab', sans-serif;
margin-bottom: 20px;
margin-left: 20px;
padding: 14px 30px 14px 30px;
border: 3px solid #fff;
border-radius: 0px;
color: #fff;
background-color: #3B3131;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: pointer;
user-select: none;
transition: background-color .2s, box-shadow .2s, width .3s;
}
input {
display: block;
font: 1em/1 'Roboto+Slab', sans-serif;
margin-bottom: 20px;
margin-left: 20px;
padding: 14px 30px 14px 30px;
border: 3px solid #fff;
border-radius: 0px;
color: #fff;
background-color: #3B3131;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: pointer;
user-select: none;
transition: background-color .2s, box-shadow .2s, width .3s;
}
.text_label {
font: 1em/1 'Roboto+Slab', sans-serif;
margin-left: 20px;
padding: 15px 30px 15px 30px;
border: 3px solid #fff;
border-radius: 0px;
float: left;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.box {
position: absolute;
left: -9999px;
}
label {
display: block;
position: relative;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 20px;
padding: 15px 30px 15px 62px;
border: 3px solid #fff;
border-radius: 0px;
color: #0A0A0A;
background-color: #D1D0CE;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: pointer;
user-select: none;
transition: background-color .2s, box-shadow .2s, width .3s;
}
label::before {
content: '';
display: block;
position: absolute;
top: 10px;
bottom: 10px;
left: 10px;
width: 1.6em;
border: 3px solid #fff;
border-radius: 100px;
transition: background-color .2s;
}
label:hover, input:focus + label {
box-shadow: 0 0 20px rgba(0, 0, 0, .6);
}
input:checked + label {
background-color: #3B3131;
color: #fff;
}
input:checked + label::before {
background-color: #00FF2D;
}
/* CSS SPECIFIC TO UPLOAD PAGE */
h1 {
display: block;
font-size: 1em;
-webkit-margin-before: 0.67em;
-webkit-margin-after: 0.67em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
font-weight: normal;
}
.dropzone {
padding: 20px 20px;
border: 1px solid #fff;
background: #ACD8FF;
padding: 20px 20px;
width: 45%;
margin-left: 26%;
margin-right: auto;
}
.dropzone .dz-preview .dz-image {
border-radius: 15px;
overflow: hidden;
width: 0px !important;
height: 0px !important;
position: relative;
display: block;
z-index: 10;
margin-left: 135px;
/*margin-right: auto;*/
}
.dropzone .dz-preview .dz-details {
font-size: 1em;
background-color: deepskyblue;
}
.dropzone .dz-preview .dz-progress {
opacity: 1;
z-index: 1000;
pointer-events: none;
position: absolute;
height: 12px;
left: 50%;
top: 50%;
margin-top: 6px;
width: 150px;
margin-left: -80px;
background: rgba(255, 255, 255, 0.9);
-webkit-transform: scale(1);
border-radius: 8px;
overflow: hidden;
}
.dz-default {
color: #FFFFFF;
}
#uploadselect {
margin-left: auto;
margin-right: auto;
}
input[type="file" i] {
display: block;
float:left;
font: 1.4em/1 'Raleway', sans-serif;
padding: 14px 30px 14px 30px;
border: 3px solid #fff;
border-radius: 0px;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: text;
}
#fileupload {
display: block;
float:left;
font: 1.4em/1 'Raleway', sans-serif;
padding: 14px 30px 14px 30px;
border: 3px solid #fff;
border-radius: 0px;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
white-space: nowrap;
cursor: pointer;
}
.about_vidinf {
margin-bottom: 25px;
}
#video_info {
margin-left: auto;
margin-right: auto;
margin-top: 25px;
margin-bottom: 25px;
}
.field_title {
display: table;
font: 1.4em/1 'Raleway', sans-serif;
margin-left: auto;
color: #FFFFFF;
margin-right: auto;
}
.ul_warning {
margin-left: auto;
color: #BB0000;
margin-right: auto;
width: 15%
}
#new_buttons {
margin-left: 25%;
}
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>edX video pipeline</title>
<link rel="shortcut icon" type="image/png" href="/static/img/MPT-Logo.png"/>
{% load staticfiles %}
<link rel="stylesheet" href="{% static "css/fe_style.css" %}">
<style>
body {
background: radial-gradient(#B1D8FB, #0086FF);
}
</style>
</head>
<body>
<div class="veda_title">
<img alt="veda_logo" src="{% static "img/veda_logo.png" %}">
<ul>
{% if auth == 'YES' %}
{% for k, e in links.items %}
<li><a href='{{e}}'>{{k}}</a>
{% endfor %}
{% endif %}
</ul>
</div>
</body>
// Eventing and Form Handling
// Upload Page
var information_fields = {
"course_name" : "Institution and Course Name",
"course_url" : "edX Studio URL"
};
var field_information = {
"course_url" : 75,
"course_name" : 60
};
var field_value = {
"course_url" : "https://studio.edx.org/course/"
};
var field_validation = {
"course_url" : "is_url",
"pm_email" : "is_email",
};
// ADD FILENAME //
function add_filename(filename) {
$.ajax({
url : "../about_input/", // the endpoint
type : "POST", // http method
data : {
abvid_serial : window.abvid_serial,
orig_filename : filename
},
success : function(json) {
console.log('filename input // sanity check');
},
error : function(xhr,errmsg,err) {
$('#results').html("<span>SERVER ERROR: "+errmsg+ " : " +err+"</span>");
}
});
}
function begin_transcode(success) {
$.ajax({
url : "../about_input/", // the endpoint
type : "POST", // http method
data : {
abvid_serial : window.abvid_serial,
success : success
},
success : function(json) {
console.log('transcode input // sanity check');
},
error : function(xhr,errmsg,err) {
$('#results').html("<span>SERVER ERROR: "+errmsg+ " : " +err+"</span>");
}
});
if (success == true) {
$('#uploadselect').fadeOut();
$('#inst_lookup').fadeIn();
$('#inst_lookup').focus();
}
}
///////////////////////
// DROPZONE EVENTING //
var success;
window.Dropzone.options.dmz = {
init: function() {
this.on("addedfile", function(file) { add_filename(file.name) });
this.on("success", function(file) { begin_transcode(success=true) });
this.on("canceled", function(file) { begin_transcode(success=false) });
this.on("error", function(file) { begin_transcode(success=false) });
}
};
////////////////
// RESET FORM //
$('#reset-form').hide();
// Reset Button
$('#reset-form').on('reset', function(event){
event.preventDefault();
document.location.reload()
});
/////////////
// WARNING //
function create_warning(message) {
var $warning_div = $("<div>", {
class: "ul_warning"
});
$warning_div.append('<span>'+message+'</span><br>');
return $warning_div
}
/////////////////
// SUBMIT FORM //
/////////////////
$('#submit-form').hide();
$('#submit-form').on('submit', function(event){
event.preventDefault();
console.log("final submit // sanity check");
var submit = check_submit();
if (submit == true) {
submit_data();
$('#video_info').fadeOut();
$('#uploadselect').fadeIn();
$('#dmz').focus();
$('#submit-form').fadeOut();
}
});
// Checking Functions //
var is = {
is_url: function(field) {
valid = false;
if (field.indexOf('https://studio.edx.org/course/') > -1 && field.length > 35 ) {
valid = true
}
else {
valid = "Invalid URL"
}
return valid
},
is_email: function(field) {
if (field.indexOf('@edx.org') > -1) {
valid = true
}
else {
valid = "Invalid email"
}
return valid
}
};
function make_textboxes(title, placeholder) {
var $edit_div = $("<div>", {
class: "about_vidinf"
});
var textbox = document.createElement("input");
textbox.setAttribute("type", "text");
textbox.setAttribute("name", title);
textbox.setAttribute("id", title);
textbox.setAttribute("style", "float: none !important; margin-left: auto;margin-right: auto;")
textbox.setAttribute("size", field_information[title]);
textbox.setAttribute("placeholder", placeholder)
// textbox.setAttribute("label", placeholder)
var box_label = document.createElement("label");
box_label.setAttribute("class", "sr");
box_label.setAttribute("for", title);
box_label.setAttribute("value", placeholder);
$edit_div.append(box_label)
if (field_value[title] != undefined ) {
textbox.setAttribute("value", field_value[title])
textbox.setAttribute("aria-describedby", "Full URL path to edX studio course instance")
// Needed?
var $html_span = '<span class=\"field_title\">edX Studio Course URL</span>'
$edit_div.append($html_span)
}
$edit_div.append(textbox);
$('#vid_inf').append($edit_div);
}
// Generate Information
var i;
for (i in information_fields) {
make_textboxes(title=i, placeholder=information_fields[i])
}
function check_submit() {
var submits = [];
for (j in information_fields) {
if (field_validation[j] != undefined) {
console.log(field_validation[j]);
// Variable function names
is[field_validation[j]](field=$('#'+j).val());
if (valid != true) {
$('#'+j).parent().find('.ul_warning').empty();
var $add = create_warning(message=valid);
$('#'+j).parent().prepend($add);
$('#'+j).attr("style", "float: none !important; margin-left: auto;margin-right: auto; border-color: #FF0000;");
submits.push(false);
}
else {
$('#'+j).parent().find('.ul_warning').empty();
$('#'+j).attr("style", "float: none !important; margin-left: auto;margin-right: auto; border-color: #00A731;");
submits.push(true)
}
}
}
submit = true;
if (submits.indexOf(false) > -1) {
submit = false
}
return submit
}
function submit_data() {
$.ajax({
url : "../about_input/", // the endpoint
type : "POST", // http method
data : {
abvid_serial : window.abvid_serial,
orig_filename : window.file,
// This will sub out the mailing list for the email -- but leave backend in place
pm_email : 'aboutvids@edx.org',
// Quickest fix/patch (with unpatch avail)
studio_url : $('#course_url').val(),
course_name : $("#course_name").val(),
},
success : function(json) {
console.log('input_data // sanity check');
},
error : function(xhr,errmsg,err) {
$('#results').html("<span>SERVER ERROR: "+errmsg+ " : " +err+"</span>");
}
});
}
/////////////////////////
// //
// Crossdomain Handler //
// //
/////////////////////////
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, Cache-Control, Accept, Origin, X-Session-ID');
res.header('Access-Control-Allow-Methods', 'GET,POST,PUT,HEAD,DELETE,TRACE,COPY,LOCK,MKCOL,MOVE,PROPFIND,PROPPATCH,UNLOCK,REPORT,MKACTIVITY,CHECKOUT,MERGE,M-SEARCH,NOTIFY,SUBSCRIBE,UNSUBSCRIBE,PATCH');
res.header('Access-Control-Allow-Credentials', 'false');
res.header('Access-Control-Max-Age', '1000');
next();
};
//////////////////////////////////
// //
// CSRF HANDLER FOR AJAX CALLS //
// //
//////////////////////////////////
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
/*
The functions below will create a header with csrftoken
*/
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
function sameOrigin(url) {
// test that a given url is a same-origin URL
// url could be relative or scheme relative or absolute
var host = document.location.host; // host + port
var protocol = document.location.protocol;
var sr_origin = '//' + host;
var origin = protocol + sr_origin;
// Allow absolute or scheme relative URLs to same origin
return (url == origin || url.slice(0, origin.length + 1) == origin + '/') ||
(url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') ||
// or any other URL that isn't scheme relative or absolute i.e relative.
!(/^(\/\/|http:|https:).*/.test(url));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) {
// Send the token to same-origin, relative URLs only.
// Send the token only if the method warrants CSRF protection
// Using the CSRFToken value acquired earlier
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
User-agent: *
Disallow: /
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