1/** 2 * @param apiUrl 3 * @param fileHashSelector 4 * @param payload 5 * @constructor 6 */ 7function VideoWatched(apiUrl, fileHashSelector, payload) { 8 var files = {}; 9 this.apiUrl = apiUrl; 10 this.payload = payload; 11 12 $(fileHashSelector).each(function (i, item) { 13 var el = $(item); 14 var vhFilesStr = item.getAttribute('data-vh-files'); 15 var lessonId = el.data('lesson-id'); 16 if (lessonId > 0 && vhFilesStr && vhFilesStr.length > 0) { 17 var gcFileIds = vhFilesStr.split(','); 18 for (i in gcFileIds) { 19 var gcFileId = gcFileIds[i]; 20 if (gcFileId && gcFileId.length > 0) { 21 if (!files[lessonId]) { 22 files[lessonId] = []; 23 } 24 files[lessonId].push(gcFileId); 25 } 26 } 27 } 28 }); 29 30 this.files = files; 31} 32 33VideoWatched.prototype.updateStatuses = function (watchedVideo) { 34 const self = this; 35 const watchedHashes = watchedVideo.map(item => { 36 return item.gc_file_id; 37 }); 38 for (let file of Object.entries(self.files)) { 39 const lessonId = file[0]; 40 let isWatched = watchedVideo.length > 0; 41 42 file[1].forEach(local_hash => { 43 var localGcFileId = parseInt(local_hash, 10); 44 if (!watchedHashes.includes(localGcFileId)) { 45 isWatched = false; 46 } 47 }); 48 49 if (isWatched) { 50 $(`[data-lesson-id=${lessonId}]`).addClass('lesson-list_watched'); 51 } 52 } 53}; 54 55VideoWatched.prototype.checkWatched = function () { 56 const self = this; 57 $.ajax({ 58 url: this.apiUrl, 59 method: 'POST', 60 data: {json: this.payload} 61 } 62 ).done(function (data) { 63 self.updateStatuses(data); 64 }).fail(function (data, status) { 65 console.log('error--', data, status); 66 }); 67}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.