-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubiquity-validate.js
66 lines (63 loc) · 2.65 KB
/
ubiquity-validate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/************************
* This Ubiquity plugin validates the following doc types:
* html
* css
*
* By: Patrick Tully <[email protected]>
* Company: Avatar New York
***********************/
CmdUtils.CreateCommand({
name: "validate-html",
icon: "http://www.avatarnewyork.com/sites/all/themes/avatarnewyork/favicon.ico",
homepage: "http://www.avatarnewyork.com",
author: { name: "Patrick Tully", email: "[email protected]"},
license: "GPL",
description: "This application validates the html of the current page using http://validator.w3.org",
help: "Goto the webpage you want to validate and type the command: validate-html",
//takes: {"doc": noun_type_doc},
preview: function( pblock, input ) {
var template = "This page's html is ${name}";
var button = "";
var doc = Application.activeWindow.activeTab.document;
//if(input.text == 'html'){
var baseUrl = "http://validator.w3.org/check?uri="+doc.location;
var params = {output : 'text'};
jQuery.get( baseUrl, params, function(report) {
if(report.match(/(.*)class\=\"(valid)\"(.*)/gi)){
button = "<a href=\"" + baseUrl + "\"><font color=\"green\">valid</font>.</a>";
}else{
button = "<a href=\"" + baseUrl + "\"><font color=\"red\">not valid</font>.</a>";
}
pblock.innerHTML = CmdUtils.renderTemplate(template, {"name": button});
});
//}
}
});
CmdUtils.CreateCommand({
name: "validate-css",
icon: "http://www.avatarnewyork.com/sites/all/themes/avatarnewyork/favicon.ico",
homepage: "http://www.avatarnewyork.com",
author: { name: "Patrick Tully", email: "[email protected]"},
license: "GPL",
description: "This application validates the css of the current page using http://validator.w3.org",
help: "Goto the webpage you want to validate and type the command: validate-css",
//takes: {"doc": noun_type_doc},
preview: function( pblock, input ) {
var template = "This page's CSS is ${name}";
var button = "";
var doc = Application.activeWindow.activeTab.document;
//if(input.text == 'html'){
var baseUrl = "http://jigsaw.w3.org/css-validator/validator?uri="+doc.location;
var params = {output : 'html'};
jQuery.get( baseUrl, params, function(report) {
if(report.match(/(.*)id\=\'(congrats)\'(.*)/gi)){
button = "<a href=\"" + baseUrl + "\"><font color=\"green\">valid</font>.</a>";
}else{
button = "<a href=\"" + baseUrl + "\"><font color=\"red\">not valid</font>.</a>";
}
//button = report;
pblock.innerHTML = CmdUtils.renderTemplate(template, {"name": button});
});
//}
}
});