Skip to content
Permalink
Browse files

精简文章目录

  • Loading branch information...
mikukonai committed Mar 16, 2019
1 parent 0601310 commit 08530f10892824e0029c4dc6d4a8f590423be4ab
Binary file not shown.
@@ -167,8 +167,9 @@
function getTypeColor(type) {
const TYPE_COLOR = {
"原创":"#9dd9ff",
"翻译":"pink",
"翻译":"orange",
"转载":"#aadd33",
"置顶":"pink",
};
return (type in TYPE_COLOR) ? TYPE_COLOR[type] : '#cccdcd';
}
@@ -185,7 +186,7 @@
let item = CONTENTS.ARTICLES[i];
let flagSpan = (item.flag.length > 0) ? ('<span class="articles_item_flag">' + item.flag + '</span>') : '';
// 先组装HTML
let itemNumberBgColor = (item.top) ? 'orange' : getTypeColor(item.type);
let itemNumberBgColor = (item.top) ? getTypeColor('置顶') : getTypeColor(item.type);
let itemTypeTag = (item.top) ? '置顶' : item.type;
let htmlstr = `<div class="articles_item_line enter"><span class="articles_item_number" style="color:${itemNumberBgColor};border-color:${itemNumberBgColor};">${addPreZero(i+1)}</span><span style="display:inline-block;max-width:50%;"><a class="article_link" href="${item.link}">${item.title}</a>${flagSpan}</span><span class="articles_item_date"><span style="color:${itemNumberBgColor};">${itemTypeTag}</span> · ${item.date}</span></div>`;
@@ -208,7 +209,7 @@
for(let i = 0; i < indexArray.length; i++) {
let item = CONTENTS.ARTICLES[indexArray[i]];
let flagSpan = (item.flag.length > 0) ? ('<span class="articles_item_flag">' + item.flag + '</span>') : '';
let itemNumberBgColor = (item.top) ? 'orange' : getTypeColor(item.type);
let itemNumberBgColor = (item.top) ? getTypeColor('置顶') : getTypeColor(item.type);
let itemTypeTag = (item.top) ? '置顶' : item.type;
html += `<div class="articles_item_line enter"><span class="articles_item_number" style="color:${itemNumberBgColor};border-color:${itemNumberBgColor};">${addPreZero(i+1)}</span><span style="display:inline-block;max-width:50%;"><a class="article_link" href="${item.link}">${item.title}</a>${flagSpan}</span><span class="articles_item_date"><span style="color:${itemNumberBgColor};">${itemTypeTag}</span> · ${item.date}</span></div>`;
}
@@ -7,17 +7,17 @@ function stringToBlocks(str, highlightIndex, divId) {
let html = '';
for(let i = 0; i < str.length; i++) {
if(i <= highlightIndex) {
html += `<span class="charblock highlight">${str[i]}</span>`;
html += `<span class="edit_distance_charblock edit_distance_highlight">${str[i]}</span>`;
}
else {
html += `<span class="charblock">${str[i]}</span>`;
html += `<span class="edit_distance_charblock">${str[i]}</span>`;
}
}
document.getElementById(divId).innerHTML = html;
}

function showMatrix(mat, highlightX, highlightY, str1, str2, divId) {
let html = `<table><tr><td>&nbsp;</td><td>.</td>`;
let html = `<table class="edit_distance_table"><tr><td>&nbsp;</td><td>.</td>`;
for(let c = 0; c < str2.length; c++) {
html += `<td>${str2[c]}</td>`;
}
@@ -28,7 +28,7 @@ function showMatrix(mat, highlightX, highlightY, str1, str2, divId) {
html += `<tr><td>${(str1[i-1]===undefined)?'.':str1[i-1]}</td>`;
for(let j = 0; j < line.length; j++) {
if(j === highlightX && i === highlightY) {
html += `<td class="highlight">${line[j]}</td>`;
html += `<td class="edit_distance_highlight">${line[j]}</td>`;
}
else {
html += `<td>${line[j]}</td>`;
@@ -107,28 +107,3 @@ LevenshteinDistance.prototype = {
this.gen.next();
},
};


window.onload = function() {
let editDistance = null;
let initFlag = false;
document.getElementById('auto').addEventListener('click', ()=> {
let argv = new Array();
argv[0] = document.getElementById('input1').value;
argv[1] = document.getElementById('input2').value;
let editDistance = new LevenshteinDistance(argv[0], argv[1]);
editDistance.auto();
});

document.getElementById('step').addEventListener('click', ()=> {
let argv = new Array();
argv[0] = document.getElementById('input1').value;
argv[1] = document.getElementById('input2').value;
if(!initFlag) {
initFlag = true;
editDistance = new LevenshteinDistance(argv[0], argv[1]);
}
editDistance.step();
});

}
Oops, something went wrong.

0 comments on commit 08530f1

Please sign in to comment.
You can’t perform that action at this time.