Merge branch 'master' into webpack-frontend

This commit is contained in:
Yukai Huang 2016-10-11 18:39:15 +08:00
commit 6e651c8108
527 changed files with 2584 additions and 601 deletions

View file

@ -1,20 +1,18 @@
var config = require('./config');
var domain = config.domain; // domain name
var urlpath = config.urlpath; // sub url path, like: www.example.com/<urlpath>
var debug = config.debug;
var GOOGLE_API_KEY = config.GOOGLE_API_KEY;
var GOOGLE_CLIENT_ID = config.GOOGLE_CLIENT_ID;
var DROPBOX_APP_KEY = config.DROPBOX_APP_KEY;
//common
var domain = ''; // domain name
var urlpath = ''; // sub url path, like: www.example.com/<urlpath>
//settings
var debug = false;
var GOOGLE_API_KEY = '';
var GOOGLE_CLIENT_ID = '';
var DROPBOX_APP_KEY = '';
var port = window.location.port;
var serverurl = window.location.protocol + '//' + (domain ? domain : window.location.hostname) + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : '');
var noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1];
var noteurl = serverurl + '/' + noteid;
var version = '0.4.4';
var version = '0.4.5';
var checkAuth = false;
var profile = null;

View file

@ -0,0 +1,19 @@
//config
var domain = ''; // domain name
var urlpath = ''; // sub url path, like: www.example.com/<urlpath>
//settings
var debug = false;
var GOOGLE_API_KEY = '';
var GOOGLE_CLIENT_ID = '';
var DROPBOX_APP_KEY = '';
module.exports = {
domain: domain,
urlpath: urlpath,
debug: debug,
GOOGLE_API_KEY: GOOGLE_API_KEY,
GOOGLE_CLIENT_ID: GOOGLE_CLIENT_ID,
DROPBOX_APP_KEY: DROPBOX_APP_KEY
};

View file

