Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Untitled diff
Created
11 years ago
Diff never expires
Clear
Export
Share
Explain
19 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
66 lines
Copy
61 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
68 lines
Copy
Copy
Copied
Copy
Copied
//
Problem: No user interaction causes no change to application
//
Problem: No user interaction causes no change to application
.
//
Solution: When user interacts
cause changes appropriately
//
Solution: When user interacts
,
cause changes appropriately
.
var color = $(".selected").css("background-color");
var color = $(".selected").css("background-color");
var $canvas = $("canvas");
var $canvas = $("canvas");
var context = $canvas[0].getContext("2d");
var context = $canvas[0].getContext("2d");
var lastEvent;
var lastEvent;
var mouseDown = false;
var mouseDown = false;
Copy
Copied
Copy
Copied
//
When clicking on control list items
//
When clicking on control list items
$(".controls").on("click", "li", function()
{
$(".controls").on("click", "li", function()
{
//
Deselect sibling elements
//
Deselect sibling elements
$(this).siblings().removeClass("selected");
$(this).siblings().removeClass("selected");
//
Select clicked element
//
Select clicked element
$(this).addClass("selected");
$(this).addClass("selected");
// C
ache current color
//c
ache current color
color = $(this).css("background-color");
color = $(this).css("background-color");
});
});
Copy
Copied
Copy
Copied
//
When "New Color" is
pressed
//
When "New Color" is
clicked
$("#revealColorSelect").click(function(){
$("#revealColorSelect").click(function(){
Copy
Copied
Copy
Copied
//
Show color select or hide the color select
//
Show color select or hide the color select
changeColor();
changeColor();
$("#colorSelect").toggle();
$("#colorSelect").toggle();
});
});
Copy
Copied
Copy
Copied
//
u
pdate the new color span
//
U
pdate the new color span
function changeColor() {
function changeColor() {
Copy
Copied
Copy
Copied
var r = $("#red").val();
var r = $("#red").val();
var g = $("#green").val();
var g = $("#green").val();
var b = $("#blue").val();
var b = $("#blue").val();
$("#newColor").css("background-color", "rgb(" + r + "," + g +
",
" + b + ")");
$("#newColor").css("background-color", "rgb(" + r + "," + g +
",
" + b + ")");
}
}
Copy
Copied
Copy
Copied
//
When color sliders change
//
When color sliders change
$("input[type=range]").change(changeColor);
$("input[type=range]").change(changeColor);
Copy
Copied
Copy
Copied
//
When "Add Color" is pressed
//
When "Add Color" is pressed
$("#addNewColor").click(function(){
$("#addNewColor").click(function(){
Copy
Copied
Copy
Copied
//
Append the color to the control
s ul
//
Append the color to the control
list
var $newColor = $("<li></li>");
var $newColor = $("<li></li>");
$newColor.css("background-color", $("#newColor").css("background-color"));
$newColor.css("background-color", $("#newColor").css("background-color"));
$(".controls ul").append($newColor);
$(".controls ul").append($newColor);
//
Select the new color
//
Select the new color
$newColor.click();
$newColor.click();
});
});
Copy
Copied
Copy
Copied
//
On mouse event
s
on the canvas
//
On mouse event
on the canvas
$canvas.mousedown(function(e){
$canvas.mousedown(function(e){
Copy
Copied
Copy
Copied
lastEvent = e;
lastEvent = e;
mouseDown = true;
mouseDown = true;
}).mousemove(function(e){
}).mousemove(function(e){
Copy
Copied
Copy
Copied
//
Draw lines
//
Draw lines
if(mouseDown) {
if(mouseDown) {
context.beginPath();
context.beginPath();
context.moveTo(lastEvent.offset
x
, lastEvent.offset
y
);
context.moveTo(lastEvent.offset
X
, lastEvent.offset
Y
);
context.lineTo(e.offset
x
, e.offset
y
);
context.lineTo(e.offset
X
, e.offset
Y
);
context.strokeStyle = color;
context.strokeStyle = color;
context.stroke();
context.stroke();
lastEvent = e;
lastEvent = e;
}
}
}).mouseup(function(){
}).mouseup(function(){
Copy
Copied
Copy
Copied
mouseDown = false;
mouseDown = false;
}).mouse
L
eave(function(){
}).mouse
l
eave(function(){
$canvas.mouseup();
$canvas.mouseup();
});
});
Saved diffs
Original text
Open file
//Problem: No user interaction causes no change to application //Solution: When user interacts cause changes appropriately var color = $(".selected").css("background-color"); var $canvas = $("canvas"); var context = $canvas[0].getContext("2d"); var lastEvent; var mouseDown = false; //When clicking on control list items $(".controls").on("click", "li", function(){ //Deselect sibling elements $(this).siblings().removeClass("selected"); //Select clicked element $(this).addClass("selected"); //cache current color color = $(this).css("background-color"); }); //When "New Color" is pressed $("#revealColorSelect").click(function(){ //Show color select or hide the color select changeColor(); $("#colorSelect").toggle(); }); //update the new color span function changeColor() { var r = $("#red").val(); var g = $("#green").val(); var b = $("#blue").val(); $("#newColor").css("background-color", "rgb(" + r + "," + g +", " + b + ")"); } //When color sliders change $("input[type=range]").change(changeColor); //When "Add Color" is pressed $("#addNewColor").click(function(){ //Append the color to the controls ul var $newColor = $("<li></li>"); $newColor.css("background-color", $("#newColor").css("background-color")); $(".controls ul").append($newColor); //Select the new color $newColor.click(); }); //On mouse events on the canvas $canvas.mousedown(function(e){ lastEvent = e; mouseDown = true; }).mousemove(function(e){ //Draw lines if(mouseDown) { context.beginPath(); context.moveTo(lastEvent.offsetx, lastEvent.offsety); context.lineTo(e.offsetx, e.offsety); context.strokeStyle = color; context.stroke(); lastEvent = e; } }).mouseup(function(){ mouseDown = false; }).mouseLeave(function(){ $canvas.mouseup(); });
Changed text
Open file
// Problem: No user interaction causes no change to application. // Solution: When user interacts, cause changes appropriately. var color = $(".selected").css("background-color"); var $canvas = $("canvas"); var context = $canvas[0].getContext("2d"); var lastEvent; var mouseDown = false; // When clicking on control list items $(".controls").on("click", "li", function() { // Deselect sibling elements $(this).siblings().removeClass("selected"); // Select clicked element $(this).addClass("selected"); // Cache current color color = $(this).css("background-color"); }); // When "New Color" is clicked $("#revealColorSelect").click(function(){ // Show color select or hide the color select changeColor(); $("#colorSelect").toggle(); }); // Update the new color span function changeColor() { var r = $("#red").val(); var g = $("#green").val(); var b = $("#blue").val(); $("#newColor").css("background-color", "rgb(" + r + "," + g + "," + b + ")"); } // When color sliders change $("input[type=range]").change(changeColor); // When "Add Color" is pressed $("#addNewColor").click(function(){ // Append the color to the control list var $newColor = $("<li></li>"); $newColor.css("background-color", $("#newColor").css("background-color")); $(".controls ul").append($newColor); // Select the new color $newColor.click(); }); // On mouse event on the canvas $canvas.mousedown(function(e){ lastEvent = e; mouseDown = true; }).mousemove(function(e){ // Draw lines if(mouseDown) { context.beginPath(); context.moveTo(lastEvent.offsetX, lastEvent.offsetY); context.lineTo(e.offsetX, e.offsetY); context.strokeStyle = color; context.stroke(); lastEvent = e; } }).mouseup(function(){ mouseDown = false; }).mouseleave(function(){ $canvas.mouseup(); });
Find difference