',
'' + getMsg('restoreFromThisVersion') + '',
'',
'
',
'',
'/** * @file 历史记录 * @author life * */ define('history', [], function() { var tpl = ['
'].join(''); var $tpl = $(tpl); var $historyContent = $tpl.find('.history-content'); var $historyList = $tpl.find('.history-list'); var $historyNum = $tpl.find('.history-num'); var view = { note: null, list: [], curIndex: 0, renderContent: function (i) { var content = this.list[i].Content; this.curIndex = i; var wrap = ''; wrapEnd = ''; content = trimTitle(content) // for xss } $historyContent.html(wrap + content + wrapEnd); var as = $historyList.find('a'); as.removeClass('active'); as.eq(i).addClass('active'); }, render: function (list) { var navs = ''; this.list = list; if (list) { for(var i = 0; i < list.length; ++i) { var content = list[i]; navs += '#' + (i+1)+ '' + goNowToDatetime(content.UpdatedTime) + ''; } } $historyList.html(navs); this.renderContent(0); $historyNum.html(list.length); // show $tpl.modal({show: true}); }, bind: function () { var me = this; $("#contentHistory").click(function() { me.getHistories(); }); $historyList.on('click', 'a', function () { var index = $(this).data('index'); me.renderContent(index); }); // 还原 $tpl.find('.back').click(function() { if(confirm(getMsg("confirmBackup"))) { // 保存当前版本 Note.curChangedSaveIt(true); // 设置之 note = Note.cache[Note.curNoteId]; setEditorContent(me.list[me.curIndex].Content, note.IsMarkdown); $tpl.modal('hide'); // 保存 Note.curChangedSaveIt(true); } }); }, getHistories: function () { var me = this; var note = Note.getCurNote(); me.note = note; ajaxGet("/noteContentHistory/listHistories", {noteId: Note.curNoteId}, function(re) { if(!isArray(re)) { alert(getMsg('noHistories')); return; } me.render(re); return; // 组装成一个tab var str = "
" + getMsg("historiesNum") + '
#' + (i+1) +'<' + s + ' class="each-content">' + content.Ab + '' + s + '> ' + getMsg("datetime") + ': ' + goNowToDatetime(content.UpdatedTime) + ' |