@ -35,7 +35,11 @@ var options = {
</div>\
</div>\
</a>\
</li>'
</li>',
page: 18,
plugins: [
ListPagination({})
]
};
var historyList = new List('history', options);
@ -183,19 +187,32 @@ function parseHistoryCallback(list, notehistory) {
pinned = false;
item._values.pinned = false;
}
getHistory(function (notehistory) {
for(var i = 0; i < notehistory.length; i++) {
if (notehistory[i].id == id) {
notehistory[i].pinned = pinned;
break;
}
}
saveHistory(notehistory);
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
});
checkIfAuth(function () {
postHistoryToServer(id, {
pinned: pinned
}, function (err, result) {
if (!err) {
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
}
});
}, function () {
getHistory(function (notehistory) {
for(var i = 0; i < notehistory.length; i++) {
if (notehistory[i].id == id) {
notehistory[i].pinned = pinned;
break;
}
}
saveHistory(notehistory);
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
});
})
});
buildTagsFilter(filtertags);
}
@ -216,23 +233,40 @@ var clearHistory = false;
var deleteId = null;
function deleteHistory() {
if (clearHistory) {
saveHistory([]);
historyList.clear();
checkHistoryList();
deleteId = null;
} else {
if (!deleteId) return;
getHistory(function (notehistory) {
var newnotehistory = removeHistory(deleteId, notehistory);
saveHistory(newnotehistory);
historyList.remove('id', deleteId);
checkIfAuth(function () {
deleteServerHistory(deleteId, function (err, result) {
if (!err) {
if (clearHistory) {
historyList.clear();
checkHistoryList();
} else {
historyList.remove('id', deleteId);
checkHistoryList();
}
}
$('.delete-modal').modal('hide');
deleteId = null;
clearHistory = false;
});
}, function () {
if (clearHistory) {
saveHistory([]);
historyList.clear();
checkHistoryList();
deleteId = null;
});
}
$('.delete-modal').modal('hide');
clearHistory = false;
} else {
if (!deleteId) return;
getHistory(function (notehistory) {
var newnotehistory = removeHistory(deleteId, notehistory);
saveHistory(newnotehistory);
historyList.remove('id', deleteId);
checkHistoryList();
deleteId = null;
});
}
$('.delete-modal').modal('hide');
clearHistory = false;
});
}
$(".ui-delete-modal-confirm").click(function () {

View file

@ -12,6 +12,7 @@ var lastchangeui = {
user: $(".ui-lastchangeuser"),
nouser: $(".ui-no-lastchangeuser")
}
var ownerui = $(".ui-owner");
function updateLastChange() {
if (!lastchangeui) return;
@ -46,6 +47,23 @@ function updateLastChangeUser() {
}
}
var owner = null;
var ownerprofile = null;
function updateOwner() {
if (ownerui) {
if (owner && ownerprofile && owner !== lastchangeuser) {
var icon = ownerui.children('i');
icon.attr('title', ownerprofile.name).tooltip('fixTitle');
var styleString = 'background-image:url(' + ownerprofile.photo + ')';
if (ownerprofile.photo && icon.attr('style') !== styleString)
icon.attr('style', styleString);
ownerui.show();
} else {
ownerui.hide();
}
}
}
//get title
function getTitle(view) {
var title = "";
@ -426,6 +444,33 @@ function finishView(view) {
height: '400px'
});
});
//syntax highlighting
view.find("pre.raw").removeClass("raw")
.each(function (key, value) {
var langDiv = $(value).find('code.hljs');
if (langDiv.length > 0) {
var reallang = langDiv[0].className.replace('hljs', '').trim();
var codeDiv = $(value).find('.code');
var code = "";
if (codeDiv.length > 0) code = codeDiv.html();
else code = langDiv.html();
code = md.utils.unescapeAll(code);
if (reallang == "tiddlywiki" || reallang == "mediawiki") {
var result = {
value: Prism.highlight(code, Prism.languages.wiki)
};
} else {
var languages = hljs.listLanguages();
if (languages.indexOf(reallang) == -1) {
var result = hljs.highlightAuto(code);
} else {
var result = hljs.highlight(reallang, code);
}
}
if (codeDiv.length > 0) codeDiv.html(result.value);
else langDiv.html(result.value);
}
});
//render title
document.title = renderTitle(view);
}
@ -766,19 +811,9 @@ function highlightRender(code, lang) {
} else if (lang == 'mermaid') {
return '<div class="mermaid raw">' + code + '</div>';
}
var reallang = lang.replace(/\=$|\=\d+$|\=\+$/, '');
if (reallang == "tiddlywiki" || reallang == "mediawiki") {
var result = {
value: Prism.highlight(code, Prism.languages.wiki)
};
} else {
var languages = hljs.listLanguages();
if (languages.indexOf(reallang) == -1) {
var result = hljs.highlightAuto(code);
} else {
var result = hljs.highlight(reallang, code);
}
}
var result = {
value: code
};
var showlinenumbers = /\=$|\=\d+$|\=\+$/.test(lang);
if (showlinenumbers) {
var startnumber = 1;
@ -878,7 +913,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
return highlighted + '\n';
}
return '<pre><code' + self.renderAttrs(token) + '>'
return '<pre class="raw"><code' + self.renderAttrs(token) + '>'
+ highlighted
+ '</code></pre>\n';
};
@ -1050,5 +1085,6 @@ module.exports = {
renderFilename: renderFilename,
generateToc: generateToc,
smoothHashScroll: smoothHashScroll,
scrollToHash: scrollToHash
scrollToHash: scrollToHash,
owner: owner
};

View file

