Skip to content

Commit

Permalink
DONE #3: When markup validation doesn't work, timeout with 10 seconds…
Browse files Browse the repository at this point in the history
… and provide manual validation link.
  • Loading branch information
goonoo committed Mar 30, 2013
1 parent c6772d5 commit 22759ca
Show file tree
Hide file tree
Showing 27 changed files with 2,632 additions and 5,045 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = function (grunt) {
'lib/Sections.js',
'lib/Score.js'
],
dest: 'OpenWAX-' + pkgInfo.version + '.js'
dest: 'release/OpenWAX-' + pkgInfo.version + '.js'
},

bookmarklet: {
Expand Down
56 changes: 39 additions & 17 deletions lib/Sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,19 @@ labelLoop:
return $res;
};

var getItemEl = function (url) {
var el = rdoc.getElementById("w3c_validation");
var itemEls = el.querySelectorAll("li.validationItem");
var i;

for (i = 0; i < itemEls.length; i++) {
var urlEl = itemEls[i].getElementsByClassName("url")[0];
if (urlEl.innerText === url || urlEl.textContent === url) {
return itemEls[i];
}
}
};

var doValidation = function (url, doc) {
var sourceUrl = url;
var req = new XMLHttpRequest();
Expand All @@ -1637,6 +1650,18 @@ labelLoop:
var html = req.responseText;
var req2 = new XMLHttpRequest();
var charset = html.indexOf('euc-kr') > 0 ? 'euc-kr' : 'utf-8';
var ggTimeout = setTimeout(function () {
var itemEl = getItemEl(url);
var errcntEl = itemEl.getElementsByClassName("errcnt")[0];
var directValidationLink = rdoc.createElement("a");
directValidationLink.target = '_blank';
directValidationLink.href = 'http://validator.w3.org/check?uri=' + encodeURIComponent(url);
directValidationLink.textContent = '(' + achecker.i18n.get('ValidateManually') + ')';
errcntEl.innerText = achecker.i18n.get('ValidationTimeout') + ' ';
errcntEl.textContent = achecker.i18n.get('ValidationTimeout') + ' ';
errcntEl.appendChild(directValidationLink);
}, 10 * 1000);

req2.onreadystatechange = function () {
try {
var i;
Expand All @@ -1648,32 +1673,29 @@ labelLoop:
if (req2.readyState === 4) {
if (req2.status === 200) {
var res = filterValidationResult(JSON.parse(req2.responseText));

var el = rdoc.getElementById("w3c_validation");
var headerEl = el.querySelector("h2");
var itemEls = el.querySelectorAll("li.validationItem");
var itemEl = getItemEl(url);
var errcnt = 0;
for (i = 0; i < res.messages.length; i++) {
if (res.messages[i].type === 'error') {
errcnt++;
}
}
for (i = 0; i < itemEls.length; i++) {
var urlEl = itemEls[i].getElementsByClassName("url")[0];
var errcntEl = itemEls[i].getElementsByClassName("errcnt")[0];
if (urlEl.innerText === url || urlEl.textContent === url) {
//urlEl.setAttribute('href', 'validation_result.html?res=' + encodeURIComponent(req2.responseText));
errcntEl.innerText = errcnt + ' Errors';
errcntEl.textContent = errcnt + ' Errors';
itemEls[i].className = errcnt > 0 ? 'fail' : 'pass';
if (errcnt > 0) {
headerEl.className += " fail";
}
var $res = getResultDetailEl(res.messages, url);
$res.style.display = 'none';
itemEls[i].appendChild($res);
itemEls[i].onclick = onClickItem;
}

clearTimeout(ggTimeout);
var errcntEl = itemEl.getElementsByClassName("errcnt")[0];
errcntEl.innerText = errcnt + ' Errors';
errcntEl.textContent = errcnt + ' Errors';
itemEl.className = errcnt > 0 ? 'fail' : 'pass';
if (errcnt > 0) {
headerEl.className += " fail";
}
var $res = getResultDetailEl(res.messages, url);
$res.style.display = 'none';
itemEl.appendChild($res);
itemEl.onclick = onClickItem;
}
}
} catch (e) {
Expand Down
8 changes: 8 additions & 0 deletions owax_bookmarklet/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@
"message": "Cannot check frameset page. You could move to page in frameset and try again.",
"description": ""
},
"ValidationTimeout": {
"message": "Timeout",
"description": ""
},
"ValidateManually": {
"message": "Validate Manually",
"description": ""
},

"No1": {
"message": "Alternative text",
Expand Down
8 changes: 8 additions & 0 deletions owax_bookmarklet/_locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@
"message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.",
"description": ""
},
"ValidationTimeout": {
"message": "시간초과",
"description": ""
},
"ValidateManually": {
"message": "수동 검사",
"description": ""
},

"No1": {
"message": "적절한 대체 텍스트",
Expand Down
66 changes: 48 additions & 18 deletions owax_bookmarklet/dist/built.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! OpenWAX - v1.9.5 - 2013-03-27 */
/*! OpenWAX - v1.9.6 - 2013-03-30 */
(function (g) {
"use strict";

Expand Down Expand Up @@ -2170,6 +2170,19 @@ labelLoop:
return $res;
};

var getItemEl = function (url) {
var el = rdoc.getElementById("w3c_validation");
var itemEls = el.querySelectorAll("li.validationItem");
var i;

for (i = 0; i < itemEls.length; i++) {
var urlEl = itemEls[i].getElementsByClassName("url")[0];
if (urlEl.innerText === url || urlEl.textContent === url) {
return itemEls[i];
}
}
};

var doValidation = function (url, doc) {
var sourceUrl = url;
var req = new XMLHttpRequest();
Expand All @@ -2180,6 +2193,18 @@ labelLoop:
var html = req.responseText;
var req2 = new XMLHttpRequest();
var charset = html.indexOf('euc-kr') > 0 ? 'euc-kr' : 'utf-8';
var ggTimeout = setTimeout(function () {
var itemEl = getItemEl(url);
var errcntEl = itemEl.getElementsByClassName("errcnt")[0];
var directValidationLink = rdoc.createElement("a");
directValidationLink.target = '_blank';
directValidationLink.href = 'http://validator.w3.org/check?uri=' + encodeURIComponent(url);
directValidationLink.textContent = '(' + achecker.i18n.get('ValidateManually') + ')';
errcntEl.innerText = achecker.i18n.get('ValidationTimeout') + ' ';
errcntEl.textContent = achecker.i18n.get('ValidationTimeout') + ' ';
errcntEl.appendChild(directValidationLink);
}, 10 * 1000);

req2.onreadystatechange = function () {
try {
var i;
Expand All @@ -2191,32 +2216,29 @@ labelLoop:
if (req2.readyState === 4) {
if (req2.status === 200) {
var res = filterValidationResult(JSON.parse(req2.responseText));

var el = rdoc.getElementById("w3c_validation");
var headerEl = el.querySelector("h2");
var itemEls = el.querySelectorAll("li.validationItem");
var itemEl = getItemEl(url);
var errcnt = 0;
for (i = 0; i < res.messages.length; i++) {
if (res.messages[i].type === 'error') {
errcnt++;
}
}
for (i = 0; i < itemEls.length; i++) {
var urlEl = itemEls[i].getElementsByClassName("url")[0];
var errcntEl = itemEls[i].getElementsByClassName("errcnt")[0];
if (urlEl.innerText === url || urlEl.textContent === url) {
//urlEl.setAttribute('href', 'validation_result.html?res=' + encodeURIComponent(req2.responseText));
errcntEl.innerText = errcnt + ' Errors';
errcntEl.textContent = errcnt + ' Errors';
itemEls[i].className = errcnt > 0 ? 'fail' : 'pass';
if (errcnt > 0) {
headerEl.className += " fail";
}
var $res = getResultDetailEl(res.messages, url);
$res.style.display = 'none';
itemEls[i].appendChild($res);
itemEls[i].onclick = onClickItem;
}

clearTimeout(ggTimeout);
var errcntEl = itemEl.getElementsByClassName("errcnt")[0];
errcntEl.innerText = errcnt + ' Errors';
errcntEl.textContent = errcnt + ' Errors';
itemEl.className = errcnt > 0 ? 'fail' : 'pass';
if (errcnt > 0) {
headerEl.className += " fail";
}
var $res = getResultDetailEl(res.messages, url);
$res.style.display = 'none';
itemEl.appendChild($res);
itemEl.onclick = onClickItem;
}
}
} catch (e) {
Expand Down Expand Up @@ -2654,6 +2676,14 @@ achecker_locale["messages"] = {
"message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.",
"description": ""
},
"ValidationTimeout": {
"message": "시간초과",
"description": ""
},
"ValidateManually": {
"message": "수동 검사",
"description": ""
},

"No1": {
"message": "적절한 대체 텍스트",
Expand Down
6 changes: 3 additions & 3 deletions owax_bookmarklet/dist/built.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions owax_bookmarklet/dist/locale_ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ achecker_locale["messages"] = {
"message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.",
"description": ""
},
"ValidationTimeout": {
"message": "시간초과",
"description": ""
},
"ValidateManually": {
"message": "수동 검사",
"description": ""
},

"No1": {
"message": "적절한 대체 텍스트",
Expand Down
128 changes: 0 additions & 128 deletions owax_bookmarklet/lib/Score.js

This file was deleted.

1 change: 1 addition & 0 deletions owax_bookmarklet/lib/Score.js
Loading

0 comments on commit 22759ca

Please sign in to comment.