Skip to content

Commit

Permalink
Convert tabs to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
valx76 committed Aug 28, 2014
1 parent dccedda commit 109a85e
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 74 deletions.
124 changes: 62 additions & 62 deletions main.js
Expand Up @@ -2,68 +2,68 @@
/*global define, brackets, $, window, W3CValidator */

define(function (require, exports, module) {
'use strict';
'use strict';

var CodeInspection = brackets.getModule("language/CodeInspection"),
AppInit = brackets.getModule("utils/AppInit"),
Menus = brackets.getModule("command/Menus"),
CommandManager = brackets.getModule("command/CommandManager"),
DocumentManager = brackets.getModule("document/DocumentManager");
var COMMAND_ID = "w3cvalidator_refresh",
PROVIDER_ID = "W3CValidation";
require('w3cvalidator');
function _handleValidation(text, fullPath) {
var response = new $.Deferred();
var result = {errors:[]};
W3CValidator.validate(text, function (res) {
var messages = res.messages;
if (messages.length) {
messages.forEach(function (item) {
//console.log('W3CValidation messsage ',item);
var type = CodeInspection.Type.ERROR;
if (item.type === "warning")
type = CodeInspection.Type.WARNING;
result.errors.push({
pos: {line:item.lastLine-1, ch:0},
message:item.message,
type:type
});
});
}
var CodeInspection = brackets.getModule("language/CodeInspection"),
AppInit = brackets.getModule("utils/AppInit"),
Menus = brackets.getModule("command/Menus"),
CommandManager = brackets.getModule("command/CommandManager"),
DocumentManager = brackets.getModule("document/DocumentManager");
var COMMAND_ID = "w3cvalidator_refresh",
PROVIDER_ID = "W3CValidation";
require('w3cvalidator');
function _handleValidation(text, fullPath) {
var response = new $.Deferred();
var result = {errors:[]};
W3CValidator.validate(text, function (res) {
var messages = res.messages;
if (messages.length) {
messages.forEach(function (item) {
//console.log('W3CValidation messsage ',item);
var type = CodeInspection.Type.ERROR;
if (item.type === "warning")
type = CodeInspection.Type.WARNING;
result.errors.push({
pos: {line:item.lastLine-1, ch:0},
message:item.message,
type:type
});
});
}

response.resolve(result);
});
return response.promise();
}
function _refreshValidation() {
var currentDoc = DocumentManager.getCurrentDocument();
currentDoc.notifySaved();
}
AppInit.appReady(function () {
CodeInspection.register("html", {
//name: "W3CValidation",
name: PROVIDER_ID,
scanFileAsync: _handleValidation
});
});
// Command
CommandManager.register("Refresh W3C validation", COMMAND_ID, _refreshValidation);
// Menu
var editMenu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);
editMenu.addMenuItem(COMMAND_ID);
response.resolve(result);
});
return response.promise();
}
function _refreshValidation() {
var currentDoc = DocumentManager.getCurrentDocument();
currentDoc.notifySaved();
}
AppInit.appReady(function () {
CodeInspection.register("html", {
//name: "W3CValidation",
name: PROVIDER_ID,
scanFileAsync: _handleValidation
});
});
// Command
CommandManager.register("Refresh W3C validation", COMMAND_ID, _refreshValidation);
// Menu
var editMenu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);
editMenu.addMenuItem(COMMAND_ID);
});
24 changes: 12 additions & 12 deletions w3cvalidator.js
@@ -1,14 +1,14 @@
var W3CValidator = (function() {
var W3CURL = "http://validator.w3.org/check";
return {
validate:function(str,cb) {
$.post(W3CURL, {
"fragment":str,
"output":"json"
}, function(res,code) {
cb(res);
});
}
};
var W3CURL = "http://validator.w3.org/check";
return {
validate:function(str,cb) {
$.post(W3CURL, {
"fragment":str,
"output":"json"
}, function(res,code) {
cb(res);
});
}
};
}());

0 comments on commit 109a85e

Please sign in to comment.