Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a demo #22

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Lint the demo script
macro1 committed Oct 26, 2014

Verified

This commit was signed with the committer’s verified signature.
inkydragon Chengyu Han
commit de2b2d8104c3b55301d1ca94af4810f9052f61db
18 changes: 10 additions & 8 deletions _js/demo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function($) {
(function ($) {

var editorconfig = require('editorconfig');

@@ -10,18 +10,20 @@
}

// Resize textarea automatically
$('textarea').on('input', function (event) {
$('textarea').on('input', function () {
// Set textarea height
this.style.height = 'auto';
this.style.height = this.scrollHeight + 16 + 'px';
}).trigger('input');

function renderOutput (configFiles) {
function renderOutput(configFiles) {
$('#output [name=filename]').each(function (index, el) {
var output = "";
var config = editorconfig.parseFromFiles(el.value, configFiles);
for (var key in config) {
output += key + " = " + config[key] + "\n";
var output = "", config, key;
config = editorconfig.parseFromFiles(el.value, configFiles);
for (key in config) {
if (config.hasOwnProperty(key)) {
output += key + " = " + config[key] + "\n";
}
}
$('#output pre').text(output);
});
@@ -32,7 +34,7 @@
renderOutput(createFiles());
}).trigger('input');

$('.demo-link').click(function() {
$('.demo-link').click(function () {
$('#editorconfig input').val($(this).siblings('input').val());
$('#editorconfig textarea')
.val($(this).siblings('pre').text())
Loading