From b16cabaa775c8bb44af1fe27f9b3bb87402b58bd Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Wed, 12 Oct 2016 14:40:00 +0200 Subject: [PATCH] chapter hinting now works without reloading, closes #57 --- static/moderator.js | 12 ++++++++++++ templates/lecture.html | 7 +++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/static/moderator.js b/static/moderator.js index 5a11898..977fc41 100644 --- a/static/moderator.js +++ b/static/moderator.js @@ -93,6 +93,18 @@ var moderator = { if (confirm('Realy delete this?')) { moderator.api.set($(src).data('path'),1,true); } + }, + hintchapterclick: function(src) { + $.ajax({ + method: "GET", + url: $(src).data('url'), + data: $(src).serialize(), + success: function(data) + { + alert("Kapitelmarker vorgeschlagen. Danke!"); + } + }); + return false; } }, permissioneditor: { diff --git a/templates/lecture.html b/templates/lecture.html index ec27203..98a9b82 100644 --- a/templates/lecture.html +++ b/templates/lecture.html @@ -71,10 +71,9 @@ $(function() { var h = zeropad( Math.trunc(timestamp/3600),2); var m = zeropad( Math.trunc((timestamp%3600)/60),2); var s = zeropad( Math.trunc(timestamp%60),2); - var timeasstring = h+':'+m+':'+s - return '<form method="post" action="{{url_for('suggest_chapter', ref=request.url, lectureid=lecture.id)}}"><input placeholder="00:00.000" name="time" type="text" value="'+timeasstring+'"><br><input placeholder="Kapitel" name="text" type="texz"><br><input type="submit" value="Vorschlagen"></form>' - - } + var timeasstring = h+':'+m+':'+s; + return '<form method="post" data-url="{{ url_for('suggest_chapter', lectureid=lecture.id) }}" onSubmit="return moderator.editor.hintchapterclick(this);"><input placeholder="00:00.000" name="time" type="text" value="'+timeasstring+'"><br><input placeholder="Kapitel" name="text" type="texz"><br><input type="submit" value="Vorschlagen"></form>'; + } }) }); -- GitLab