Skip to content

Commit

Permalink
Tweak CSSLintDemo.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Aug 19, 2014
1 parent 13314c8 commit 7f50a8e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
9 changes: 5 additions & 4 deletions demos/CSSLintDemo.htm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
.error { color: #D9534F; font-weight: bold; }
.warning { color: #F0AD4E; }
</style>
<script src="../release/csslint.js"></script>
<script src="../build/csslint.js"></script>
<script src="demo.js"></script>
</head>
<body>
<h1>CSSLint Demo</h1>
<textarea rows="50" cols="100" id="input">
<textarea rows="30" cols="100" id="input">
@charset "UTF-8";

@import url("booya.css") print, screen;
Expand Down Expand Up @@ -73,9 +74,9 @@ <h1>CSSLint Demo</h1>
}
}
</textarea>
<input type="button" id="lint-btn" value="Run CSSLint">
<br>
<button id="lint-btn">Run CSSLint</button>
<p>(You may want to keep the CSS kinda small, this could take a while.)</p>
<div id="output"></div>
<script src="demo.js"></script>
</body>
</html>
41 changes: 22 additions & 19 deletions demos/demo.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
/* jshint browser:true */
(function() {
"use strict";

document.body.onclick = function(event) {
event = event || window.event;
var target = event.target || event.srcElement,
results,
messages,
i,
len;
window.onload = function() {
document.body.onclick = function(event) {
event = event || window.event;
var target = event.target || event.srcElement,
results,
messages,
i,
len;

function log(value, level) {
var output = document.getElementById("output");
output.innerHTML += "<span class=\"" + level + "\">" + value.replace(/ /g, "&nbsp;") + "</span><br>";
}

if (target.id === "lint-btn") {
document.getElementById("output").innerHTML = "";
results = CSSLint.verify(document.getElementById("input").value);
messages = results.messages;
for (i=0, len=messages.length; i < len; i++) {
log(messages[i].message + " (line " + messages[i].line + ", col " + messages[i].col + ")", messages[i].type);
}

if (target.id == "lint-btn") {
document.getElementById("output").innerHTML = "";
results = CSSLint.verify(document.getElementById("input").value);
messages = results.messages;
for (i=0, len=messages.length; i < len; i++) {
log(messages[i].message + " (line " + messages[i].line + ", col " + messages[i].col + ")", messages[i].type);
}

}
};
};

function log(value, level) {
var output = document.getElementById("output");
output.innerHTML += "<span class=\"" + level + "\">" + value.replace(/ /g, "&nbsp;") + "</span><br>";
}
})();

0 comments on commit 7f50a8e

Please sign in to comment.