chnages in notestime for vimeo player
Showing
6 changed files
with
461 additions
and
291 deletions
... | @@ -23,6 +23,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -23,6 +23,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
23 | }; | 23 | }; |
24 | var mynotes = { | 24 | var mynotes = { |
25 | getMynotesValidatedUrl: function(baseurl) { | 25 | getMynotesValidatedUrl: function(baseurl) { |
26 | |||
26 | var a = document.createElement('a'); | 27 | var a = document.createElement('a'); |
27 | a.href = baseurl; | 28 | a.href = baseurl; |
28 | return (a.search.length > 0) ? baseurl : baseurl + '?'; | 29 | return (a.search.length > 0) ? baseurl : baseurl + '?'; |
... | @@ -74,85 +75,28 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -74,85 +75,28 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
74 | var params = {}; | 75 | var params = {}; |
75 | var scope = this; | 76 | var scope = this; |
76 | 77 | ||
77 | |||
78 | |||
79 | |||
80 | |||
81 | var url= $(location).attr('href'); | 78 | var url= $(location).attr('href'); |
82 | //notes player time starts | ||
83 | $('document').ready(function(){ | ||
84 | if(url.includes('/mod/page/view.php')){ | ||
85 | |||
86 | var iframe = document.querySelector('iframe'); | ||
87 | // console.log(iframe); | ||
88 | var player = new Vimeo.Player(iframe); | ||
89 | console.log(player); | ||
90 | player.pause().then(function() { | ||
91 | }) | ||
92 | |||
93 | var time; | ||
94 | player.getCurrentTime().then(function(seconds) { | ||
95 | |||
96 | var str = '</br></br><font color="green">newly You have taken notes at '; | ||
97 | str +=seconds; | ||
98 | str +=" secs in this video.</font>"; | ||
99 | |||
100 | var rootPath = M.cfg.wwwroot; | ||
101 | $.ajax({ | ||
102 | url: rootPath + "/blocks/mynotes/timerajax.php", | ||
103 | type: 'POST', | ||
104 | data: {notestime: 'pollathavan'}, | ||
105 | success: function(data){ | ||
106 | |||
107 | } | ||
108 | }); | ||
109 | |||
110 | // if ( url.includes('/mod/page/view.php') ){ | ||
111 | |||
112 | $.ajax({url: rootPath + "/blocks/mynotes/timerajax.php", success: function(result){ | ||
113 | if(result){ | ||
114 | var JSONObject = JSON.parse(result); | ||
115 | var profile_field=JSONObject.profile2; | ||
116 | |||
117 | console.log("***************"); | ||
118 | console.log(profile_field); | ||
119 | console.log("***************"); | ||
120 | // $('.'+profile_field).show(); | ||
121 | } | ||
122 | }}); | ||
123 | // } | ||
124 | |||
125 | |||
126 | // params['notestime'] = str; | ||
127 | |||
128 | // console.log(str); | ||
129 | }) | ||
130 | // | ||
131 | |||
132 | // var result = str.fontcolor("green"); | ||
133 | } | ||
134 | }); | ||
135 | //notes player time ends | ||
136 | |||
137 | |||
138 | |||
139 | |||
140 | |||
141 | |||
142 | 79 | ||
143 | 80 | if(url.includes('/mod/page/view.php')){ | |
144 | if (args['scope']) { | 81 | //notes player timer starts |
145 | scope = args['scope']; | 82 | var iframe = document.querySelector('iframe'); |
146 | } | 83 | var player = new Vimeo.Player(iframe); |
147 | params['contextarea'] = scope.currenttab.replace(CONFIG.prefix, ''); | 84 | |
148 | params['contextarea'] = params['contextarea'].replace('#', ''); | 85 | player.pause() |
149 | if (args.params) { | ||
150 | for (i in args.params) { | ||
151 | params[i] = args.params[i]; | ||
152 | } | ||
153 | } | 86 | } |
154 | params['sesskey'] = M.cfg.sesskey; | 87 | |
155 | 88 | if (args['scope']) { | |
89 | scope = args['scope']; | ||
90 | } | ||
91 | params['contextarea'] = scope.currenttab.replace(CONFIG.prefix, ''); | ||
92 | params['contextarea'] = params['contextarea'].replace('#', ''); | ||
93 | |||
94 | if (args.params) { | ||
95 | for (i in args.params) { | ||
96 | params[i] = args.params[i]; | ||
97 | } | ||
98 | } | ||
99 | params['sesskey'] = M.cfg.sesskey; | ||
156 | 100 | ||
157 | var cfg = { | 101 | var cfg = { |
158 | method: 'POST', | 102 | method: 'POST', |
... | @@ -191,55 +135,142 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -191,55 +135,142 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
191 | Y.io(this.api, cfg); | 135 | Y.io(this.api, cfg); |
192 | }, | 136 | }, |
193 | saveMynotes: function(e) { | 137 | saveMynotes: function(e) { |
194 | e.preventDefault(); | 138 | |
195 | var scope = this; | 139 | var result=''; |
196 | if (scope.checkInputText() == false) { | 140 | |
197 | return false; | 141 | e.preventDefault(); |
198 | } | 142 | var scope = this; |
199 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); | 143 | if (scope.checkInputText() == false) { |
200 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { | 144 | return false; |
201 | return false; | 145 | } |
202 | } | 146 | |
203 | var arg = { | 147 | var url= $(location).attr('href'); |
204 | contextid: CONFIG.contextid, | 148 | |
205 | content: ta.val(), | 149 | if(url.includes('/mod/page/view.php')){ |
206 | action: 'add', | 150 | //notes player timer starts |
207 | contextarea: scope.currenttabindex, | 151 | var iframe = document.querySelector('iframe'); |
208 | }; | 152 | var player = new Vimeo.Player(iframe); |
209 | ta.attr('disabled', true); | 153 | |
210 | ta.css({ | 154 | player.pause(); |
211 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', | 155 | |
212 | 'backgroundRepeat': 'no-repeat', | 156 | player.getCurrentTime().then(function(seconds) { |
213 | 'backgroundPosition': 'center center' | 157 | |
214 | }); | 158 | var str = "</br>You have taken notes at "; |
215 | this.request({ | 159 | str +=seconds; |
216 | params: arg, | 160 | str +=" in this video." |
217 | callback: function(id, ret, args) { | 161 | result = str.fontcolor("green"); |
218 | if (!ret.notes) { | 162 | |
219 | return false; | 163 | |
220 | } | 164 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); |
221 | $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(''); | 165 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { |
222 | $('#id_mynotecontent-' + CONFIG.instanceid).val(M.util.get_string('placeholdercontent', 'block_mynotes')); | 166 | return false; |
223 | $('#id_mynotecontent-' + CONFIG.instanceid).removeAttr('disabled'); | 167 | } |
224 | $('#id_mynotecontent-' + CONFIG.instanceid).css({ | 168 | var arg = { |
225 | backgroundImage: '' | 169 | contextid: CONFIG.contextid, |
226 | }); | 170 | content: ta.val(), |
227 | if (scope.currenttab != scope.defaulttab) { | 171 | action: 'add', |
228 | scope.currenttab = scope.defaulttab; | 172 | contextarea: scope.currenttabindex, |
229 | var tab = scope.currenttab.replace('#', '#tab-'); | 173 | notestime:result, |
230 | $(SELECTORS.MYNOTES_BASE + ' ul.tabs-menu li').removeClass("current"); | 174 | |
231 | $(SELECTORS.MYNOTES_BASE + ' ' + tab).addClass('current'); | 175 | |
232 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').has(scope.currenttab).addClass('current'); | 176 | }; |
233 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').not(scope.currenttab).css("display", "none"); | 177 | |
234 | $(SELECTORS.MYNOTES_BASE + ' ' + scope.currenttab + '.tab-content').css("display", "block"); | 178 | ta.attr('disabled', true); |
235 | } | 179 | ta.css({ |
236 | scope.addToList(ret, 'add'); | 180 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', |
237 | scope.displayMynotes(); | 181 | 'backgroundRepeat': 'no-repeat', |
238 | $(SELECTORS.MYNOTES_BASE).find('.responsetext').html(M.util.get_string('savedsuccess', 'block_mynotes')); | 182 | 'backgroundPosition': 'center center' |
239 | } | 183 | }); |
240 | }); | 184 | |
185 | scope.request({ | ||
186 | params: arg, | ||
187 | callback: function(id, ret, args) { | ||
188 | if (!ret.notes) { | ||
189 | return false; | ||
190 | } | ||
191 | $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(''); | ||
192 | $('#id_mynotecontent-' + CONFIG.instanceid).val(M.util.get_string('placeholdercontent', 'block_mynotes')); | ||
193 | $('#id_mynotecontent-' + CONFIG.instanceid).removeAttr('disabled'); | ||
194 | $('#id_mynotecontent-' + CONFIG.instanceid).css({ | ||
195 | backgroundImage: '' | ||
196 | }); | ||
197 | if (scope.currenttab != scope.defaulttab) { | ||
198 | scope.currenttab = scope.defaulttab; | ||
199 | var tab = scope.currenttab.replace('#', '#tab-'); | ||
200 | $(SELECTORS.MYNOTES_BASE + ' ul.tabs-menu li').removeClass("current"); | ||
201 | $(SELECTORS.MYNOTES_BASE + ' ' + tab).addClass('current'); | ||
202 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').has(scope.currenttab).addClass('current'); | ||
203 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').not(scope.currenttab).css("display", "none"); | ||
204 | $(SELECTORS.MYNOTES_BASE + ' ' + scope.currenttab + '.tab-content').css("display", "block"); | ||
205 | } | ||
206 | scope.addToList(ret, 'add'); | ||
207 | scope.displayMynotes(); | ||
208 | $(SELECTORS.MYNOTES_BASE).find('.responsetext').html(M.util.get_string('savedsuccess', 'block_mynotes')); | ||
209 | } | ||
210 | }); | ||
211 | |||
212 | |||
213 | }); | ||
214 | |||
215 | |||
216 | } | ||
217 | else{ | ||
218 | |||
219 | |||
220 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); | ||
221 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { | ||
222 | return false; | ||
223 | } | ||
224 | var arg = { | ||
225 | contextid: CONFIG.contextid, | ||
226 | content: ta.val(), | ||
227 | action: 'add', | ||
228 | contextarea: scope.currenttabindex, | ||
229 | notestime:result, | ||
230 | |||
231 | |||
232 | }; | ||
233 | |||
234 | ta.attr('disabled', true); | ||
235 | ta.css({ | ||
236 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', | ||
237 | 'backgroundRepeat': 'no-repeat', | ||
238 | 'backgroundPosition': 'center center' | ||
239 | }); | ||
240 | |||
241 | scope.request({ | ||
242 | params: arg, | ||
243 | callback: function(id, ret, args) { | ||
244 | if (!ret.notes) { | ||
245 | return false; | ||
246 | } | ||
247 | $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(''); | ||
248 | $('#id_mynotecontent-' + CONFIG.instanceid).val(M.util.get_string('placeholdercontent', 'block_mynotes')); | ||
249 | $('#id_mynotecontent-' + CONFIG.instanceid).removeAttr('disabled'); | ||
250 | $('#id_mynotecontent-' + CONFIG.instanceid).css({ | ||
251 | backgroundImage: '' | ||
252 | }); | ||
253 | if (scope.currenttab != scope.defaulttab) { | ||
254 | scope.currenttab = scope.defaulttab; | ||
255 | var tab = scope.currenttab.replace('#', '#tab-'); | ||
256 | $(SELECTORS.MYNOTES_BASE + ' ul.tabs-menu li').removeClass("current"); | ||
257 | $(SELECTORS.MYNOTES_BASE + ' ' + tab).addClass('current'); | ||
258 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').has(scope.currenttab).addClass('current'); | ||
259 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').not(scope.currenttab).css("display", "none"); | ||
260 | $(SELECTORS.MYNOTES_BASE + ' ' + scope.currenttab + '.tab-content').css("display", "block"); | ||
261 | } | ||
262 | scope.addToList(ret, 'add'); | ||
263 | scope.displayMynotes(); | ||
264 | $(SELECTORS.MYNOTES_BASE).find('.responsetext').html(M.util.get_string('savedsuccess', 'block_mynotes')); | ||
265 | } | ||
266 | }); | ||
267 | |||
268 | } | ||
269 | |||
270 | |||
241 | }, | 271 | }, |
242 | addToList: function(notesobj, action = '') { | 272 | addToList: function(notesobj, action = '') { |
273 | |||
243 | var scope = this; | 274 | var scope = this; |
244 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); | 275 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); |
245 | if (action == 'add') { | 276 | if (action == 'add') { |
... | @@ -257,9 +288,13 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -257,9 +288,13 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
257 | getMynotes: function(page = 0) { | 288 | getMynotes: function(page = 0) { |
258 | var scope = this; | 289 | var scope = this; |
259 | page = parseInt(page); | 290 | page = parseInt(page); |
291 | |||
260 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); | 292 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); |
293 | |||
261 | var notescount = el.find('li').length; | 294 | var notescount = el.find('li').length; |
295 | |||
262 | var lastpage = Math.ceil(notescount / CONFIG.perpage); | 296 | var lastpage = Math.ceil(notescount / CONFIG.perpage); |
297 | |||
263 | if (notescount > 0 && lastpage > page) { | 298 | if (notescount > 0 && lastpage > page) { |
264 | scope.displayMynotes(); | 299 | scope.displayMynotes(); |
265 | return false; | 300 | return false; |
... | @@ -278,6 +313,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -278,6 +313,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
278 | }); | 313 | }); |
279 | }, | 314 | }, |
280 | updateMynotesInfo: function(mynotescount, page) { | 315 | updateMynotesInfo: function(mynotescount, page) { |
316 | console.log(mynotescount); | ||
281 | page = parseInt(page); | 317 | page = parseInt(page); |
282 | mynotescount = parseInt(mynotescount); | 318 | mynotescount = parseInt(mynotescount); |
283 | var scope = this; | 319 | var scope = this; |
... | @@ -297,15 +333,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -297,15 +333,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
297 | pagenum = page + 1; | 333 | pagenum = page + 1; |
298 | if (pagenum != lastpage) { | 334 | if (pagenum != lastpage) { |
299 | nextlink = scope.createLink(pagenum, M.util.get_string('nextpage', 'block_mynotes'), 'next'); | 335 | nextlink = scope.createLink(pagenum, M.util.get_string('nextpage', 'block_mynotes'), 'next'); |
336 | |||
300 | } | 337 | } |
301 | paging = prevlink; | 338 | paging = prevlink; |
339 | |||
302 | if (prevlink != '' && nextlink != '') { | 340 | if (prevlink != '' && nextlink != '') { |
303 | paging += '<span class="separator"></span>'; | 341 | paging += '<span class="separator"></span>'; |
342 | |||
304 | } | 343 | } |
305 | paging += nextlink; | 344 | paging += nextlink; |
306 | paging = '<span class="paging">' + paging + '</span>'; | 345 | paging = '<span class="paging">' + paging + '</span>'; |
346 | |||
307 | } | 347 | } |
308 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); | 348 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); |
349 | |||
309 | if (mynotescount > 0) { | 350 | if (mynotescount > 0) { |
310 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount); | 351 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount); |
311 | } else { | 352 | } else { |
... | @@ -337,16 +378,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -337,16 +378,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
337 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; | 378 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; |
338 | }, | 379 | }, |
339 | displayMynotes: function() { | 380 | displayMynotes: function() { |
381 | |||
340 | var scope = this; | 382 | var scope = this; |
341 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); | 383 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); |
342 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); | 384 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); |
385 | |||
343 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); | 386 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); |
387 | |||
344 | var notescount = el.find('li').length; | 388 | var notescount = el.find('li').length; |
345 | var lastpage = Math.ceil(notescount / CONFIG.perpage); | 389 | var lastpage = Math.ceil(notescount / CONFIG.perpage); |
346 | if (notescount > 0 && lastpage <= page) { | 390 | if (notescount > 0 && lastpage <= page) { |
347 | page = lastpage - 1; | 391 | page = lastpage - 1; |
348 | } | 392 | } |
349 | var upperlimit = page * CONFIG.perpage + CONFIG.perpage; | 393 | //parsing required for backward flow |
394 | var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage)); | ||
350 | var lowerlimit = page * CONFIG.perpage; | 395 | var lowerlimit = page * CONFIG.perpage; |
351 | el.find('li').css('display', 'none'); | 396 | el.find('li').css('display', 'none'); |
352 | el.find('li').each(function(i, el) { | 397 | el.find('li').each(function(i, el) { |
... | @@ -378,21 +423,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -378,21 +423,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
378 | } | 423 | } |
379 | }); | 424 | }); |
380 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'focus blur', function(e) { | 425 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'focus blur', function(e) { |
426 | var url= $(location).attr('href'); | ||
427 | if(url.includes('/mod/page/view.php')){ | ||
428 | //notes player timer starts | ||
429 | var iframe = document.querySelector('iframe'); | ||
430 | var player = new Vimeo.Player(iframe); | ||
431 | |||
432 | player.pause() | ||
433 | } | ||
434 | |||
381 | scope.toggle_textarea(e); | 435 | scope.toggle_textarea(e); |
382 | }); | 436 | }); |
383 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { | 437 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { |
438 | |||
384 | scope.getWarnings(scope.checkInputText()); | 439 | scope.getWarnings(scope.checkInputText()); |
385 | }); | 440 | }); |
386 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { | 441 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { |
387 | e.preventDefault(); | 442 | e.preventDefault(); |
388 | var regex = new RegExp(/[\?&]page=(\d+)/); | 443 | var regex = new RegExp(/[\?&]page=(\d+)/); |
389 | var results = regex.exec($(this).attr('href')); | 444 | var results = regex.exec($(this).attr('href')); |
445 | |||
390 | var page = 0; | 446 | var page = 0; |
391 | if (results[1]) { | 447 | if (results[1]) { |
392 | page = results[1]; | 448 | page = results[1]; |
393 | } | 449 | } |
394 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage', parseInt(page)); | 450 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage', parseInt(page)); |
395 | scope.getMynotes(page); | 451 | scope.getMynotes(page); |
452 | |||
396 | }); | 453 | }); |
397 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { | 454 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { |
398 | e.preventDefault(); | 455 | e.preventDefault(); |
... | @@ -418,6 +475,17 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -418,6 +475,17 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
418 | }); | 475 | }); |
419 | }, | 476 | }, |
420 | displayDialogue: function(e) { | 477 | displayDialogue: function(e) { |
478 | |||
479 | var url= $(location).attr('href'); | ||
480 | if(url.includes('/mod/page/view.php')){ | ||
481 | //notes player timer starts | ||
482 | var iframe = document.querySelector('iframe'); | ||
483 | var player = new Vimeo.Player(iframe); | ||
484 | |||
485 | player.pause() | ||
486 | } | ||
487 | |||
488 | |||
421 | var scope = mynotes; | 489 | var scope = mynotes; |
422 | if (panel === null) { | 490 | if (panel === null) { |
423 | str.get_strings([{ | 491 | str.get_strings([{ | ... | ... |
1 | define(["jquery"],function(e){return{init:function(){var n=e(location).attr("href");e("document").ready(function(){if(n.includes("/mod/page/view.php")){var t=document.querySelector("iframe"),i=new Vimeo.Player(t);console.log(i),e("#mynotepencil").click(function(){setTimeout(function(){i.getCurrentTime().then(function(e){})},1e3)})}})}}}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | define(["jquery"],function(e){return{init:function(){var n=e(location).attr("href");e("document").ready(function(){if(n.includes("/mod/page/view.php")){var e=document.querySelector("iframe");new Vimeo.Player(e)}})}}}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -23,6 +23,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -23,6 +23,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
23 | }; | 23 | }; |
24 | var mynotes = { | 24 | var mynotes = { |
25 | getMynotesValidatedUrl: function(baseurl) { | 25 | getMynotesValidatedUrl: function(baseurl) { |
26 | |||
26 | var a = document.createElement('a'); | 27 | var a = document.createElement('a'); |
27 | a.href = baseurl; | 28 | a.href = baseurl; |
28 | return (a.search.length > 0) ? baseurl : baseurl + '?'; | 29 | return (a.search.length > 0) ? baseurl : baseurl + '?'; |
... | @@ -74,85 +75,28 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -74,85 +75,28 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
74 | var params = {}; | 75 | var params = {}; |
75 | var scope = this; | 76 | var scope = this; |
76 | 77 | ||
77 | |||
78 | |||
79 | |||
80 | |||
81 | var url= $(location).attr('href'); | 78 | var url= $(location).attr('href'); |
82 | //notes player time starts | ||
83 | $('document').ready(function(){ | ||
84 | if(url.includes('/mod/page/view.php')){ | ||
85 | |||
86 | var iframe = document.querySelector('iframe'); | ||
87 | // console.log(iframe); | ||
88 | var player = new Vimeo.Player(iframe); | ||
89 | console.log(player); | ||
90 | player.pause().then(function() { | ||
91 | }) | ||
92 | |||
93 | var time; | ||
94 | player.getCurrentTime().then(function(seconds) { | ||
95 | |||
96 | var str = '</br></br><font color="green">newly You have taken notes at '; | ||
97 | str +=seconds; | ||
98 | str +=" secs in this video.</font>"; | ||
99 | |||
100 | var rootPath = M.cfg.wwwroot; | ||
101 | $.ajax({ | ||
102 | url: rootPath + "/blocks/mynotes/timerajax.php", | ||
103 | type: 'POST', | ||
104 | data: {notestime: 'pollathavan'}, | ||
105 | success: function(data){ | ||
106 | |||
107 | } | ||
108 | }); | ||
109 | |||
110 | // if ( url.includes('/mod/page/view.php') ){ | ||
111 | |||
112 | $.ajax({url: rootPath + "/blocks/mynotes/timerajax.php", success: function(result){ | ||
113 | if(result){ | ||
114 | var JSONObject = JSON.parse(result); | ||
115 | var profile_field=JSONObject.profile2; | ||
116 | |||
117 | console.log("***************"); | ||
118 | console.log(profile_field); | ||
119 | console.log("***************"); | ||
120 | // $('.'+profile_field).show(); | ||
121 | } | ||
122 | }}); | ||
123 | // } | ||
124 | |||
125 | |||
126 | // params['notestime'] = str; | ||
127 | |||
128 | // console.log(str); | ||
129 | }) | ||
130 | // | ||
131 | |||
132 | // var result = str.fontcolor("green"); | ||
133 | } | ||
134 | }); | ||
135 | //notes player time ends | ||
136 | |||
137 | |||
138 | |||
139 | |||
140 | |||
141 | |||
142 | 79 | ||
143 | 80 | if(url.includes('/mod/page/view.php')){ | |
144 | if (args['scope']) { | 81 | //notes player timer starts |
145 | scope = args['scope']; | 82 | var iframe = document.querySelector('iframe'); |
146 | } | 83 | var player = new Vimeo.Player(iframe); |
147 | params['contextarea'] = scope.currenttab.replace(CONFIG.prefix, ''); | 84 | |
148 | params['contextarea'] = params['contextarea'].replace('#', ''); | 85 | player.pause() |
149 | if (args.params) { | ||
150 | for (i in args.params) { | ||
151 | params[i] = args.params[i]; | ||
152 | } | ||
153 | } | 86 | } |
154 | params['sesskey'] = M.cfg.sesskey; | 87 | |
155 | 88 | if (args['scope']) { | |
89 | scope = args['scope']; | ||
90 | } | ||
91 | params['contextarea'] = scope.currenttab.replace(CONFIG.prefix, ''); | ||
92 | params['contextarea'] = params['contextarea'].replace('#', ''); | ||
93 | |||
94 | if (args.params) { | ||
95 | for (i in args.params) { | ||
96 | params[i] = args.params[i]; | ||
97 | } | ||
98 | } | ||
99 | params['sesskey'] = M.cfg.sesskey; | ||
156 | 100 | ||
157 | var cfg = { | 101 | var cfg = { |
158 | method: 'POST', | 102 | method: 'POST', |
... | @@ -191,55 +135,142 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -191,55 +135,142 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
191 | Y.io(this.api, cfg); | 135 | Y.io(this.api, cfg); |
192 | }, | 136 | }, |
193 | saveMynotes: function(e) { | 137 | saveMynotes: function(e) { |
194 | e.preventDefault(); | 138 | |
195 | var scope = this; | 139 | var result=''; |
196 | if (scope.checkInputText() == false) { | 140 | |
197 | return false; | 141 | e.preventDefault(); |
198 | } | 142 | var scope = this; |
199 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); | 143 | if (scope.checkInputText() == false) { |
200 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { | 144 | return false; |
201 | return false; | 145 | } |
202 | } | 146 | |
203 | var arg = { | 147 | var url= $(location).attr('href'); |
204 | contextid: CONFIG.contextid, | 148 | |
205 | content: ta.val(), | 149 | if(url.includes('/mod/page/view.php')){ |
206 | action: 'add', | 150 | //notes player timer starts |
207 | contextarea: scope.currenttabindex, | 151 | var iframe = document.querySelector('iframe'); |
208 | }; | 152 | var player = new Vimeo.Player(iframe); |
209 | ta.attr('disabled', true); | 153 | |
210 | ta.css({ | 154 | player.pause(); |
211 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', | 155 | |
212 | 'backgroundRepeat': 'no-repeat', | 156 | player.getCurrentTime().then(function(seconds) { |
213 | 'backgroundPosition': 'center center' | 157 | |
214 | }); | 158 | var str = "</br>You have taken notes at "; |
215 | this.request({ | 159 | str +=seconds; |
216 | params: arg, | 160 | str +=" in this video." |
217 | callback: function(id, ret, args) { | 161 | result = str.fontcolor("green"); |
218 | if (!ret.notes) { | 162 | |
219 | return false; | 163 | |
220 | } | 164 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); |
221 | $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(''); | 165 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { |
222 | $('#id_mynotecontent-' + CONFIG.instanceid).val(M.util.get_string('placeholdercontent', 'block_mynotes')); | 166 | return false; |
223 | $('#id_mynotecontent-' + CONFIG.instanceid).removeAttr('disabled'); | 167 | } |
224 | $('#id_mynotecontent-' + CONFIG.instanceid).css({ | 168 | var arg = { |
225 | backgroundImage: '' | 169 | contextid: CONFIG.contextid, |
226 | }); | 170 | content: ta.val(), |
227 | if (scope.currenttab != scope.defaulttab) { | 171 | action: 'add', |
228 | scope.currenttab = scope.defaulttab; | 172 | contextarea: scope.currenttabindex, |
229 | var tab = scope.currenttab.replace('#', '#tab-'); | 173 | notestime:result, |
230 | $(SELECTORS.MYNOTES_BASE + ' ul.tabs-menu li').removeClass("current"); | 174 | |
231 | $(SELECTORS.MYNOTES_BASE + ' ' + tab).addClass('current'); | 175 | |
232 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').has(scope.currenttab).addClass('current'); | 176 | }; |
233 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').not(scope.currenttab).css("display", "none"); | 177 | |
234 | $(SELECTORS.MYNOTES_BASE + ' ' + scope.currenttab + '.tab-content').css("display", "block"); | 178 | ta.attr('disabled', true); |
235 | } | 179 | ta.css({ |
236 | scope.addToList(ret, 'add'); | 180 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', |
237 | scope.displayMynotes(); | 181 | 'backgroundRepeat': 'no-repeat', |
238 | $(SELECTORS.MYNOTES_BASE).find('.responsetext').html(M.util.get_string('savedsuccess', 'block_mynotes')); | 182 | 'backgroundPosition': 'center center' |
239 | } | 183 | }); |
240 | }); | 184 | |
185 | scope.request({ | ||
186 | params: arg, | ||
187 | callback: function(id, ret, args) { | ||
188 | if (!ret.notes) { | ||
189 | return false; | ||
190 | } | ||
191 | $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(''); | ||
192 | $('#id_mynotecontent-' + CONFIG.instanceid).val(M.util.get_string('placeholdercontent', 'block_mynotes')); | ||
193 | $('#id_mynotecontent-' + CONFIG.instanceid).removeAttr('disabled'); | ||
194 | $('#id_mynotecontent-' + CONFIG.instanceid).css({ | ||
195 | backgroundImage: '' | ||
196 | }); | ||
197 | if (scope.currenttab != scope.defaulttab) { | ||
198 | scope.currenttab = scope.defaulttab; | ||
199 | var tab = scope.currenttab.replace('#', '#tab-'); | ||
200 | $(SELECTORS.MYNOTES_BASE + ' ul.tabs-menu li').removeClass("current"); | ||
201 | $(SELECTORS.MYNOTES_BASE + ' ' + tab).addClass('current'); | ||
202 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').has(scope.currenttab).addClass('current'); | ||
203 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').not(scope.currenttab).css("display", "none"); | ||
204 | $(SELECTORS.MYNOTES_BASE + ' ' + scope.currenttab + '.tab-content').css("display", "block"); | ||
205 | } | ||
206 | scope.addToList(ret, 'add'); | ||
207 | scope.displayMynotes(); | ||
208 | $(SELECTORS.MYNOTES_BASE).find('.responsetext').html(M.util.get_string('savedsuccess', 'block_mynotes')); | ||
209 | } | ||
210 | }); | ||
211 | |||
212 | |||
213 | }); | ||
214 | |||
215 | |||
216 | } | ||
217 | else{ | ||
218 | |||
219 | |||
220 | var ta = $('#id_mynotecontent-' + CONFIG.instanceid); | ||
221 | if (ta.val() == "" || ta.val() == M.util.get_string('placeholdercontent', 'block_mynotes')) { | ||
222 | return false; | ||
223 | } | ||
224 | var arg = { | ||
225 | contextid: CONFIG.contextid, | ||
226 | content: ta.val(), | ||
227 | action: 'add', | ||
228 | contextarea: scope.currenttabindex, | ||
229 | notestime:result, | ||
230 | |||
231 | |||
232 | }; | ||
233 | |||
234 | ta.attr('disabled', true); | ||
235 | ta.css({ | ||
236 | 'backgroundImage': 'url(' + M.util.image_url('i/loading_small', 'core') + ')', | ||
237 | 'backgroundRepeat': 'no-repeat', | ||
238 | 'backgroundPosition': 'center center' | ||
239 | }); | ||
240 | |||
241 | scope.request({ | ||
242 | params: arg, | ||
243 | callback: function(id, ret, args) { | ||
244 | if (!ret.notes) { | ||
245 | return false; | ||
246 | } | ||
247 | $('#addmynote-label-' + CONFIG.instanceid + ' span.warning').html(''); | ||
248 | $('#id_mynotecontent-' + CONFIG.instanceid).val(M.util.get_string('placeholdercontent', 'block_mynotes')); | ||
249 | $('#id_mynotecontent-' + CONFIG.instanceid).removeAttr('disabled'); | ||
250 | $('#id_mynotecontent-' + CONFIG.instanceid).css({ | ||
251 | backgroundImage: '' | ||
252 | }); | ||
253 | if (scope.currenttab != scope.defaulttab) { | ||
254 | scope.currenttab = scope.defaulttab; | ||
255 | var tab = scope.currenttab.replace('#', '#tab-'); | ||
256 | $(SELECTORS.MYNOTES_BASE + ' ul.tabs-menu li').removeClass("current"); | ||
257 | $(SELECTORS.MYNOTES_BASE + ' ' + tab).addClass('current'); | ||
258 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').has(scope.currenttab).addClass('current'); | ||
259 | $(SELECTORS.MYNOTES_BASE + ' .tab-content').not(scope.currenttab).css("display", "none"); | ||
260 | $(SELECTORS.MYNOTES_BASE + ' ' + scope.currenttab + '.tab-content').css("display", "block"); | ||
261 | } | ||
262 | scope.addToList(ret, 'add'); | ||
263 | scope.displayMynotes(); | ||
264 | $(SELECTORS.MYNOTES_BASE).find('.responsetext').html(M.util.get_string('savedsuccess', 'block_mynotes')); | ||
265 | } | ||
266 | }); | ||
267 | |||
268 | } | ||
269 | |||
270 | |||
241 | }, | 271 | }, |
242 | addToList: function(notesobj, action = '') { | 272 | addToList: function(notesobj, action = '') { |
273 | |||
243 | var scope = this; | 274 | var scope = this; |
244 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); | 275 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); |
245 | if (action == 'add') { | 276 | if (action == 'add') { |
... | @@ -257,9 +288,13 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -257,9 +288,13 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
257 | getMynotes: function(page = 0) { | 288 | getMynotes: function(page = 0) { |
258 | var scope = this; | 289 | var scope = this; |
259 | page = parseInt(page); | 290 | page = parseInt(page); |
291 | |||
260 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); | 292 | var el = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab + '-list'); |
293 | |||
261 | var notescount = el.find('li').length; | 294 | var notescount = el.find('li').length; |
295 | |||
262 | var lastpage = Math.ceil(notescount / CONFIG.perpage); | 296 | var lastpage = Math.ceil(notescount / CONFIG.perpage); |
297 | |||
263 | if (notescount > 0 && lastpage > page) { | 298 | if (notescount > 0 && lastpage > page) { |
264 | scope.displayMynotes(); | 299 | scope.displayMynotes(); |
265 | return false; | 300 | return false; |
... | @@ -272,12 +307,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -272,12 +307,14 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
272 | this.request({ | 307 | this.request({ |
273 | params: arg, | 308 | params: arg, |
274 | callback: function(id, ret, args) { | 309 | callback: function(id, ret, args) { |
310 | |||
275 | scope.addToList(ret); | 311 | scope.addToList(ret); |
276 | scope.displayMynotes(); | 312 | scope.displayMynotes(); |
277 | } | 313 | } |
278 | }); | 314 | }); |
279 | }, | 315 | }, |
280 | updateMynotesInfo: function(mynotescount, page) { | 316 | updateMynotesInfo: function(mynotescount, page) { |
317 | |||
281 | page = parseInt(page); | 318 | page = parseInt(page); |
282 | mynotescount = parseInt(mynotescount); | 319 | mynotescount = parseInt(mynotescount); |
283 | var scope = this; | 320 | var scope = this; |
... | @@ -297,15 +334,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -297,15 +334,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
297 | pagenum = page + 1; | 334 | pagenum = page + 1; |
298 | if (pagenum != lastpage) { | 335 | if (pagenum != lastpage) { |
299 | nextlink = scope.createLink(pagenum, M.util.get_string('nextpage', 'block_mynotes'), 'next'); | 336 | nextlink = scope.createLink(pagenum, M.util.get_string('nextpage', 'block_mynotes'), 'next'); |
337 | |||
300 | } | 338 | } |
301 | paging = prevlink; | 339 | paging = prevlink; |
340 | |||
302 | if (prevlink != '' && nextlink != '') { | 341 | if (prevlink != '' && nextlink != '') { |
303 | paging += '<span class="separator"></span>'; | 342 | paging += '<span class="separator"></span>'; |
343 | |||
304 | } | 344 | } |
305 | paging += nextlink; | 345 | paging += nextlink; |
306 | paging = '<span class="paging">' + paging + '</span>'; | 346 | paging = '<span class="paging">' + paging + '</span>'; |
347 | |||
307 | } | 348 | } |
308 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); | 349 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); |
350 | |||
309 | if (mynotescount > 0) { | 351 | if (mynotescount > 0) { |
310 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount); | 352 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount); |
311 | } else { | 353 | } else { |
... | @@ -337,16 +379,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -337,16 +379,20 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
337 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; | 379 | return '<a href="' + this.api + '&page=' + page + '"' + classattribute + '>' + text + '</a>'; |
338 | }, | 380 | }, |
339 | displayMynotes: function() { | 381 | displayMynotes: function() { |
382 | |||
340 | var scope = this; | 383 | var scope = this; |
341 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); | 384 | var page = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage')); |
342 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); | 385 | var mynotescount = parseInt($(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('notes-count')); |
386 | |||
343 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); | 387 | var el = $(SELECTORS.MYNOTES_BASE).find(' ' + scope.currenttab + '-list'); |
388 | |||
344 | var notescount = el.find('li').length; | 389 | var notescount = el.find('li').length; |
345 | var lastpage = Math.ceil(notescount / CONFIG.perpage); | 390 | var lastpage = Math.ceil(notescount / CONFIG.perpage); |
346 | if (notescount > 0 && lastpage <= page) { | 391 | if (notescount > 0 && lastpage <= page) { |
347 | page = lastpage - 1; | 392 | page = lastpage - 1; |
348 | } | 393 | } |
349 | var upperlimit = page * CONFIG.perpage + CONFIG.perpage; | 394 | //parsing required for backward flow |
395 | var upperlimit = (parseInt(page) * parseInt(CONFIG.perpage))+ (parseInt(CONFIG.perpage)); | ||
350 | var lowerlimit = page * CONFIG.perpage; | 396 | var lowerlimit = page * CONFIG.perpage; |
351 | el.find('li').css('display', 'none'); | 397 | el.find('li').css('display', 'none'); |
352 | el.find('li').each(function(i, el) { | 398 | el.find('li').each(function(i, el) { |
... | @@ -378,21 +424,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -378,21 +424,33 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
378 | } | 424 | } |
379 | }); | 425 | }); |
380 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'focus blur', function(e) { | 426 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'focus blur', function(e) { |
427 | var url= $(location).attr('href'); | ||
428 | if(url.includes('/mod/page/view.php')){ | ||
429 | //notes player timer starts | ||
430 | var iframe = document.querySelector('iframe'); | ||
431 | var player = new Vimeo.Player(iframe); | ||
432 | |||
433 | player.pause() | ||
434 | } | ||
435 | |||
381 | scope.toggle_textarea(e); | 436 | scope.toggle_textarea(e); |
382 | }); | 437 | }); |
383 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { | 438 | $('body').delegate('#id_mynotecontent-' + CONFIG.instanceid, 'change keypress keyup', function(e) { |
439 | |||
384 | scope.getWarnings(scope.checkInputText()); | 440 | scope.getWarnings(scope.checkInputText()); |
385 | }); | 441 | }); |
386 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { | 442 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' .mynotes-paging .paging a', 'click', function(e) { |
387 | e.preventDefault(); | 443 | e.preventDefault(); |
388 | var regex = new RegExp(/[\?&]page=(\d+)/); | 444 | var regex = new RegExp(/[\?&]page=(\d+)/); |
389 | var results = regex.exec($(this).attr('href')); | 445 | var results = regex.exec($(this).attr('href')); |
446 | |||
390 | var page = 0; | 447 | var page = 0; |
391 | if (results[1]) { | 448 | if (results[1]) { |
392 | page = results[1]; | 449 | page = results[1]; |
393 | } | 450 | } |
394 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage', parseInt(page)); | 451 | $(SELECTORS.MYNOTES_BASE).find(scope.currenttab).attr('onpage', parseInt(page)); |
395 | scope.getMynotes(page); | 452 | scope.getMynotes(page); |
453 | |||
396 | }); | 454 | }); |
397 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { | 455 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { |
398 | e.preventDefault(); | 456 | e.preventDefault(); |
... | @@ -418,6 +476,17 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -418,6 +476,17 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
418 | }); | 476 | }); |
419 | }, | 477 | }, |
420 | displayDialogue: function(e) { | 478 | displayDialogue: function(e) { |
479 | |||
480 | var url= $(location).attr('href'); | ||
481 | if(url.includes('/mod/page/view.php')){ | ||
482 | //notes player timer starts | ||
483 | var iframe = document.querySelector('iframe'); | ||
484 | var player = new Vimeo.Player(iframe); | ||
485 | |||
486 | player.pause() | ||
487 | } | ||
488 | |||
489 | |||
421 | var scope = mynotes; | 490 | var scope = mynotes; |
422 | if (panel === null) { | 491 | if (panel === null) { |
423 | str.get_strings([{ | 492 | str.get_strings([{ | ... | ... |
... | @@ -12,38 +12,6 @@ define(['jquery'], function($) { | ... | @@ -12,38 +12,6 @@ define(['jquery'], function($) { |
12 | 12 | ||
13 | var player = new Vimeo.Player(iframe); | 13 | var player = new Vimeo.Player(iframe); |
14 | 14 | ||
15 | console.log(player); | ||
16 | $('#mynotepencil').click(function(){ | ||
17 | |||
18 | setTimeout(function(){ | ||
19 | player.getCurrentTime().then(function(seconds) { | ||
20 | |||
21 | var str = "</br><br><div style='display: none !important;'> You have taken notes at "; | ||
22 | str +=seconds; | ||
23 | str +=" in this video.</div>" | ||
24 | // var result = str.fontcolor("green"); | ||
25 | // $("#id_mynotecontent-54").val(str); | ||
26 | |||
27 | }) | ||
28 | // console.log($mynotestime); | ||
29 | // console.log(self); | ||
30 | |||
31 | // | ||
32 | |||
33 | |||
34 | // var str = "<div> You have taken notes at "; | ||
35 | // str +=time; | ||
36 | // str +=" in this video.</div>" | ||
37 | // var result = str.fontcolor("green"); | ||
38 | // $("#id_mynotecontent-258").val(result); | ||
39 | |||
40 | }, 1000); | ||
41 | |||
42 | }); | ||
43 | |||
44 | |||
45 | |||
46 | |||
47 | } | 15 | } |
48 | }); | 16 | }); |
49 | } | 17 | } | ... | ... |
... | @@ -70,7 +70,7 @@ class block_mynotes_manager { | ... | @@ -70,7 +70,7 @@ class block_mynotes_manager { |
70 | } | 70 | } |
71 | $sql = "SELECT $ufields, | 71 | $sql = "SELECT $ufields, |
72 | m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat, | 72 | m.id AS mynoteid, m.content AS ccontent, m.contextarea, m.contextid, m.format AS cformat, |
73 | m.timecreated AS timecreated, c.fullname as coursename, m.courseid | 73 | m.timecreated AS timecreated,m.notestime AS notestime, c.fullname as coursename, m.courseid |
74 | FROM {block_mynotes} m | 74 | FROM {block_mynotes} m |
75 | JOIN {user} u ON u.id = m.userid | 75 | JOIN {user} u ON u.id = m.userid |
76 | LEFT JOIN {course} c ON c.id = m.courseid | 76 | LEFT JOIN {course} c ON c.id = m.courseid |
... | @@ -94,6 +94,13 @@ class block_mynotes_manager { | ... | @@ -94,6 +94,13 @@ class block_mynotes_manager { |
94 | $c->contextarea = $u->contextarea; | 94 | $c->contextarea = $u->contextarea; |
95 | $c->format = $u->cformat; | 95 | $c->format = $u->cformat; |
96 | $c->timecreated = userdate($u->timecreated, $strftime); | 96 | $c->timecreated = userdate($u->timecreated, $strftime); |
97 | $c->userid = $u->id; | ||
98 | if (!empty($u->notestime)) { | ||
99 | $c->notestime = $u->notestime; | ||
100 | } else { | ||
101 | $c->notestime = ''; | ||
102 | } | ||
103 | // $c->notestime = $u->notestime; | ||
97 | $c->content = format_text($c->content, $c->format, $formatoptions); | 104 | $c->content = format_text($c->content, $c->format, $formatoptions); |
98 | $c->delete = true; | 105 | $c->delete = true; |
99 | $mynotes[] = $c; | 106 | $mynotes[] = $c; |
... | @@ -108,24 +115,59 @@ class block_mynotes_manager { | ... | @@ -108,24 +115,59 @@ class block_mynotes_manager { |
108 | * @param object $options | 115 | * @param object $options |
109 | * @return int The count of records | 116 | * @return int The count of records |
110 | */ | 117 | */ |
111 | public function count_mynotes($options) { | 118 | /* public function count_mynotes($options) { |
112 | global $DB, $USER; | 119 | global $DB, $USER; |
113 | $params = array(); | 120 | $params = array(); |
114 | // $params ['contextid']= $options->contextid; | 121 | $params['userid'] = $USER->id; |
115 | // $params= $options->contextid; | 122 | |
116 | $sql='select COUNT(contextarea) from {block_mynotes} where contextid= :contextid'; | 123 | $sql='select COUNT(contextarea) from {block_mynotes} where contextid= :contextid'; |
117 | $params ['contextid']= $options->contextid; | 124 | $params ['contextid']= $options->contextid; |
118 | return $DB->count_records_sql($sql,$params); | 125 | print_object($sql); |
119 | /* $params['userid'] = $USER->id; | 126 | // return $DB->count_records_sql($sql,$params); |
127 | |||
128 | |||
129 | |||
130 | |||
120 | if (isset($options->contextarea) && !empty($options->contextarea)) { | 131 | if (isset($options->contextarea) && !empty($options->contextarea)) { |
121 | $params['contextarea'] = $options->contextarea; | 132 | $params['contextarea'] = $options->contextarea; |
122 | } | 133 | } |
123 | if (isset($options->contextid) && !empty($options->contextid)) { | 134 | if (isset($options->contextid) && !empty($options->contextid)) { |
124 | $params['contextid'] = $options->contextid; | 135 | $params['contextid'] = $options->contextid; |
125 | } | 136 | } |
126 | return $DB->count_records('block_mynotes',$params); */ | 137 | |
138 | |||
139 | return $DB->count_records('block_mynotes',$params); | ||
127 | 140 | ||
141 | } */ | ||
142 | |||
143 | |||
144 | |||
145 | public function count_mynotes($options) { | ||
146 | global $DB, $USER; | ||
147 | |||
148 | $params = array(); | ||
149 | $params['userid'] = $USER->id; | ||
150 | if (isset($options->contextarea) && !empty($options->contextarea)) { | ||
151 | $params['contextarea'] = $options->contextarea; | ||
152 | } | ||
153 | if (isset($options->contextid) && !empty($options->contextid)) { | ||
154 | $params['contextid'] = $options->contextid; | ||
155 | } | ||
156 | |||
157 | $sql='select count(contextarea) from {block_mynotes} where userid=? and contextarea=? and contextid=?'; | ||
158 | |||
159 | $result=$DB->get_records_sql($sql,$params); | ||
160 | |||
161 | $count; | ||
162 | foreach ($result as $val){ | ||
163 | $count=$val->count; | ||
164 | |||
165 | } | ||
166 | |||
167 | return $count; | ||
168 | // return $DB->count_records('block_mynotes', $params); | ||
128 | } | 169 | } |
170 | |||
129 | 171 | ||
130 | /* | 172 | /* |
131 | * Returns paging bar for mynotes | 173 | * Returns paging bar for mynotes |
... | @@ -149,7 +191,7 @@ class block_mynotes_manager { | ... | @@ -149,7 +191,7 @@ class block_mynotes_manager { |
149 | */ | 191 | */ |
150 | public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) { | 192 | public function addmynote($context, $contextarea, $course, $content,$timer, $format = FORMAT_MOODLE) { |
151 | global $CFG, $DB, $USER, $OUTPUT; | 193 | global $CFG, $DB, $USER, $OUTPUT; |
152 | $content=$content.$timer; | 194 | // $content=$content.$timer; |
153 | $newnote = new stdClass; | 195 | $newnote = new stdClass; |
154 | $newnote->contextid = $context->id; | 196 | $newnote->contextid = $context->id; |
155 | $newnote->contextarea = $contextarea; | 197 | $newnote->contextarea = $contextarea; |
... | @@ -158,12 +200,14 @@ class block_mynotes_manager { | ... | @@ -158,12 +200,14 @@ class block_mynotes_manager { |
158 | $newnote->format = $format; | 200 | $newnote->format = $format; |
159 | $newnote->userid = $USER->id; | 201 | $newnote->userid = $USER->id; |
160 | $newnote->timecreated = time(); | 202 | $newnote->timecreated = time(); |
203 | $newnote->notestime=$timer; | ||
161 | 204 | ||
162 | if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) { | 205 | if ($cmtid = $DB->insert_record('block_mynotes', $newnote)) { |
163 | $newnote->id = $cmtid; | 206 | $newnote->id = $cmtid; |
164 | $newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true)); | 207 | $newnote->content = format_text($newnote->content, $newnote->format, array('overflowdiv' => true)); |
165 | $newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig')); | 208 | $newnote->timecreated = userdate($newnote->timecreated, get_string('strftimerecentfull', 'langconfig')); |
166 | $newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname; | 209 | $newnote->coursename = ($newnote->courseid == SITEID) ? '' : $course->fullname; |
210 | $newnote->notestime = ($newnote->notestime) ? '' : $newnote->notestime; | ||
167 | if (!empty($newnote->coursename)) { | 211 | if (!empty($newnote->coursename)) { |
168 | $newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename); | 212 | $newnote->coursename = html_writer::link(course_get_url($course), $newnote->coursename); |
169 | } | 213 | } |
... | @@ -249,4 +293,5 @@ class block_mynotes_manager { | ... | @@ -249,4 +293,5 @@ class block_mynotes_manager { |
249 | * Mynotes exception class | 293 | * Mynotes exception class |
250 | */ | 294 | */ |
251 | class mynotes_exception extends moodle_exception { | 295 | class mynotes_exception extends moodle_exception { |
252 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
296 | } | ||
297 | ... | ... |
... | @@ -62,6 +62,7 @@ $config = get_config('block_mynotes'); | ... | @@ -62,6 +62,7 @@ $config = get_config('block_mynotes'); |
62 | 62 | ||
63 | echo $OUTPUT->header(); //...send headers | 63 | echo $OUTPUT->header(); //...send headers |
64 | // process ajax request | 64 | // process ajax request |
65 | |||
65 | switch ($action) { | 66 | switch ($action) { |
66 | case 'add': | 67 | case 'add': |
67 | $content = optional_param('content', '', PARAM_RAW); | 68 | $content = optional_param('content', '', PARAM_RAW); |
... | @@ -75,8 +76,10 @@ switch ($action) { | ... | @@ -75,8 +76,10 @@ switch ($action) { |
75 | $options->contextid = $context->id; | 76 | $options->contextid = $context->id; |
76 | $options->context = $context; | 77 | $options->context = $context; |
77 | $options->contextarea = $contextarea; | 78 | $options->contextarea = $contextarea; |
79 | // $options->notestime=$timer; | ||
78 | unset($options->courseid); | 80 | unset($options->courseid); |
79 | $count = $manager->count_mynotes($options); | 81 | $count = $manager->count_mynotes($options); |
82 | |||
80 | echo json_encode(array('notes' => array($note), 'count' => $count)); | 83 | echo json_encode(array('notes' => array($note), 'count' => $count)); |
81 | } else { | 84 | } else { |
82 | echo json_encode(array('error' => 'Unable to add note')); | 85 | echo json_encode(array('error' => 'Unable to add note')); |
... | @@ -89,9 +92,21 @@ switch ($action) { | ... | @@ -89,9 +92,21 @@ switch ($action) { |
89 | $options->page = $page; | 92 | $options->page = $page; |
90 | $options->contextid = $context->id; | 93 | $options->contextid = $context->id; |
91 | $options->contextarea = $contextarea; | 94 | $options->contextarea = $contextarea; |
95 | $options->courseid = $course->id; | ||
96 | |||
92 | $count = $manager->count_mynotes($options); | 97 | $count = $manager->count_mynotes($options); |
93 | $notes = $manager->get_mynotes($options); | 98 | $notes = $manager->get_mynotes($options); |
94 | echo json_encode(array('notes' => $notes, 'count' => $count)); | 99 | |
100 | if (empty($notes)){ | ||
101 | $count=0; | ||
102 | |||
103 | echo json_encode(array('notes' => $notes, 'count' => $count)); | ||
104 | } | ||
105 | else{ | ||
106 | echo json_encode(array('notes' => $notes, 'count' => $count)); | ||
107 | |||
108 | } | ||
109 | |||
95 | die(); | 110 | die(); |
96 | break; | 111 | break; |
97 | case 'delete': | 112 | case 'delete': |
... | @@ -101,12 +116,17 @@ switch ($action) { | ... | @@ -101,12 +116,17 @@ switch ($action) { |
101 | if ($manager->delete($noteid)) { | 116 | if ($manager->delete($noteid)) { |
102 | $options = new stdClass(); | 117 | $options = new stdClass(); |
103 | $options->page = $page; | 118 | $options->page = $page; |
119 | $options->contextid = $context->id; | ||
104 | $options->contextarea = $contextarea; | 120 | $options->contextarea = $contextarea; |
121 | $options->courseid = $course->id; | ||
105 | $count = $manager->count_mynotes($options); | 122 | $count = $manager->count_mynotes($options); |
123 | |||
106 | if ($limitfrom) { | 124 | if ($limitfrom) { |
107 | $options->limitfrom = $limitfrom - 1; | 125 | $options->limitfrom = $limitfrom - 1; |
108 | } | 126 | } |
109 | $notes = $manager->get_mynotes($options); | 127 | $notes = $manager->get_mynotes($options); |
128 | |||
129 | |||
110 | echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid)); | 130 | echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid)); |
111 | } | 131 | } |
112 | die(); | 132 | die(); | ... | ... |
-
Please register or sign in to post a comment