Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
move timer js from static folder to product page
  • Loading branch information
dtraviglia committed May 19, 2015
1 parent c3b2435 commit 4e1756c096b90062329911614bd41813e70ae8b5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
@@ -90,4 +90,8 @@ class Meta:

# class UserSessionID(models.Model):
# userprofile = models.ForeignKey(UserProfile)
# datecreated = models.DateTimeField(default=None, blank=True, null=True)
# datecreated = models.DateTimeField(default=None, blank=True, null=True)

# class Experiment(models.Model):
# name = models.CharField()
# task_count = models.IntegerField(default=0)
@@ -72,11 +72,24 @@
<form id="timerblock">
{% csrf_token %}
<script>
var myVar = setInterval(function(){myTimer()},1000);
var time = 30*60;

function myTimer() {
time = time - 1;
minutes = parseInt(time / 60);
seconds = time % 60;
document.getElementById("minutes").innerHTML = pad(minutes);
document.getElementById("seconds").innerHTML = pad(seconds);
}

function pad(n) {return (n<10) ? ("0"+n) : n;}

var redirect = function(url, method) {
var form = document.getElementById('timerblock');
form.method = method;
form.action = url;
form.submit();
var form = document.getElementById('timerblock');
form.method = method;
form.action = url;
form.submit();
};

setTimeout('redirect("{% url 'op_tasks:product' task_pk %}", "post")', 1000*60*30);
@@ -23,6 +23,7 @@ def set_cookie(response, key, value, days_expire = 7):
domain=settings.SESSION_COOKIE_DOMAIN,
secure=None)

# manages which prodct is delivered to the current user
def product(request, task_pk):
if request.method == 'POST':
user = request.user
@@ -85,6 +86,7 @@ def product(request, task_pk):
set_cookie(response, 'USID', '%s::%s' % (userprofile.user_hash, tasklistitem.pk))
return response

# cretaes a new user and assigns tasks
def register(request):
# Like before, get the request's context.
context = RequestContext(request)
@@ -204,15 +206,14 @@ def task_list(request):
return render(request, 'task_list.html',
{'userprofile': userprofile, 'all_complete': all_complete})


def intro(request, process=None):
if process == 'register':
follow = '/tasking/register'
elif process == 'login':
follow = '/tasking/login'
return render(request, 'intro.html', {'user': request.user, 'follow': follow})

# def login_intro(request):
# return render(request, 'login_intro.html', {'user': request.user})

def instruct(request, read=None):
user = request.user
@@ -17,15 +17,3 @@ function toggle() {
}
}

var myVar = setInterval(function(){myTimer()},1000);
var time = 30*60;

function myTimer() {
time = time - 1;
minutes = parseInt(time / 60);
seconds = time % 60;
document.getElementById("minutes").innerHTML = pad(minutes);
document.getElementById("seconds").innerHTML = pad(seconds);
}

function pad(n) {return (n<10) ? ("0"+n) : n;}

0 comments on commit 4e1756c

Please sign in to comment.