Browse Source

Docisteni HTML a JS, opravy komentaru.

Komentare uz se daji i upravovat.
remotes/origin/opraf
parent
commit
2de2aa40a4
  1. 22
      korektury/static/korektury/opraf.js
  2. 26
      korektury/templates/korektury/opraf.html
  3. 10
      korektury/views.py

22
korektury/static/korektury/opraf.js

@ -83,7 +83,6 @@ function textarea_onkey(ev)
//hide comment form //hide comment form
function close_commform() { function close_commform() {
var formdiv = document.getElementById('commform-div'); var formdiv = document.getElementById('commform-div');
if( formdiv == null ) { if( formdiv == null ) {
alert("form null"); alert("form null");
@ -116,9 +115,8 @@ function img_click(element, ev) {
// show comment form, when 'edit' or 'comment' button pressed // show comment form, when 'edit' or 'comment' button pressed
function box_edit(button, action) function box_edit(button, action)
{ {
var divbox = button.parentNode.parentNode.parentNode.parentNode; var divbox = button.parentNode.parentNode.parentNode;
var id = divbox.id; var id = divbox.id;
//alert("id: " + id);
var divpointer = document.getElementById(divbox.id + '-pointer'); var divpointer = document.getElementById(divbox.id + '-pointer');
var text; var text;
@ -135,24 +133,22 @@ function box_edit(button, action)
//alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo ); //alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo );
id = id.substring(2); id = id.substring(2);
return show_form(divbox.img_id, dx, dy, id, text, action); return show_form(divbox.img_id, dx, dy, id, text, action);
} }
// show comment form when 'update-comment' button pressed // show comment form when 'update-comment' button pressed
function update_comment(button) function update_comment(button)
{ {
var divbox = button.parentNode.parentNode.parentNode; var divbox = button.parentNode.parentNode.parentNode.parentNode;
var id = divbox.id; var id = divbox.id;
var divpointer = document.getElementById(divbox.id + '-pointer'); var divpointer = document.getElementById(divbox.id + '-pointer');
var dx = parseInt(divpointer.style.left); var dx = parseInt(divpointer.style.left);
var dy = parseInt(divpointer.style.top); var dy = parseInt(divpointer.style.top);
var commentdiv = button.parentNode.parentNode; var commentdiv = button.parentNode.parentNode.parentNode;
var id = commentdiv.id.substring(1); var id = commentdiv.id.substring(1);
var text = document.getElementById('kt' + id).innerHTML.unescapeHTML();
var text = document.getElementById('kt' + id).innerHTML.unescapeHTML(); return show_form(divbox.img_id, dx, dy, id, text, 'update-comment');
return show_form(divbox.img_id, dx, dy, id, text, 'update-comment');
} }
//fill up comment form and show him //fill up comment form and show him
@ -202,8 +198,6 @@ function box_onmouseover(box, done)
var id = box.id; var id = box.id;
var pointer = document.getElementById(box.id + '-pointer'); var pointer = document.getElementById(box.id + '-pointer');
pointer.className = done ? 'pointer-done-hi' : 'pointer-hi'; pointer.className = done ? 'pointer-done-hi' : 'pointer-hi';
//console.log('mouseout');
} }
function box_onmouseout(box, done) function box_onmouseout(box, done)
@ -211,8 +205,6 @@ function box_onmouseout(box, done)
var id = box.id; var id = box.id;
var pointer = document.getElementById(box.id + '-pointer'); var pointer = document.getElementById(box.id + '-pointer');
pointer.className = done ? 'pointer-done' : 'pointer'; pointer.className = done ? 'pointer-done' : 'pointer';
//console.log('mousein');
} }
function save_scroll(form) function save_scroll(form)
@ -220,8 +212,6 @@ function save_scroll(form)
//alert('save_scroll:' + document.body.scrollTop); //alert('save_scroll:' + document.body.scrollTop);
form.scroll.value = document.body.scrollTop; form.scroll.value = document.body.scrollTop;
//alert('save_scroll:' + form.scroll.value); //alert('save_scroll:' + form.scroll.value);
return true; return true;
} }

26
korektury/templates/korektury/opraf.html

@ -99,21 +99,21 @@
<img src="/static/korektury/imgs/check.png"/> <img src="/static/korektury/imgs/check.png"/>
</button> </button>
{% endif %} {% endif %}
{% if o.komentare %}
<button type='button' title="Korekturu nelze upravit &ndash; už ji někdo okomentoval">
<img src="/static/korektury/imgs/edit-gr.png"/>
</button>
{% else %}
<button type='button' onclick='box_edit(this,"update");' title='Oprav opravu'>
<img src="/static/korektury/imgs/edit.png"/>
</button>
{% endif %}
<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'>
<img src="/static/korektury/imgs/comment.png"/>
</button>
</form> </form>
<!-- /Existujici korektura !--> <!-- /Existujici korektura !-->
{% if o.komentare %}
<button type='button' title="Korekturu nelze upravit &ndash; už ji někdo okomentoval">
<img src="/static/korektury/imgs/edit-gr.png"/>
</button>
{% else %}
<button type='button' onclick='box_edit(this,"update");' title='Oprav opravu'>
<img src="/static/korektury/imgs/edit.png"/>
</button>
{% endif %}
<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'>
<img src="/static/korektury/imgs/comment.png"/>
</button>
<button type='button' title='Link na opravu'> <button type='button' title='Link na opravu'>
<a href='#op{{o.id}}'> <a href='#op{{o.id}}'>
<img src="/static/korektury/imgs/link.png"/> <img src="/static/korektury/imgs/link.png"/>

10
korektury/views.py

@ -37,6 +37,7 @@ class KorekturyView(generic.TemplateView):
q = request.POST q = request.POST
scroll = q.get('scroll') scroll = q.get('scroll')
autor = q.get('au') autor = q.get('au')
print "autor:" + str(autor)
if not autor: if not autor:
autor = 'anonym' autor = 'anonym'
if not scroll: if not scroll:
@ -60,7 +61,6 @@ class KorekturyView(generic.TemplateView):
elif (action == u'update'): elif (action == u'update'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.filter(id=id).first()
autor = q.get('au')
text = q.get('txt') text = q.get('txt')
op.autor = autor op.autor = autor
op.text = text op.text = text
@ -78,10 +78,16 @@ class KorekturyView(generic.TemplateView):
elif (action == u'comment'): elif (action == u'comment'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.filter(id=id).first()
autor = q.get('au')
text = q.get('txt') text = q.get('txt')
kom = Komentar(oprava=op,autor=autor,text=text) kom = Komentar(oprava=op,autor=autor,text=text)
kom.save() kom.save()
elif (action == u'update-comment'):
id = int(q.get('id'))
kom = Komentar.objects.filter(id=id).first()
text = q.get('txt')
kom.text = text
kom.autor = autor
kom.save()
elif (action == u'del-comment'): elif (action == u'del-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.filter(id=id).first() kom = Komentar.objects.filter(id=id).first()

Loading…
Cancel
Save