Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mealey-rohwer/filereader/grocery store.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hey grandma, I'm going to the store to get some bananas. I love bananas. A banana is all that I need for all my fruity needs. Would you like a banana too?
138 changes: 138 additions & 0 deletions mealey-rohwer/filereader/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>FileReader Example</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Styles should be in a separate file. Please make external.

body {
background:#584f44;
font-family:"Monaco";
color:white;
text-align:center;
}
h1 {
text-align:center;
}
.block {
width:50%;
padding:50px;
margin:50px auto 0 auto;
background:rgba(0,0,0,0.1);
border:4px solid #e1871c;
text-align:left;
font-size:22px;
}
.block table {
width:100%;
}
.block table thead {
opacity:0.5;
}
th, td {
width:50%;
vertical-align:top;
}
.block em {
color:#44ce19;
}
input[type=text]{
font-size:18px;
border:2px solid #44ce19;
padding:5px;
background:transparent;
color:white;
}
input[type=text]:focus{
background:rgba(0,0,0,0.1);
}
section {
margin:15px 0;
}
</style>
</head>
<body>
<main>
<h1>Apples and Bananas</h1>
<section class="block">
<form action="#" id="upload">
<section>
<label>
Find: <input type="text" id="find">
</label>
<label>
Replace: <input type="text" id="replace">
</label>
</section>
<label>
File: <input type="file" id="file">
</label>
</form>
<hr>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hr tags are semantically meaningless. Please remove.

<table>
<thead>
<tr>
<td>Before</td>
<td>After</td>
</tr>
</thead>
<tbody>
<tr>
<td id="input"></td>
<td id="output"></td>
</tr>
</tbody>
</table>
</section>

</main>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make scripts external

$(document).ready(function(){

$('#file').change(function(){

// Create a new file reader
var reader = new FileReader();

// Read the file as text
reader.readAsText(this.files[0]);

// When the file loads, find and replace text
reader.onload = function() {
$('#input').html(this.result);

var find = $('#find').val();
var replace = $('#replace').val();

// Find global, case insensitive terms
var PATTERN = new RegExp(find, 'gi');
var result = this.result.replace(PATTERN, function(input){
var letter1 = input[0];

// Maintain capitalized words
if(letter1 === letter1.toUpperCase()){
replace = " " + replace[0].toUpperCase() + replace.slice(1);
}

// Return an HTML string
return "<em>" + replace + "</em>";
});

// Set the output text
$('#output').html(result);
}

// Updated automatically as we type
$('#find, #replace').keyup(function(){
reader.onload();
});

});
});

</script>
</body>
</html>
6 changes: 6 additions & 0 deletions mealey-rohwer/filereader/snow white.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

Queen: And because you've been so good to poor old Granny, I'll share a secret with you. This is no ordinary apple, it's a magic wishing apple.
Snow White: A wishing apple?
Queen: Yes! One bite, and all your dreams will come true.
Snow White: Really?
Queen: Yes, girlie. Now, make a wish, and take a bite.
97 changes: 97 additions & 0 deletions mealey-rohwer/local-storage/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html>
<head>
<title>Local Storage Demo</title>
<style type="text/css">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make CSS external

body {
margin:0;
font-family:Monaco;
}
.circle {
height:100px;
width:100px;
border-radius:100px;
position:absolute;
background:rgb(162, 207, 81);
border:5px solid rgb(120, 147, 73);
cursor:move;
}
main {
position:fixed;
height:100%;
width:100%;
}
main h1 {
text-align:center;
font-size:20px;
color:gray;
}
</style>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
</head>
<body>
<main>
<header>
<h1></h1>
</header>
<div class="circle" role="button"></div>
</main>
<script type="text/javascript">
$(document).ready(function(){

// Get the element
var elem = $('.circle');

// Set heading data
var heading = $('header h1');

function setHeading(offset){
heading.text("Left: " + Math.round(offset.left) + "px" + " Top: " + Math.round(offset.top) + "px");
}

// Saves the data to local storage
function saveLocation(offset){
localStorage.setItem("circleX", offset.left);
localStorage.setItem("circleY", offset.top);
}

// Set an event to act on drag
elem.draggable({
containment: 'main',
drag: function(){
var offset = $(this).offset();
setHeading(offset);
saveLocation(offset);
}
});

// Sets element from the data
elem.setPosition = function(){
var x = localStorage["circleX"];
var y = localStorage["circleY"];
setHeading({top:y, left:x});

elem.offset({
left: x,
top: y
});
}

// Initially render
elem.setPosition();

// Set an interval to check for changes
var relayEnabled;

// Don't run stuff while focused
$(window).blur(function(){
relayEnabled = setInterval(elem.setPosition, 1);
}).focus(function(){
clearInterval(relayEnabled);
});

});
</script>
</body>
</html>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs an additional blank line at the bottom

4 changes: 4 additions & 0 deletions mealey-rohwer/local-storage/js/jquery-1.7.1.min.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions mealey-rohwer/local-storage/js/jquery-ui.min.js

Large diffs are not rendered by default.