script.min.js
4.74 KB
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
104
105
106
107
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
define(['jquery','core/config',], function($,config) {
return {
init: function() {
var CONFIG;
$('.notes_overview').hide();
var url= $(location).attr('href');
if(url.includes('/mynotes/view.php')){
$('.page-header').css('margin-top','2em !important');
$('.page-title').css('margin-top','inherit !important');
}
$(document).ready(function(){
$(".notes_section").click(function(){
var eventId=this.id;
$('#notes_table_id'+eventId).toggle();
});
$(".notes_section").click(function(){
var eventId=this.id;
var classname=$( "div#"+eventId ).children()[0].className;
if (classname === 'notes_course fa fa-chevron-circle-right'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-right' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-down' );
}
else if (classname === 'notes_course fa fa-chevron-circle-down'){
$( "#icon"+eventId ).removeClass( 'notes_course fa fa-chevron-circle-down' );
$( "#icon"+eventId ).addClass( 'notes_course fa fa-chevron-circle-right' );
}
});
$("#excel_download").click(function(){
var rootPath = M.cfg.wwwroot
var arg = {
action: 'download',
};
$.ajax({
url: rootPath+"/blocks/mynotes/notes_excel.php",
type: "POST",
data: arg,
success: function(response){
//do action
},
error: function(){
// do action
}
});
});
$("a.delete_note").click(function(){
var deleteId=this.id;
var arg = {
action: 'delete',
noteid: deleteId,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
var deleteid=data.noteid;
$("#notes"+deleteid).remove();
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
}
});
});
$("a.edit_note").click(function(){
var editId=this.id;
// notes_content+editId;
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
document.getElementById('notes_content'+editId).focus();
// console.log('notes_content'+editId);
$('#notes_content'+editId).keypress(function(event) {
if (event.keyCode == 13) {
var newstring= $('#notes_content'+editId).text();
// console.log(newstring);
var vals=document.getElementById('notes_content'+editId).contentEditable = false;
var arg = {
action: 'edit',
noteid: editId,
newnotes:newstring,
};
var rootPath = M.cfg.wwwroot;
$.ajax({
type: 'post',
url: rootPath+'/blocks/mynotes/allnotes_ajax.php',
data:arg,
success: function( data ) {
},
error: function(data, errorThrown)
{
alert('request failed :'+errorThrown);
var vals=document.getElementById('notes_content'+editId).contentEditable = true;
}
});
}
});
});
});
}
};
});