Add more comments in the code and remove unused code file

This commit is contained in:
Wu Cheng-Han 2016-10-10 20:48:56 +08:00
parent e4b40d11a2
commit b54b3cbe69
2 changed files with 3 additions and 45 deletions

View file

@ -518,13 +518,16 @@ function disconnect(socket) {
var noteId = socket.noteId; var noteId = socket.noteId;
var note = notes[noteId]; var note = notes[noteId];
if (note) { if (note) {
// delete user in users
delete note.users[socket.id]; delete note.users[socket.id];
// remove sockets in the note socks
do { do {
var index = note.socks.indexOf(socket); var index = note.socks.indexOf(socket);
if (index != -1) { if (index != -1) {
note.socks.splice(index, 1); note.socks.splice(index, 1);
} }
} while (index != -1); } while (index != -1);
// remove note in notes if no user inside
if (Object.keys(note.users).length <= 0) { if (Object.keys(note.users).length <= 0) {
if (note.server.isDirty) { if (note.server.isDirty) {
updateNote(note, function (err, _note) { updateNote(note, function (err, _note) {

View file

@ -1,45 +0,0 @@
//parse Youtube
result.find(".youtube").each(function (key, value) {
if (!$(value).attr('videoid')) return;
setSizebyAttr(this, this);
var icon = '<i class="icon fa fa-youtube-play fa-5x"></i>';
$(this).append(icon);
var videoid = $(value).attr('videoid');
var thumbnail_src = '//img.youtube.com/vi/' + videoid + '/hqdefault.jpg';
$(value).css('background-image', 'url(' + thumbnail_src + ')');
$(this).click(function () {
imgPlayiframe(this, '//www.youtube.com/embed/');
});
});
//parse vimeo
result.find(".vimeo").each(function (key, value) {
if (!$(value).attr('videoid')) return;
setSizebyAttr(this, this);
var icon = '<i class="icon fa fa-vimeo-square fa-5x"></i>';
$(this).append(icon);
var videoid = $(value).attr('videoid');
$.ajax({
type: 'GET',
url: 'http://vimeo.com/api/v2/video/' + videoid + '.json',
jsonp: 'callback',
dataType: 'jsonp',
success: function (data) {
var thumbnail_src = data[0].thumbnail_large;
$(value).css('background-image', 'url(' + thumbnail_src + ')');
}
});
$(this).click(function () {
imgPlayiframe(this, '//player.vimeo.com/video/');
});
});
//todo list
var lis = result[0].getElementsByTagName('li');
for (var i = 0; i < lis.length; i++) {
var html = lis[i].innerHTML;
if (/^\s*\[[x ]\]\s*/.test(html)) {
lis[i].innerHTML = html.replace(/^\s*\[ \]\s*/, '<input type="checkbox" class="task-list-item-checkbox" disabled>')
.replace(/^\s*\[x\]\s*/, '<input type="checkbox" class="task-list-item-checkbox" checked disabled>');
lis[i].setAttribute('class', 'task-list-item');
}
}