Edit note with right click

Remove default parameters (thanks Chrome...)
Add number of registered people
This commit is contained in:
Gregory Soutade 2015-10-12 18:05:07 +02:00
parent 46082b8dcb
commit f48b0516df
5 changed files with 37 additions and 27 deletions

View File

@ -26,7 +26,7 @@ function getPreference(cname) {
return null; return null;
} }
function set_visible(id, visible, display="block") function set_visible(id, visible, display)
{ {
widget = document.getElementById(id); widget = document.getElementById(id);
if (visible) if (visible)
@ -64,21 +64,21 @@ function updateHiddenCategories(cat_id, add)
setPreference('hidden_categories', hidden_categories.join(",")); setPreference('hidden_categories', hidden_categories.join(","));
} }
function hide_category(cat_id, update_cookie=true) function hide_category(cat_id, update_cookie)
{ {
set_visible("content_" + cat_id, false); set_visible("content_" + cat_id, false, "");
set_visible("minus_" + cat_id, false); set_visible("minus_" + cat_id, false, "");
set_visible("plus_" + cat_id, true, "inline-block"); set_visible("plus_" + cat_id, true, "inline-block");
if (update_cookie) if (update_cookie)
updateHiddenCategories(cat_id, true); updateHiddenCategories(cat_id, true);
} }
function show_category(cat_id, update_cookie=true) function show_category(cat_id, update_cookie)
{ {
set_visible("content_" + cat_id, true); set_visible("content_" + cat_id, true, "block");
set_visible("minus_" + cat_id, true, "inline-block"); set_visible("minus_" + cat_id, true, "inline-block");
set_visible("plus_" + cat_id, false); set_visible("plus_" + cat_id, false, "");
if (update_cookie) if (update_cookie)
updateHiddenCategories(cat_id, false); updateHiddenCategories(cat_id, false);
@ -115,12 +115,14 @@ function category_setup()
function startup() function startup()
{ {
category_setup(); category_setup();
if (location.search.search('edit_note') != -1)
edit_note();
} }
function edit_category(cat_id, name) function edit_category(cat_id, name)
{ {
set_visible("category_" + cat_id, false); set_visible("category_" + cat_id, false, "");
set_visible("edit_category_" + cat_id, true); set_visible("edit_category_" + cat_id, true, "block");
input = document.getElementById("cat_name_" + cat_id); input = document.getElementById("cat_name_" + cat_id);
input.value = name; input.value = name;
@ -129,8 +131,8 @@ function edit_category(cat_id, name)
function end_edit_category(cat_id) function end_edit_category(cat_id)
{ {
set_visible("category_" + cat_id, true); set_visible("category_" + cat_id, true, "block");
set_visible("edit_category_" + cat_id, false); set_visible("edit_category_" + cat_id, false, "");
} }
function submit_category_name(cat_id, orig) function submit_category_name(cat_id, orig)
@ -157,19 +159,24 @@ function handleKeyPress(e, cat_id, orig){
function edit_note() function edit_note()
{ {
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
set_visible("title", false); set_visible("title", false, "");
set_visible("transformed_content", false); set_visible("transformed_content", false, "");
set_visible("edit_button", false); set_visible("edit_button", false, "");
set_visible("form_delete", false); set_visible("form_delete", false, "");
set_visible("div_edit", true); set_visible("div_edit", true, "block");
} }
function cancel_edit_note() function cancel_edit_note()
{ {
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
set_visible("title", true); set_visible("title", true, "block");
set_visible("transformed_content", true); set_visible("transformed_content", true, "block");
set_visible("edit_button", true, "inline"); set_visible("edit_button", true, "inline");
set_visible("form_delete", true, "inline"); set_visible("form_delete", true, "inline");
set_visible("div_edit", false); set_visible("div_edit", false, "");
}
function DoEdit(url) {
window.location.href = '/note/' + url + '?edit_note=1';
return false;
} }

View File

@ -23,7 +23,7 @@
{% for meta_note in notes_by_category %} {% for meta_note in notes_by_category %}
<div class="category" category_id="{{ meta_note.category_id }}"> <div class="category" category_id="{{ meta_note.category_id }}">
<div id="category_{{ meta_note.category_id }}" class="name" ondblclick="edit_category({{ meta_note.category_id }}, '{{ meta_note.category }}')"> <div id="category_{{ meta_note.category_id }}" class="name" ondblclick="edit_category({{ meta_note.category_id }}, '{{ meta_note.category }}')">
<img id="minus_{{ meta_note.category_id }}" src="{{ STATIC_URL }}images/denote_minus.png" onclick="hide_category({{ meta_note.category_id }});"/><img id="plus_{{ meta_note.category_id }}" src="{{ STATIC_URL }}images/denote_plus.png" onclick="show_category({{ meta_note.category_id }});"/>{{ meta_note.category }} ({{ meta_note.notes|length }}) <img id="minus_{{ meta_note.category_id }}" src="{{ STATIC_URL }}images/denote_minus.png" onclick="hide_category({{ meta_note.category_id }},true);"/><img id="plus_{{ meta_note.category_id }}" src="{{ STATIC_URL }}images/denote_plus.png" onclick="show_category({{ meta_note.category_id }},true);"/>{{ meta_note.category }} ({{ meta_note.notes|length }})
</div> </div>
<div class="edit_category" id="edit_category_{{ meta_note.category_id }}"> <div class="edit_category" id="edit_category_{{ meta_note.category_id }}">
<form id="form_edit_category_{{ meta_note.category_id }}" action="/category/edit/{{ meta_note.category_id }}" method="post" onsubmit="return submit_category_name({{ meta_note.category_id }}, '{{ meta_note.category }}');"> <form id="form_edit_category_{{ meta_note.category_id }}" action="/category/edit/{{ meta_note.category_id }}" method="post" onsubmit="return submit_category_name({{ meta_note.category_id }}, '{{ meta_note.category }}');">
@ -34,7 +34,7 @@
<div id="content_{{ meta_note.category_id }}" class="content" > <div id="content_{{ meta_note.category_id }}" class="content" >
{% for note in meta_note.notes %} {% for note in meta_note.notes %}
<div class="note"> <div class="note">
<a href="/note/{{ note.id}}"><div class="title">{{ note.title }}</div></a> <a href="/note/{{ note.id}}" oncontextmenu="return DoEdit('{{ note.id}}');"><div class="title">{{ note.title }}</div></a>
<div class="date">{{ note.created_date }}</div> <div class="date">{{ note.created_date }}</div>
<div class="summary">{{ note.short_summary }}</div> <div class="summary">{{ note.short_summary }}</div>
</div> </div>
@ -45,11 +45,11 @@
{% if notes_without_category|length != 0 %} {% if notes_without_category|length != 0 %}
<div class="category" category_id="-1"> <div class="category" category_id="-1">
<div id="category_-1" class="name"> <div id="category_-1" class="name">
<img id="minus_-1" src="{{ STATIC_URL }}images/denote_minus.png" onclick="hide_category(-1);"/><img id="plus_-1" src="{{ STATIC_URL }}images/denote_plus.png" onclick="show_category(-1);"/>Other ({{ notes_without_category|length }})</div> <img id="minus_-1" src="{{ STATIC_URL }}images/denote_minus.png" onclick="hide_category(-1,true);"/><img id="plus_-1" src="{{ STATIC_URL }}images/denote_plus.png" onclick="show_category(-1,true);"/>Other ({{ notes_without_category|length }})</div>
<div id="content_-1" class="content"> <div id="content_-1" class="content">
{% for note in notes_without_category %} {% for note in notes_without_category %}
<div class="note"> <div class="note">
<a href="/note/{{ note.id}}"><div class="title">{{ note.title }}</div></a> <a href="/note/{{ note.id}}" oncontextmenu="return DoEdit('{{ note.id}}');"><div class="title">{{ note.title }}</div></a>
<div class="date">{{ note.created_date }}</div> <div class="date">{{ note.created_date }}</div>
<div class="summary">{{ note.short_summary }}</div> <div class="summary">{{ note.short_summary }}</div>
</div> </div>

View File

@ -26,7 +26,7 @@
<tr><td>Login</td><td><input type="text" name="login"/></td></tr> <tr><td>Login</td><td><input type="text" name="login"/></td></tr>
<tr><td>Password</td><td><input id="password" type="password" name="password"/></td></tr> <tr><td>Password</td><td><input id="password" type="password" name="password"/></td></tr>
<tr><td/><td><input type="submit" value="Connect"/></td></tr> <tr><td/><td><input type="submit" value="Connect"/></td></tr>
<tr><td/><td><a href="/user/add">Create an account</a></td></tr> <tr><td/><td><a href="/user/add">Create an account</a><br/>(already {{ nb_people_registered }} people(s) registered)</td></tr>
</table> </table>
</form> </form>
</div> </div>

View File

@ -4,9 +4,9 @@
{% for note in notes %} {% for note in notes %}
<div class="note"> <div class="note">
{% if note.category != None %} {% if note.category != None %}
<div class="title"><a href="/note/{{ note.id }}">{{ note.title }} [{{ note.category.name }}]</a></div> <div class="title"><a href="/note/{{ note.id}}" oncontextmenu="return DoEdit('{{ note.id}}');">{{ note.title }} [{{ note.category.name }}]</a></div>
{% else %} {% else %}
<div class="title"><a href="/note/{{ note.id }}">{{ note.title }}</a></div> <div class="title"><a href="/note/{{ note.id}}" oncontextmenu="return DoEdit('{{ note.id}}');">{{ note.title }}</a></div>
{% endif %} {% endif %}
<div class="date">{{ note.modified_date }}</div> <div class="date">{{ note.modified_date }}</div>
<div class="summary">{{ note.long_summary }}</div> <div class="summary">{{ note.long_summary }}</div>

View File

@ -46,7 +46,10 @@ def index(request):
else: else:
return user_home(request, request.user) return user_home(request, request.user)
c = {'login_failed' : login_failed} c = {
'login_failed' : login_failed,
'nb_people_registered' : User.objects.all().count()
}
return render(request, 'login.html', c) return render(request, 'login.html', c)