|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
$(function() {
$("button#delete_user_note").click(delete_user_note);
$("button#goto_lemma").click(goto_lemma);
// czysci pamiec sesji o wybranej notatce
$("#menu_option").click(function(){
$.ajax({url: ajax_note_session_clear,
async: false});
});
$("#public-notes-paginate").paginate({
count : publicNotesPagesCount,
start : 1,
display : 10,
border : true,
border_color : '#fff',
text_color : 'black',
background_color : '#D8D8D8',
border_hover_color : '#ccc',
text_hover_color : '#000',
background_hover_color : '#fff',
images : false,
mouse : 'press',
onChange : function(page){
$("#public-notes-table").empty();
$("#public-notes-table").load(ajax_notes_page, {page: page, notes_private: false});
}
});
$("#private-notes-paginate").paginate({
count : privateNotesPagesCount,
start : 1,
display : 10,
border : true,
border_color : '#fff',
text_color : 'black',
background_color : '#D8D8D8',
border_hover_color : '#ccc',
text_hover_color : '#000',
background_hover_color : '#fff',
images : false,
mouse : 'press',
onChange : function(page){
$("#private-notes-table").empty();
$("#private-notes-table").load(ajax_notes_page, {page: page, notes_private: true});
}
});
$(".user_notes_container").tabs();
$("#public-notes-table").load(ajax_notes_page, {page: 1, notes_private: false});
$("#private-notes-table").load(ajax_notes_page, {page: 1, notes_private: true});
});
var publicNotesPagesCount = 0;
var privateNotesPagesCount = 0;
function goto_lemma()
{
var id = get_selected_note();
if(id == undefined)
{
alert('Zaznacz notatkę aby przejść do powiązanego z nią hasła.');
return false;
}
lemma_view_location = window.location.toString();
// trzeba by to moze z czasem poprawic na cos madrzejszego
lemma_view_location = lemma_view_location.replace('/notatki/', '');
window.location = lemma_view_location;
}
function delete_user_note() {
var id = get_selected_note();
if(id == undefined)
{
alert('Zaznacz notatkę aby ją usunąć.');
return false;
}
message_id = id.replace('note_', '');
$.ajaxJSON({
method: 'post',
url: ajax_remove_note,
data: {
message_id: message_id
},
callback: function(result) {
$('#'+id).remove();
$('#lemma_note_text').empty();
selected_notes_row_id = -1;
},
error_callback: function(xhr, status, error) {
error_alert(status + ': ' + error);
},
bad_data_callback: function(result) {
if (result == 'can not remove') {
error_alert('Usuwać można jedynie notatki prywatne.');
return false;
}
|
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
else
return true;
},
});
return false;
}
function get_selected_note() {
return $('[id^=note_][selected=selected]').first().attr('id');
}
function get_lemma_from_note(id)
{
// znajdz identyfikator hasla do ktorego dodano notatke
message_id = id.replace('note_', '');
$.ajaxJSON({
method: 'post',
url: ajax_get_lemma_from_note,
data: {
message_id: message_id
},
callback: function(result) {
if(result['new_notes_count']>0)
$('#menu_option.notes a').text('Notatki ['+result['new_notes_count']+']');
else
$('#menu_option.notes a').text('Notatki');
},
error_callback: function(xhr, status, error) {
error_alert(status + ': ' + error);
},
|
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
});
}
function selectNote(note_id) {
clearNoteSelection();
$('#' + note_id).attr('selected', "selected");
$('#' + note_id).children().each(function(){
$(this).css('background-color', "LightSteelBlue");
});
message_id = note_id.replace('note_', '');
$('#lemma_note_text').load(ajax_get_note_text, 'id='+message_id, function(){
$('#'+note_id+' td#new').text(' ');
get_lemma_from_note(note_id);
});
}
function clearNoteSelection() {
$('[id^=note_][selected=selected]').each(function(){
$(this).removeAttr('selected');
$(this).children().each(function(){
$(this).css('background-color', "");
});
});
}
|