mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
history of all recent files. display path if filename is the same.
This commit is contained in:
@@ -83,7 +83,8 @@ body {
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
margin-left: 5px;
|
||||
width: 200px;
|
||||
overflow: hidden;
|
||||
width: 310px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@@ -145,6 +146,7 @@ body {
|
||||
font-weight: normal;
|
||||
margin: 0px;
|
||||
margin-bottom: 4px;
|
||||
overflow: hidden;
|
||||
padding: 2px 40px 2px 12px;
|
||||
position: relative;
|
||||
}
|
||||
@@ -157,6 +159,23 @@ body {
|
||||
-webkit-transition: background 0s;
|
||||
}
|
||||
|
||||
.menulist .menulistitem .delete {
|
||||
background: url('../img/x.png') center no-repeat;
|
||||
background-size: auto 15px;
|
||||
cursor: default;
|
||||
filter: alpha(opacity=70);
|
||||
height: 10px;
|
||||
opacity: 0.7;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.menulist .menulistitem .delete:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
background-color: #fff;
|
||||
border: 1px solid #d9d9d9;
|
||||
@@ -331,7 +350,6 @@ input[type=text].form-error{
|
||||
padding: 0 10px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 46px;
|
||||
transition: opacity 0.13s;
|
||||
-webkit-transition: opacity 0.13s;
|
||||
white-space: nowrap;
|
||||
@@ -396,6 +414,10 @@ input[type=text].form-error{
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.new-diff {
|
||||
top: 42px;
|
||||
}
|
||||
|
||||
#left-side #prev-chunk {
|
||||
background: url('../img/arrow-up.jpg') center no-repeat;
|
||||
background-size: auto 20px;
|
||||
@@ -408,8 +430,12 @@ input[type=text].form-error{
|
||||
}
|
||||
|
||||
#left-side .tooltip.prev-chunk {
|
||||
left: 13px;
|
||||
top: 105px;
|
||||
left: 0px;
|
||||
top: 110px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.prev-chunk .pointer {
|
||||
left: 23px;
|
||||
}
|
||||
|
||||
#left-side #next-chunk {
|
||||
@@ -423,11 +449,15 @@ input[type=text].form-error{
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.prev-chunk {
|
||||
left: 13px;
|
||||
#left-side .tooltip.next-chunk {
|
||||
left: 0px;
|
||||
top: 135px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.next-chunk .pointer {
|
||||
left: 23px;
|
||||
}
|
||||
|
||||
#left-side #expand-all,
|
||||
#left-side #collapse-all {
|
||||
cursor: pointer;
|
||||
@@ -443,18 +473,26 @@ input[type=text].form-error{
|
||||
}
|
||||
|
||||
#left-side .tooltip.expand-all {
|
||||
top: 65px;
|
||||
top: 73px;
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.expand-all .pointer {
|
||||
left: 15px;
|
||||
}
|
||||
|
||||
#left-side #collapse-all {
|
||||
background: url('../img/minus_all.png') center no-repeat;
|
||||
left: 21px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.collapse-all {
|
||||
top: 65px;
|
||||
left: 23px;
|
||||
top: 73px;
|
||||
left: 18px;
|
||||
}
|
||||
|
||||
#left-side .tooltip.collapse-all .pointer {
|
||||
left: 15px;
|
||||
}
|
||||
|
||||
#left-side #expand-all.disabled,
|
||||
@@ -477,31 +515,31 @@ input[type=text].form-error{
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
#check-container {
|
||||
border-right: 2px solid #666;
|
||||
}
|
||||
|
||||
#arrow-container::-webkit-scrollbar {
|
||||
#arrow-container::-webkit-scrollbar,
|
||||
#check-container::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#arrow-container .arrow {
|
||||
background: url('../img/arrow-right.png') center no-repeat;
|
||||
background-size: auto 95px;
|
||||
background-size: auto 85px;
|
||||
height: 16px;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#check-container .check {
|
||||
background: url('../img/checkmark.png') center no-repeat;
|
||||
background-size: auto 16px;
|
||||
height: 16px;
|
||||
background: url('../img/arrow-left.png') center no-repeat;
|
||||
background-size: auto 85px;
|
||||
height: 20px;
|
||||
margin-left: 5px;
|
||||
margin-bottom: -4px;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#arrow-container .undo,
|
||||
#check-container .undo,
|
||||
#arrow-container .holder {
|
||||
#arrow-container .holder,
|
||||
#check-container .holder {
|
||||
background: url('../img/undo.svg') right no-repeat;
|
||||
height: 16px;
|
||||
opacity: 0;
|
||||
@@ -545,6 +583,11 @@ div.file-name {
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
span.file-name-info {
|
||||
color: #777;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.file-diff,
|
||||
textarea {
|
||||
background: #fff;
|
||||
@@ -563,13 +606,11 @@ textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#file0-container .file-diff::-webkit-scrollbar,
|
||||
#file1-container .file-diff::-webkit-scrollbar {
|
||||
#file0-container .file-diff::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#file0-container .file-diff,
|
||||
#file1-container .file-diff {
|
||||
#file0-container .file-diff {
|
||||
border-right: 1px solid #999;
|
||||
}
|
||||
|
||||
@@ -590,10 +631,16 @@ div.button.save {
|
||||
|
||||
.tooltip.save {
|
||||
right: 0px;
|
||||
top: 39px;
|
||||
}
|
||||
|
||||
.tooltip.save .pointer {
|
||||
left: 43px;
|
||||
}
|
||||
|
||||
.tooltip.edit {
|
||||
right: 55px;
|
||||
top: 39px;
|
||||
}
|
||||
|
||||
div.button.done {
|
||||
@@ -760,6 +807,15 @@ div.button.done {
|
||||
background: none;
|
||||
}
|
||||
|
||||
#file0-container .file-diff div.correct span.ins {
|
||||
display: block;
|
||||
background: none;
|
||||
}
|
||||
|
||||
#file0-container .file-diff div.correct span.del {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.file-diff div.correct span {
|
||||
background: none;
|
||||
}
|
||||
|
||||
BIN
diff/img/arrow-l.jpeg
Normal file
BIN
diff/img/arrow-l.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
diff/img/arrow-r.jpeg
Normal file
BIN
diff/img/arrow-r.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -11,4 +11,8 @@ function onLaunched(launchData) {
|
||||
});
|
||||
}
|
||||
|
||||
chrome.runtime.onInstalled.addListener(function() {
|
||||
chrome.storage.local.set({});
|
||||
});
|
||||
|
||||
chrome.experimental.app.onLaunched.addListener(onLaunched);
|
||||
|
||||
@@ -17,10 +17,10 @@ $(document).ready(function() {
|
||||
var buttons = [ '#new-diff',
|
||||
'#save',
|
||||
'#edit',
|
||||
// '#expand-all',
|
||||
// '#collapse-all',
|
||||
// '#next-chunk',
|
||||
// '#prev-chunk'
|
||||
'#expand-all',
|
||||
'#collapse-all',
|
||||
'#next-chunk',
|
||||
'#prev-chunk'
|
||||
];
|
||||
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
@@ -100,7 +100,7 @@ $(document).ready(function() {
|
||||
function keyboardShortcut(event) {
|
||||
if (event.which == 74)
|
||||
selectNextChunk();
|
||||
else if (event.which == 75)
|
||||
else if (evenjjkt.which == 75)
|
||||
selectPrevChunk();
|
||||
else if ((event.which == 76)
|
||||
&& (selectedChunk > 0) && (selectedChunk <= totalChunks))
|
||||
@@ -129,8 +129,10 @@ function getText(fileNum) {
|
||||
&& !$(lines[i]).hasClass('hidden')) {
|
||||
var line = $(lines[i]).children();
|
||||
for (var j = 0; j < line.length; j++) {
|
||||
if ($(lines[i]).hasClass('left')) {
|
||||
if (!$(line[j]).hasClass('ins'))
|
||||
if ($(lines[i]).hasClass('merged')) {
|
||||
if (fileNum == 1 && !$(line[j]).hasClass('ins'))
|
||||
text += $(line[j]).html();
|
||||
if (fileNum == 0 && !$(line[j]).hasClass('del'))
|
||||
text += $(line[j]).html();
|
||||
} else {
|
||||
if (fileNum == 0 && !$(line[j]).hasClass('ins'))
|
||||
@@ -218,6 +220,12 @@ function computeDiff(file1, file2) {
|
||||
}
|
||||
}
|
||||
|
||||
function patchToFile2(file1, patchText) {
|
||||
var patches = dmp.patch_fromText(patchText);
|
||||
var patchData = dmp.patch_apply(patches, file1);
|
||||
return patchData[0];
|
||||
}
|
||||
|
||||
function createHtmlLines(diffs) {
|
||||
var pattern_amp = /&/g;
|
||||
var pattern_lt = /</g;
|
||||
@@ -334,10 +342,16 @@ function isBlankLine(lineDiv, realLineNum) {
|
||||
} else {
|
||||
var realLine = 'realLine-' + realLineNum;
|
||||
}
|
||||
return ($(lineDiv).hasClass('blank') && !$(lineDiv).hasClass('fix'))
|
||||
return ( $(lineDiv).hasClass('blank')
|
||||
&& !$(lineDiv).hasClass('fix')
|
||||
&& !$(lineDiv).hasClass('correct')
|
||||
)
|
||||
|| ( $(lineDiv).hasClass('fix')
|
||||
&& ($('#file0-container .' + realLine).hasClass('blank'))
|
||||
)
|
||||
|| ( $(lineDiv).hasClass('correct')
|
||||
&& ($('#file1-container .' + realLine).hasClass('blank'))
|
||||
)
|
||||
|| $(lineDiv).hasClass('collapsed-num');
|
||||
}
|
||||
|
||||
@@ -348,7 +362,7 @@ function setLineNums() {
|
||||
var realLineNum = 1;
|
||||
$('.file-diff.' + files[i] + ' > div').each(function() {
|
||||
if (!isBlankLine(this, realLineNum)) {
|
||||
$(this).html('<div class="text right">' + $(this).html() + '</div>');
|
||||
$(this).html('<div class="text orig">' + $(this).html() + '</div>');
|
||||
$(this).prepend('<div class="lineNum">' + lineNum + '</div>');
|
||||
if ($(this).parent().hasClass('0'))
|
||||
$(this).prepend('<div class="expand"></div>');
|
||||
@@ -620,10 +634,10 @@ function moveChunk(chunkNum) {
|
||||
for (var i = 0; i < lines1.length; i++) {
|
||||
var realLineNum = getRealLine(lines1[i]);
|
||||
var text = '';
|
||||
if ($('.file-diff.0 .' + realLineNum).children('.text.right').length > 0)
|
||||
if ($('.file-diff.0 .' + realLineNum).children('.text.orig').length > 0)
|
||||
text = $('.file-diff.0 .' + realLineNum + ' > div.text').html();
|
||||
var div = '<div class="left text">' + text + '</div>';
|
||||
$('.file-diff.1 > .' + realLineNum + ' > .text.right').addClass('hidden');
|
||||
var div = '<div class="merged text">' + text + '</div>';
|
||||
$('.file-diff.1 > .' + realLineNum + ' > .text.orig').addClass('hidden');
|
||||
$('.file-diff.1 > .' + realLineNum).append(div);
|
||||
$('.file-diff.0 > .' + realLineNum).addClass('fix');
|
||||
$('.file-diff.1 > .' + realLineNum).addClass('fix');
|
||||
@@ -650,8 +664,8 @@ function undoMoveChunk(chunkNum) {
|
||||
var lines2 = $('.file-diff.1').children('div.' + chunkNum);
|
||||
for (var i = 0; i < lines1.length; i++) {
|
||||
var lineNum = getRealLine(lines1[i]);
|
||||
$('.file-diff.1 > .' + lineNum + ' > .text.right').removeClass('hidden');
|
||||
$('.file-diff.1 > .' + lineNum + ' > .left').remove();
|
||||
$('.file-diff.1 > .' + lineNum + ' > .text.orig').removeClass('hidden');
|
||||
$('.file-diff.1 > .' + lineNum + ' > .merged').remove();
|
||||
$('.file-diff.0 > .' + lineNum).removeClass('fix');
|
||||
$('.file-diff.1 > .' + lineNum).removeClass('fix');
|
||||
}
|
||||
@@ -677,6 +691,12 @@ function checkRight(chunkNum) {
|
||||
var lines2 = $('.file-diff.1').children('div.' + chunkNum);
|
||||
for (var i = 0; i < lines1.length; i++) {
|
||||
var realLineNum = getRealLine(lines1[i]);
|
||||
var text = '';
|
||||
if ($('.file-diff.1 .' + realLineNum).children('.text.orig').length > 0)
|
||||
text = $('.file-diff.1 .' + realLineNum + ' > div.text').html();
|
||||
var div = '<div class="merged text">' + text + '</div>';
|
||||
$('.file-diff.0 > .' + realLineNum + ' > .text.orig').addClass('hidden');
|
||||
$('.file-diff.0 > .' + realLineNum).append(div);
|
||||
$('.file-diff.0 > .' + realLineNum).addClass('correct');
|
||||
$('.file-diff.1 > .' + realLineNum).addClass('correct');
|
||||
}
|
||||
@@ -690,6 +710,8 @@ function checkRight(chunkNum) {
|
||||
$('#num-diffs').html(numChunks + ' conflict');
|
||||
else
|
||||
$('#num-diffs').html(numChunks + ' conflicts');
|
||||
var text = getText(0);
|
||||
saveFile(text, 'file0.txt');
|
||||
var num = parseInt(chunkNum.slice(6));
|
||||
if (selectedChunk == num)
|
||||
selectNextChunk();
|
||||
@@ -700,6 +722,8 @@ function undoCheckRight(chunkNum) {
|
||||
var lines2 = $('.file-diff.1').children('div.' + chunkNum);
|
||||
for (var i = 0; i < lines1.length; i++) {
|
||||
var lineNum = getRealLine(lines1[i]);
|
||||
$('.file-diff.0 > .' + lineNum + ' > .text.orig').removeClass('hidden');
|
||||
$('.file-diff.0 > .' + lineNum + ' > .merged').remove();
|
||||
$('.file-diff.0 > .' + lineNum).removeClass('correct');
|
||||
$('.file-diff.1 > .' + lineNum).removeClass('correct');
|
||||
}
|
||||
@@ -714,6 +738,8 @@ function undoCheckRight(chunkNum) {
|
||||
$('#num-diffs').html(numChunks + ' conflict');
|
||||
else
|
||||
$('#num-diffs').html(numChunks + ' conflicts');
|
||||
var text = getText(0);
|
||||
saveFile(text, 'file0.txt');
|
||||
var num = parseInt(chunkNum.slice(6));
|
||||
selectChunk(num);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
var FILE_SIZE = 1024 * 1024;
|
||||
var displayNames = [null, null];
|
||||
var paths = [null, null];
|
||||
var paths = {};
|
||||
var fileEntries = [null, null];
|
||||
var texts = [null, null];
|
||||
var urlNum = null;
|
||||
@@ -110,21 +110,34 @@ $(document).ready(function() {
|
||||
|
||||
function registerMenulistitemClicks() {
|
||||
$('li.menulistitem').click(function() {
|
||||
if (!$(this).hasClass('selected')) {
|
||||
var fileNum = $(this).parent().attr('class').split(' ')[1];
|
||||
var fileName = $(this).text();
|
||||
if ($(this).hasClass('choose-new-file')) {
|
||||
var fileNum = parseInt($(this).parent().attr('class').split(' ')[1]);
|
||||
selectFile(fileNum, true);
|
||||
}
|
||||
else if (!$(this).hasClass('selected')) {
|
||||
var fileNum = parseInt($(this).parent().attr('class').split(' ')[1]);
|
||||
var fileName = $(this).children('.file-name').text();
|
||||
$(this).parent().children('li.menulistitem').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
displayNames[fileNum] = fileName;
|
||||
texts[fileNum] = fileHistory[fileName];
|
||||
texts[fileNum] = fileHistory[paths[fileName]];
|
||||
setFileName(fileNum);
|
||||
saveFile(texts[fileNum], 'file' + fileNum + '.txt');
|
||||
saveFile(displayNames[fileNum], 'name' + fileNum + '.txt');
|
||||
submitDiffs();
|
||||
saveFile(paths[displayNames[fileNum]], 'name' + fileNum + '.txt');
|
||||
computeDiff(texts[0], texts[1]);
|
||||
}
|
||||
console.log($('.menulist').hasClass('shown'));
|
||||
console.log($(this).parent().hasClass('shown'));
|
||||
$('.menulist').removeClass('shown');
|
||||
console.log($('.menulist').hasClass('shown'));
|
||||
});
|
||||
|
||||
$('li.menulistitem .delete').click(function() {
|
||||
var name = $(this).parent().children('.file-name').text();
|
||||
var path = paths[name];
|
||||
delete fileHistory[path];
|
||||
chrome.storage.local.set({'fileHistory': fileHistory});
|
||||
$('li.menulistitem').each(function() {
|
||||
if ($(this).children('.file-name').text() == name)
|
||||
$(this).remove();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,11 +152,13 @@ function selectURL() {
|
||||
function(text) {
|
||||
var urlSecs = url.split('/');
|
||||
displayNames[urlNum] = urlSecs[urlSecs.length-1];
|
||||
paths[displayNames[urlNum]] = url;
|
||||
badURL = false;
|
||||
texts[urlNum] = text;
|
||||
rememberFile(fileNum);
|
||||
var name = 'file' + urlNum + '.txt';
|
||||
saveFile(text, name);
|
||||
saveFile(displayNames[urlNum], 'name' + urlNum + '.txt');
|
||||
saveFile(paths[displayNames[urlNum]], 'name' + urlNum + '.txt');
|
||||
},
|
||||
'html'
|
||||
);
|
||||
@@ -152,12 +167,14 @@ function selectURL() {
|
||||
}
|
||||
}
|
||||
|
||||
function selectFile(fileNum) {
|
||||
function selectFile(fileNum, chooseNew) {
|
||||
chrome.fileSystem.chooseFile({'type': 'openFile'}, function(fileEntry) {
|
||||
fileEntries[fileNum] = fileEntry;
|
||||
chrome.fileSystem.getDisplayPath(fileEntry, function(path) {
|
||||
path = path.split('/');
|
||||
displayNames[fileNum] = path[path.length - 1];
|
||||
var pathList = path.split('/');
|
||||
var l = pathList.length - 1;
|
||||
displayNames[fileNum] = pathList[l];
|
||||
paths[displayNames[fileNum]] = path;
|
||||
$('.modal-dialog.new-diff .file-name.' + fileNum).text(displayNames[fileNum]);
|
||||
fileEntries[fileNum].file(function(file) {
|
||||
var reader = new FileReader();
|
||||
@@ -168,8 +185,10 @@ function selectFile(fileNum) {
|
||||
texts[fileNum] = this.result;
|
||||
rememberFile(fileNum);
|
||||
var name = 'file' + fileNum + '.txt';
|
||||
saveFile(this.result, name);
|
||||
saveFile(displayNames[fileNum], 'name' + fileNum + '.txt');
|
||||
saveFile(texts[fileNum], name);
|
||||
saveFile(paths[displayNames[fileNum]], 'name' + fileNum + '.txt');
|
||||
if (chooseNew)
|
||||
chooseNewFile(fileNum);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}, errorHandler);
|
||||
@@ -177,36 +196,89 @@ function selectFile(fileNum) {
|
||||
});
|
||||
}
|
||||
|
||||
function rememberFile(fileNum) {
|
||||
fileHistory[displayNames[fileNum]] = texts[fileNum];
|
||||
$('ul.menulist.' + fileNum + ' .menulistitem').removeClass('selected');
|
||||
$('ul.menulist.' + fileNum).append('<li class="menulistitem selected">'
|
||||
+ displayNames[fileNum] + '</li>');
|
||||
$('ul.menulist.' + ((fileNum + 1) % 2)).append('<li class="menulistitem">'
|
||||
+ displayNames[fileNum] + '</li>');
|
||||
registerMenulistitemClicks();
|
||||
function getExtension(fileName) {
|
||||
var parts = fileName.split('.');
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
|
||||
function selectRememberedFile(fileNum, fileName) {
|
||||
texts[fileNum] = fileHistory[fileName];
|
||||
displayNames[fileNum] = fileName;
|
||||
submitDiffs();
|
||||
function isPatch(fileName) {
|
||||
return getExtension(fileName).toLowerCase() == 'patch';
|
||||
}
|
||||
|
||||
function addToMenulistDisplayed(listNum, displayNum, selected) {
|
||||
var name = displayNames[displayNum];
|
||||
var path = paths[displayNames[displayNum]].split('/').slice(-5, -2).join('/');
|
||||
$('ul.menulist.' + listNum).append(
|
||||
'<li class="menulistitem ' + selected + '">'
|
||||
+ '<span class="file-name">' + name + '</span>'
|
||||
+ '<span class="file-name-info"> - ' + path + '</span>'
|
||||
+ '<span class="delete"></span></li>');
|
||||
}
|
||||
|
||||
function addToMenulist(path) {
|
||||
var pathSecs = path.split('/');
|
||||
var name = pathSecs[pathSecs.length - 1];
|
||||
var displayPath = pathSecs.slice(-5, -2).join('/');
|
||||
paths[name] = path;
|
||||
for (var listNum = 0; listNum < 2; listNum++) {
|
||||
$('ul.menulist.' + listNum).append(
|
||||
'<li class="menulistitem">'
|
||||
+ '<span class="file-name">' + name + '</span>'
|
||||
+ '<span class="file-name-info"> - ' + displayPath + '</span>'
|
||||
+ '<span class="delete"></span></li>');
|
||||
}
|
||||
}
|
||||
|
||||
function setFileName(fileNum) {
|
||||
var name = displayNames[fileNum];
|
||||
var path = paths[displayNames[fileNum]].split('/').slice(-5, -2).join('/');
|
||||
$('#file' + fileNum + '-container .label.file-name').html(
|
||||
'<span class="file-name">' + name + '</span>'
|
||||
+ '<span class="file-name-info"> - ' + path + '</span>');
|
||||
}
|
||||
|
||||
function createDropdown() {
|
||||
for (var i = 0; i < 2; i++) {
|
||||
$('ul.menulist.' + i).append('<li class="menulistitem selected">'
|
||||
+ displayNames[i] + '</li>'
|
||||
+ '<li class="menulistitem">'
|
||||
+ displayNames[((i + 1) % 2)] + '</li>');
|
||||
$('ul.menulist').html('<li class="menulistitem choose-new-file">Choose File</li>');
|
||||
for (path in fileHistory) {
|
||||
if (path == paths[displayNames[0]]) {
|
||||
addToMenulistDisplayed(0, 0, 'selected');
|
||||
addToMenulistDisplayed(0, 1, '');
|
||||
}
|
||||
else if (path == paths[displayNames[1]]) {
|
||||
addToMenulistDisplayed(1, 0, '');
|
||||
addToMenulistDisplayed(1, 1, 'selected');
|
||||
}
|
||||
else {
|
||||
addToMenulist(path);
|
||||
}
|
||||
}
|
||||
registerMenulistitemClicks();
|
||||
}
|
||||
|
||||
function rememberFile(fileNum) {
|
||||
fileHistory[paths[displayNames[fileNum]]] = texts[fileNum];
|
||||
chrome.storage.local.set({'fileHistory': fileHistory});
|
||||
$('ul.menulist.' + fileNum + ' .menulistitem').removeClass('selected');
|
||||
addToMenulistDisplayed(fileNum, fileNum, 'selected');
|
||||
addToMenulistDisplayed(((fileNum + 1) % 2), fileNum, '');
|
||||
registerMenulistitemClicks();
|
||||
}
|
||||
|
||||
function selectRememberedFile(fileNum, fileName) {
|
||||
texts[fileNum] = fileHistory[paths[fileName]];
|
||||
displayNames[fileNum] = fileName;
|
||||
submitDiffs();
|
||||
}
|
||||
|
||||
function submitDiffs() {
|
||||
if (texts[0] && texts[1] && !badURL) {
|
||||
$('.file-name.0').text(displayNames[0]);
|
||||
$('.file-name.1').text(displayNames[1]);
|
||||
setFileName(0);
|
||||
setFileName(1);
|
||||
if (isPatch(displayNames[1])) {
|
||||
texts[1] = patchToFile2(texts[0], texts[1]);
|
||||
rememberFile(1);
|
||||
saveFile(texts[1], 'file1.txt');
|
||||
}
|
||||
computeDiff(texts[0], texts[1]);
|
||||
$('.modal-dialog.new-diff .close-button').click();
|
||||
$('.button.edit').removeClass('hidden');
|
||||
@@ -222,6 +294,24 @@ function submitDiffs() {
|
||||
}
|
||||
}
|
||||
|
||||
function chooseNewFile(fileNum) {
|
||||
setFileName(fileNum);
|
||||
if (texts[0] && texts[1]) {
|
||||
if ((fileNum == 1) && isPatch(displayNames[1])) {
|
||||
texts[1] = patchToFile2(texts[0], texts[1]);
|
||||
rememberFile(1);
|
||||
saveFile(texts[1], 'file1.txt');
|
||||
}
|
||||
computeDiff(texts[0], texts[1]);
|
||||
}
|
||||
else
|
||||
$('.file-diff.' + fileNum).text(texts[fileNum]);
|
||||
if (fileNum == 1) {
|
||||
$('.button.edit').removeClass('hidden');
|
||||
$('.button.save').removeClass('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function saveFile(content, fileName) {
|
||||
window.webkitRequestFileSystem(
|
||||
window.PERSISTENT,
|
||||
@@ -263,10 +353,13 @@ function readFile(fileName, fileNum) {
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function(e) {
|
||||
texts[fileNum] = this.result;
|
||||
fileHistory[displayNames[fileNum]] = texts[fileNum];
|
||||
if (texts[0] && texts[1]) {
|
||||
createDropdown();
|
||||
computeDiff(texts[0], texts[1]);
|
||||
chrome.storage.local.get(function(items) {
|
||||
for (key in items['fileHistory'])
|
||||
fileHistory[key] = items['fileHistory'][key];
|
||||
createDropdown();
|
||||
computeDiff(texts[0], texts[1]);
|
||||
});
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
@@ -284,8 +377,12 @@ function readFileName(fileName, fileNum) {
|
||||
fileEntry.file(function(file) {
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function(e) {
|
||||
displayNames[fileNum] = this.result;
|
||||
$('.file-name.' + fileNum).text(displayNames[fileNum]);
|
||||
path = this.result;
|
||||
var pathList = path.split('/');
|
||||
var l = pathList.length - 1;
|
||||
displayNames[fileNum] = pathList[l];
|
||||
paths[displayNames[fileNum]] = path;
|
||||
setFileName(fileNum);
|
||||
readFile('file' + fileNum + '.txt', fileNum);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
|
||||
@@ -51,21 +51,15 @@
|
||||
<span class="label file-name 0">No File Selected</span>
|
||||
<span class="indicator"></span>
|
||||
<ul class="menulist 0">
|
||||
<!--
|
||||
<li class="menulistitem">Option 1</li>
|
||||
<li class="menulistitem selected">Option 2</li>
|
||||
<li class="menulistitem">Option 3</li>
|
||||
-->
|
||||
<li class="menulistitem choose-new-file">Choose File</li>
|
||||
</ul>
|
||||
</span>
|
||||
<!--
|
||||
<div class="file-name 0">No File Selected</div>
|
||||
-->
|
||||
|
||||
<div class="file-diff 0" id="drop-zone0"></div>
|
||||
</div>
|
||||
|
||||
<div id="arrow-container"></div>
|
||||
<div id="check-container"></div>
|
||||
|
||||
<div id="file1-container">
|
||||
|
||||
@@ -73,15 +67,12 @@
|
||||
<span class="label file-name 1">No File Selected</span>
|
||||
<span class="indicator"></span>
|
||||
<ul class="menulist 1">
|
||||
<li class="menulistitem choose-new-file">Choose File</li>
|
||||
</ul>
|
||||
</span>
|
||||
|
||||
<!--
|
||||
<div class="file-name 1">No File Selected</div>
|
||||
-->
|
||||
|
||||
<div class="button save hidden" id="save"><img src="img/save.png" /></div>
|
||||
<div class="tooltip save hidden">Save<span class="pointer"</span></div>
|
||||
<div class="tooltip save hidden">Save As<span class="pointer"</span></div>
|
||||
<div class="button edit hidden" id="edit"><img src="img/edit.png" /></div>
|
||||
<div class="tooltip edit hidden">Edit<span class="pointer"</span></div>
|
||||
<div class="button done hidden">Done</div>
|
||||
@@ -91,8 +82,6 @@
|
||||
<textarea class="diff-text hidden"></textarea>
|
||||
</div>
|
||||
|
||||
<div id="check-container"></div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="expand-all"></div>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
}
|
||||
},
|
||||
"permissions": ["experimental",
|
||||
"storage",
|
||||
"unlimitedStorage",
|
||||
"fileSystem",
|
||||
"fileSystemWrite",
|
||||
|
||||
BIN
diff/tests/.DS_Store
vendored
Normal file
BIN
diff/tests/.DS_Store
vendored
Normal file
Binary file not shown.
70
diff/tests/patch.patch
Normal file
70
diff/tests/patch.patch
Normal file
@@ -0,0 +1,70 @@
|
||||
@@ -10,37 +10,38 @@
|
||||
very model of a
|
||||
-moder
|
||||
+cartoo
|
||||
n Major-General,
|
||||
@@ -45,53 +45,52 @@
|
||||
al,%0A
|
||||
-I've information vegetable, anim
|
||||
+My animation's comical, unusu
|
||||
al, and
|
||||
-miner
|
||||
+whimsic
|
||||
al,%0A
|
||||
@@ -126,37 +126,36 @@
|
||||
and I quote the
|
||||
-fight
|
||||
+play
|
||||
s historical%0AFro
|
||||
@@ -205,240 +205,8 @@
|
||||
l;%0A%0A
|
||||
-I'm very well acquainted, too, with matters mathematical,%0AI understand equations, both the simple and quadratical,%0AAbout binomial theorem I'm teeming with a lot o' news,%0AWith many cheerful facts about the square of the hypotenuse.%0A%0A
|
||||
I'm
|
||||
@@ -331,36 +331,37 @@
|
||||
ers
|
||||
-vegetable, anim
|
||||
+comical, unusu
|
||||
al, and
|
||||
-miner
|
||||
+whimsic
|
||||
al,%0A
|
||||
@@ -377,37 +377,38 @@
|
||||
very model of a
|
||||
-moder
|
||||
+cartoo
|
||||
n Major-General.
|
||||
@@ -409,16 +409,235 @@
|
||||
neral.%0A%0A
|
||||
+I know our mythic history, King Arthur's and Sir Caradoc's;%0AI answer hard acrostics, I've a pretty taste for paradox,%0AI quote in elegiacs all the crimes of Heliogabalus,%0AIn conics I can floor peculiarities parabolous;%0A%0A
|
||||
I can te
|
||||
@@ -1011,36 +1011,37 @@
|
||||
ers
|
||||
-vegetable, anim
|
||||
+comical, unusu
|
||||
al, and
|
||||
-miner
|
||||
+whimsic
|
||||
al,%0A
|
||||
@@ -1057,37 +1057,38 @@
|
||||
very model of a
|
||||
-moder
|
||||
+cartoo
|
||||
n Major-General.
|
||||
@@ -1709,36 +1709,37 @@
|
||||
ers
|
||||
-vegetable, anim
|
||||
+comical, unusu
|
||||
al, and
|
||||
-miner
|
||||
+whimsic
|
||||
al,%0A
|
||||
@@ -1755,37 +1755,38 @@
|
||||
very model of a
|
||||
-moder
|
||||
+cartoo
|
||||
n Major-General.
|
||||
@@ -3777,37 +3777,38 @@
|
||||
very model of a
|
||||
-moder
|
||||
+cartoo
|
||||
n Major-General.
|
||||
@@ -1,134 +0,0 @@
|
||||
I am the very model of a modern Major-General,
|
||||
I've information vegetable, animal, and mineral,
|
||||
I know the kings of England, and I quote the fights historical
|
||||
From Marathon to Waterloo, in order categorical;
|
||||
|
||||
I'm very well acquainted, too, with matters mathematical,
|
||||
I understand equations, both the simple and quadratical,
|
||||
About binomial theorem I'm teeming with a lot o' news,
|
||||
With many cheerful facts about the square of the hypotenuse.
|
||||
|
||||
I'm very good at integral and differential calculus;
|
||||
I know the scientific names of beings animalculous:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I know our mythic history, King Arthur's and Sir Caradoc's;
|
||||
I answer hard acrostics, I've a pretty taste for paradox,
|
||||
I quote in elegiacs all the crimes of Heliogabalus,
|
||||
In conics I can floor peculiarities parabolous;
|
||||
|
||||
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
|
||||
I know the croaking chorus from The Frogs of Aristophanes!
|
||||
Then I can hum a fugue of which I've heard the music's din afore,
|
||||
And whistle all the airs from that infernal nonsense Pinafore.
|
||||
|
||||
Then I can write a washing bill in Babylonic cuneiform,
|
||||
And tell you ev'ry detail of Caractacus's uniform:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
In fact, when I know what is meant by "mamelon" and "ravelin",
|
||||
When I can tell at sight a Mauser rifle from a Javelin,
|
||||
When such affairs as sorties and surprises I'm more wary at,
|
||||
And when I know precisely what is meant by "commissariat",
|
||||
|
||||
When I have learnt what progress has been made in modern gunnery,
|
||||
When I know more of tactics than a novice in a nunnery—
|
||||
In short, when I've a smattering of elemental strategy—
|
||||
You'll say a better Major-General has never sat a gee.
|
||||
|
||||
For my military knowledge, though I'm plucky and adventury,
|
||||
Has only been brought down to the beginning of the century;
|
||||
But still, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I am the very model of a modern Major-General,
|
||||
I've information vegetable, animal, and mineral,
|
||||
I know the kings of England, and I quote the fights historical
|
||||
From Marathon to Waterloo, in order categorical;
|
||||
|
||||
I'm very well acquainted, too, with matters mathematical,
|
||||
I understand equations, both the simple and quadratical,
|
||||
About binomial theorem I'm teeming with a lot o' news,
|
||||
With many cheerful facts about the square of the hypotenuse.
|
||||
|
||||
I'm very good at integral and differential calculus;
|
||||
I know the scientific names of beings animalculous:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I know our mythic history, King Arthur's and Sir Caradoc's;
|
||||
I answer hard acrostics, I've a pretty taste for paradox,
|
||||
I quote in elegiacs all the crimes of Heliogabalus,
|
||||
In conics I can floor peculiarities parabolous;
|
||||
|
||||
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
|
||||
I know the croaking chorus from The Frogs of Aristophanes!
|
||||
Then I can hum a fugue of which I've heard the music's din afore,
|
||||
And whistle all the airs from that infernal nonsense Pinafore.
|
||||
|
||||
Then I can write a washing bill in Babylonic cuneiform,
|
||||
And tell you ev'ry detail of Caractacus's uniform:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
In fact, when I know what is meant by "mamelon" and "ravelin",
|
||||
When I can tell at sight a Mauser rifle from a Javelin,
|
||||
When such affairs as sorties and surprises I'm more wary at,
|
||||
And when I know precisely what is meant by "commissariat",
|
||||
|
||||
When I have learnt what progress has been made in modern gunnery,
|
||||
When I know more of tactics than a novice in a nunnery—
|
||||
In short, when I've a smattering of elemental strategy—
|
||||
You'll say a better Major-General has never sat a gee.
|
||||
|
||||
For my military knowledge, though I'm plucky and adventury,
|
||||
Has only been brought down to the beginning of the century;
|
||||
But still, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I am the very model of a modern Major-General,
|
||||
I've information vegetable, animal, and mineral,
|
||||
I know the kings of England, and I quote the fights historical
|
||||
From Marathon to Waterloo, in order categorical;
|
||||
|
||||
I'm very well acquainted, too, with matters mathematical,
|
||||
I understand equations, both the simple and quadratical,
|
||||
About binomial theorem I'm teeming with a lot o' news,
|
||||
With many cheerful facts about the square of the hypotenuse.
|
||||
|
||||
I'm very good at integral and differential calculus;
|
||||
I know the scientific names of beings animalculous:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I know our mythic history, King Arthur's and Sir Caradoc's;
|
||||
I answer hard acrostics, I've a pretty taste for paradox,
|
||||
I quote in elegiacs all the crimes of Heliogabalus,
|
||||
In conics I can floor peculiarities parabolous;
|
||||
|
||||
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
|
||||
I know the croaking chorus from The Frogs of Aristophanes!
|
||||
Then I can hum a fugue of which I've heard the music's din afore,
|
||||
And whistle all the airs from that infernal nonsense Pinafore.
|
||||
|
||||
Then I can write a washing bill in Babylonic cuneiform,
|
||||
And tell you ev'ry detail of Caractacus's uniform:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
In fact, when I know what is meant by "mamelon" and "ravelin",
|
||||
When I can tell at sight a Mauser rifle from a Javelin,
|
||||
When such affairs as sorties and surprises I'm more wary at,
|
||||
And when I know precisely what is meant by "commissariat",
|
||||
|
||||
When I have learnt what progress has been made in modern gunnery,
|
||||
When I know more of tactics than a novice in a nunnery—
|
||||
In short, when I've a smattering of elemental strategy—
|
||||
You'll say a better Major-General has never sat a gee.
|
||||
|
||||
For my military knowledge, though I'm plucky and adventury,
|
||||
Has only been brought down to the beginning of the century;
|
||||
But still, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
@@ -1,129 +0,0 @@
|
||||
I am the very model of a cartoon Major-General,
|
||||
My animation's comical, unusual, and whimsical,
|
||||
I know the kings of England, and I quote the plays historical
|
||||
From Marathon to Waterloo, in order categorical;
|
||||
|
||||
I'm very good at integral and differential calculus;
|
||||
I know the scientific names of beings animalculous:
|
||||
In short, in matters comical, unusual, and whimsical,
|
||||
I am the very model of a cartoon Major-General.
|
||||
|
||||
I know our mythic history, King Arthur's and Sir Caradoc's;
|
||||
I answer hard acrostics, I've a pretty taste for paradox,
|
||||
I quote in elegiacs all the crimes of Heliogabalus,
|
||||
In conics I can floor peculiarities parabolous;
|
||||
|
||||
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
|
||||
I know the croaking chorus from The Frogs of Aristophanes!
|
||||
Then I can hum a fugue of which I've heard the music's din afore,
|
||||
And whistle all the airs from that infernal nonsense Pinafore.
|
||||
|
||||
Then I can write a washing bill in Babylonic cuneiform,
|
||||
And tell you ev'ry detail of Caractacus's uniform:
|
||||
In short, in matters comical, unusual, and whimsical,
|
||||
I am the very model of a cartoon Major-General.
|
||||
|
||||
In fact, when I know what is meant by "mamelon" and "ravelin",
|
||||
When I can tell at sight a Mauser rifle from a Javelin,
|
||||
When such affairs as sorties and surprises I'm more wary at,
|
||||
And when I know precisely what is meant by "commissariat",
|
||||
|
||||
When I have learnt what progress has been made in modern gunnery,
|
||||
When I know more of tactics than a novice in a nunnery—
|
||||
In short, when I've a smattering of elemental strategy—
|
||||
You'll say a better Major-General has never sat a gee.
|
||||
|
||||
For my military knowledge, though I'm plucky and adventury,
|
||||
Has only been brought down to the beginning of the century;
|
||||
But still, in matters comical, unusual, and whimsical,
|
||||
I am the very model of a cartoon Major-General.
|
||||
|
||||
I am the very model of a modern Major-General,
|
||||
I've information vegetable, animal, and mineral,
|
||||
I know the kings of England, and I quote the fights historical
|
||||
From Marathon to Waterloo, in order categorical;
|
||||
|
||||
I'm very well acquainted, too, with matters mathematical,
|
||||
I understand equations, both the simple and quadratical,
|
||||
About binomial theorem I'm teeming with a lot o' news,
|
||||
With many cheerful facts about the square of the hypotenuse.
|
||||
|
||||
I'm very good at integral and differential calculus;
|
||||
I know the scientific names of beings animalculous:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I know our mythic history, King Arthur's and Sir Caradoc's;
|
||||
I answer hard acrostics, I've a pretty taste for paradox,
|
||||
I quote in elegiacs all the crimes of Heliogabalus,
|
||||
In conics I can floor peculiarities parabolous;
|
||||
|
||||
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
|
||||
I know the croaking chorus from The Frogs of Aristophanes!
|
||||
Then I can hum a fugue of which I've heard the music's din afore,
|
||||
And whistle all the airs from that infernal nonsense Pinafore.
|
||||
|
||||
Then I can write a washing bill in Babylonic cuneiform,
|
||||
And tell you ev'ry detail of Caractacus's uniform:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
In fact, when I know what is meant by "mamelon" and "ravelin",
|
||||
When I can tell at sight a Mauser rifle from a Javelin,
|
||||
When such affairs as sorties and surprises I'm more wary at,
|
||||
And when I know precisely what is meant by "commissariat",
|
||||
|
||||
When I have learnt what progress has been made in modern gunnery,
|
||||
When I know more of tactics than a novice in a nunnery—
|
||||
In short, when I've a smattering of elemental strategy—
|
||||
You'll say a better Major-General has never sat a gee.
|
||||
|
||||
For my military knowledge, though I'm plucky and adventury,
|
||||
Has only been brought down to the beginning of the century;
|
||||
But still, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a cartoon Major-General.
|
||||
|
||||
I am the very model of a modern Major-General,
|
||||
I've information vegetable, animal, and mineral,
|
||||
I know the kings of England, and I quote the fights historical
|
||||
From Marathon to Waterloo, in order categorical;
|
||||
|
||||
I'm very well acquainted, too, with matters mathematical,
|
||||
I understand equations, both the simple and quadratical,
|
||||
About binomial theorem I'm teeming with a lot o' news,
|
||||
With many cheerful facts about the square of the hypotenuse.
|
||||
|
||||
I'm very good at integral and differential calculus;
|
||||
I know the scientific names of beings animalculous:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
I know our mythic history, King Arthur's and Sir Caradoc's;
|
||||
I answer hard acrostics, I've a pretty taste for paradox,
|
||||
I quote in elegiacs all the crimes of Heliogabalus,
|
||||
In conics I can floor peculiarities parabolous;
|
||||
|
||||
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
|
||||
I know the croaking chorus from The Frogs of Aristophanes!
|
||||
Then I can hum a fugue of which I've heard the music's din afore,
|
||||
And whistle all the airs from that infernal nonsense Pinafore.
|
||||
|
||||
Then I can write a washing bill in Babylonic cuneiform,
|
||||
And tell you ev'ry detail of Caractacus's uniform:
|
||||
In short, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
|
||||
In fact, when I know what is meant by "mamelon" and "ravelin",
|
||||
When I can tell at sight a Mauser rifle from a Javelin,
|
||||
When such affairs as sorties and surprises I'm more wary at,
|
||||
And when I know precisely what is meant by "commissariat",
|
||||
|
||||
When I have learnt what progress has been made in modern gunnery,
|
||||
When I know more of tactics than a novice in a nunnery—
|
||||
In short, when I've a smattering of elemental strategy—
|
||||
You'll say a better Major-General has never sat a gee.
|
||||
|
||||
For my military knowledge, though I'm plucky and adventury,
|
||||
Has only been brought down to the beginning of the century;
|
||||
But still, in matters vegetable, animal, and mineral,
|
||||
I am the very model of a modern Major-General.
|
||||
Reference in New Issue
Block a user