@ -58,7 +58,7 @@ function saveHistoryToStorage(notehistory) {
if (store.enabled)
store.set('notehistory', JSON.stringify(notehistory));
else
saveHistoryToStorage(notehistory);
saveHistoryToCookie(notehistory);
}
function saveHistoryToCookie(notehistory) {
@ -107,8 +107,8 @@ function clearDuplicatedHistory(notehistory) {
var id = notehistory[i].id.replace(/\=+$/, '');
var newId = newnotehistory[j].id.replace(/\=+$/, '');
if (id == newId || notehistory[i].id == newnotehistory[j].id || !notehistory[i].id || !newnotehistory[j].id) {
var time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a');
var newTime = moment(newnotehistory[j].time, 'MMMM Do YYYY, h:mm:ss a');
var time = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
var newTime = (typeof newnotehistory[i].time === 'number' ? moment(newnotehistory[i].time) : moment(newnotehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
if(time >= newTime) {
newnotehistory[j] = notehistory[i];
}
@ -150,7 +150,8 @@ function removeHistory(id, notehistory) {
function writeHistory(view) {
checkIfAuth(
function () {
writeHistoryToServer(view);
// no need to do this anymore, this will count from server-side
// writeHistoryToServer(view);
},
function () {
writeHistoryToStorage(view);
@ -176,8 +177,8 @@ function writeHistoryToServer(view) {
var newnotehistory = generateHistory(view, notehistory);
saveHistoryToServer(newnotehistory);
})
.fail(function () {
writeHistoryToStorage(view);
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
});
}
@ -257,7 +258,7 @@ function renderHistory(view) {
return {
id: id,
text: title,
time: moment().format('MMMM Do YYYY, h:mm:ss a'),
time: moment().valueOf(),
tags: tags
};
}
@ -297,8 +298,8 @@ function getServerHistory(callback) {
callback(data.history);
}
})
.fail(function () {
getStorageHistory(callback);
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
});
}
@ -338,8 +339,8 @@ function parseServerToHistory(list, callback) {
parseToHistory(list, data.history, callback);
}
})
.fail(function () {
parseStorageToHistory(list, callback);
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
});
}
@ -368,9 +369,10 @@ function parseToHistory(list, notehistory, callback) {
else if (notehistory && notehistory.length > 0) {
for (var i = 0; i < notehistory.length; i++) {
//parse time to timestamp and fromNow
notehistory[i].timestamp = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').valueOf();
notehistory[i].fromNow = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').fromNow();
notehistory[i].time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').format('llll');
var timestamp = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
notehistory[i].timestamp = timestamp.valueOf();
notehistory[i].fromNow = timestamp.fromNow();
notehistory[i].time = timestamp.format('llll');
if (notehistory[i].id && list.get('id', notehistory[i].id).length == 0)
list.add(notehistory[i]);
}
@ -378,6 +380,31 @@ function parseToHistory(list, notehistory, callback) {
callback(list, notehistory);
}
function postHistoryToServer(noteId, data, callback) {
$.post(serverurl + '/history/' + noteId, data)
.done(function (result) {
return callback(null, result);
})
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
return callback(error, null);
});
}
function deleteServerHistory(noteId, callback) {
$.ajax({
url: serverurl + '/history' + (noteId ? '/' + noteId : ""),
type: 'DELETE'
})
.done(function (result) {
return callback(null, result);
})
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
return callback(error, null);
});
}
module.exports = {
writeHistory: writeHistory,
parseHistory: parseHistory,
@ -385,5 +412,7 @@ module.exports = {
getHistory: getHistory,
saveHistory: saveHistory,
removeHistory: removeHistory,
parseStorageToHistory: parseStorageToHistory
parseStorageToHistory: parseStorageToHistory,
postHistoryToServer: postHistoryToServer,
deleteServerHistory: deleteServerHistory
}

View file

@ -62,6 +62,7 @@ var renderTOC = extra.renderTOC;
var renderTitle = extra.renderTitle;
var renderFilename = extra.renderFilename;
var scrollToHash = extra.scrollToHash;
var owner = extra.owner;
var historyModule = require('./history');
var writeHistory = historyModule.writeHistory;
@ -72,6 +73,7 @@ var preventXSS = renderer.preventXSS;
var defaultTextHeight = 20;
var viewportMargin = 20;
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
var defaultEditorMode = 'gfm';
var defaultExtraKeys = {
"F10": function (cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
@ -214,7 +216,7 @@ var cursorMenuThrottle = 50;
var cursorActivityDebounce = 50;
var cursorAnimatePeriod = 100;
var supportContainers = ['success', 'info', 'warning', 'danger'];
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
var supportHeaders = [
{
@ -430,8 +432,8 @@ window.fileTypes = {
var textit = document.getElementById("textit");
if (!textit) throw new Error("There was no textit area!");
window.editor = CodeMirror.fromTextArea(textit, {
mode: 'gfm',
backdrop: 'gfm',
mode: defaultEditorMode,
backdrop: defaultEditorMode,
keyMap: "sublime",
viewportMargin: viewportMargin,
styleActiveLine: true,
@ -440,7 +442,6 @@ window.editor = CodeMirror.fromTextArea(textit, {
showCursorWhenSelecting: true,
highlightSelectionMatches: true,
indentUnit: 4,
indentWithTabs: true,
continueComments: "Enter",
theme: "one-dark",
inputStyle: "textarea",
@ -675,7 +676,7 @@ function setSpellcheck() {
if (cookieSpellcheck === 'true' || cookieSpellcheck === true) {
mode = 'spell-checker';
} else {
mode = 'gfm';
mode = defaultEditorMode;
}
if (mode && mode !== editor.getOption('mode')) {
editor.setOption('mode', mode);
@ -685,10 +686,10 @@ function setSpellcheck() {
var spellcheckToggle = statusSpellcheck.find('.ui-spellcheck-toggle');
spellcheckToggle.click(function () {
var mode = editor.getOption('mode');
if (mode == "gfm") {
if (mode == defaultEditorMode) {
mode = "spell-checker";
} else {
mode = "gfm";
mode = defaultEditorMode;
}
if (mode && mode !== editor.getOption('mode')) {
editor.setOption('mode', mode);
@ -700,7 +701,7 @@ function setSpellcheck() {
});
function checkSpellcheck() {
var mode = editor.getOption('mode');
if (mode == "gfm") {
if (mode == defaultEditorMode) {
spellcheckToggle.removeClass('active');
} else {
spellcheckToggle.addClass('active');
@ -748,7 +749,18 @@ function updateStatusBar() {
statusCursor.text(cursorText);
var fileText = ' — ' + editor.lineCount() + ' Lines';
statusFile.text(fileText);
statusLength.text('Length ' + editor.getValue().length);
var docLength = editor.getValue().length;
statusLength.text('Length ' + docLength);
if (docLength > (docmaxlength * 0.95)) {
statusLength.css('color', 'red');
statusLength.attr('title', 'Your almost reach note max length limit.');
} else if (docLength > (docmaxlength * 0.8)) {
statusLength.css('color', 'orange');
statusLength.attr('title', 'You nearly fill the note, consider to make more pieces.');
} else {
statusLength.css('color', 'white');
statusLength.attr('title', 'You could write up to ' + docmaxlength + ' characters in this note.');
}
}
//ui vars
@ -800,7 +812,8 @@ var ui = {
editable: $(".ui-permission-editable"),
locked: $(".ui-permission-locked"),
private: $(".ui-permission-private")
}
},
delete: $(".ui-delete-note")
},
toc: {
toc: $('.ui-toc'),
@ -989,7 +1002,7 @@ $(window).resize(function () {
});
//when page unload
$(window).on('unload', function () {
updateHistoryInner();
//updateHistoryInner();
});
$(window).on('error', function () {
//setNeedRefresh();
@ -1817,7 +1830,7 @@ function initRevisionViewer() {
if (revisionViewer) return;
var revisionViewerTextArea = document.getElementById("revisionViewer");
revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, {
mode: 'gfm',
mode: defaultEditorMode,
viewportMargin: viewportMargin,
lineNumbers: true,
lineWrapping: true,
@ -2175,6 +2188,13 @@ ui.infobar.permission.locked.click(function () {
ui.infobar.permission.private.click(function () {
emitPermission("private");
});
// delete note
ui.infobar.delete.click(function () {
$('.delete-modal').modal('show');
});
$('.ui-delete-modal-confirm').click(function () {
socket.emit('delete');
});
function emitPermission(_permission) {
if (_permission != permission) {
@ -2263,24 +2283,30 @@ socket.on('info', function (data) {
console.error(data);
switch (data.code) {
case 403:
location.href = "./403";
location.href = serverurl + "/403";
break;
case 404:
location.href = "./404";
location.href = serverurl + "/404";
break;
case 500:
location.href = "./500";
location.href = serverurl + "/500";
break;
}
});
socket.on('error', function (data) {
console.error(data);
if (data.message && data.message.indexOf('AUTH failed') === 0)
location.href = "./403";
location.href = serverurl + "/403";
});
socket.on('delete', function () {
deleteServerHistory(noteid, function (err, data) {
if (!err) location.href = serverurl;
});
});
var retryOnDisconnect = false;
var retryTimer = null;
socket.on('maintenance', function () {
cmClient.revision = -1;
retryOnDisconnect = true;
});
socket.on('disconnect', function (data) {
@ -2310,8 +2336,6 @@ socket.on('connect', function (data) {
personalInfo['id'] = socket.id;
showStatus(statusType.connected);
socket.emit('version');
if (socket.id.indexOf('/') == -1)
socket.id = socket.nsp + '#' + socket.id;
});
socket.on('version', function (data) {
if (version != data.version) {
@ -2328,7 +2352,7 @@ var authorship = [];
var authorshipMarks = {};
var authorMarks = {}; // temp variable
var addTextMarkers = []; // temp variable
function updateLastInfo(data) {
function updateInfo(data) {
//console.log(data);
if (data.hasOwnProperty('createtime') && createtime !== data.createtime) {
createtime = data.createtime;
@ -2338,10 +2362,16 @@ function updateLastInfo(data) {
lastchangetime = data.updatetime;
updateLastChange();
}
if (data.hasOwnProperty('owner') && owner !== data.owner) {
owner = data.owner;
ownerprofile = data.ownerprofile;
updateOwner();
}
if (data.hasOwnProperty('lastchangeuser') && lastchangeuser !== data.lastchangeuser) {
lastchangeuser = data.lastchangeuser;
lastchangeuserprofile = data.lastchangeuserprofile;
updateLastChangeUser();
updateOwner();
}
if (data.hasOwnProperty('authors') && authors !== data.authors) {
authors = data.authors;
@ -2391,7 +2421,7 @@ var addStyleRule = (function () {
}());
function updateAuthorshipInner() {
// ignore when ot not synced yet
if (Object.keys(cmClient.state).length > 0) return;
if (cmClient && Object.keys(cmClient.state).length > 0) return;
authorMarks = {};
for (var i = 0; i < authorship.length; i++) {
var atom = authorship[i];
@ -2556,14 +2586,12 @@ socket.on('check', function (data) {
data = LZString.decompressFromUTF16(data);
data = JSON.parse(data);
//console.log(data);
updateLastInfo(data);
updateInfo(data);
});
socket.on('permission', function (data) {
updatePermission(data.permission);
});
var docmaxlength = null;
var otk = null;
var owner = null;
var permission = null;
socket.on('refresh', function (data) {
data = LZString.decompressFromUTF16(data);
@ -2571,10 +2599,8 @@ socket.on('refresh', function (data) {
//console.log(data);
docmaxlength = data.docmaxlength;
editor.setOption("maxLength", docmaxlength);
otk = data.otk;
owner = data.owner;
updateInfo(data);
updatePermission(data.permission);
updateLastInfo(data);
if (!loaded) {
// auto change mode if no content detected
var nocontent = editor.getValue().length <= 0;
@ -2617,16 +2643,14 @@ socket.on('doc', function (obj) {
obj = LZString.decompressFromUTF16(obj);
obj = JSON.parse(obj);
var body = obj.str;
var bodyMismatch = (editor.getValue() != body);
var bodyMismatch = editor.getValue() !== body;
var setDoc = !cmClient || (cmClient && cmClient.revision === -1) || obj.force;
saveInfo();
if (bodyMismatch) {
if (cmClient)
cmClient.editorAdapter.ignoreNextChange = true;
if (body)
editor.setValue(body);
else
editor.setValue("");
if (setDoc && bodyMismatch) {
if (cmClient) cmClient.editorAdapter.ignoreNextChange = true;
if (body) editor.setValue(body);
else editor.setValue("");
}
if (!loaded) {
@ -2635,12 +2659,8 @@ socket.on('doc', function (obj) {
ui.content.fadeIn();
} else {
//if current doc is equal to the doc before disconnect
if (bodyMismatch)
editor.clearHistory();
else {
if (lastInfo.history)
editor.setHistory(lastInfo.history);
}
if (setDoc && bodyMismatch) editor.clearHistory();
else if (lastInfo.history) editor.setHistory(lastInfo.history);
lastInfo.history = null;
}
@ -2649,7 +2669,7 @@ socket.on('doc', function (obj) {
obj.revision, obj.clients,
new SocketIOAdapter(socket), new CodeMirrorAdapter(editor)
);
} else {
} else if (setDoc) {
if (bodyMismatch) {
cmClient.undoManager.undoStack.length = 0;
cmClient.undoManager.redoStack.length = 0;
@ -2660,7 +2680,7 @@ socket.on('doc', function (obj) {
cmClient.initializeClients(obj.clients);
}
if (bodyMismatch) {
if (setDoc && bodyMismatch) {
isDirty = true;
updateView();
}

View file

@ -78,7 +78,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
if (tokens[idx].map && tokens[idx].level === 0) {
var startline = tokens[idx].map[0] + 1;
var endline = tokens[idx].map[1];
return '<pre class="part" data-startline="' + startline + '" data-endline="' + endline + '"><code' + self.renderAttrs(token) + '>'
return '<pre class="part raw" data-startline="' + startline + '" data-endline="' + endline + '"><code' + self.renderAttrs(token) + '>'
+ highlighted
+ '</code></pre>\n';
}

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');
}
}