Skip to content

Commit

Permalink
0.5.0: Add online eol converter
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanve committed Jan 2, 2017
1 parent 66ffd48 commit 138f056
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 16 deletions.
8 changes: 8 additions & 0 deletions converter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$('.js-converter__form').on('submit', function(e) {
e.preventDefault()
var $form = $(this)
var $output = $form.find('.js-converter__output')
var method = $form.find('.js-converter__method')[0].value
var text = $form.find('.js-converter__input')[0].value
$output.text(eol[method](text))
});
36 changes: 36 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en-US" class="scheme--white">
<title>EOL converter</title>
<meta name="description" content="Newline character converter">
<link rel="stylesheet" href="style.css">

<header class="m-b-3">
<h1 class="m-b-1">eol converter</h1>
<a class="button scheme--light" href="https://github.com/ryanve/eol">Github</a>
<a class="button scheme--light" href="https://www.npmjs.com/package/eol">npm</a>
</header>

<form class="js-converter__form">
<fieldset class="m-b-2">
<label class="block m-b-2">
<b>Input</b>
<textarea class="area border-radius scheme--white js-converter__input"></textarea>
</label>
<button type="submit" class="button scheme--dark">Convert line endings to</button>
<label class="inline-block m-b-2">
<select class="button scheme--light js-converter__method" aria-label="Convert to">
<option selected>lf</option>
<option>crlf</option>
<option>cr</option>
</select>
</label>
</fieldset>
<section>
<h2 class="inherit-size">Output</h2>
<div class="area scheme--white border-radius js-converter__output" contenteditable></div>
</section>
</form>

<script src="eol.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.slim.min.js"></script>
<script src="converter.js"></script>
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eol",
"description": "Newline character converter",
"version": "0.4.0",
"version": "0.5.0",
"homepage": "https://github.com/ryanve/eol",
"license": "MIT",
"author": "Ryan Van Etten",
Expand All @@ -21,7 +21,8 @@
],
"main": "eol.js",
"scripts": {
"pretest": "jshint eol.js && jshint test.js",
"lint": "jshint eol.js && jshint test.js",
"pretest": "npm run lint",
"test": "node test.js"
},
"repository": {
Expand Down
71 changes: 71 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.scheme--white { background: #fafafa; color: #020202 }
.scheme--dark { background: navy; color: #fafafa }
.scheme--light { background: gainsboro; color: navy }

*, :before, :after { box-sizing: border-box }
html { font: 1em/2 sans-serif; }
body { width: 100%; margin: auto; padding: 1em }
a { text-decoration: none }
a:hover { text-decoration: underline }
textarea, select { font: inherit }
textarea { max-width: 100%; margin: 0 }
header, section { display: block }
fieldset { padding: 0; border: 0 }
label { margin: 0; padding: 0 }
h1, h2 { line-height: 1 }

.border-radius {
border-radius: .25em;
}

.inherit-size {
font-size: inherit;
}

.button {
font-size: inherit;
font-style: inherit;
font-weight: bold;
min-height: 2.5em;
display: inline-block;
border: 0;
border-radius: .25em;
padding: .33333em .66666em;
margin: 0;
}

.button:enabled:hover {
cursor: pointer;
text-decoration: underline;
}

.m-b-1 {
margin-bottom: .5em;
}

.m-b-2 {
margin-bottom: 1em;
}

.m-b-3 {
margin-bottom: 2em;
}

.inline-block {
display: inline-block;
}

.block {
display: block;
}

.area {
border: 2px solid gainsboro;
padding: .25em;
display: block;
overflow: auto;
resize: vertical;
width: 100%;
height: 7.5em;
line-height: 1.1;
}
14 changes: 0 additions & 14 deletions test.html

This file was deleted.

0 comments on commit 138f056

Please sign in to comment.