diff --git a/Gruntfile.js b/Gruntfile.js index 0487e4e..7f4033d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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: { diff --git a/lib/Sections.js b/lib/Sections.js index 59f2bed..63df259 100644 --- a/lib/Sections.js +++ b/lib/Sections.js @@ -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(); @@ -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; @@ -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) { diff --git a/owax_bookmarklet/_locales/en/messages.json b/owax_bookmarklet/_locales/en/messages.json index 32a8ab5..1a447f4 100644 --- a/owax_bookmarklet/_locales/en/messages.json +++ b/owax_bookmarklet/_locales/en/messages.json @@ -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", diff --git a/owax_bookmarklet/_locales/ko/messages.json b/owax_bookmarklet/_locales/ko/messages.json index 757f9a5..1eecf10 100644 --- a/owax_bookmarklet/_locales/ko/messages.json +++ b/owax_bookmarklet/_locales/ko/messages.json @@ -266,6 +266,14 @@ "message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.", "description": "" }, + "ValidationTimeout": { + "message": "시간초과", + "description": "" + }, + "ValidateManually": { + "message": "수동 검사", + "description": "" + }, "No1": { "message": "적절한 대체 텍스트", diff --git a/owax_bookmarklet/dist/built.js b/owax_bookmarklet/dist/built.js index c5d9903..c7307b8 100644 --- a/owax_bookmarklet/dist/built.js +++ b/owax_bookmarklet/dist/built.js @@ -1,4 +1,4 @@ -/*! OpenWAX - v1.9.5 - 2013-03-27 */ +/*! OpenWAX - v1.9.6 - 2013-03-30 */ (function (g) { "use strict"; @@ -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(); @@ -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; @@ -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) { @@ -2654,6 +2676,14 @@ achecker_locale["messages"] = { "message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.", "description": "" }, + "ValidationTimeout": { + "message": "시간초과", + "description": "" + }, + "ValidateManually": { + "message": "수동 검사", + "description": "" + }, "No1": { "message": "적절한 대체 텍스트", diff --git a/owax_bookmarklet/dist/built.min.js b/owax_bookmarklet/dist/built.min.js index 37b71b7..d13e9be 100644 --- a/owax_bookmarklet/dist/built.min.js +++ b/owax_bookmarklet/dist/built.min.js @@ -1,3 +1,3 @@ -/*! OpenWAX - v1.9.5 - 2013-03-27 */ -(function(e){"use strict";var t=function(t,n,a){t.addEventListener?t.addEventListener(n,a,!1):t.attachEvent&&(t["e"+n+a]=a,t[n+a]=function(){t["e"+n+a](e.event)},t.attachEvent("on"+n,t[n+a]))},n=function(t,n){return t.currentStyle?t.currentStyle.style:e.getComputedStyle(t,null)[n]},a=function(e){e.className=e.className.indexOf("folded")>-1?e.className.replace(/folded/g,""):e.className+" folded",document&&document.all&&(document.body.className=document.body.getAttribute("className"))},i={};i.getElementXPath=function(e){return e&&e.id?'//*[@id="'+e.id+'"]':i.getElementTreeXPath(e)},i.getElementTreeXPath=function(e){var t,n=[],a=10;for(e;e&&1===e.nodeType;e=e.parentNode){var i=0;for(t=e.previousSibling;t;t=t.previousSibling)t.nodeType!==a&&t.nodeName===e.nodeName&&++i;var r=e.nodeName.toLowerCase(),l=i?"["+(i+1)+"]":"";n.splice(0,0,r+l)}return n.length?"/"+n.join("/"):null},e.achecker=e.achecker||{},e.achecker.Wax=e.achecker.Wax||{},e.achecker.Wax.Section=function(){throw"not implemented"},e.achecker.Wax.Section.prototype={getAsElement:function(){throw"not implemented"}},e.achecker.Wax.isElHidden=function(e){if(e&&e.tagName&&("TITLE"===e.tagName||"BODY"===e.tagName||"HTML"===e.tagName))return!1;do{if(e.tagName&&"none"===n(e,"display"))return!0;e=e.parentNode}while(e);return!1},e.achecker.Wax.ListSection=e.achecker.Wax.Section,e.achecker.Wax.ListSection=function(e,t,n,a,i,r,l,s,o,c,d){this.cwin=e,this.rdoc=t,this.title=n,this.emptyMessage=s,this.contents=this._getContents(e,r,l,a,o,c,d,i)},e.achecker.Wax.ListSection.prototype._getContentsFromDocument=function(e,t,n,a,i,r,l){l||(l=99999);var s,o=e.querySelectorAll(n),c=[];for(s=0;o.length>s&&!(0>=l);s++){var d=o[s],h="function"==typeof a?a.apply(d,[e,t]):a;h!==!1&&(c.push({el:d,doc:d.ownerDocument,validStatus:"function"==typeof i?i.apply(d,[e,t]):"string"==typeof i?i:"",content:"function"==typeof a?a.apply(d,[e,t]):a,eventHandlers:r}),l--)}return c},e.achecker.Wax.ListSection.prototype._getContents=function(e,t,n,a,i,r,l,s){s||(s=99999);var o,c,d=this._getContentsFromDocument(e.document,e.location.href,a,i,r,l,s);if(s-=d.length,t&&s>0)for(o=0,c=n.length;c>o&&!(0>=s);o++){var h=this._getContentsFromDocument(n[o].doc,n[o].src,a,i,r,l,s);d=d.concat(h),s-=h.length}return d},e.achecker.Wax.ListSection.prototype.getAsElement=function(){var n,r=this.rdoc,l=r.createElement("ul"),s=!1,o=!1,c=function(){parent.Firebug&&parent.Firebug.Inspector.clearAllHighlights();var t=this["data-el"],n=e.achecker.Wax.isElHidden(t);if("TITLE"===t.tagName)for(;t&&"HTML"!==t.tagName;)t=t.parentNode;if(!n){var a=t.getAttribute("tabindex");t.setAttribute("tabindex",0),t.focus(),null===a?t.removeAttribute("tabindex"):t.setAttribute("tabindex",a)}parent.Firebug&&t?(parent.Firebug.Inspector.inspectFromContextMenu(t),parent.Firebug.Inspector.highlightObject(t,parent.Firebug.currentContext)):e.console&&e.console.log&&t&&e.console.log("OpenWAX Info: ",i.getElementXPath(t))};for(n=0;this.contents.length>n;n++){var d,h=this.contents[n],p=e.achecker.Wax.isElHidden(h.el)?" hidden_el":"",g=r.createElement("li");if(g.className=h.validStatus+" "+p,"string"==typeof h.content?(g.innerText=h.content,g.textContent=h.content):g.appendChild(h.content),g["data-el"]=h.el,h.eventHandlers)for(d in h.eventHandlers)h.eventHandlers.hasOwnProperty(d)&&t(g,d,h.eventHandlers[d]);"fail"===h.validStatus?o=!0:"warning"===h.validStatus&&(s=!0),t(g,"click",c),l.appendChild(g)}var u=r.createElement("div");u.className="waxSection";var m=r.createElement("h2"),f=r.createElement("span");if(m.innerText=this.title+" ",m.textContent=this.title+" ",m.className="folded",o?m.className+=" fail":s&&(m.className+=" warning"),f.innerText="("+this.contents.length+")",f.textContent="("+this.contents.length+")",m.appendChild(f),u.appendChild(m),0>=l.childNodes.length){var b=r.createElement("p");b.className="comment",b.innerText=this.emptyMessage,b.textContent=this.emptyMessage,u.appendChild(b)}else u.appendChild(l);return t(m,"click",function(){a(this)}),u},e.achecker.Wax.ListSection.prototype.getScore=function(){for(var e=this.contents.length,t=0,n=0;e>n;n++)"fail"!==this.contents[n].validStatus&&t++;return{all:e,pass:t}},e.achecker.Wax.TableSection=e.achecker.Wax.Section,e.achecker.Wax.TableSection=function(e,t,n,a,i,r,l,s,o,c,d){this.cwin=e,this.rdoc=t,this.title=n,this.colInfo=i,this.emptyMessage=s,this.contents=this._getContents(e,r,l,a,o,c,d)},e.achecker.Wax.TableSection.prototype._getContentsFromDocument=function(e,t,n,a,i,r){var l,s=e.querySelectorAll(n),o=[];for(l=0;s.length>l;l++){var c=s[l],d="function"==typeof a?a.apply(c,[e,t]):a;d!==!1&&o.push({el:c,doc:c.ownerDocument,validStatus:"function"==typeof i?i.apply(c,[e,t]):"string"==typeof i?i:"",content:"function"==typeof a?a.apply(c,[e,t]):a,eventHandlers:r})}return o},e.achecker.Wax.TableSection.prototype._getContents=function(e,t,n,a,i,r,l){var s,o,c=this._getContentsFromDocument(e.document,e.location.href,a,i,r,l);if(t)for(s=0,o=n.length;o>s;s++){var d=this._getContentsFromDocument(n[s].doc,n[s].src,a,i,r,l);c=c.concat(d)}return c},e.achecker.Wax.TableSection.prototype.getAsElement=function(){var n,r=this.rdoc,l=r.createElement("table"),s=r.createElement("thead"),o=r.createElement("tr"),c=!1,d=!1,h=function(){parent.Firebug&&parent.Firebug.Inspector.clearAllHighlights();var t=this["data-el"],n=e.achecker.Wax.isElHidden(t);if("TITLE"===t.tagName)for(;t&&"HTML"!==t.tagName;)t=t.parentNode;if(!n){var a=t.getAttribute("tabindex");t.setAttribute("tabindex",0),t.focus(),null===a?t.removeAttribute("tabindex"):t.setAttribute("tabindex",a)}parent.Firebug&&t?(parent.Firebug.Inspector.inspectFromContextMenu(t),parent.Firebug.Inspector.highlightObject(t,parent.Firebug.currentContext)):e.console&&e.console.log&&t&&e.console.log("OpenWAX Info: ",i.getElementXPath(t))};for(n=0;this.colInfo.length>n;n++){var p=r.createElement("th");p.setAttribute("scope","col"),p.innerText=this.colInfo[n].label,p.textContent=this.colInfo[n].label,this.colInfo[n].width&&(p.style.width=this.colInfo[n].width+"px"),this.colInfo[n].minWidth&&(p.style.minWidth=this.colInfo[n].minWidth+"px"),this.colInfo[n].maxWidth&&(p.style.maxWidth=this.colInfo[n].maxWidth+"px"),this.colInfo[n].className&&(p.className=this.colInfo[n].className),o.appendChild(p)}s.appendChild(o),l.appendChild(s);var g=r.createElement("tbody");for(n=0;this.contents.length>n;n++){var u,m,f=this.contents[n],b=e.achecker.Wax.isElHidden(f.el)?" hidden_el":"",x=r.createElement("tr");x.className=f.validStatus+" "+b;for(u in f.content)if(f.content.hasOwnProperty(u)){var C=f.content[u],v=r.createElement("td");"string"==typeof C?(v.innerText=C,v.textContent=C,v.innerHTML=C.replace(//g,">").replace(/\[__\[/g,'').replace(/\]__\]/g,"")):v.appendChild(C),this.colInfo[u].className&&(v.className=this.colInfo[u].className),x.appendChild(v)}if(x["data-el"]=f.el,f.eventHandlers)for(m in f.eventHandlers)f.eventHandlers.hasOwnProperty(m)&&t(x,m,f.eventHandlers[m]);"fail"===f.validStatus?d=!0:"warning"===f.validStatus&&(c=!0),t(x,"click",h),g.appendChild(x),l.appendChild(g)}var N=r.createElement("div");N.className="waxSection";var y=r.createElement("h2"),E=r.createElement("span");if(y.innerText=this.title+" ",y.textContent=this.title+" ",y.className="folded",d?y.className+=" fail":c&&(y.className+=" warning"),E.innerText="("+this.contents.length+")",E.textContent="("+this.contents.length+")",y.appendChild(E),N.appendChild(y),0>=g.childNodes.length){var T=r.createElement("p");T.className="comment",T.innerText=this.emptyMessage,T.textContent=this.emptyMessage,N.appendChild(T)}else N.appendChild(l);return t(y,"click",function(){a(this)}),N},e.achecker.Wax.TableSection.prototype.getScore=function(){for(var e=this.contents.length,t=0,n=0;e>n;n++)"fail"!==this.contents[n].validStatus&&t++;return{all:e,pass:t}},e.achecker.Wax.ToolSection=function(e,t,n,a,i,r){this.cwin=e,this.rdoc=t,this.id=n,this.title=a,this.content="function"==typeof i?i.apply(this,[this.cwin,this.rdoc]):i,this.eventHandlers=r},e.achecker.Wax.ToolSection.prototype.getAsElement=function(){var e=this.rdoc,n=e.createElement("div");n.id=this.id,n.className="waxSection";var i=e.createElement("h2");i.className="folded",i.innerText=this.title,i.textContent=this.title;var r=e.createElement("div");return"string"==typeof this.content?(r.innerText=this.content,r.textContent=this.content):r.appendChild(this.content),n.appendChild(i),n.appendChild(r),i.setAttribute("tabindex",0),t(i,"click",function(){a(this)}),n},e.achecker.Wax.ToolSection.prototype.getScore=function(){return null}})(window),function(e,t){"use strict";var n=e.achecker||{};n.Wax=n.Wax||{};var a=function(t,n,a){t.addEventListener?t.addEventListener(n,a,!1):t.attachEvent&&(t["e"+n+a]=a,t[n+a]=function(){t["e"+n+a](e.event)},t.attachEvent("on"+n,t[n+a]))},i=n.Wax.ListSection,r=n.Wax.TableSection,l=n.Wax.ToolSection,s=function(e,t){var n=[],a=0;if(e.length&&e.push){for(a=0;e.length>a;a++)n=n.concat(s(e[a],t));return n}var i=e.childNodes;if(i&&i.length){for(a=0;i.length>a;a++)i[a].tagName&&i[a].tagName.toLowerCase()===t.toLowerCase()&&n.push(i[a]);return n}return[]},o=function(e){e.className="folded"===e.className?"":"folded",t&&t.all&&(t.body.className=t.body.getAttribute("className"))},c=function(e,t){var n,a,i,r,l,s,o,c;if(0===t.indexOf("#")&&(t=t.substr(1,t.length-1)),0===e.indexOf("#")&&(e=e.substr(1,e.length-1)),i=parseInt(e.substr(0,2),16)/255,.03928>=i?i/=12.92:i=Math.pow((i+.055)/1.055,2.4),r=parseInt(e.substr(2,2),16)/255,.03928>=r?r/=12.92:r=Math.pow((r+.055)/1.055,2.4),l=parseInt(e.substr(4,2),16)/255,.03928>=l?l/=12.92:l=Math.pow((l+.055)/1.055,2.4),s=parseInt(t.substr(0,2),16)/255,.03928>=s?s/=12.92:s=Math.pow((s+.055)/1.055,2.4),o=parseInt(t.substr(2,2),16)/255,.03928>=o?o/=12.92:o=Math.pow((o+.055)/1.055,2.4),c=parseInt(t.substr(4,2),16)/255,.03928>=c?c/=12.92:c=Math.pow((c+.055)/1.055,2.4),n=.2126*i+.7152*r+.0722*l,a=.2126*s+.7152*o+.0722*c,n+=.05,a+=.05,a>n){var d=n;n=a,a=d}return n/=a,n=n.toFixed(1)},d=function(e){var t,n,a,i,r,l,s,o="",c=e.ownerDocument;e:for(i=0,r=c.getElementsByTagName("label").length;r>i;i++){if(n=c.getElementsByTagName("label")[i],a=n.childNodes,n.htmlFor&&n.htmlFor===e.id){t=n;break e}for(l=0,s=a.length;s>l;l++)if(a[l]===e){t=n;break e}}if(t)for(a=t.childNodes,i=0,r=a.length;r>i;i++)a[i].tagName||(o+=a[i].nodeValue.replace(/^\s+/,"").replace(/\s+$/,""));return o||(o=e.title?e.title:e.id?e.id:e.name?e.name:""),o},h=function(e){var t,n=1,a="",i=e.nodeType,r=e.tagName?e.tagName.toUpperCase():"",l=e.getAttribute?e.getAttribute("type"):"";try{var s=e.currentStyle||e.ownerDocument.defaultView.getComputedStyle(e,null);t=s.display}catch(o){t=""}if(i===n&&"none"===t&&(a+="[__["),i===n&&"IMG"===r)a+=e.getAttribute("alt");else if(i===n&&"AREA"===r)a+=e.getAttribute("alt");else if(i===n&&"INPUT"===r&&"image"===l)a+=e.getAttribute("alt");else if(i!==n||"INPUT"!==r||"submit"!==l&&"reset"!==l&&"button"!==l)if(i===n&&"INPUT"===r)a+=d(e);else if(i!==n||"TEXTAREA"!==r&&"SELECT"!==r){if(i!==n||"SCRIPT"!==r&&"STYLE"!==r){var c,p,g=e.childNodes,u=3;for(c=0,p=g.length;p>c;c++)a+=g[c].nodeType===u?g[c].nodeValue:h(g[c])}}else a+=d(e);else a+=e.value;return i===n&&"none"===t&&(a+="]__]"),a=a?a.replace(/^\s+/,"").replace(/\s+$/,""):""},p=function(e,t){var n,a;if(t=t.replace(/\?.*$/,""),e&&-1===e.indexOf("//"))if("../"===e.substr(0,3)){for(n=t.substr(0,t.lastIndexOf("/")>10?t.lastIndexOf("/"):t.length);"../"===e.substr(0,3);)n=n.substr(0,n.lastIndexOf("/")>10?n.lastIndexOf("/"):n.length),e=e.substr(3);e=n+"/"+e}else"/"===e.substr(0,1)?(a=t.replace(/^((?:https?\:\/\/|file\:\/\/\/)[^\/]+)\/.*$/,"$1"),e=a+"/"+e):(a=t.substr(0,t.lastIndexOf("/")),e=a+"/"+e);return e};n.Wax.run=function(t,d,g,u,m){return{header:function(){var e=d.createElement("div");e.className="waxFrames";var i=d.createElement("div"),r=d.createElement("button");i.className="toggleAll",r.className="fold",r.setAttribute("data-folded","folded"),r.title=n.i18n.get("UnfoldAll"),r.setAttribute("type","button"),r.innerText="Toggle All",r.textContent="Toggle All",r.onclick=function(){var e,t,a=d.querySelectorAll(".waxSection h2,.waxFrames h2"),i="folded"===this.getAttribute("data-folded")?"":"folded";for(e=0,t=a.length;t>e;e++)a[e].className=a[e].className.replace("folded","")+" "+i;i?(this.className="unfold",this.title=n.i18n.get("UnfoldAll")):(this.className="fold",this.title=n.i18n.get("FoldAll")),this.setAttribute("data-folded",i),d.body.className=d.body.getAttribute("className")},i.appendChild(r),e.appendChild(i);var l=d.createElement("h2");l.className="",l.innerText=n.i18n.get("TargetPage"),l.textContent=n.i18n.get("TargetPage"),a(l,"click",function(){o(this)});var s,c,h,p,f=d.createElement("ul"),b=d.createElement("li"),x=d.createElement("a");if(x.setAttribute("href",t.location.href),x.setAttribute("target","_blank"),x.innerText=t.location.href,x.textContent=t.location.href,b.appendChild(x),f.appendChild(b),g)for(c=0,h=u.length;h>c;c++)p=d.createElement("li"),s=d.createElement("a"),s.setAttribute("href",u[c].src),s.setAttribute("target","_blank"),s.innerText=u[c].src,s.textContent=u[c].src,p.appendChild(s),f.appendChild(p);if(e.appendChild(l),e.appendChild(f),m&&m.length)for(l=d.createElement("h2"),l.innerText=n.i18n.get("NoneTargetPage"),l.textContent=n.i18n.get("NoneTargetPage"),l.className="folded",a(l,"click",function(){o(this)}),f=d.createElement("ul"),c=0,h=m.length;h>c;c++)p=d.createElement("li"),s=d.createElement("a"),s.setAttribute("href",m[c]),s.setAttribute("target","_blank"),s.innerText=m[c],s.textContent=m[c],p.appendChild(s),f.appendChild(p);return e.appendChild(l),e.appendChild(f),e}(),sections:{altText:new r(t,d,"1. "+n.i18n.get("No1")+" (img)","input[type=image],img,area",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Preview"),width:106},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Contents")}],g,u,n.i18n.get("NotApplicable"),function(e,t){var a=this.tagName.toLowerCase(),i={hidden:"",preview:"",el:"",alt:""},r=this,l=function(){var e=null!==r.getAttribute("alt");if(i.alt=d.createElement("span"),e?r.getAttribute("alt")?(i.alt.innerText=r.getAttribute("alt"),i.alt.textContent=r.getAttribute("alt")):(i.alt.innerText='alt=""',i.alt.textContent='alt=""'):(i.alt.innerText="alt "+n.i18n.get("Undefined"),i.alt.textContent="alt "+n.i18n.get("Undefined")),i.el=a,r.getAttribute("longdesc")){var l=d.createElement("a");l.setAttribute("href",p(r.getAttribute("longdesc"),t)),l.setAttribute("target","_blank"),l.innerText="longdesc link",l.textContent="longdesc link",i.alt.innerText+=" ",i.alt.textContent+=" ",i.alt.appendChild(l)}var s=r.getAttribute("src"),o=d.createElement("div");o.style.width="100px",o.style.margin="0 auto",o.style.overflow="hidden";var c=d.createElement("img");return c.setAttribute("alt",""),c.setAttribute("src",p(s,t)),o.appendChild(c),i.preview=o,[i.hidden,i.preview,i.el,i.alt]};switch(a){case"input":if("image"!==this.type.toLowerCase())break;return l();case"img":return l();case"area":var s=null!==this.getAttribute("alt");return i.alt=d.createElement("span"),s?this.getAttribute("alt")?(i.alt.innerText=this.getAttribute("alt"),i.alt.textContent=this.getAttribute("alt")):(i.alt.innerText='alt=""',i.alt.textContent='alt=""'):(i.alt.innerText="alt "+n.i18n.get("Undefined"),i.alt.textContent="alt "+n.i18n.get("Undefined")),i.el=a,[i.hidden,i.preview,i.el,i.alt]}return!1},function(){var e=this.tagName;switch(e){case"IMG":case"INPUT":case"AREA":var t=null!==this.getAttribute("alt");return t?this.getAttribute("alt")?"pass":"warning":"fail"}}),altTextBG:new r(t,d,"1. "+n.i18n.get("No1")+" (bg)","body *",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Preview"),width:106},{label:n.i18n.get("Contents")}],g,u,n.i18n.get("NotApplicable"),function(e,n){var a={hidden:"",preview:"",content:""},i=this.currentStyle||t.getComputedStyle(this,null),r=i.backgroundImage;if("none"!==r&&10>this.getElementsByTagName("*").length){var l=d.createElement("span");n=r.replace(/^url\("?/,"").replace(/"?\)$/,"");try{l.style.backgroundImage=r,l.style.backgroundPosition=i.backgroundPosition,l.style.backgroundRepeat=i.backgroundRepeat,l.style.width=i.width,l.style.height=i.height}catch(s){}return l.style.maxWidth="100px",l.style.maxHeight="200px",l.style.display="inline-block",l.style.overflow="hidden",a.preview=l,a.content=h(this),[a.hidden,a.preview,a.content]}return!1}),altTextEmbed:new r(t,d,"1. "+n.i18n.get("No1")+" (object)","object,embed,video,audio,canvas,svg",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element")}],g,u,n.i18n.get("NotApplicable"),function(){var e=this.tagName;switch(e){case"OBJECT":return this.parentNode&&this.parentNode.tagName&&("OBJECT"===this.parentNode.tagName||"EMBED"===this.parentNode.tagName)?!1:["",""];case"EMBED":return this.parentNode&&this.parentNode.tagName&&("OBJECT"===this.parentNode.tagName||"EMBED"===this.parentNode.tagName)?!1:["",""]}return!1}),contrast:new l(t,d,"contrast","5. "+n.i18n.get("No5"),function(e,t){if(!n.colorInspector){var a=t.createElement("p");return a.className="comment",a.innerText="Not Supported.",a.textContent="Not Supported.",a}var i=t.createElement("ul");i.className="contrast";var r=t.createElement("li"),l=t.createElement("li"),s=t.createElement("li");r.className="color1";var o=t.createElement("span");o.innerText=n.i18n.get("Foreground")+": ",o.textContent=n.i18n.get("Foreground")+": ";var d=t.createElement("span");d.className="color",d.style.backgroundColor="#000";var h=t.createElement("span");h.className="val",h.innerText="#000000",h.textContent="#000000";var p=t.createElement("button");p.innerText=n.i18n.get("SelectForegroundColor"),p.textContent=n.i18n.get("SelectForegroundColor"),r.appendChild(o),r.appendChild(d),r.appendChild(t.createTextNode(" ")),r.appendChild(h),r.appendChild(t.createTextNode(" ")),r.appendChild(p),r.onclick=function(){n.showOverlay(),n.colorInspector.startInspect(function(e){n.hideOverlay(),r.getElementsByClassName("color")[0].style.backgroundColor=e,r.getElementsByClassName("val")[0].innerText=e,r.getElementsByClassName("val")[0].textContent=e;var t=c(e,l.getElementsByClassName("val")[0].innerText);s.className=t>=4.5?"pass":t>=3?"warning":"fail",s.getElementsByClassName("result")[0].innerText=t+":1",s.getElementsByClassName("result")[0].textContent=t+":1",s.getElementsByClassName("resultText")[0].style.color=e})},l.className="color2";var g=t.createElement("span");g.innerText=n.i18n.get("Background")+": ",g.textContent=n.i18n.get("Background")+": ";var u=t.createElement("span");u.className="color",u.style.backgroundColor="#FFF";var m=t.createElement("span");m.className="val",m.innerText="#FFFFFF",m.textContent="#FFFFFF";var f=t.createElement("button");f.innerText=n.i18n.get("SelectBackgroundColor"),f.textContent=n.i18n.get("SelectBackgroundColor"),l.appendChild(g),l.appendChild(u),l.appendChild(t.createTextNode(" ")),l.appendChild(m),l.appendChild(t.createTextNode(" ")),l.appendChild(f),l.onclick=function(){n.showOverlay(),n.colorInspector.startInspect(function(e){n.hideOverlay(),l.getElementsByClassName("color")[0].style.backgroundColor=e,l.getElementsByClassName("val")[0].innerText=e,l.getElementsByClassName("val")[0].textContent=e;var t=c(e,r.getElementsByClassName("val")[0].innerText);s.className=t>=4.5?"pass":t>=3?"warning":"fail",s.getElementsByClassName("result")[0].innerText=t+":1",s.getElementsByClassName("result")[0].textContent=t+":1",s.getElementsByClassName("resultText")[0].style.backgroundColor=e})},s.className="pass";var b=t.createElement("span");b.innerText=n.i18n.get("Result")+": ",b.textContent=n.i18n.get("Result")+": ";var x=t.createElement("span");x.className="result",x.innerText="21:1",x.textContent="21:1";var C=t.createElement("span");return C.className="resultText",C.innerText=n.i18n.get("Test"),C.textContent=n.i18n.get("Test"),s.appendChild(b),s.appendChild(x),s.appendChild(t.createTextNode(" ")),s.appendChild(C),i.appendChild(r),i.appendChild(l),i.appendChild(s),i}),kbdFocus:new r(t,d,"8. "+n.i18n.get("No8"),"*",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("ErrorType"),width:65},{label:n.i18n.get("Contents")}],g,u,n.i18n.get("RequireConfirmation"),function(){try{var e=this.wrappedJSObject||this,t=!1;e.onfocus&&(""+e.onfocus).indexOf("blur()")>-1?t=!0:e.onclick&&(""+e.onclick).indexOf("blur()")>-1&&(t=!0);var n=this.style.getPropertyValue("outline-width"),a="0"===n||"0pt"===n||"0px"===n;return t?["","blur()",h(this)]:a?["","outline:0",h(this)]:!1}catch(i){return!1}},function(){try{var e=this.wrappedJSObject||this,t=e.onfocus?(""+e.onfocus).indexOf("blur()")>-1:!1,n=this.style.getPropertyValue("outline-width"),a="0"===n||"0pt"===n||"0px"===n;return t?"fail":a?"fail":"pass"}catch(i){return!1}}),skipNav:new r(t,d,"12. "+n.i18n.get("No12"),'a[href^="#"]',[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("No"),width:65},{label:n.i18n.get("Contents")},{label:n.i18n.get("Connected"),width:45}],g,u,"-",function(e){if(t.document!==e)return!1;var a,i,r,l=this.getAttribute("href"),s="#"===l?!1:!!e.getElementById(l.replace("#",""))||e.getElementsByName(l.replace("#","")).length>0;for(i=0,r=e.getElementsByTagName("a").length;r>i;i++)if(e.getElementsByTagName("a")[i]===this){if(a=i+1,a>20)return!1;break}return["",a+n.i18n.get("ThLink"),"("+l+") "+h(this),s?"O":"X"]},function(e){var t=this.getAttribute("href"),n="#"===t?!1:!!e.getElementById(t.replace("#",""))||e.getElementsByName(t.replace("#","")).length>0;return n?"pass":"fail"}),pageTitle:new i(t,d,"13. "+n.i18n.get("No13")+"()","title",null,g,u,"-",function(e,t){var a=d.createElement("span"),i=d.createElement("strong"),r=this.textContent||this.innerText||n.i18n.get("NoPageTitle");return a.innerText=t+": ",a.textContent=t+": ",i.innerText=r,i.textContent=r,a.appendChild(i),a},function(){for(var e=this.textContent||this.innerText||"",t=["::","||","--","@@","##","$$","%%","&&","**","((","))","++","==","~~",";;","<<",">>","[[","]]","★★","☆☆","◎◎","●●","◆◆","◇◇","□□","■■","△△","▲▲","▽▽","▼▼","◁◁","◀◀","▷▷","▶▶","♠♠","♤♤","♡♡","♥♥","♧♧","♣♣","⊙⊙","◈◈","▣▣","◐◐","◑◑","▒▒","▤▤","▥▥","▨▨","▧▧","▦▦","▩▩","♨♨","☏☏","☎☎"],n=!!e,a=!1,i=0;t.length>i;i++)if(e.indexOf(t[i])>-1){a=!0;break}return n&&!a?"pass":"fail"}),frame:new r(t,d,"13. "+n.i18n.get("No13")+"(frame)","iframe",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Title"),minWidth:50,className:"lt"},{label:n.i18n.get("Contents"),maxWidth:200}],g,u,n.i18n.get("NotApplicable"),function(){var e={hidden:"",el:"",title:"",url:""},t=this.getAttribute("src"),a=this.getAttribute("title");if(e.el="iframe",t){var i=d.createElement("a");i.setAttribute("href",t),i.setAttribute("target","_blank"),i.innerText=t,i.textContent=t,e.url=i}else e.url=n.i18n.get("NoSrc");return e.title=a||n.i18n.get("NoTitle"),[e.hidden,e.el,e.title,e.url]},function(){var e=this.getAttribute("title");return e?"pass":"fail"}),blockTitle:new r(t,d,"13. "+n.i18n.get("No13")+"(<h1>~<h6>)","h1,h2,h3,h4,h5,h6",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Contents")}],g,u,n.i18n.get("RequireConfirmation"),function(){return["",this.tagName.toLowerCase(),h(this)]}),linkText:new r(t,d,"14. "+n.i18n.get("No14"),"a,area",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Contents")}],g,u,n.i18n.get("NotApplicable"),function(){var e=h(this),t=this.getAttribute("title");return["",this.tagName.toLowerCase(),(e||"-")+(t?" (title: "+t+")":"")]},function(){var e=h(this);return e?"pass":"fail"}),pageLang:new i(t,d,"15. "+n.i18n.get("No15"),"html",null,g,u,"-",function(e,t){var a=this.getAttribute("xmlns"),i="",r=d.createElement("span");if("http"!==t.substr(0,4).toLowerCase()&&".html"!==t.substr(-5).toLowerCase())return!1;i=a&&this.getAttribute("xml:lang")&&this.getAttribute("lang")?"xml:lang="+this.getAttribute("xml:lang")+", lang="+this.getAttribute("lang"):a&&this.getAttribute("xml:lang")?"xml:lang="+this.getAttribute("xml:lang"):a&&this.getAttribute("lang")?"xml:lang="+n.i18n.get("None")+", lang="+this.getAttribute("lang"):!a&&this.getAttribute("lang")?"lang="+this.getAttribute("lang"):n.i18n.get("NoMainLang"),r.innerText=t+": ",r.textContent=t+": ";var l=d.createElement("strong");return l.innerText=i,l.textContent=i,r.appendChild(l),r},function(){var e=this.getAttribute("xmlns");return e&&this.getAttribute("xml:lang")?"pass":e&&this.getAttribute("lang")?"warning":!e&&this.getAttribute("lang")?"pass":"fail"}),unintendedFunction:new r(t,d,"16. "+n.i18n.get("No16"),"a,area,input,button",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Event"),width:80},{label:n.i18n.get("Contents"),className:"lt"},{label:n.i18n.get("TitleAttribute")}],g,u,n.i18n.get("RequireConfirmation"),function(){var e,t={hidden:"",event:"",content:"",title:""},n=this.wrappedJSObject||this;try{e=n.onclick?(""+n.onclick).indexOf("window.open")>-1:!1}catch(a){e=null}return t.content=h(this),t.title=this.getAttribute("title")?this.getAttribute("title"):"_blank"===this.getAttribute("target")?'target="_blank"':"-",e?(t.event="window.open",[t.hidden,t.event,t.content,t.title]):!1},function(){return this.getAttribute("title")?"warning":"_blank"===this.getAttribute("target")?"pass":"fail"}),tableTitle:new r(t,d,"18. "+n.i18n.get("No18")+"(caption, summary)","table",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("CaptionContent"),className:"lt"},{label:n.i18n.get("SummaryContent")}],g,u,n.i18n.get("NotApplicable"),function(){var e,t=this.childNodes,a=null,i={hidden:"",caption:"",summary:""};for(e=0;t.length>e;e++)if(t[e].tagName&&"caption"===t[e].tagName.toLowerCase()){a=t[e];break}var r=!!a,l=!!this.getAttribute("summary");return i.caption=r?h(a):n.i18n.get("None"),i.summary=l?this.getAttribute("summary"):n.i18n.get("None"),[i.hidden,i.caption,i.summary]},function(){var e,t=this.childNodes,n=null;for(e=0;t.length>e;e++)if(t[e].tagName&&"caption"===t[e].tagName.toLowerCase()){n=t[e];break}var a=!!n,i=!!this.getAttribute("summary");return a?"pass":a||i?"fail":"warning"}),tableStructure:new r(t,d,"18. "+n.i18n.get("No18")+"(th)","table",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Structure"),className:"tb_str"}],g,u,n.i18n.get("NotApplicable"),function(){var e={hidden:"",structure:""},t=s(this,"thead"),n=s(this,"tfoot"),a=s(this,"tbody"),i=s(s(t,"tr"),"th"),r=s(s(n,"tr"),"th"),l=s(s(a,"tr"),"th").concat(s(s(this,"tr"),"th"));!!i.length||!!r.length||l.length;var o=d.createElement("table"),c=d.createElement("thead"),p=d.createElement("tbody"),g=d.createElement("tr"),u=d.createElement("th"),m=d.createElement("th"),f=d.createElement("th");u.innerText="요소",u.textContent="요소",m.innerText="유무",m.textContent="유무",f.innerText="제목셀 정보 (scope 속성값)",f.textContent="제목셀 정보 (scope 속성값)",g.appendChild(u),g.appendChild(m),g.appendChild(f),c.appendChild(g),o.appendChild(c),o.appendChild(p);var b,x,C,v,N,y,E=d.createElement("tr"),T=d.createElement("td"),w=d.createElement("td"),k=d.createElement("td");if(t.length){for(b=d.createElement("ul"),T.innerText="thead",T.textContent="thead",w.innerText="O",w.textContent="O",x=0,C=i.length;C>x;x++)v=i[x],N=v.getAttribute("scope"),y=d.createElement("li"),y.innerText=h(v)+(N?"("+N+")":"(X)"),y.textContent=h(v)+(N?"("+N+")":"(X)"),b.appendChild(y);k.appendChild(b)}else T.innerText="thead",T.textContent="thead",w.innerText="X",w.textContent="X",k.innerText="-",k.textContent="-";if(E.appendChild(T),E.appendChild(w),E.appendChild(k),p.appendChild(E),E=d.createElement("tr"),T=d.createElement("td"),w=d.createElement("td"),k=d.createElement("td"),n.length){for(b=d.createElement("ul"),T.innerText="tfoot",T.textContent="tfoot",w.innerText="O",w.textContent="O",x=0,C=r.length;C>x;x++)v=r[x],N=v.getAttribute("scope"),y=d.createElement("li"),y.innerText=h(v)+(N?"("+N+")":"(X)"),y.textContent=h(v)+(N?"("+N+")":"(X)"),b.appendChild(y);k.appendChild(b)}else T.innerText="tfoot",T.textContent="tfoot",w.innerText="X",w.textContent="X",k.innerText="-",k.textContent="-";if(E.appendChild(T),E.appendChild(w),E.appendChild(k),p.appendChild(E),E=d.createElement("tr"),T=d.createElement("td"),w=d.createElement("td"),k=d.createElement("td"),a.length){for(b=d.createElement("ul"),T.innerText="tbody",T.textContent="tbody",w.innerText="O",w.textContent="O",x=0,C=l.length;C>x;x++)v=l[x],N=v.getAttribute("scope"),y=d.createElement("li"),y.innerText=h(v)+(N?"("+N+")":"(X)"),y.textContent=h(v)+(N?"("+N+")":"(X)"),b.appendChild(y);k.appendChild(b)}else T.innerText="tbody",T.textContent="tbody",w.innerText="X",w.textContent="X",k.innerText="-",k.textContent="-";return E.appendChild(T),E.appendChild(w),E.appendChild(k),p.appendChild(E),e.structure=o,[e.hidden,e.structure]},function(){var e=s(s(s(this,"thead"),"tr"),"th"),t=s(s(s(this,"tfoot"),"tr"),"th"),n=s(s(s(this,"tbody"),"tr"),"th").concat(s(s(this,"tr"),"th")),a=e.length||t.length||n.length,i=function(e){var t,n;for(t=0,n=e.length;n>t;t++)if(!e[t].getAttribute("scope"))return!1;return!0};return a&&i(e)&&i(t)&&i(n)?"pass":a||e.length||t.length?"fail":"warning"}),label:new r(t,d,"19. "+n.i18n.get("No19"),"input,textarea,select",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("FormType"),width:66},{label:n.i18n.get("LabelConnection"),className:"lt"},{label:n.i18n.get("TitleAttribute")}],g,u,n.i18n.get("NotApplicable"),function(e){var t=this.getAttribute("type")?this.getAttribute("type").toLowerCase():null;if("INPUT"===this.tagName&&("submit"===t||"button"===t||"image"===t||"hidden"===t||"reset"===t))return!1;var n,a,i={hidden:"",el:"",type:"",label:"",title:""},r=this.getAttribute("id"),l=e.getElementsByTagName("label"),s=!1,o=null;if(r)for(n=0,a=l.length;a>n;n++)if(l[n].getAttribute("for")===r){s=!0,o=l[n];break}!!this.getAttribute("title");var c=!1,d=this.parentNode;do if(d=d.parentNode,"LABEL"===d.tagName){c=!0,o=d;break}while(d.parentNode);return i.el=this.tagName.toLowerCase(),i.type=t||"-",i.label=o?h(o):"",i.label||(i.label="X"),i.title=this.getAttribute("title"),i.title||(i.title="-"),[i.hidden,i.el,i.type,i.label,i.title]},function(e){var t,n,a=this.getAttribute("id"),i=e.getElementsByTagName("label"),r=!1;if(a)for(t=0,n=i.length;n>t;t++)if(i[t].getAttribute("for")===a){r=!0;break}var l=!!this.getAttribute("title"),s=!1,o=this.parentNode;do o=o.parentNode,"LABEL"===o.tagName&&(s=!0);while(o.parentNode);return r?"pass":s?"pass":l?"warning":"fail"}),validation:new l(t,d,"w3c_validation","21. "+n.i18n.get("No21"),function(t,i){var r="object"==typeof chrome&&chrome.extension,l="object"==typeof Components&&Components.classes;if(!r&&!l){var s=i.createElement("p");return s.className="comment",s.innerText="Not Supported.",s.textContent="Not Supported.",s}var o,c,d=function(e){var t,n,a=e.messages,i=[],r=[/^document type does not allow element .* here; missing one of .* start\-tag.*/,/^end tag for .* which is not finished.*/,/^end tag for element .* which is not open.*/,/^ID .* already defined.*/,/^unclosed start-tag requires SHORTTAG YES.*/,/^unclosed end-tag requires SHORTTAG YES.*/,/^empty start-tag.*/,/^empty end-tag.*/];for(t=0;a.length>t;t++)if("error"===a[t].type)for(n=0;r.length>n;n++)if(r[n].test(a[t].message)){i.push(a[t]);break}return e.messages=i,e},h=function(e,t){var n=i.createElement("div");n.className="validationResult";var r=i.createElement("h3");r.innerText="Error",r.textContent="Error",r.className="fail";var l=i.createElement("ul"),s=i.createElement("h3");s.innerText="Warning",s.textContent="Warning",s.className="warning";var o,c=i.createElement("ul"),d=function(e){e.preventDefault(),e.stopPropagation(),openDialog("chrome://global/content/viewSource.xul","achecker_sourceView","scrollbars,resizable,chrome,dialog=no",t,null,null,this.getAttribute("data-line"),!1)};for(o=0;e.length>o;o++){var h=e[o],p=i.createElement("li"),g=i.createElement("div"),u=i.createElement("a");u.innerText=h.message,u.textContent=h.message,u.setAttribute("href","#"),u.setAttribute("data-line",h.lastLine),a(u,"click",d),g.appendChild(u); -var m=i.createElement("div");switch(m.className="subinfo",m.innerText=h.lastLine+" line, "+h.lastColumn+" column",m.textContent=h.lastLine+" line, "+h.lastColumn+" column",p.appendChild(g),p.appendChild(m),h.type){case"error":l.appendChild(p);break;case"info":c.appendChild(p)}}return n.appendChild(r),n.appendChild(l),n.appendChild(s),n.appendChild(c),n},p=function(t){var a=t,r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status){var a=r.responseText,l=new XMLHttpRequest;a.indexOf("euc-kr")>0?"euc-kr":"utf-8",l.onreadystatechange=function(){try{var e,n=function(){var e=this.getElementsByTagName("div")[0];e.style.display="none"===e.style.display?"block":"none"};if(4===l.readyState&&200===l.status){var a=d(JSON.parse(l.responseText)),r=i.getElementById("w3c_validation"),s=r.querySelector("h2"),o=r.querySelectorAll("li.validationItem"),c=0;for(e=0;a.messages.length>e;e++)"error"===a.messages[e].type&&c++;for(e=0;o.length>e;e++){var p=o[e].getElementsByClassName("url")[0],g=o[e].getElementsByClassName("errcnt")[0];if(p.innerText===t||p.textContent===t){g.innerText=c+" Errors",g.textContent=c+" Errors",o[e].className=c>0?"fail":"pass",c>0&&(s.className+=" fail");var u=h(a.messages,t);u.style.display="none",o[e].appendChild(u),o[e].onclick=n}}}}catch(m){}};try{if(l.open("POST","http://validator.w3.org/check",!0),"object"!=typeof FormData)l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.send("fragment="+e.escape(a)+"&doctype=Inline"+"&output=json");else{var s=new FormData;s.append("fragment",a),s.append("doctype","Inline"),s.append("output","json"),l.send(s)}}catch(o){}}else e.alert(n.i18n.get("ValidationFail"))},r.open("GET",a,!0),r.send(null)},m=[],f=[];if(("http://"===t.location.href.substr(0,7)||"https://"===t.location.href.substr(0,8))&&(m.push(t.location.href),f.push(t.document)),g)for(o=0,c=u.length;c>o;o++){var b=u[o].src;("http://"===b.substr(0,7)||"https://"===b.substr(0,8))&&(m.push(b),f.push(u[o]))}var x=i.createElement("ul");for(o=0,c=m.length;c>o;o++){p(m[o],f[o]);var C=i.createElement("li");C.className="validationItem";var v=i.createElement("span");v.className="url",v.innerText=m[o],v.textContent=m[o];var N=i.createElement("b");N.className="errcnt",N.innerText=n.i18n.get("Loading"),N.textContent=n.i18n.get("Loading"),C.appendChild(v),C.appendChild(i.createTextNode(": ")),C.appendChild(N),x.appendChild(C)}return x})}}}}(window,window.document),function(e){"use strict";var t={altText:30,kbdFocus:10,frame:10,linkText:10,pageLang:10,unintendedFunction:10,label:20},n=function(e){return e>=95?"perfect":e>80?"good":e>60?"bad":"fail"},a=function(e){var t,n=e.location.href,a=e.document.getElementsByTagName("link"),i=a.length;for(t=0;i>t;t++)"canonical"===a[t].getAttribute("rel")&&a[t].getAttribute("href")&&(n=a[t].getAttribute("href"));return n=n.replace(/\#.*$/,"")};e.achecker=e.achecker||{},e.achecker.Wax=e.achecker.Wax||{},e.achecker.Wax.score=function(e){var n,a=0;for(var i in t)t.hasOwnProperty(i)&&(n=e[i]?e[i].getScore():null,a+=n&&n.all>0?parseInt(10*n.pass/n.all*t[i],10)/10:parseInt(t[i],10));return parseInt(10*a,10)/10},e.achecker.Wax.scoreAsElement=function(t,i,r,l){var s=e.achecker.Wax.score(r),o=i.createElement("div");o.className="waxScore "+n(s);var c=i.createElement("h2"),d=i.createElement("a");d.setAttribute("href","http://openwax.miya.pe.kr/#guide_score"),d.setAttribute("target","_blank"),d.innerText="WAX Score: ",d.textContent="WAX Score: ";var h=i.createElement("strong");if(h.innerText=s,h.textContent=s,d.appendChild(h),c.appendChild(d),o.appendChild(c),l){var p=i.createElement("img");p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.setAttribute("src","http://openwax.miya.pe.kr/log?url="+encodeURIComponent(a(t))+"&"+"title="+encodeURIComponent(t.document.title)+"&"+"score="+s+"&"),o.appendChild(p)}return o}}(window);var achecker_locale={};achecker_locale.messages={Target:{message:"대상",description:""},TargetPage:{message:"대상 페이지",description:""},NoneTargetPage:{message:"비대상 페이지",description:""},AltText:{message:"대체 텍스트",description:""},Undefined:{message:"미정의",description:""},ValidationFail:{message:"유효성 검사 오류 발생!",description:""},Loading:{message:"로딩중...",description:""},TableTitle:{message:"표 제목",description:""},None:{message:"없음",description:""},TableStructure:{message:"표 구조화",description:""},HasThead:{message:"thead있음",description:""},HasTfoot:{message:"tfoot있음",description:""},HasTbody:{message:"tbody있음",description:""},NoThead:{message:"thead없음",description:""},NoTfoot:{message:"tfoot없음",description:""},NoTbody:{message:"tbody없음",description:""},LevelAA:{message:"레벨AA",description:""},DocumentsForView:{message:"단순 열람 문서 형식",description:""},ShortCut:{message:"단축키",description:""},PageMainLang:{message:"주언어 명시",description:""},NoMainLang:{message:"주언어 없음",description:""},Contrast:{message:"명도 대비",description:""},Foreground:{message:"전경",description:""},SelectForegroundColor:{message:"전경색 선택",description:""},Background:{message:"배경",description:""},SelectBackgroundColor:{message:"배경색 선택",description:""},Result:{message:"결과",description:""},Test:{message:"테스트",description:""},KeyboardFocus:{message:"키보드 포커스",description:""},Error:{message:"오류",description:""},PageTitle:{message:"페이지 제목",description:""},NoPageTitle:{message:"페이지 제목 없음",description:""},UseFrame:{message:"프레임 사용",description:""},NoSrc:{message:"src 없음",description:""},NoTitle:{message:"title 없음",description:""},BlockTitle:{message:"콘텐츠 블록 제목",description:""},SkipNavigation:{message:"건너뛰기 링크",description:""},NthLink:{message:"번째 링크",description:""},Link:{message:"링크",description:""},Connected:{message:"연결",description:""},IsConnected:{message:"연결됨",description:""},IsNotConnected:{message:"연결되지 않음",description:""},LinkText:{message:"링크 텍스트",description:""},NoText:{message:"텍스트 없음",description:""},UnintendedFunction:{message:"의도하지 않은 기능",description:""},Label:{message:"레이블",description:""},No:{message:"번호",description:""},ThLink:{message:"번째 링크",description:""},NotApplicable:{message:"해당없음",description:""},RequireConfirmation:{message:"직접 확인 필요",description:""},FoldAll:{message:"전체 접기",description:""},UnfoldAll:{message:"전체 펼치기",description:""},Hidden:{message:"숨김",description:""},Preview:{message:"미리보기",description:""},Element:{message:"요소",description:""},Contents:{message:"내용",description:""},CaptionContent:{message:"Caption 내용",description:""},SummaryContent:{message:"Summary 내용",description:""},Structure:{message:"구조",description:""},ErrorType:{message:"오류 유형",description:""},Title:{message:"제목",description:""},Event:{message:"이벤트",description:""},TitleAttribute:{message:"title 속성값",description:""},FormType:{message:"폼 유형",description:""},LabelConnection:{message:"label 연결",description:""},CannotCheckFrameset:{message:"프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.",description:""},No1:{message:"적절한 대체 텍스트",description:""},No5:{message:"텍스트 콘텐츠의 명도 대비",description:""},No8:{message:"초점 이동",description:""},No12:{message:"건너뛰기 링크",description:""},No13:{message:"제목 제공",description:""},No14:{message:"적절한 링크 텍스트",description:""},No15:{message:"기본 언어 표시",description:""},No16:{message:"사용자 요구에 따른 실행",description:""},No18:{message:"표의 구성",description:""},No19:{message:"레이블 제공",description:""},No21:{message:"마크업 오류 방지",description:""}},function(e){"use strict";var t=e.achecker||{};t.i18n={get:function(e){return achecker_locale.messages[e].message||""}}}(window),function(e){"use strict";e.achecker=e.achecker||{},e.achecker.showOverlay=function(){if(document.getElementById("_acheckeroverlay"))return document.getElementById("_acheckeroverlay").style.display="block",void 0;var e=document.createElement("div");e.id="_acheckeroverlay",e.style.display="block",e.style.zIndex="99999999",e.style.position="fixed",e.style.top="0",e.style.right="0",e.style.bottom="0",e.style.left="400px",e.style.backgroundColor="#fff",e.style.opacity="0.01",document.body.appendChild(e)},e.achecker.hideOverlay=function(){document.getElementById("_acheckeroverlay")&&(document.getElementById("_acheckeroverlay").style.display="none")};var t=function(t){var n,a,i=[],r=[];if(t)for(n=0,a=document.getElementsByTagName("iframe").length;a>n;n++){var l=document.getElementsByTagName("iframe")[n];l.src&&l.contentDocument?i.push({src:l.src,doc:l.contentDocument}):l.src&&r.push(l.src)}var s=window,o=document;if(!i.length&&!s.document.documentElement)return{err:!0,message:"You cannot check this page.",text_message:"You cannot check this page."};if(s.document.getElementsByTagName("frameset").length>0){var c=s.document.getElementsByTagName("frame"),d="<ul>";for(n=0,a=c.length;a>n;n++)c[n].src.indexOf("http")>-1&&(d+='<li><a href="'+c[n].src+'" target="_blank"">'+c[n].src+"</a></li>");return d+="</ul>",{err:!0,message:"<p>"+e.achecker.i18n.get("CannotCheckFrameset")+"</p>"+d,text_message:e.achecker.i18n.get("CannotCheckFrameset")}}var h=o.createElement("div");h.id="achecker-result",o.documentElement.className+=" achecker-included";var p=e.achecker.Wax.run(s,o,t,i,r),g=p.header,u=p.sections,m=e.achecker.Wax.scoreAsElement(s,o,u,!0);h.appendChild(m),h.appendChild(g);for(n in u)u.hasOwnProperty(n)&&h.appendChild(u[n].getAsElement());return o.body.appendChild(h),{err:!1}},n=function(e){if(!document.getElementById("achecker-css")){var n=document.createElement("link");n.rel="stylesheet",n.id="achecker-css",n.href="http://openwax.miya.pe.kr/c/bookmarklet.css?t="+(new Date).valueOf(),document.getElementsByTagName("head")[0].appendChild(n)}if(document.getElementById("achecker-result"))return document.body.removeChild(document.getElementById("achecker-result")),document.documentElement.className=document.documentElement.className.replace(/ achecker\-included/,""),{err:!1};var a=t(e);return a},a=n();a.err&&window.alert(a.text_message)}(window); \ No newline at end of file +/*! OpenWAX - v1.9.6 - 2013-03-30 */ +(function(e){"use strict";var t=function(t,n,a){t.addEventListener?t.addEventListener(n,a,!1):t.attachEvent&&(t["e"+n+a]=a,t[n+a]=function(){t["e"+n+a](e.event)},t.attachEvent("on"+n,t[n+a]))},n=function(t,n){return t.currentStyle?t.currentStyle.style:e.getComputedStyle(t,null)[n]},a=function(e){e.className=e.className.indexOf("folded")>-1?e.className.replace(/folded/g,""):e.className+" folded",document&&document.all&&(document.body.className=document.body.getAttribute("className"))},i={};i.getElementXPath=function(e){return e&&e.id?'//*[@id="'+e.id+'"]':i.getElementTreeXPath(e)},i.getElementTreeXPath=function(e){var t,n=[],a=10;for(e;e&&1===e.nodeType;e=e.parentNode){var i=0;for(t=e.previousSibling;t;t=t.previousSibling)t.nodeType!==a&&t.nodeName===e.nodeName&&++i;var r=e.nodeName.toLowerCase(),l=i?"["+(i+1)+"]":"";n.splice(0,0,r+l)}return n.length?"/"+n.join("/"):null},e.achecker=e.achecker||{},e.achecker.Wax=e.achecker.Wax||{},e.achecker.Wax.Section=function(){throw"not implemented"},e.achecker.Wax.Section.prototype={getAsElement:function(){throw"not implemented"}},e.achecker.Wax.isElHidden=function(e){if(e&&e.tagName&&("TITLE"===e.tagName||"BODY"===e.tagName||"HTML"===e.tagName))return!1;do{if(e.tagName&&"none"===n(e,"display"))return!0;e=e.parentNode}while(e);return!1},e.achecker.Wax.ListSection=e.achecker.Wax.Section,e.achecker.Wax.ListSection=function(e,t,n,a,i,r,l,s,o,c,d){this.cwin=e,this.rdoc=t,this.title=n,this.emptyMessage=s,this.contents=this._getContents(e,r,l,a,o,c,d,i)},e.achecker.Wax.ListSection.prototype._getContentsFromDocument=function(e,t,n,a,i,r,l){l||(l=99999);var s,o=e.querySelectorAll(n),c=[];for(s=0;o.length>s&&!(0>=l);s++){var d=o[s],h="function"==typeof a?a.apply(d,[e,t]):a;h!==!1&&(c.push({el:d,doc:d.ownerDocument,validStatus:"function"==typeof i?i.apply(d,[e,t]):"string"==typeof i?i:"",content:"function"==typeof a?a.apply(d,[e,t]):a,eventHandlers:r}),l--)}return c},e.achecker.Wax.ListSection.prototype._getContents=function(e,t,n,a,i,r,l,s){s||(s=99999);var o,c,d=this._getContentsFromDocument(e.document,e.location.href,a,i,r,l,s);if(s-=d.length,t&&s>0)for(o=0,c=n.length;c>o&&!(0>=s);o++){var h=this._getContentsFromDocument(n[o].doc,n[o].src,a,i,r,l,s);d=d.concat(h),s-=h.length}return d},e.achecker.Wax.ListSection.prototype.getAsElement=function(){var n,r=this.rdoc,l=r.createElement("ul"),s=!1,o=!1,c=function(){parent.Firebug&&parent.Firebug.Inspector.clearAllHighlights();var t=this["data-el"],n=e.achecker.Wax.isElHidden(t);if("TITLE"===t.tagName)for(;t&&"HTML"!==t.tagName;)t=t.parentNode;if(!n){var a=t.getAttribute("tabindex");t.setAttribute("tabindex",0),t.focus(),null===a?t.removeAttribute("tabindex"):t.setAttribute("tabindex",a)}parent.Firebug&&t?(parent.Firebug.Inspector.inspectFromContextMenu(t),parent.Firebug.Inspector.highlightObject(t,parent.Firebug.currentContext)):e.console&&e.console.log&&t&&e.console.log("OpenWAX Info: ",i.getElementXPath(t))};for(n=0;this.contents.length>n;n++){var d,h=this.contents[n],p=e.achecker.Wax.isElHidden(h.el)?" hidden_el":"",g=r.createElement("li");if(g.className=h.validStatus+" "+p,"string"==typeof h.content?(g.innerText=h.content,g.textContent=h.content):g.appendChild(h.content),g["data-el"]=h.el,h.eventHandlers)for(d in h.eventHandlers)h.eventHandlers.hasOwnProperty(d)&&t(g,d,h.eventHandlers[d]);"fail"===h.validStatus?o=!0:"warning"===h.validStatus&&(s=!0),t(g,"click",c),l.appendChild(g)}var m=r.createElement("div");m.className="waxSection";var u=r.createElement("h2"),f=r.createElement("span");if(u.innerText=this.title+" ",u.textContent=this.title+" ",u.className="folded",o?u.className+=" fail":s&&(u.className+=" warning"),f.innerText="("+this.contents.length+")",f.textContent="("+this.contents.length+")",u.appendChild(f),m.appendChild(u),0>=l.childNodes.length){var b=r.createElement("p");b.className="comment",b.innerText=this.emptyMessage,b.textContent=this.emptyMessage,m.appendChild(b)}else m.appendChild(l);return t(u,"click",function(){a(this)}),m},e.achecker.Wax.ListSection.prototype.getScore=function(){for(var e=this.contents.length,t=0,n=0;e>n;n++)"fail"!==this.contents[n].validStatus&&t++;return{all:e,pass:t}},e.achecker.Wax.TableSection=e.achecker.Wax.Section,e.achecker.Wax.TableSection=function(e,t,n,a,i,r,l,s,o,c,d){this.cwin=e,this.rdoc=t,this.title=n,this.colInfo=i,this.emptyMessage=s,this.contents=this._getContents(e,r,l,a,o,c,d)},e.achecker.Wax.TableSection.prototype._getContentsFromDocument=function(e,t,n,a,i,r){var l,s=e.querySelectorAll(n),o=[];for(l=0;s.length>l;l++){var c=s[l],d="function"==typeof a?a.apply(c,[e,t]):a;d!==!1&&o.push({el:c,doc:c.ownerDocument,validStatus:"function"==typeof i?i.apply(c,[e,t]):"string"==typeof i?i:"",content:"function"==typeof a?a.apply(c,[e,t]):a,eventHandlers:r})}return o},e.achecker.Wax.TableSection.prototype._getContents=function(e,t,n,a,i,r,l){var s,o,c=this._getContentsFromDocument(e.document,e.location.href,a,i,r,l);if(t)for(s=0,o=n.length;o>s;s++){var d=this._getContentsFromDocument(n[s].doc,n[s].src,a,i,r,l);c=c.concat(d)}return c},e.achecker.Wax.TableSection.prototype.getAsElement=function(){var n,r=this.rdoc,l=r.createElement("table"),s=r.createElement("thead"),o=r.createElement("tr"),c=!1,d=!1,h=function(){parent.Firebug&&parent.Firebug.Inspector.clearAllHighlights();var t=this["data-el"],n=e.achecker.Wax.isElHidden(t);if("TITLE"===t.tagName)for(;t&&"HTML"!==t.tagName;)t=t.parentNode;if(!n){var a=t.getAttribute("tabindex");t.setAttribute("tabindex",0),t.focus(),null===a?t.removeAttribute("tabindex"):t.setAttribute("tabindex",a)}parent.Firebug&&t?(parent.Firebug.Inspector.inspectFromContextMenu(t),parent.Firebug.Inspector.highlightObject(t,parent.Firebug.currentContext)):e.console&&e.console.log&&t&&e.console.log("OpenWAX Info: ",i.getElementXPath(t))};for(n=0;this.colInfo.length>n;n++){var p=r.createElement("th");p.setAttribute("scope","col"),p.innerText=this.colInfo[n].label,p.textContent=this.colInfo[n].label,this.colInfo[n].width&&(p.style.width=this.colInfo[n].width+"px"),this.colInfo[n].minWidth&&(p.style.minWidth=this.colInfo[n].minWidth+"px"),this.colInfo[n].maxWidth&&(p.style.maxWidth=this.colInfo[n].maxWidth+"px"),this.colInfo[n].className&&(p.className=this.colInfo[n].className),o.appendChild(p)}s.appendChild(o),l.appendChild(s);var g=r.createElement("tbody");for(n=0;this.contents.length>n;n++){var m,u,f=this.contents[n],b=e.achecker.Wax.isElHidden(f.el)?" hidden_el":"",x=r.createElement("tr");x.className=f.validStatus+" "+b;for(m in f.content)if(f.content.hasOwnProperty(m)){var C=f.content[m],v=r.createElement("td");"string"==typeof C?(v.innerText=C,v.textContent=C,v.innerHTML=C.replace(/</g,"<").replace(/>/g,">").replace(/\[__\[/g,'<span style="color:#777!important;text-decoration:line-through">').replace(/\]__\]/g,"</span>")):v.appendChild(C),this.colInfo[m].className&&(v.className=this.colInfo[m].className),x.appendChild(v)}if(x["data-el"]=f.el,f.eventHandlers)for(u in f.eventHandlers)f.eventHandlers.hasOwnProperty(u)&&t(x,u,f.eventHandlers[u]);"fail"===f.validStatus?d=!0:"warning"===f.validStatus&&(c=!0),t(x,"click",h),g.appendChild(x),l.appendChild(g)}var N=r.createElement("div");N.className="waxSection";var y=r.createElement("h2"),E=r.createElement("span");if(y.innerText=this.title+" ",y.textContent=this.title+" ",y.className="folded",d?y.className+=" fail":c&&(y.className+=" warning"),E.innerText="("+this.contents.length+")",E.textContent="("+this.contents.length+")",y.appendChild(E),N.appendChild(y),0>=g.childNodes.length){var T=r.createElement("p");T.className="comment",T.innerText=this.emptyMessage,T.textContent=this.emptyMessage,N.appendChild(T)}else N.appendChild(l);return t(y,"click",function(){a(this)}),N},e.achecker.Wax.TableSection.prototype.getScore=function(){for(var e=this.contents.length,t=0,n=0;e>n;n++)"fail"!==this.contents[n].validStatus&&t++;return{all:e,pass:t}},e.achecker.Wax.ToolSection=function(e,t,n,a,i,r){this.cwin=e,this.rdoc=t,this.id=n,this.title=a,this.content="function"==typeof i?i.apply(this,[this.cwin,this.rdoc]):i,this.eventHandlers=r},e.achecker.Wax.ToolSection.prototype.getAsElement=function(){var e=this.rdoc,n=e.createElement("div");n.id=this.id,n.className="waxSection";var i=e.createElement("h2");i.className="folded",i.innerText=this.title,i.textContent=this.title;var r=e.createElement("div");return"string"==typeof this.content?(r.innerText=this.content,r.textContent=this.content):r.appendChild(this.content),n.appendChild(i),n.appendChild(r),i.setAttribute("tabindex",0),t(i,"click",function(){a(this)}),n},e.achecker.Wax.ToolSection.prototype.getScore=function(){return null}})(window),function(e,t){"use strict";var n=e.achecker||{};n.Wax=n.Wax||{};var a=function(t,n,a){t.addEventListener?t.addEventListener(n,a,!1):t.attachEvent&&(t["e"+n+a]=a,t[n+a]=function(){t["e"+n+a](e.event)},t.attachEvent("on"+n,t[n+a]))},i=n.Wax.ListSection,r=n.Wax.TableSection,l=n.Wax.ToolSection,s=function(e,t){var n=[],a=0;if(e.length&&e.push){for(a=0;e.length>a;a++)n=n.concat(s(e[a],t));return n}var i=e.childNodes;if(i&&i.length){for(a=0;i.length>a;a++)i[a].tagName&&i[a].tagName.toLowerCase()===t.toLowerCase()&&n.push(i[a]);return n}return[]},o=function(e){e.className="folded"===e.className?"":"folded",t&&t.all&&(t.body.className=t.body.getAttribute("className"))},c=function(e,t){var n,a,i,r,l,s,o,c;if(0===t.indexOf("#")&&(t=t.substr(1,t.length-1)),0===e.indexOf("#")&&(e=e.substr(1,e.length-1)),i=parseInt(e.substr(0,2),16)/255,.03928>=i?i/=12.92:i=Math.pow((i+.055)/1.055,2.4),r=parseInt(e.substr(2,2),16)/255,.03928>=r?r/=12.92:r=Math.pow((r+.055)/1.055,2.4),l=parseInt(e.substr(4,2),16)/255,.03928>=l?l/=12.92:l=Math.pow((l+.055)/1.055,2.4),s=parseInt(t.substr(0,2),16)/255,.03928>=s?s/=12.92:s=Math.pow((s+.055)/1.055,2.4),o=parseInt(t.substr(2,2),16)/255,.03928>=o?o/=12.92:o=Math.pow((o+.055)/1.055,2.4),c=parseInt(t.substr(4,2),16)/255,.03928>=c?c/=12.92:c=Math.pow((c+.055)/1.055,2.4),n=.2126*i+.7152*r+.0722*l,a=.2126*s+.7152*o+.0722*c,n+=.05,a+=.05,a>n){var d=n;n=a,a=d}return n/=a,n=n.toFixed(1)},d=function(e){var t,n,a,i,r,l,s,o="",c=e.ownerDocument;e:for(i=0,r=c.getElementsByTagName("label").length;r>i;i++){if(n=c.getElementsByTagName("label")[i],a=n.childNodes,n.htmlFor&&n.htmlFor===e.id){t=n;break e}for(l=0,s=a.length;s>l;l++)if(a[l]===e){t=n;break e}}if(t)for(a=t.childNodes,i=0,r=a.length;r>i;i++)a[i].tagName||(o+=a[i].nodeValue.replace(/^\s+/,"").replace(/\s+$/,""));return o||(o=e.title?e.title:e.id?e.id:e.name?e.name:""),o},h=function(e){var t,n=1,a="",i=e.nodeType,r=e.tagName?e.tagName.toUpperCase():"",l=e.getAttribute?e.getAttribute("type"):"";try{var s=e.currentStyle||e.ownerDocument.defaultView.getComputedStyle(e,null);t=s.display}catch(o){t=""}if(i===n&&"none"===t&&(a+="[__["),i===n&&"IMG"===r)a+=e.getAttribute("alt");else if(i===n&&"AREA"===r)a+=e.getAttribute("alt");else if(i===n&&"INPUT"===r&&"image"===l)a+=e.getAttribute("alt");else if(i!==n||"INPUT"!==r||"submit"!==l&&"reset"!==l&&"button"!==l)if(i===n&&"INPUT"===r)a+=d(e);else if(i!==n||"TEXTAREA"!==r&&"SELECT"!==r){if(i!==n||"SCRIPT"!==r&&"STYLE"!==r){var c,p,g=e.childNodes,m=3;for(c=0,p=g.length;p>c;c++)a+=g[c].nodeType===m?g[c].nodeValue:h(g[c])}}else a+=d(e);else a+=e.value;return i===n&&"none"===t&&(a+="]__]"),a=a?a.replace(/^\s+/,"").replace(/\s+$/,""):""},p=function(e,t){var n,a;if(t=t.replace(/\?.*$/,""),e&&-1===e.indexOf("//"))if("../"===e.substr(0,3)){for(n=t.substr(0,t.lastIndexOf("/")>10?t.lastIndexOf("/"):t.length);"../"===e.substr(0,3);)n=n.substr(0,n.lastIndexOf("/")>10?n.lastIndexOf("/"):n.length),e=e.substr(3);e=n+"/"+e}else"/"===e.substr(0,1)?(a=t.replace(/^((?:https?\:\/\/|file\:\/\/\/)[^\/]+)\/.*$/,"$1"),e=a+"/"+e):(a=t.substr(0,t.lastIndexOf("/")),e=a+"/"+e);return e};n.Wax.run=function(t,d,g,m,u){return{header:function(){var e=d.createElement("div");e.className="waxFrames";var i=d.createElement("div"),r=d.createElement("button");i.className="toggleAll",r.className="fold",r.setAttribute("data-folded","folded"),r.title=n.i18n.get("UnfoldAll"),r.setAttribute("type","button"),r.innerText="Toggle All",r.textContent="Toggle All",r.onclick=function(){var e,t,a=d.querySelectorAll(".waxSection h2,.waxFrames h2"),i="folded"===this.getAttribute("data-folded")?"":"folded";for(e=0,t=a.length;t>e;e++)a[e].className=a[e].className.replace("folded","")+" "+i;i?(this.className="unfold",this.title=n.i18n.get("UnfoldAll")):(this.className="fold",this.title=n.i18n.get("FoldAll")),this.setAttribute("data-folded",i),d.body.className=d.body.getAttribute("className")},i.appendChild(r),e.appendChild(i);var l=d.createElement("h2");l.className="",l.innerText=n.i18n.get("TargetPage"),l.textContent=n.i18n.get("TargetPage"),a(l,"click",function(){o(this)});var s,c,h,p,f=d.createElement("ul"),b=d.createElement("li"),x=d.createElement("a");if(x.setAttribute("href",t.location.href),x.setAttribute("target","_blank"),x.innerText=t.location.href,x.textContent=t.location.href,b.appendChild(x),f.appendChild(b),g)for(c=0,h=m.length;h>c;c++)p=d.createElement("li"),s=d.createElement("a"),s.setAttribute("href",m[c].src),s.setAttribute("target","_blank"),s.innerText=m[c].src,s.textContent=m[c].src,p.appendChild(s),f.appendChild(p);if(e.appendChild(l),e.appendChild(f),u&&u.length)for(l=d.createElement("h2"),l.innerText=n.i18n.get("NoneTargetPage"),l.textContent=n.i18n.get("NoneTargetPage"),l.className="folded",a(l,"click",function(){o(this)}),f=d.createElement("ul"),c=0,h=u.length;h>c;c++)p=d.createElement("li"),s=d.createElement("a"),s.setAttribute("href",u[c]),s.setAttribute("target","_blank"),s.innerText=u[c],s.textContent=u[c],p.appendChild(s),f.appendChild(p);return e.appendChild(l),e.appendChild(f),e}(),sections:{altText:new r(t,d,"1. "+n.i18n.get("No1")+" (img)","input[type=image],img,area",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Preview"),width:106},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Contents")}],g,m,n.i18n.get("NotApplicable"),function(e,t){var a=this.tagName.toLowerCase(),i={hidden:"",preview:"",el:"",alt:""},r=this,l=function(){var e=null!==r.getAttribute("alt");if(i.alt=d.createElement("span"),e?r.getAttribute("alt")?(i.alt.innerText=r.getAttribute("alt"),i.alt.textContent=r.getAttribute("alt")):(i.alt.innerText='alt=""',i.alt.textContent='alt=""'):(i.alt.innerText="alt "+n.i18n.get("Undefined"),i.alt.textContent="alt "+n.i18n.get("Undefined")),i.el=a,r.getAttribute("longdesc")){var l=d.createElement("a");l.setAttribute("href",p(r.getAttribute("longdesc"),t)),l.setAttribute("target","_blank"),l.innerText="longdesc link",l.textContent="longdesc link",i.alt.innerText+=" ",i.alt.textContent+=" ",i.alt.appendChild(l)}var s=r.getAttribute("src"),o=d.createElement("div");o.style.width="100px",o.style.margin="0 auto",o.style.overflow="hidden";var c=d.createElement("img");return c.setAttribute("alt",""),c.setAttribute("src",p(s,t)),o.appendChild(c),i.preview=o,[i.hidden,i.preview,i.el,i.alt]};switch(a){case"input":if("image"!==this.type.toLowerCase())break;return l();case"img":return l();case"area":var s=null!==this.getAttribute("alt");return i.alt=d.createElement("span"),s?this.getAttribute("alt")?(i.alt.innerText=this.getAttribute("alt"),i.alt.textContent=this.getAttribute("alt")):(i.alt.innerText='alt=""',i.alt.textContent='alt=""'):(i.alt.innerText="alt "+n.i18n.get("Undefined"),i.alt.textContent="alt "+n.i18n.get("Undefined")),i.el=a,[i.hidden,i.preview,i.el,i.alt]}return!1},function(){var e=this.tagName;switch(e){case"IMG":case"INPUT":case"AREA":var t=null!==this.getAttribute("alt");return t?this.getAttribute("alt")?"pass":"warning":"fail"}}),altTextBG:new r(t,d,"1. "+n.i18n.get("No1")+" (bg)","body *",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Preview"),width:106},{label:n.i18n.get("Contents")}],g,m,n.i18n.get("NotApplicable"),function(e,n){var a={hidden:"",preview:"",content:""},i=this.currentStyle||t.getComputedStyle(this,null),r=i.backgroundImage;if("none"!==r&&10>this.getElementsByTagName("*").length){var l=d.createElement("span");n=r.replace(/^url\("?/,"").replace(/"?\)$/,"");try{l.style.backgroundImage=r,l.style.backgroundPosition=i.backgroundPosition,l.style.backgroundRepeat=i.backgroundRepeat,l.style.width=i.width,l.style.height=i.height}catch(s){}return l.style.maxWidth="100px",l.style.maxHeight="200px",l.style.display="inline-block",l.style.overflow="hidden",a.preview=l,a.content=h(this),[a.hidden,a.preview,a.content]}return!1}),altTextEmbed:new r(t,d,"1. "+n.i18n.get("No1")+" (object)","object,embed,video,audio,canvas,svg",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element")}],g,m,n.i18n.get("NotApplicable"),function(){var e=this.tagName;switch(e){case"OBJECT":return this.parentNode&&this.parentNode.tagName&&("OBJECT"===this.parentNode.tagName||"EMBED"===this.parentNode.tagName)?!1:["","<object>"];case"EMBED":return this.parentNode&&this.parentNode.tagName&&("OBJECT"===this.parentNode.tagName||"EMBED"===this.parentNode.tagName)?!1:["","<embed>"]}return!1}),contrast:new l(t,d,"contrast","5. "+n.i18n.get("No5"),function(e,t){if(!n.colorInspector){var a=t.createElement("p");return a.className="comment",a.innerText="Not Supported.",a.textContent="Not Supported.",a}var i=t.createElement("ul");i.className="contrast";var r=t.createElement("li"),l=t.createElement("li"),s=t.createElement("li");r.className="color1";var o=t.createElement("span");o.innerText=n.i18n.get("Foreground")+": ",o.textContent=n.i18n.get("Foreground")+": ";var d=t.createElement("span");d.className="color",d.style.backgroundColor="#000";var h=t.createElement("span");h.className="val",h.innerText="#000000",h.textContent="#000000";var p=t.createElement("button");p.innerText=n.i18n.get("SelectForegroundColor"),p.textContent=n.i18n.get("SelectForegroundColor"),r.appendChild(o),r.appendChild(d),r.appendChild(t.createTextNode(" ")),r.appendChild(h),r.appendChild(t.createTextNode(" ")),r.appendChild(p),r.onclick=function(){n.showOverlay(),n.colorInspector.startInspect(function(e){n.hideOverlay(),r.getElementsByClassName("color")[0].style.backgroundColor=e,r.getElementsByClassName("val")[0].innerText=e,r.getElementsByClassName("val")[0].textContent=e;var t=c(e,l.getElementsByClassName("val")[0].innerText);s.className=t>=4.5?"pass":t>=3?"warning":"fail",s.getElementsByClassName("result")[0].innerText=t+":1",s.getElementsByClassName("result")[0].textContent=t+":1",s.getElementsByClassName("resultText")[0].style.color=e})},l.className="color2";var g=t.createElement("span");g.innerText=n.i18n.get("Background")+": ",g.textContent=n.i18n.get("Background")+": ";var m=t.createElement("span");m.className="color",m.style.backgroundColor="#FFF";var u=t.createElement("span");u.className="val",u.innerText="#FFFFFF",u.textContent="#FFFFFF";var f=t.createElement("button");f.innerText=n.i18n.get("SelectBackgroundColor"),f.textContent=n.i18n.get("SelectBackgroundColor"),l.appendChild(g),l.appendChild(m),l.appendChild(t.createTextNode(" ")),l.appendChild(u),l.appendChild(t.createTextNode(" ")),l.appendChild(f),l.onclick=function(){n.showOverlay(),n.colorInspector.startInspect(function(e){n.hideOverlay(),l.getElementsByClassName("color")[0].style.backgroundColor=e,l.getElementsByClassName("val")[0].innerText=e,l.getElementsByClassName("val")[0].textContent=e;var t=c(e,r.getElementsByClassName("val")[0].innerText);s.className=t>=4.5?"pass":t>=3?"warning":"fail",s.getElementsByClassName("result")[0].innerText=t+":1",s.getElementsByClassName("result")[0].textContent=t+":1",s.getElementsByClassName("resultText")[0].style.backgroundColor=e})},s.className="pass";var b=t.createElement("span");b.innerText=n.i18n.get("Result")+": ",b.textContent=n.i18n.get("Result")+": ";var x=t.createElement("span");x.className="result",x.innerText="21:1",x.textContent="21:1";var C=t.createElement("span");return C.className="resultText",C.innerText=n.i18n.get("Test"),C.textContent=n.i18n.get("Test"),s.appendChild(b),s.appendChild(x),s.appendChild(t.createTextNode(" ")),s.appendChild(C),i.appendChild(r),i.appendChild(l),i.appendChild(s),i}),kbdFocus:new r(t,d,"8. "+n.i18n.get("No8"),"*",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("ErrorType"),width:65},{label:n.i18n.get("Contents")}],g,m,n.i18n.get("RequireConfirmation"),function(){try{var e=this.wrappedJSObject||this,t=!1;e.onfocus&&(""+e.onfocus).indexOf("blur()")>-1?t=!0:e.onclick&&(""+e.onclick).indexOf("blur()")>-1&&(t=!0);var n=this.style.getPropertyValue("outline-width"),a="0"===n||"0pt"===n||"0px"===n;return t?["","blur()",h(this)]:a?["","outline:0",h(this)]:!1}catch(i){return!1}},function(){try{var e=this.wrappedJSObject||this,t=e.onfocus?(""+e.onfocus).indexOf("blur()")>-1:!1,n=this.style.getPropertyValue("outline-width"),a="0"===n||"0pt"===n||"0px"===n;return t?"fail":a?"fail":"pass"}catch(i){return!1}}),skipNav:new r(t,d,"12. "+n.i18n.get("No12"),'a[href^="#"]',[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("No"),width:65},{label:n.i18n.get("Contents")},{label:n.i18n.get("Connected"),width:45}],g,m,"-",function(e){if(t.document!==e)return!1;var a,i,r,l=this.getAttribute("href"),s="#"===l?!1:!!e.getElementById(l.replace("#",""))||e.getElementsByName(l.replace("#","")).length>0;for(i=0,r=e.getElementsByTagName("a").length;r>i;i++)if(e.getElementsByTagName("a")[i]===this){if(a=i+1,a>20)return!1;break}return["",a+n.i18n.get("ThLink"),"("+l+") "+h(this),s?"O":"X"]},function(e){var t=this.getAttribute("href"),n="#"===t?!1:!!e.getElementById(t.replace("#",""))||e.getElementsByName(t.replace("#","")).length>0;return n?"pass":"fail"}),pageTitle:new i(t,d,"13. "+n.i18n.get("No13")+"(<title>)","title",null,g,m,"-",function(e,t){var a=d.createElement("span"),i=d.createElement("strong"),r=this.textContent||this.innerText||n.i18n.get("NoPageTitle");return a.innerText=t+": ",a.textContent=t+": ",i.innerText=r,i.textContent=r,a.appendChild(i),a},function(){for(var e=this.textContent||this.innerText||"",t=["::","||","--","@@","##","$$","%%","&&","**","((","))","++","==","~~",";;","<<",">>","[[","]]","★★","☆☆","◎◎","●●","◆◆","◇◇","□□","■■","△△","▲▲","▽▽","▼▼","◁◁","◀◀","▷▷","▶▶","♠♠","♤♤","♡♡","♥♥","♧♧","♣♣","⊙⊙","◈◈","▣▣","◐◐","◑◑","▒▒","▤▤","▥▥","▨▨","▧▧","▦▦","▩▩","♨♨","☏☏","☎☎"],n=!!e,a=!1,i=0;t.length>i;i++)if(e.indexOf(t[i])>-1){a=!0;break}return n&&!a?"pass":"fail"}),frame:new r(t,d,"13. "+n.i18n.get("No13")+"(frame)","iframe",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Title"),minWidth:50,className:"lt"},{label:n.i18n.get("Contents"),maxWidth:200}],g,m,n.i18n.get("NotApplicable"),function(){var e={hidden:"",el:"",title:"",url:""},t=this.getAttribute("src"),a=this.getAttribute("title");if(e.el="iframe",t){var i=d.createElement("a");i.setAttribute("href",t),i.setAttribute("target","_blank"),i.innerText=t,i.textContent=t,e.url=i}else e.url=n.i18n.get("NoSrc");return e.title=a||n.i18n.get("NoTitle"),[e.hidden,e.el,e.title,e.url]},function(){var e=this.getAttribute("title");return e?"pass":"fail"}),blockTitle:new r(t,d,"13. "+n.i18n.get("No13")+"(<h1>~<h6>)","h1,h2,h3,h4,h5,h6",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Contents")}],g,m,n.i18n.get("RequireConfirmation"),function(){return["",this.tagName.toLowerCase(),h(this)]}),linkText:new r(t,d,"14. "+n.i18n.get("No14"),"a,area",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("Contents")}],g,m,n.i18n.get("NotApplicable"),function(){var e=h(this),t=this.getAttribute("title");return["",this.tagName.toLowerCase(),(e||"-")+(t?" (title: "+t+")":"")]},function(){var e=h(this);return e?"pass":"fail"}),pageLang:new i(t,d,"15. "+n.i18n.get("No15"),"html",null,g,m,"-",function(e,t){var a=this.getAttribute("xmlns"),i="",r=d.createElement("span");if("http"!==t.substr(0,4).toLowerCase()&&".html"!==t.substr(-5).toLowerCase())return!1;i=a&&this.getAttribute("xml:lang")&&this.getAttribute("lang")?"xml:lang="+this.getAttribute("xml:lang")+", lang="+this.getAttribute("lang"):a&&this.getAttribute("xml:lang")?"xml:lang="+this.getAttribute("xml:lang"):a&&this.getAttribute("lang")?"xml:lang="+n.i18n.get("None")+", lang="+this.getAttribute("lang"):!a&&this.getAttribute("lang")?"lang="+this.getAttribute("lang"):n.i18n.get("NoMainLang"),r.innerText=t+": ",r.textContent=t+": ";var l=d.createElement("strong");return l.innerText=i,l.textContent=i,r.appendChild(l),r},function(){var e=this.getAttribute("xmlns");return e&&this.getAttribute("xml:lang")?"pass":e&&this.getAttribute("lang")?"warning":!e&&this.getAttribute("lang")?"pass":"fail"}),unintendedFunction:new r(t,d,"16. "+n.i18n.get("No16"),"a,area,input,button",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Event"),width:80},{label:n.i18n.get("Contents"),className:"lt"},{label:n.i18n.get("TitleAttribute")}],g,m,n.i18n.get("RequireConfirmation"),function(){var e,t={hidden:"",event:"",content:"",title:""},n=this.wrappedJSObject||this;try{e=n.onclick?(""+n.onclick).indexOf("window.open")>-1:!1}catch(a){e=null}return t.content=h(this),t.title=this.getAttribute("title")?this.getAttribute("title"):"_blank"===this.getAttribute("target")?'target="_blank"':"-",e?(t.event="window.open",[t.hidden,t.event,t.content,t.title]):!1},function(){return this.getAttribute("title")?"warning":"_blank"===this.getAttribute("target")?"pass":"fail"}),tableTitle:new r(t,d,"18. "+n.i18n.get("No18")+"(caption, summary)","table",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("CaptionContent"),className:"lt"},{label:n.i18n.get("SummaryContent")}],g,m,n.i18n.get("NotApplicable"),function(){var e,t=this.childNodes,a=null,i={hidden:"",caption:"",summary:""};for(e=0;t.length>e;e++)if(t[e].tagName&&"caption"===t[e].tagName.toLowerCase()){a=t[e];break}var r=!!a,l=!!this.getAttribute("summary");return i.caption=r?h(a):n.i18n.get("None"),i.summary=l?this.getAttribute("summary"):n.i18n.get("None"),[i.hidden,i.caption,i.summary]},function(){var e,t=this.childNodes,n=null;for(e=0;t.length>e;e++)if(t[e].tagName&&"caption"===t[e].tagName.toLowerCase()){n=t[e];break}var a=!!n,i=!!this.getAttribute("summary");return a?"pass":a||i?"fail":"warning"}),tableStructure:new r(t,d,"18. "+n.i18n.get("No18")+"(th)","table",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Structure"),className:"tb_str"}],g,m,n.i18n.get("NotApplicable"),function(){var e={hidden:"",structure:""},t=s(this,"thead"),n=s(this,"tfoot"),a=s(this,"tbody"),i=s(s(t,"tr"),"th"),r=s(s(n,"tr"),"th"),l=s(s(a,"tr"),"th").concat(s(s(this,"tr"),"th"));!!i.length||!!r.length||l.length;var o=d.createElement("table"),c=d.createElement("thead"),p=d.createElement("tbody"),g=d.createElement("tr"),m=d.createElement("th"),u=d.createElement("th"),f=d.createElement("th");m.innerText="요소",m.textContent="요소",u.innerText="유무",u.textContent="유무",f.innerText="제목셀 정보 (scope 속성값)",f.textContent="제목셀 정보 (scope 속성값)",g.appendChild(m),g.appendChild(u),g.appendChild(f),c.appendChild(g),o.appendChild(c),o.appendChild(p);var b,x,C,v,N,y,E=d.createElement("tr"),T=d.createElement("td"),w=d.createElement("td"),k=d.createElement("td");if(t.length){for(b=d.createElement("ul"),T.innerText="thead",T.textContent="thead",w.innerText="O",w.textContent="O",x=0,C=i.length;C>x;x++)v=i[x],N=v.getAttribute("scope"),y=d.createElement("li"),y.innerText=h(v)+(N?"("+N+")":"(X)"),y.textContent=h(v)+(N?"("+N+")":"(X)"),b.appendChild(y);k.appendChild(b)}else T.innerText="thead",T.textContent="thead",w.innerText="X",w.textContent="X",k.innerText="-",k.textContent="-";if(E.appendChild(T),E.appendChild(w),E.appendChild(k),p.appendChild(E),E=d.createElement("tr"),T=d.createElement("td"),w=d.createElement("td"),k=d.createElement("td"),n.length){for(b=d.createElement("ul"),T.innerText="tfoot",T.textContent="tfoot",w.innerText="O",w.textContent="O",x=0,C=r.length;C>x;x++)v=r[x],N=v.getAttribute("scope"),y=d.createElement("li"),y.innerText=h(v)+(N?"("+N+")":"(X)"),y.textContent=h(v)+(N?"("+N+")":"(X)"),b.appendChild(y);k.appendChild(b)}else T.innerText="tfoot",T.textContent="tfoot",w.innerText="X",w.textContent="X",k.innerText="-",k.textContent="-";if(E.appendChild(T),E.appendChild(w),E.appendChild(k),p.appendChild(E),E=d.createElement("tr"),T=d.createElement("td"),w=d.createElement("td"),k=d.createElement("td"),a.length){for(b=d.createElement("ul"),T.innerText="tbody",T.textContent="tbody",w.innerText="O",w.textContent="O",x=0,C=l.length;C>x;x++)v=l[x],N=v.getAttribute("scope"),y=d.createElement("li"),y.innerText=h(v)+(N?"("+N+")":"(X)"),y.textContent=h(v)+(N?"("+N+")":"(X)"),b.appendChild(y);k.appendChild(b)}else T.innerText="tbody",T.textContent="tbody",w.innerText="X",w.textContent="X",k.innerText="-",k.textContent="-";return E.appendChild(T),E.appendChild(w),E.appendChild(k),p.appendChild(E),e.structure=o,[e.hidden,e.structure]},function(){var e=s(s(s(this,"thead"),"tr"),"th"),t=s(s(s(this,"tfoot"),"tr"),"th"),n=s(s(s(this,"tbody"),"tr"),"th").concat(s(s(this,"tr"),"th")),a=e.length||t.length||n.length,i=function(e){var t,n;for(t=0,n=e.length;n>t;t++)if(!e[t].getAttribute("scope"))return!1;return!0};return a&&i(e)&&i(t)&&i(n)?"pass":a||e.length||t.length?"fail":"warning"}),label:new r(t,d,"19. "+n.i18n.get("No19"),"input,textarea,select",[{label:n.i18n.get("Hidden"),width:45},{label:n.i18n.get("Element"),width:45},{label:n.i18n.get("FormType"),width:66},{label:n.i18n.get("LabelConnection"),className:"lt"},{label:n.i18n.get("TitleAttribute")}],g,m,n.i18n.get("NotApplicable"),function(e){var t=this.getAttribute("type")?this.getAttribute("type").toLowerCase():null;if("INPUT"===this.tagName&&("submit"===t||"button"===t||"image"===t||"hidden"===t||"reset"===t))return!1;var n,a,i={hidden:"",el:"",type:"",label:"",title:""},r=this.getAttribute("id"),l=e.getElementsByTagName("label"),s=!1,o=null;if(r)for(n=0,a=l.length;a>n;n++)if(l[n].getAttribute("for")===r){s=!0,o=l[n];break}!!this.getAttribute("title");var c=!1,d=this.parentNode;do if(d=d.parentNode,"LABEL"===d.tagName){c=!0,o=d;break}while(d.parentNode);return i.el=this.tagName.toLowerCase(),i.type=t||"-",i.label=o?h(o):"",i.label||(i.label="X"),i.title=this.getAttribute("title"),i.title||(i.title="-"),[i.hidden,i.el,i.type,i.label,i.title]},function(e){var t,n,a=this.getAttribute("id"),i=e.getElementsByTagName("label"),r=!1;if(a)for(t=0,n=i.length;n>t;t++)if(i[t].getAttribute("for")===a){r=!0;break}var l=!!this.getAttribute("title"),s=!1,o=this.parentNode;do o=o.parentNode,"LABEL"===o.tagName&&(s=!0);while(o.parentNode);return r?"pass":s?"pass":l?"warning":"fail"}),validation:new l(t,d,"w3c_validation","21. "+n.i18n.get("No21"),function(t,i){var r="object"==typeof chrome&&chrome.extension,l="object"==typeof Components&&Components.classes;if(!r&&!l){var s=i.createElement("p");return s.className="comment",s.innerText="Not Supported.",s.textContent="Not Supported.",s}var o,c,d=function(e){var t,n,a=e.messages,i=[],r=[/^document type does not allow element .* here; missing one of .* start\-tag.*/,/^end tag for .* which is not finished.*/,/^end tag for element .* which is not open.*/,/^ID .* already defined.*/,/^unclosed start-tag requires SHORTTAG YES.*/,/^unclosed end-tag requires SHORTTAG YES.*/,/^empty start-tag.*/,/^empty end-tag.*/];for(t=0;a.length>t;t++)if("error"===a[t].type)for(n=0;r.length>n;n++)if(r[n].test(a[t].message)){i.push(a[t]);break}return e.messages=i,e},h=function(e,t){var n=i.createElement("div");n.className="validationResult";var r=i.createElement("h3");r.innerText="Error",r.textContent="Error",r.className="fail";var l=i.createElement("ul"),s=i.createElement("h3");s.innerText="Warning",s.textContent="Warning",s.className="warning";var o,c=i.createElement("ul"),d=function(e){e.preventDefault(),e.stopPropagation(),openDialog("chrome://global/content/viewSource.xul","achecker_sourceView","scrollbars,resizable,chrome,dialog=no",t,null,null,this.getAttribute("data-line"),!1)};for(o=0;e.length>o;o++){var h=e[o],p=i.createElement("li"),g=i.createElement("div"),m=i.createElement("a");m.innerText=h.message,m.textContent=h.message,m.setAttribute("href","#"),m.setAttribute("data-line",h.lastLine),a(m,"click",d),g.appendChild(m); +var u=i.createElement("div");switch(u.className="subinfo",u.innerText=h.lastLine+" line, "+h.lastColumn+" column",u.textContent=h.lastLine+" line, "+h.lastColumn+" column",p.appendChild(g),p.appendChild(u),h.type){case"error":l.appendChild(p);break;case"info":c.appendChild(p)}}return n.appendChild(r),n.appendChild(l),n.appendChild(s),n.appendChild(c),n},p=function(e){var t,n=i.getElementById("w3c_validation"),a=n.querySelectorAll("li.validationItem");for(t=0;a.length>t;t++){var r=a[t].getElementsByClassName("url")[0];if(r.innerText===e||r.textContent===e)return a[t]}},u=function(t){var a=t,r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status){var a=r.responseText,l=new XMLHttpRequest;a.indexOf("euc-kr")>0?"euc-kr":"utf-8";var s=setTimeout(function(){var e=p(t),a=e.getElementsByClassName("errcnt")[0],r=i.createElement("a");r.target="_blank",r.href="http://validator.w3.org/check?uri="+encodeURIComponent(t),r.textContent="("+n.i18n.get("ValidateManually")+")",a.innerText=n.i18n.get("ValidationTimeout")+" ",a.textContent=n.i18n.get("ValidationTimeout")+" ",a.appendChild(r)},1e4);l.onreadystatechange=function(){try{var e,n=function(){var e=this.getElementsByTagName("div")[0];e.style.display="none"===e.style.display?"block":"none"};if(4===l.readyState&&200===l.status){var a=d(JSON.parse(l.responseText)),r=i.getElementById("w3c_validation"),o=r.querySelector("h2"),c=p(t),g=0;for(e=0;a.messages.length>e;e++)"error"===a.messages[e].type&&g++;clearTimeout(s);var m=c.getElementsByClassName("errcnt")[0];m.innerText=g+" Errors",m.textContent=g+" Errors",c.className=g>0?"fail":"pass",g>0&&(o.className+=" fail");var u=h(a.messages,t);u.style.display="none",c.appendChild(u),c.onclick=n}}catch(f){}};try{if(l.open("POST","http://validator.w3.org/check",!0),"object"!=typeof FormData)l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.send("fragment="+e.escape(a)+"&doctype=Inline"+"&output=json");else{var o=new FormData;o.append("fragment",a),o.append("doctype","Inline"),o.append("output","json"),l.send(o)}}catch(c){}}else e.alert(n.i18n.get("ValidationFail"))},r.open("GET",a,!0),r.send(null)},f=[],b=[];if(("http://"===t.location.href.substr(0,7)||"https://"===t.location.href.substr(0,8))&&(f.push(t.location.href),b.push(t.document)),g)for(o=0,c=m.length;c>o;o++){var x=m[o].src;("http://"===x.substr(0,7)||"https://"===x.substr(0,8))&&(f.push(x),b.push(m[o]))}var C=i.createElement("ul");for(o=0,c=f.length;c>o;o++){u(f[o],b[o]);var v=i.createElement("li");v.className="validationItem";var N=i.createElement("span");N.className="url",N.innerText=f[o],N.textContent=f[o];var y=i.createElement("b");y.className="errcnt",y.innerText=n.i18n.get("Loading"),y.textContent=n.i18n.get("Loading"),v.appendChild(N),v.appendChild(i.createTextNode(": ")),v.appendChild(y),C.appendChild(v)}return C})}}}}(window,window.document),function(e){"use strict";var t={altText:30,kbdFocus:10,frame:10,linkText:10,pageLang:10,unintendedFunction:10,label:20},n=function(e){return e>=95?"perfect":e>80?"good":e>60?"bad":"fail"},a=function(e){var t,n=e.location.href,a=e.document.getElementsByTagName("link"),i=a.length;for(t=0;i>t;t++)"canonical"===a[t].getAttribute("rel")&&a[t].getAttribute("href")&&(n=a[t].getAttribute("href"));return n=n.replace(/\#.*$/,"")};e.achecker=e.achecker||{},e.achecker.Wax=e.achecker.Wax||{},e.achecker.Wax.score=function(e){var n,a=0;for(var i in t)t.hasOwnProperty(i)&&(n=e[i]?e[i].getScore():null,a+=n&&n.all>0?parseInt(10*n.pass/n.all*t[i],10)/10:parseInt(t[i],10));return parseInt(10*a,10)/10},e.achecker.Wax.scoreAsElement=function(t,i,r,l){var s=e.achecker.Wax.score(r),o=i.createElement("div");o.className="waxScore "+n(s);var c=i.createElement("h2"),d=i.createElement("a");d.setAttribute("href","http://openwax.miya.pe.kr/#guide_score"),d.setAttribute("target","_blank"),d.innerText="WAX Score: ",d.textContent="WAX Score: ";var h=i.createElement("strong");if(h.innerText=s,h.textContent=s,d.appendChild(h),c.appendChild(d),o.appendChild(c),l){var p=i.createElement("img");p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.setAttribute("src","http://openwax.miya.pe.kr/log?url="+encodeURIComponent(a(t))+"&"+"title="+encodeURIComponent(t.document.title)+"&"+"score="+s+"&"),o.appendChild(p)}return o}}(window);var achecker_locale={};achecker_locale.messages={Target:{message:"대상",description:""},TargetPage:{message:"대상 페이지",description:""},NoneTargetPage:{message:"비대상 페이지",description:""},AltText:{message:"대체 텍스트",description:""},Undefined:{message:"미정의",description:""},ValidationFail:{message:"유효성 검사 오류 발생!",description:""},Loading:{message:"로딩중...",description:""},TableTitle:{message:"표 제목",description:""},None:{message:"없음",description:""},TableStructure:{message:"표 구조화",description:""},HasThead:{message:"thead있음",description:""},HasTfoot:{message:"tfoot있음",description:""},HasTbody:{message:"tbody있음",description:""},NoThead:{message:"thead없음",description:""},NoTfoot:{message:"tfoot없음",description:""},NoTbody:{message:"tbody없음",description:""},LevelAA:{message:"레벨AA",description:""},DocumentsForView:{message:"단순 열람 문서 형식",description:""},ShortCut:{message:"단축키",description:""},PageMainLang:{message:"주언어 명시",description:""},NoMainLang:{message:"주언어 없음",description:""},Contrast:{message:"명도 대비",description:""},Foreground:{message:"전경",description:""},SelectForegroundColor:{message:"전경색 선택",description:""},Background:{message:"배경",description:""},SelectBackgroundColor:{message:"배경색 선택",description:""},Result:{message:"결과",description:""},Test:{message:"테스트",description:""},KeyboardFocus:{message:"키보드 포커스",description:""},Error:{message:"오류",description:""},PageTitle:{message:"페이지 제목",description:""},NoPageTitle:{message:"페이지 제목 없음",description:""},UseFrame:{message:"프레임 사용",description:""},NoSrc:{message:"src 없음",description:""},NoTitle:{message:"title 없음",description:""},BlockTitle:{message:"콘텐츠 블록 제목",description:""},SkipNavigation:{message:"건너뛰기 링크",description:""},NthLink:{message:"번째 링크",description:""},Link:{message:"링크",description:""},Connected:{message:"연결",description:""},IsConnected:{message:"연결됨",description:""},IsNotConnected:{message:"연결되지 않음",description:""},LinkText:{message:"링크 텍스트",description:""},NoText:{message:"텍스트 없음",description:""},UnintendedFunction:{message:"의도하지 않은 기능",description:""},Label:{message:"레이블",description:""},No:{message:"번호",description:""},ThLink:{message:"번째 링크",description:""},NotApplicable:{message:"해당없음",description:""},RequireConfirmation:{message:"직접 확인 필요",description:""},FoldAll:{message:"전체 접기",description:""},UnfoldAll:{message:"전체 펼치기",description:""},Hidden:{message:"숨김",description:""},Preview:{message:"미리보기",description:""},Element:{message:"요소",description:""},Contents:{message:"내용",description:""},CaptionContent:{message:"Caption 내용",description:""},SummaryContent:{message:"Summary 내용",description:""},Structure:{message:"구조",description:""},ErrorType:{message:"오류 유형",description:""},Title:{message:"제목",description:""},Event:{message:"이벤트",description:""},TitleAttribute:{message:"title 속성값",description:""},FormType:{message:"폼 유형",description:""},LabelConnection:{message:"label 연결",description:""},CannotCheckFrameset:{message:"프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.",description:""},ValidationTimeout:{message:"시간초과",description:""},ValidateManually:{message:"수동 검사",description:""},No1:{message:"적절한 대체 텍스트",description:""},No5:{message:"텍스트 콘텐츠의 명도 대비",description:""},No8:{message:"초점 이동",description:""},No12:{message:"건너뛰기 링크",description:""},No13:{message:"제목 제공",description:""},No14:{message:"적절한 링크 텍스트",description:""},No15:{message:"기본 언어 표시",description:""},No16:{message:"사용자 요구에 따른 실행",description:""},No18:{message:"표의 구성",description:""},No19:{message:"레이블 제공",description:""},No21:{message:"마크업 오류 방지",description:""}},function(e){"use strict";var t=e.achecker||{};t.i18n={get:function(e){return achecker_locale.messages[e].message||""}}}(window),function(e){"use strict";e.achecker=e.achecker||{},e.achecker.showOverlay=function(){if(document.getElementById("_acheckeroverlay"))return document.getElementById("_acheckeroverlay").style.display="block",void 0;var e=document.createElement("div");e.id="_acheckeroverlay",e.style.display="block",e.style.zIndex="99999999",e.style.position="fixed",e.style.top="0",e.style.right="0",e.style.bottom="0",e.style.left="400px",e.style.backgroundColor="#fff",e.style.opacity="0.01",document.body.appendChild(e)},e.achecker.hideOverlay=function(){document.getElementById("_acheckeroverlay")&&(document.getElementById("_acheckeroverlay").style.display="none")};var t=function(t){var n,a,i=[],r=[];if(t)for(n=0,a=document.getElementsByTagName("iframe").length;a>n;n++){var l=document.getElementsByTagName("iframe")[n];l.src&&l.contentDocument?i.push({src:l.src,doc:l.contentDocument}):l.src&&r.push(l.src)}var s=window,o=document;if(!i.length&&!s.document.documentElement)return{err:!0,message:"You cannot check this page.",text_message:"You cannot check this page."};if(s.document.getElementsByTagName("frameset").length>0){var c=s.document.getElementsByTagName("frame"),d="<ul>";for(n=0,a=c.length;a>n;n++)c[n].src.indexOf("http")>-1&&(d+='<li><a href="'+c[n].src+'" target="_blank"">'+c[n].src+"</a></li>");return d+="</ul>",{err:!0,message:"<p>"+e.achecker.i18n.get("CannotCheckFrameset")+"</p>"+d,text_message:e.achecker.i18n.get("CannotCheckFrameset")}}var h=o.createElement("div");h.id="achecker-result",o.documentElement.className+=" achecker-included";var p=e.achecker.Wax.run(s,o,t,i,r),g=p.header,m=p.sections,u=e.achecker.Wax.scoreAsElement(s,o,m,!0);h.appendChild(u),h.appendChild(g);for(n in m)m.hasOwnProperty(n)&&h.appendChild(m[n].getAsElement());return o.body.appendChild(h),{err:!1}},n=function(e){if(!document.getElementById("achecker-css")){var n=document.createElement("link");n.rel="stylesheet",n.id="achecker-css",n.href="http://openwax.miya.pe.kr/c/bookmarklet.css?t="+(new Date).valueOf(),document.getElementsByTagName("head")[0].appendChild(n)}if(document.getElementById("achecker-result"))return document.body.removeChild(document.getElementById("achecker-result")),document.documentElement.className=document.documentElement.className.replace(/ achecker\-included/,""),{err:!1};var a=t(e);return a},a=n();a.err&&window.alert(a.text_message)}(window); \ No newline at end of file diff --git a/owax_bookmarklet/dist/locale_ko.js b/owax_bookmarklet/dist/locale_ko.js index a960c18..a0ccfd8 100644 --- a/owax_bookmarklet/dist/locale_ko.js +++ b/owax_bookmarklet/dist/locale_ko.js @@ -267,6 +267,14 @@ achecker_locale["messages"] = { "message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.", "description": "" }, + "ValidationTimeout": { + "message": "시간초과", + "description": "" + }, + "ValidateManually": { + "message": "수동 검사", + "description": "" + }, "No1": { "message": "적절한 대체 텍스트", diff --git a/owax_bookmarklet/lib/Score.js b/owax_bookmarklet/lib/Score.js deleted file mode 100644 index 8510e93..0000000 --- a/owax_bookmarklet/lib/Score.js +++ /dev/null @@ -1,128 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is N-WAX(NHN Web Accessibility eXtension). - * - * The Initial Developer of the Original Code is - * Goonoo Kim (http://miya.pe.kr). - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -(function (g) { - "use strict"; - - var sectionWeights = { - "altText": 30, - "kbdFocus": 10, - "frame": 10, - "linkText": 10, - "pageLang": 10, - "unintendedFunction": 10, - "label": 20 - }; - - var getLevel = function (score) { - if (score >= 95) { - return "perfect"; - } else if (score > 80) { - return "good"; - } else if (score > 60) { - return "bad"; - } else { - return "fail"; - } - }; - - var canonicalUrl = function (win) { - var url = win.location.href; - var linkEls = win.document.getElementsByTagName("link"); - var i, l = linkEls.length; - for (i = 0; i < l; i++) { - if (linkEls[i].getAttribute("rel") === "canonical" && - linkEls[i].getAttribute("href")) { - url = linkEls[i].getAttribute("href"); - } - } - // remove fragment identifier from URL - url = url.replace(/\#.*$/, ''); - return url; - }; - - g.achecker = g.achecker || {}; - g.achecker.Wax = g.achecker.Wax || {}; - g.achecker.Wax.score = function (waxSections) { - var score = 0, info; - - for (var key in sectionWeights) { - if (sectionWeights.hasOwnProperty(key)) { - info = waxSections[key] ? waxSections[key].getScore() : null; - if (info && info.all > 0) { - score += parseInt(info.pass / info.all * sectionWeights[key] * 10, 10) / 10; - } else { - score += parseInt(sectionWeights[key], 10); - } - } - } - - return parseInt(score * 10, 10) / 10; - }; - g.achecker.Wax.scoreAsElement = function (cwin, rdoc, waxSections, allowLogging) { - var score = g.achecker.Wax.score(waxSections); - var $div = rdoc.createElement('div'); - $div.className = 'waxScore ' + getLevel(score); - - var $title = rdoc.createElement('h2'); - var $label = rdoc.createElement('a'); - $label.setAttribute('href', 'http://openwax.miya.pe.kr/#guide_score'); - $label.setAttribute('target', '_blank'); - $label.innerText = "WAX Score: "; - $label.textContent = "WAX Score: "; - var $score = rdoc.createElement('strong'); - $score.innerText = score; - $score.textContent = score; - - $label.appendChild($score); - $title.appendChild($label); - $div.appendChild($title); - - if (allowLogging) { - var $logger = rdoc.createElement('img'); - $logger.style.position = 'absolute'; - $logger.style.top = '-9999px'; - $logger.style.left = '-9999px'; - $logger.setAttribute('src', 'http://openwax.miya.pe.kr/log?' + - 'url=' + encodeURIComponent(canonicalUrl(cwin)) + '&' + - 'title=' + encodeURIComponent(cwin.document.title) + '&' + - 'score=' + score + '&'); - $div.appendChild($logger); - } - - return $div; - }; -}(window)); diff --git a/owax_bookmarklet/lib/Score.js b/owax_bookmarklet/lib/Score.js new file mode 120000 index 0000000..3a3dbe3 --- /dev/null +++ b/owax_bookmarklet/lib/Score.js @@ -0,0 +1 @@ +../../lib/Score.js \ No newline at end of file diff --git a/owax_bookmarklet/lib/Section.js b/owax_bookmarklet/lib/Section.js deleted file mode 100644 index b5a32c4..0000000 --- a/owax_bookmarklet/lib/Section.js +++ /dev/null @@ -1,613 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is N-WAX(NHN Web Accessibility eXtension). - * - * The Initial Developer of the Original Code is - * Goonoo Kim (NHN). - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -(function (g) { - "use strict"; - - var addEvent = function (obj, type, fn) { - if (obj.addEventListener) { - obj.addEventListener(type, fn, false); - } else if (obj.attachEvent) { - obj["e" + type + fn] = fn; - obj[type + fn] = function () { - obj["e" + type + fn](g.event); - }; - obj.attachEvent("on" + type, obj[type + fn]); - } - }; - var getStyle = function (el, style) { - if (el.currentStyle) { - return el.currentStyle.style; - } - return g.getComputedStyle(el, null)[style]; - }; - var toggleFoldedClass = function (el) { - el.className = el.className.indexOf('folded') > -1 ? el.className.replace(/folded/g, '') : el.className + ' folded'; - - // fix bug: IE8 won't reflow when set data-* attribute - if (document && document.all) { - document.body.className = document.body.getAttribute("className"); - } - }; - - var Xpath = {}; - - // ********************************************************************************************* // - // XPATH - - /** - * Gets an XPath for an element which describes its hierarchical location. - */ - Xpath.getElementXPath = function (element) { - if (element && element.id) { - return '//*[@id="' + element.id + '"]'; - } - return Xpath.getElementTreeXPath(element); - }; - - Xpath.getElementTreeXPath = function (element) { - var paths = []; - var DOCUMENT_TYPE_NODE = 10; - var sibling; - - // Use nodeName (instead of localName) so namespace prefix is included (if any). - for (element; element && element.nodeType === 1; element = element.parentNode) { - var index = 0; - for (sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) { - // Ignore document type declaration. - if (sibling.nodeType !== DOCUMENT_TYPE_NODE && sibling.nodeName === element.nodeName) { - ++index; - } - } - - var tagName = element.nodeName.toLowerCase(); - var pathIndex = (index ? "[" + (index + 1) + "]" : ""); - paths.splice(0, 0, tagName + pathIndex); - } - - return paths.length ? "/" + paths.join("/") : null; - }; - - g.achecker = g.achecker || {}; - g.achecker.Wax = g.achecker.Wax || {}; - g.achecker.Wax.Section = function () { - throw 'not implemented'; - }; - g.achecker.Wax.Section.prototype = { - getAsElement : function () { - throw 'not implemented'; - } - }; - - g.achecker.Wax.isElHidden = function (el) { - if (el && el.tagName && (el.tagName === 'TITLE' || el.tagName === 'BODY' || el.tagName === 'HTML')) { - return false; - } - do { - if (el.tagName && getStyle(el, 'display') === 'none') { - return true; - } - el = el.parentNode; - } while (el); - return false; - }; - - g.achecker.Wax.ListSection = g.achecker.Wax.Section; - g.achecker.Wax.ListSection = function (cwin, rdoc, title, targetSelector, - limit, isIncludeFrame, frameDocs, emptyMessage, - content, validStatus, eventHandlers) { - var this_ = this; - this.cwin = cwin; - this.rdoc = rdoc; - this.title = title; - this.emptyMessage = emptyMessage; - this.contents = this._getContents(cwin, isIncludeFrame, frameDocs, - targetSelector, content, validStatus, eventHandlers, limit); - }; - g.achecker.Wax.ListSection.prototype._getContentsFromDocument = function (doc, url, - targetSelector, content, validStatus, eventHandlers, limit) { - if (!limit) { - limit = 99999; - } - - var $target = doc.querySelectorAll(targetSelector); - var contents = [], i; - - for (i = 0; i < $target.length; i++) { - if (limit <= 0) { - break; - } - - var $el = $target[i]; - var _content = typeof content === 'function' ? content.apply($el, [doc, url]) : content; - if (_content !== false) { - contents.push({ - el: $el, - doc: $el.ownerDocument, - validStatus: typeof validStatus === 'function' ? validStatus.apply($el, [doc, url]) : (typeof validStatus === 'string' ? validStatus : ''), - content: typeof content === 'function' ? content.apply($el, [doc, url]) : content, - eventHandlers: eventHandlers - }); - limit--; - } - } - return contents; - }; - g.achecker.Wax.ListSection.prototype._getContents = function (win, isIncludeFrame, - frameDocs, targetSelector, content, validStatus, - eventHandlers, limit) { - if (!limit) { - limit = 99999; - } - var contents = this._getContentsFromDocument(win.document, win.location.href, - targetSelector, content, validStatus, eventHandlers, limit), i, l; - - limit -= contents.length; - if (isIncludeFrame && limit > 0) { - for (i = 0, l = frameDocs.length; i < l; i++) { - if (limit <= 0) { - break; - } - - var _contents = this._getContentsFromDocument( - frameDocs[i].doc, - frameDocs[i].src, - targetSelector, - content, - validStatus, - eventHandlers, - limit - ); - contents = contents.concat(_contents); - limit -= _contents.length; - } - } - return contents; - }; - g.achecker.Wax.ListSection.prototype.getAsElement = function () { - var this_ = this; - var doc = this.rdoc; - var $contentList = doc.createElement("ul"), i; - var hasWarning = false; - var hasError = false; - var onClickItem = function (e) { - if (parent.Firebug) { - parent.Firebug.Inspector.clearAllHighlights(); - } - - var $targetEl = this['data-el']; - var isHidden = g.achecker.Wax.isElHidden($targetEl); - if ($targetEl.tagName === 'TITLE') { - while ($targetEl) { - if ($targetEl.tagName === 'HTML') { - break; - } - $targetEl = $targetEl.parentNode; - } - } - - if (!isHidden) { - var oldTabindex = $targetEl.getAttribute('tabindex'); - $targetEl.setAttribute('tabindex', 0); - $targetEl.focus(); - if (oldTabindex === null) { - $targetEl.removeAttribute('tabindex'); - } else { - $targetEl.setAttribute('tabindex', oldTabindex); - } - } - if (parent.Firebug && $targetEl) { - parent.Firebug.Inspector.inspectFromContextMenu($targetEl); - // compatible with firebug 1.9.x - parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); - } else if (g.console && g.console.log && $targetEl) { - g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); - } - }; - - for (i = 0; i < this.contents.length; i++) { - var info = this.contents[i]; - var hiddenClass = g.achecker.Wax.isElHidden(info.el) ? ' hidden_el' : ''; - var $item = doc.createElement('li'); - var key; - - $item.className = info.validStatus + ' ' + hiddenClass; - if (typeof info.content === 'string') { - $item.innerText = info.content; - $item.textContent = info.content; - } else { - $item.appendChild(info.content); - } - $item['data-el'] = info.el; - if (info.eventHandlers) { - for (key in info.eventHandlers) { - if (info.eventHandlers.hasOwnProperty(key)) { - addEvent($item, key, info.eventHandlers[key]); - } - } - } - if (info.validStatus === 'fail') { - hasError = true; - } else if (info.validStatus === 'warning') { - hasWarning = true; - } - addEvent($item, 'click', onClickItem); - $contentList.appendChild($item); - } - - var $section = doc.createElement('div'); - $section.className = 'waxSection'; - var $title = doc.createElement('h2'); - var $count = doc.createElement('span'); - $title.innerText = this.title + " "; - $title.textContent = this.title + " "; - $title.className = 'folded'; - if (hasError) { - $title.className += ' fail'; - } else if (hasWarning) { - $title.className += ' warning'; - } - $count.innerText = "(" + this.contents.length + ")"; - $count.textContent = "(" + this.contents.length + ")"; - $title.appendChild($count); - /* - var $titleLink = doc.createElement('a'); - $titleLink.setAttribute('target', '_blank'); - $titleLink.setAttribute('href', - 'http://html.nhncorp.com/a11y/guide.php?no='+ - this.title.split(' ')[0] + ''); - $titleLink.innerText = 'Guide'; - $titleLink.textContent = 'Guide'; - $title.appendChild($titleLink); - */ - $section.appendChild($title); - - if ($contentList.childNodes.length <= 0) { - var $emptyItem = doc.createElement('p'); - $emptyItem.className = 'comment'; - $emptyItem.innerText = this.emptyMessage; - $emptyItem.textContent = this.emptyMessage; - $section.appendChild($emptyItem); - } else { - $section.appendChild($contentList); - } - - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - /* - addEvent($titleLink, 'click', function (e) { - e.stopPropagation(); - }); - */ - return $section; - }; - g.achecker.Wax.ListSection.prototype.getScore = function () { - var count = this.contents.length, - pass = 0; - - for (var i = 0; i < count; i++) { - if (this.contents[i].validStatus !== 'fail') { - pass++; - } - } - - return { - all: count, - pass: pass - }; - }; - - g.achecker.Wax.TableSection = g.achecker.Wax.Section; - g.achecker.Wax.TableSection = function (cwin, rdoc, title, targetSelector, - colInfo, isIncludeFrame, frameDocs, emptyMessage, - content, validStatus, eventHandlers) { - var this_ = this; - this.cwin = cwin; - this.rdoc = rdoc; - this.title = title; - this.colInfo = colInfo; - this.emptyMessage = emptyMessage; - this.contents = this._getContents(cwin, isIncludeFrame, frameDocs, - targetSelector, content, validStatus, eventHandlers); - }; - g.achecker.Wax.TableSection.prototype._getContentsFromDocument = function (doc, url, - targetSelector, content, validStatus, eventHandlers) { - var $target = doc.querySelectorAll(targetSelector); - var contents = [], i; - - for (i = 0; i < $target.length; i++) { - var $el = $target[i]; - var _content = typeof content === 'function' ? content.apply($el, [doc, url]) : content; - if (_content !== false) { - contents.push({ - el: $el, - doc: $el.ownerDocument, - validStatus: typeof validStatus === 'function' ? validStatus.apply($el, [doc, url]) : (typeof validStatus === 'string' ? validStatus : ''), - content: typeof content === 'function' ? content.apply($el, [doc, url]) : content, - eventHandlers: eventHandlers - }); - } - } - return contents; - }; - g.achecker.Wax.TableSection.prototype._getContents = function (win, isIncludeFrame, - frameDocs, targetSelector, content, validStatus, - eventHandlers) { - var contents = this._getContentsFromDocument(win.document, win.location.href, - targetSelector, content, validStatus, eventHandlers), i, l; - - if (isIncludeFrame) { - for (i = 0, l = frameDocs.length; i < l; i++) { - var _contents = this._getContentsFromDocument(frameDocs[i].doc, frameDocs[i].src, - targetSelector, content, validStatus, eventHandlers); - contents = contents.concat(_contents); - } - } - return contents; - }; - g.achecker.Wax.TableSection.prototype.getAsElement = function () { - var this_ = this; - var doc = this.rdoc; - var $table = doc.createElement('table'); - var $thead = doc.createElement('thead'); - var $theadTr = doc.createElement('tr'); - var hasWarning = false; - var hasError = false; - var i; - var onClickTr = function (e) { - if (parent.Firebug) { - parent.Firebug.Inspector.clearAllHighlights(); - } - - var $targetEl = this['data-el']; - var isHidden = g.achecker.Wax.isElHidden($targetEl); - if ($targetEl.tagName === 'TITLE') { - while ($targetEl) { - if ($targetEl.tagName === 'HTML') { - break; - } - $targetEl = $targetEl.parentNode; - } - } - - if (!isHidden) { - var oldTabindex = $targetEl.getAttribute('tabindex'); - $targetEl.setAttribute('tabindex', 0); - $targetEl.focus(); - if (oldTabindex === null) { - $targetEl.removeAttribute('tabindex'); - } else { - $targetEl.setAttribute('tabindex', oldTabindex); - } - } - if (parent.Firebug && $targetEl) { - parent.Firebug.Inspector.inspectFromContextMenu($targetEl); - // compatible with firebug 1.9.x - parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); - } else if (g.console && g.console.log && $targetEl) { - g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); - } - }; - - for (i = 0; i < this.colInfo.length; i++) { - var $theadTh = doc.createElement('th'); - $theadTh.setAttribute('scope', 'col'); - $theadTh.innerText = this.colInfo[i].label; - $theadTh.textContent = this.colInfo[i].label; - if (this.colInfo[i].width) { - $theadTh.style.width = this.colInfo[i].width + 'px'; - } - if (this.colInfo[i].minWidth) { - $theadTh.style.minWidth = this.colInfo[i].minWidth + 'px'; - } - if (this.colInfo[i].maxWidth) { - $theadTh.style.maxWidth = this.colInfo[i].maxWidth + 'px'; - } - if (this.colInfo[i].className) { - $theadTh.className = this.colInfo[i].className; - } - $theadTr.appendChild($theadTh); - } - $thead.appendChild($theadTr); - $table.appendChild($thead); - - var $tbody = doc.createElement('tbody'); - for (i = 0; i < this.contents.length; i++) { - var info = this.contents[i]; - var hiddenClass = g.achecker.Wax.isElHidden(info.el) ? ' hidden_el' : ''; - var $tr = doc.createElement('tr'); - var j, key; - - $tr.className = info.validStatus + ' ' + hiddenClass; - for (j in info.content) { - if (info.content.hasOwnProperty(j)) { - var _content = info.content[j]; - var $td = doc.createElement('td'); - if (typeof _content === 'string') { - $td.innerText = _content; - $td.textContent = _content; - $td.innerHTML = (_content - .replace(/</g, '<') - .replace(/>/g, '>') - ) - .replace(/\[__\[/g, '<span style="color:#777!important;text-decoration:line-through">') - .replace(/\]__\]/g, '</span>'); - } else { - $td.appendChild(_content); - } - if (this.colInfo[j].className) { - $td.className = this.colInfo[j].className; - } - $tr.appendChild($td); - } - } - $tr['data-el'] = info.el; - if (info.eventHandlers) { - for (key in info.eventHandlers) { - if (info.eventHandlers.hasOwnProperty(key)) { - addEvent($tr, key, info.eventHandlers[key]); - } - } - } - if (info.validStatus === 'fail') { - hasError = true; - } else if (info.validStatus === 'warning') { - hasWarning = true; - } - addEvent($tr, 'click', onClickTr); - $tbody.appendChild($tr); - $table.appendChild($tbody); - } - - var $section = doc.createElement('div'); - $section.className = 'waxSection'; - var $title = doc.createElement('h2'); - var $count = doc.createElement('span'); - $title.innerText = this.title + " "; - $title.textContent = this.title + " "; - $title.className = 'folded'; - if (hasError) { - $title.className += ' fail'; - } else if (hasWarning) { - $title.className += ' warning'; - } - $count.innerText = "(" + this.contents.length + ")"; - $count.textContent = "(" + this.contents.length + ")"; - $title.appendChild($count); - /* - var $titleLink = doc.createElement('a'); - $titleLink.setAttribute('target', '_blank'); - $titleLink.setAttribute('href', - 'http://html.nhncorp.com/a11y/guide.php?no='+ - this.title.split(' ')[0] + ''); - $titleLink.innerText = 'Guide'; - $titleLink.textContent = 'Guide'; - $title.appendChild($titleLink); - */ - $section.appendChild($title); - - if ($tbody.childNodes.length <= 0) { - var $emptyItem = doc.createElement('p'); - $emptyItem.className = 'comment'; - $emptyItem.innerText = this.emptyMessage; - $emptyItem.textContent = this.emptyMessage; - $section.appendChild($emptyItem); - } else { - $section.appendChild($table); - } - - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - /* - addEvent($titleLink, 'click', function (e) { - e.stopPropagation(); - }); - */ - return $section; - }; - g.achecker.Wax.TableSection.prototype.getScore = function () { - var count = this.contents.length, - pass = 0; - - for (var i = 0; i < count; i++) { - if (this.contents[i].validStatus !== 'fail') { - pass++; - } - } - - return { - all: count, - pass: pass - }; - }; - - g.achecker.Wax.ToolSection = function (cwin, rdoc, id, title, content, eventHandlers) { - var this_ = this; - this.cwin = cwin; - this.rdoc = rdoc; - this.id = id; - this.title = title; - this.content = typeof content === 'function' ? content.apply(this, [this.cwin, this.rdoc]) : content; - this.eventHandlers = eventHandlers; - }; - g.achecker.Wax.ToolSection.prototype.getAsElement = function () { - var doc = this.rdoc; - - var $section = doc.createElement('div'); - $section.id = this.id; - $section.className = 'waxSection'; - var $title = doc.createElement('h2'); - $title.className = 'folded'; - $title.innerText = this.title; - $title.textContent = this.title; - /* - var $titleLink = doc.createElement('a'); - $titleLink.setAttribute('target', '_blank'); - $titleLink.setAttribute('href', - 'http://html.nhncorp.com/a11y/guide.php?no='+ - this.title.split(' ')[0] + ''); - $titleLink.innerText = 'Guide'; - $titleLink.textContent = 'Guide'; - $title.appendChild($titleLink); - */ - - var $content = doc.createElement('div'); - if (typeof this.content === 'string') { - $content.innerText = this.content; - $content.textContent = this.content; - } else { - $content.appendChild(this.content); - } - $section.appendChild($title); - $section.appendChild($content); - - $title.setAttribute('tabindex', 0); - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - /* - addEvent($titleLink, 'click', function (e) { - e.stopPropagation(); - }); - */ - return $section; - }; - g.achecker.Wax.ToolSection.prototype.getScore = function () { - return null; - }; -}(window)); diff --git a/owax_bookmarklet/lib/Section.js b/owax_bookmarklet/lib/Section.js new file mode 120000 index 0000000..38191d3 --- /dev/null +++ b/owax_bookmarklet/lib/Section.js @@ -0,0 +1 @@ +../../lib/Section.js \ No newline at end of file diff --git a/owax_bookmarklet/lib/Sections.js b/owax_bookmarklet/lib/Sections.js deleted file mode 100644 index 59f2bed..0000000 --- a/owax_bookmarklet/lib/Sections.js +++ /dev/null @@ -1,1750 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is N-WAX(NHN Web Accessibility eXtension). - * - * The Initial Developer of the Original Code is - * Goonoo Kim (NHN). - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/*jslint browser: true */ -/*global chrome, Components, openDialog, XMLHttpRequest, FormData */ - -(function (global, document) { - "use strict"; - - var achecker = global.achecker || {}; - achecker.Wax = achecker.Wax || {}; - var addEvent = function (obj, type, fn) { - if (obj.addEventListener) { - obj.addEventListener(type, fn, false); - } else if (obj.attachEvent) { - obj["e" + type + fn] = fn; - obj[type + fn] = function () { - obj["e" + type + fn](global.event); - }; - obj.attachEvent("on" + type, obj[type + fn]); - } - }; - var ListSection = achecker.Wax.ListSection; - var TableSection = achecker.Wax.TableSection; - var ToolSection = achecker.Wax.ToolSection; - var getElsFromChildNodes = function (pEl, tagName) { - var els = [], i = 0; - if (pEl.length && pEl.push) { - for (i = 0; i < pEl.length; i++) { - els = els.concat(getElsFromChildNodes(pEl[i], tagName)); - } - return els; - } - var n = pEl.childNodes; - if (n && n.length) { - for (i = 0; i < n.length; i++) { - if (n[i].tagName && n[i].tagName.toLowerCase() === tagName.toLowerCase()) { - els.push(n[i]); - } - } - return els; - } - return []; - }; - var toggleFoldedClass = function (el) { - el.className = el.className === 'folded' ? '' : 'folded'; - - // fix bug: IE8 won't reflow when set data-* attribute - if (document && document.all) { - document.body.className = document.body.getAttribute('className'); - } - }; - - var getContrastRatio = function (color1, color2) { - var l1; // higher value - var l2; // lower value - var contrast; - var l1R, l1G, l1B, l2R, l2G, l2B; - - // error check, check if pound sign was put in field value - if (color2.indexOf('#') === 0) { - color2 = color2.substr(1, color2.length - 1); - } - if (color1.indexOf('#') === 0) { - color1 = color1.substr(1, color1.length - 1); - } - - //Linearised R (for example) = (R/FS)^2.2 where FS is full scale value (255 - //for 8 bit color channels). L1 is the higher value (of text or background) - //alert(parseInt("0x"+color1.substr(0, 2))); - //Math.pow(n,x); - l1R = parseInt(color1.substr(0, 2), 16) / 255; - if (l1R <= 0.03928) { - l1R = l1R / 12.92; - } else { - l1R = Math.pow(((l1R + 0.055) / 1.055), 2.4); - } - l1G = parseInt(color1.substr(2, 2), 16) / 255; - if (l1G <= 0.03928) { - l1G = l1G / 12.92; - } else { - l1G = Math.pow(((l1G + 0.055) / 1.055), 2.4); - } - l1B = parseInt(color1.substr(4, 2), 16) / 255; - if (l1B <= 0.03928) { - l1B = l1B / 12.92; - } else { - l1B = Math.pow(((l1B + 0.055) / 1.055), 2.4); - } - l2R = parseInt(color2.substr(0, 2), 16) / 255; - if (l2R <= 0.03928) { - l2R = l2R / 12.92; - } else { - l2R = Math.pow(((l2R + 0.055) / 1.055), 2.4); - } - l2G = parseInt(color2.substr(2, 2), 16) / 255; - if (l2G <= 0.03928) { - l2G = l2G / 12.92; - } else { - l2G = Math.pow(((l2G + 0.055) / 1.055), 2.4); - } - l2B = parseInt(color2.substr(4, 2), 16) / 255; - if (l2B <= 0.03928) { - l2B = l2B / 12.92; - } else { - l2B = Math.pow(((l2B + 0.055) / 1.055), 2.4); - } - //where L is luminosity and is defined as - l1 = (0.2126 * l1R) + (0.7152 * l1G) + (0.0722 * l1B); //using linearised R, G, and B value - l2 = (0.2126 * l2R) + (0.7152 * l2G) + (0.0722 * l2B); //using linearised R, G, and B value - //and L2 is the lower value. - l1 = l1 + 0.05; - l2 = l2 + 0.05; - if (l1 < l2) { - var temp = l1; - l1 = l2; - l2 = temp; - } - l1 = l1 / l2; - l1 = l1.toFixed(1); - return l1; - }; - - var getLabel = function (element) { - var currentLabel = ""; - var currentLabelElement; - var doc = element.ownerDocument; - var labelElement, labelChilds, i, l, _i, _l; - -labelLoop: - for (i = 0, l = doc.getElementsByTagName("label").length; i < l; i++) { - labelElement = doc.getElementsByTagName("label")[i]; - labelChilds = labelElement.childNodes; - - if (labelElement.htmlFor && labelElement.htmlFor === element.id) { - currentLabelElement = labelElement; - break labelLoop; - } - for (_i = 0, _l = labelChilds.length; _i < _l; _i++) { - if (labelChilds[_i] === element) { - currentLabelElement = labelElement; - break labelLoop; - } - } - } - - if (currentLabelElement) { - labelChilds = currentLabelElement.childNodes; - for (i = 0, l = labelChilds.length; i < l; i++) { - if (!labelChilds[i].tagName) { // check is text node - currentLabel += labelChilds[i].nodeValue.replace(/^\s+/, "").replace(/\s+$/, ""); - } - } - } - if (!currentLabel) { - if (element.title) { - currentLabel = element.title; - } else if (element.id) { - currentLabel = element.id; - } else if (element.name) { - currentLabel = element.name; - } else { - currentLabel = ""; - } - } - return currentLabel; - }; - - var getTextContent = function (el) { - var ELEMENT_NODE = 1; - var txt = ''; - var nodeType = el.nodeType; - var tagName = el.tagName ? el.tagName.toUpperCase() : ''; - var attrType = el.getAttribute ? el.getAttribute('type') : ''; - var styleDisplay; - - try { - var computedStyle = el.currentStyle || el.ownerDocument.defaultView.getComputedStyle(el, null); - styleDisplay = computedStyle.display; - } catch (e) { - styleDisplay = ""; - } - - if (nodeType === ELEMENT_NODE && - styleDisplay === 'none') { - txt += '[__['; - } - - if (nodeType === ELEMENT_NODE && - tagName === "IMG") { - txt += el.getAttribute('alt'); - } else if (nodeType === ELEMENT_NODE && - tagName === "AREA") { - txt += el.getAttribute('alt'); - } else if (nodeType === ELEMENT_NODE && - tagName === "INPUT" && - attrType === 'image') { - txt += el.getAttribute('alt'); - } else if (nodeType === ELEMENT_NODE && - tagName === "INPUT" && - (attrType === 'submit' || - attrType === 'reset' || - attrType === 'button')) { - txt += el.value; - } else if (nodeType === ELEMENT_NODE && - tagName === "INPUT") { - txt += getLabel(el); - } else if (nodeType === ELEMENT_NODE && - (tagName === "TEXTAREA" || tagName === "SELECT")) { - txt += getLabel(el); - } else if (nodeType !== ELEMENT_NODE || - (tagName !== "SCRIPT" && tagName !== "STYLE")) { - var cNodes = el.childNodes; - var TEXT_NODE = 3; - var i, l; - for (i = 0, l = cNodes.length; i < l; i++) { - if (cNodes[i].nodeType === TEXT_NODE) { - txt += cNodes[i].nodeValue; - } else { - txt += getTextContent(cNodes[i]); - } - } - } - - if (nodeType === ELEMENT_NODE && - styleDisplay === 'none') { - txt += ']__]'; - } - txt = txt ? txt.replace(/^\s+/, '').replace(/\s+$/, '') : ''; - return txt; - }; - - var getAbsolutePath = function (src, url) { - var newpath, orgPath; - - // remove url querystring - url = url.replace(/\?.*$/, ''); - - if (src && src.indexOf('//') === -1) { - if (src.substr(0, 3) === '../') { - newpath = url.substr(0, url.lastIndexOf('/') > 10 ? url.lastIndexOf('/') : url.length); - while (src.substr(0, 3) === '../') { - newpath = newpath.substr(0, newpath.lastIndexOf('/') > 10 ? newpath.lastIndexOf('/') : newpath.length); - src = src.substr(3); - } - src = newpath + '/' + src; - } else if (src.substr(0, 1) === '/') { - orgPath = url.replace(/^((?:https?\:\/\/|file\:\/\/\/)[^\/]+)\/.*$/, '$1'); - src = orgPath + '/' + src; - } else { - orgPath = url.substr(0, url.lastIndexOf('/')); - src = orgPath + '/' + src; - } - } - return src; - }; - - achecker.Wax.run = function (cwin, rdoc, isIncludeFrame, frameDocs, discardFrameUrls) { - return { - header: (function () { - var $div = rdoc.createElement('div'); - $div.className = 'waxFrames'; - - var $fold = rdoc.createElement('div'); - var $foldBtn = rdoc.createElement('button'); - - $fold.className = 'toggleAll'; - $foldBtn.className = 'fold'; - $foldBtn.setAttribute('data-folded', 'folded'); - $foldBtn.title = achecker.i18n.get('UnfoldAll'); - $foldBtn.setAttribute('type', 'button'); - $foldBtn.innerText = 'Toggle All'; - $foldBtn.textContent = 'Toggle All'; - $foldBtn.onclick = function () { - var $headings = rdoc.querySelectorAll('.waxSection h2,.waxFrames h2'); - var foldedClass = this.getAttribute('data-folded') === 'folded' ? '' : 'folded'; - var i, l; - - for (i = 0, l = $headings.length; i < l; i++) { - $headings[i].className = $headings[i].className.replace('folded', '') + ' ' + foldedClass; - } - - if (foldedClass) { - this.className = 'unfold'; - this.title = achecker.i18n.get('UnfoldAll'); - } else { - this.className = 'fold'; - this.title = achecker.i18n.get('FoldAll'); - } - this.setAttribute('data-folded', foldedClass); - // fix bug: IE8 won't reflow when set data-* attribute - rdoc.body.className = rdoc.body.getAttribute("className"); - }; - $fold.appendChild($foldBtn); - $div.appendChild($fold); - - var $title = rdoc.createElement('h2'); - $title.className = ''; - $title.innerText = achecker.i18n.get('TargetPage'); - $title.textContent = achecker.i18n.get('TargetPage'); - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - var $pages = rdoc.createElement('ul'), $pageLink; - var $topPage = rdoc.createElement('li'); - var $topPageLink = rdoc.createElement('a'); - var i, l, $page; - - $topPageLink.setAttribute('href', cwin.location.href); - $topPageLink.setAttribute('target', '_blank'); - $topPageLink.innerText = cwin.location.href; - $topPageLink.textContent = cwin.location.href; - $topPage.appendChild($topPageLink); - $pages.appendChild($topPage); - if (isIncludeFrame) { - for (i = 0, l = frameDocs.length; i < l; i++) { - $page = rdoc.createElement('li'); - $pageLink = rdoc.createElement('a'); - $pageLink.setAttribute('href', frameDocs[i].src); - $pageLink.setAttribute('target', '_blank'); - $pageLink.innerText = frameDocs[i].src; - $pageLink.textContent = frameDocs[i].src; - $page.appendChild($pageLink); - $pages.appendChild($page); - } - } - $div.appendChild($title); - $div.appendChild($pages); - - if (discardFrameUrls && discardFrameUrls.length) { - $title = rdoc.createElement('h2'); - $title.innerText = achecker.i18n.get('NoneTargetPage'); - $title.textContent = achecker.i18n.get('NoneTargetPage'); - $title.className = 'folded'; - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - $pages = rdoc.createElement('ul'); - for (i = 0, l = discardFrameUrls.length; i < l; i++) { - $page = rdoc.createElement('li'); - $pageLink = rdoc.createElement('a'); - $pageLink.setAttribute('href', discardFrameUrls[i]); - $pageLink.setAttribute('target', '_blank'); - $pageLink.innerText = discardFrameUrls[i]; - $pageLink.textContent = discardFrameUrls[i]; - $page.appendChild($pageLink); - $pages.appendChild($page); - } - } - $div.appendChild($title); - $div.appendChild($pages); - return $div; - }()), - sections: { - altText: new TableSection( - cwin, - rdoc, - '1. ' + achecker.i18n.get('No1') + ' (img)', - 'input[type=image],img,area', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Preview'), width: 106}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var tagName = this.tagName.toLowerCase(); - var data = { - hidden: '', - preview: '', - el: '', - alt: '' - }; - var self = this; - - var handleImg = function () { - var hasAlt = self.getAttribute('alt') !== null; - data.alt = rdoc.createElement('span'); - if (!hasAlt) { - data.alt.innerText = 'alt ' + achecker.i18n.get('Undefined'); - data.alt.textContent = 'alt ' + achecker.i18n.get('Undefined'); - } else if (!self.getAttribute('alt')) { - data.alt.innerText = 'alt=""'; - data.alt.textContent = 'alt=""'; - } else { - data.alt.innerText = self.getAttribute('alt'); - data.alt.textContent = self.getAttribute('alt'); - } - data.el = tagName; - - if (self.getAttribute('longdesc')) { - var $longdesc = rdoc.createElement('a'); - $longdesc.setAttribute('href', - getAbsolutePath(self.getAttribute('longdesc'), url)); - $longdesc.setAttribute('target', '_blank'); - $longdesc.innerText = 'longdesc link'; - $longdesc.textContent = 'longdesc link'; - data.alt.innerText += ' '; - data.alt.textContent += ' '; - data.alt.appendChild($longdesc); - } - - var src = self.getAttribute('src'); - - var $container = rdoc.createElement('div'); - $container.style.width = "100px"; - $container.style.margin = "0 auto"; - $container.style.overflow = "hidden"; - var $img = rdoc.createElement('img'); - $img.setAttribute('alt', ''); - $img.setAttribute('src', getAbsolutePath(src, url)); - $container.appendChild($img); - data.preview = $container; - - return [ - data.hidden, - data.preview, - data.el, - data.alt - ]; - }; - - switch (tagName) { - case "input": - if (this.type.toLowerCase() !== 'image') { - break; - } - return handleImg(); - - case "img": - return handleImg(); - - case "area": - var hasAlt = this.getAttribute('alt') !== null; - data.alt = rdoc.createElement('span'); - if (!hasAlt) { - data.alt.innerText = 'alt ' + achecker.i18n.get('Undefined'); - data.alt.textContent = 'alt ' + achecker.i18n.get('Undefined'); - } else if (!this.getAttribute('alt')) { - data.alt.innerText = 'alt=""'; - data.alt.textContent = 'alt=""'; - } else { - data.alt.innerText = this.getAttribute('alt'); - data.alt.textContent = this.getAttribute('alt'); - } - data.el = tagName; - - return [ - data.hidden, - data.preview, - data.el, - data.alt - ]; - } - - return false; - }, - function () { - var tagName = this.tagName; - switch (tagName) { - case "IMG": - case "INPUT": - case "AREA": - var hasAlt = this.getAttribute('alt') !== null; - - if (!hasAlt) { - return 'fail'; - } - if (!this.getAttribute('alt')) { - return 'warning'; - } - return 'pass'; - } - } - ), - - altTextBG: new TableSection( - cwin, - rdoc, - '1. ' + achecker.i18n.get('No1') + ' (bg)', - 'body *', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Preview'), width: 106}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var data = { - hidden: '', - preview: '', - content: '' - }; - var computedStyle = this.currentStyle || cwin.getComputedStyle(this, null); - var bgImage = computedStyle.backgroundImage; - if (bgImage !== 'none' && - this.getElementsByTagName('*').length < 10) { - var $bg = rdoc.createElement('span'); - url = bgImage.replace(/^url\("?/, '').replace(/"?\)$/, ''); - - try { - $bg.style.backgroundImage = bgImage; - $bg.style.backgroundPosition = computedStyle.backgroundPosition; - $bg.style.backgroundRepeat = computedStyle.backgroundRepeat; - $bg.style.width = computedStyle.width; - $bg.style.height = computedStyle.height; - } catch (e) { - } - $bg.style.maxWidth = '100px'; - $bg.style.maxHeight = '200px'; - $bg.style.display = 'inline-block'; - $bg.style.overflow = 'hidden'; - - data.preview = $bg; - data.content = getTextContent(this); - - return [ - data.hidden, - data.preview, - data.content - ]; - } - - return false; - } - ), - - altTextEmbed: new TableSection( - cwin, - rdoc, - '1. ' + achecker.i18n.get('No1') + ' (object)', - 'object,embed,video,audio,canvas,svg', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var tagName = this.tagName; - switch (tagName) { - case "OBJECT": - if (this.parentNode && this.parentNode.tagName && - (this.parentNode.tagName === 'OBJECT' || - this.parentNode.tagName === 'EMBED')) { - return false; - } - return [ - '', - '<object>' - ]; - case "EMBED": - if (this.parentNode && this.parentNode.tagName && - (this.parentNode.tagName === 'OBJECT' || - this.parentNode.tagName === 'EMBED')) { - return false; - } - return [ - '', - '<embed>' - ]; - } - - return false; - } - ), - - contrast: new ToolSection( - cwin, - rdoc, - 'contrast', - '5. ' + achecker.i18n.get('No5'), - function (win, rdoc) { - if (!achecker.colorInspector) { - var $res = rdoc.createElement('p'); - $res.className = 'comment'; - $res.innerText = 'Not Supported.'; - $res.textContent = 'Not Supported.'; - return $res; - } - - var $ul = rdoc.createElement('ul'); - $ul.className = 'contrast'; - var $color1 = rdoc.createElement('li'); - var $color2 = rdoc.createElement('li'); - var $result = rdoc.createElement('li'); - - $color1.className = 'color1'; - var $color1_label = rdoc.createElement('span'); - $color1_label.innerText = achecker.i18n.get('Foreground') + ': '; - $color1_label.textContent = achecker.i18n.get('Foreground') + ': '; - var $color1_color = rdoc.createElement('span'); - $color1_color.className = 'color'; - $color1_color.style.backgroundColor = '#000'; - var $color1_val = rdoc.createElement('span'); - $color1_val.className = 'val'; - $color1_val.innerText = '#000000'; - $color1_val.textContent = '#000000'; - var $color1_btn = rdoc.createElement('button'); - $color1_btn.innerText = achecker.i18n.get('SelectForegroundColor'); - $color1_btn.textContent = achecker.i18n.get('SelectForegroundColor'); - $color1.appendChild($color1_label); - $color1.appendChild($color1_color); - $color1.appendChild(rdoc.createTextNode(' ')); - $color1.appendChild($color1_val); - $color1.appendChild(rdoc.createTextNode(' ')); - $color1.appendChild($color1_btn); - $color1.onclick = function () { - achecker.showOverlay(); - achecker.colorInspector.startInspect(function (color) { - achecker.hideOverlay(); - $color1.getElementsByClassName('color')[0].style.backgroundColor = color; - $color1.getElementsByClassName('val')[0].innerText = color; - $color1.getElementsByClassName('val')[0].textContent = color; - var contrastRatio = getContrastRatio(color, $color2.getElementsByClassName('val')[0].innerText); - if (contrastRatio >= 4.5) { - $result.className = 'pass'; - } else if (contrastRatio >= 3) { - $result.className = 'warning'; - } else { - $result.className = 'fail'; - } - $result.getElementsByClassName('result')[0].innerText = contrastRatio + ':1'; - $result.getElementsByClassName('result')[0].textContent = contrastRatio + ':1'; - $result.getElementsByClassName('resultText')[0].style.color = color; - }); - }; - - $color2.className = 'color2'; - var $color2_label = rdoc.createElement('span'); - $color2_label.innerText = achecker.i18n.get('Background') + ': '; - $color2_label.textContent = achecker.i18n.get('Background') + ': '; - var $color2_color = rdoc.createElement('span'); - $color2_color.className = 'color'; - $color2_color.style.backgroundColor = '#FFF'; - var $color2_val = rdoc.createElement('span'); - $color2_val.className = 'val'; - $color2_val.innerText = '#FFFFFF'; - $color2_val.textContent = '#FFFFFF'; - var $color2_btn = rdoc.createElement('button'); - $color2_btn.innerText = achecker.i18n.get('SelectBackgroundColor'); - $color2_btn.textContent = achecker.i18n.get('SelectBackgroundColor'); - $color2.appendChild($color2_label); - $color2.appendChild($color2_color); - $color2.appendChild(rdoc.createTextNode(' ')); - $color2.appendChild($color2_val); - $color2.appendChild(rdoc.createTextNode(' ')); - $color2.appendChild($color2_btn); - $color2.onclick = function () { - achecker.showOverlay(); - achecker.colorInspector.startInspect(function (color) { - achecker.hideOverlay(); - $color2.getElementsByClassName('color')[0].style.backgroundColor = color; - $color2.getElementsByClassName('val')[0].innerText = color; - $color2.getElementsByClassName('val')[0].textContent = color; - var contrastRatio = getContrastRatio(color, $color1.getElementsByClassName('val')[0].innerText); - if (contrastRatio >= 4.5) { - $result.className = 'pass'; - } else if (contrastRatio >= 3) { - $result.className = 'warning'; - } else { - $result.className = 'fail'; - } - $result.getElementsByClassName('result')[0].innerText = contrastRatio + ':1'; - $result.getElementsByClassName('result')[0].textContent = contrastRatio + ':1'; - $result.getElementsByClassName('resultText')[0].style.backgroundColor = color; - }); - }; - - $result.className = 'pass'; - var $result_label = rdoc.createElement('span'); - $result_label.innerText = achecker.i18n.get('Result') + ': '; - $result_label.textContent = achecker.i18n.get('Result') + ': '; - var $result_result = rdoc.createElement('span'); - $result_result.className = 'result'; - $result_result.innerText = '21:1'; - $result_result.textContent = '21:1'; - var $result_resultText = rdoc.createElement('span'); - $result_resultText.className = 'resultText'; - $result_resultText.innerText = achecker.i18n.get('Test'); - $result_resultText.textContent = achecker.i18n.get('Test'); - $result.appendChild($result_label); - $result.appendChild($result_result); - $result.appendChild(rdoc.createTextNode(' ')); - $result.appendChild($result_resultText); - - $ul.appendChild($color1); - $ul.appendChild($color2); - $ul.appendChild($result); - - return $ul; - } - ), - - kbdFocus: new TableSection( - cwin, - rdoc, - '8. ' + achecker.i18n.get('No8'), - '*', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('ErrorType'), width: 65}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('RequireConfirmation'), - function (doc, url) { - try { - var evtWrapper = this.wrappedJSObject || this; - var hasBlurEvent = false; - if (evtWrapper.onfocus && evtWrapper.onfocus.toString().indexOf('blur()') > -1) { - hasBlurEvent = true; - } else if (evtWrapper.onclick && evtWrapper.onclick.toString().indexOf('blur()') > -1) { - hasBlurEvent = true; - } - var outlineWidth = this.style.getPropertyValue('outline-width'); - var zeroOutlineWidth = outlineWidth === '0' || outlineWidth === '0pt' || outlineWidth === '0px'; - - if (hasBlurEvent) { - return [ - '', - 'blur()', - getTextContent(this) - ]; - } - if (zeroOutlineWidth) { - return [ - '', - 'outline:0', - getTextContent(this) - ]; - } - return false; - } catch (e) { - return false; - } - }, - function (doc, url) { - try { - var evtWrapper = this.wrappedJSObject || this; - var hasBlurEvent = evtWrapper.onfocus ? - evtWrapper.onfocus.toString().indexOf('blur()') > -1 : false; - var outlineWidth = this.style.getPropertyValue('outline-width'); - var zeroOutlineWidth = outlineWidth === '0' || outlineWidth === '0pt' || outlineWidth === '0px'; - - if (hasBlurEvent) { - return 'fail'; - } - if (zeroOutlineWidth) { - return 'fail'; - } - return 'pass'; - } catch (e) { - return false; - } - } - ), - - skipNav: new TableSection( - cwin, - rdoc, - '12. ' + achecker.i18n.get('No12'), - 'a[href^="#"]', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('No'), width: 65}, - {label: achecker.i18n.get('Contents')}, - {label: achecker.i18n.get('Connected'), width: 45} - ], - isIncludeFrame, - frameDocs, - '-', - function (doc, url) { - if (cwin.document !== doc) { - return false; - } - - var href = this.getAttribute('href'); - var isConnectedLink = href === '#' ? false : - !!doc.getElementById(href.replace('#', '')) || - doc.getElementsByName(href.replace('#', '')).length > 0; - var linkIdx, i, l; - - for (i = 0, l = doc.getElementsByTagName('a').length; i < l; i++) { - if (doc.getElementsByTagName('a')[i] === this) { - linkIdx = i + 1; - if (linkIdx > 20) { - return false; - } - - break; - } - } - - return [ - '', - linkIdx + achecker.i18n.get('ThLink'), - '(' + href + ') ' + getTextContent(this), - (isConnectedLink ? 'O' : 'X') - ]; - }, - function (doc, url) { - var href = this.getAttribute('href'); - var isConnectedLink = href === '#' ? false : - !!doc.getElementById(href.replace('#', '')) || - doc.getElementsByName(href.replace('#', '')).length > 0; - return isConnectedLink ? 'pass' : 'fail'; - } - ), - - pageTitle: new ListSection( - cwin, - rdoc, - '13. ' + achecker.i18n.get('No13') + '(<title>)', - 'title', - null, - isIncludeFrame, - frameDocs, - '-', - function (doc, url) { - var $res = rdoc.createElement('span'); - var $val = rdoc.createElement('strong'); - var val = this.textContent || this.innerText || achecker.i18n.get('NoPageTitle'); - - $res.innerText = url + ': '; - $res.textContent = url + ': '; - $val.innerText = val; - $val.textContent = val; - $res.appendChild($val); - - return $res; - }, - function () { - var title = this.textContent || this.innerText || ''; - var dupCharacters = [ - '::', '||', '--', '@@', '##', '$$', '%%', '&&', '**', '((', '))', '++', '==', '~~', - ';;', '<<', '>>', '[[', ']]', '★★', '☆☆', '◎◎', '●●', '◆◆', '◇◇', '□□', '■■', '△△', - '▲▲', '▽▽', '▼▼', '◁◁', '◀◀', '▷▷', '▶▶', '♠♠', '♤♤', '♡♡', '♥♥', '♧♧', '♣♣', '⊙⊙', - '◈◈', '▣▣', '◐◐', '◑◑', '▒▒', '▤▤', '▥▥', '▨▨', '▧▧', '▦▦', '▩▩', '♨♨', '☏☏', '☎☎' - ]; - var hasTitle = !!title; - var hasSpecialCharactersDup = false; - for (var i = 0; i < dupCharacters.length; i++) { - if (title.indexOf(dupCharacters[i]) > -1) { - hasSpecialCharactersDup = true; - break; - } - } - - return hasTitle && !hasSpecialCharactersDup ? 'pass' : 'fail'; - } - ), - - frame: new TableSection( - cwin, - rdoc, - '13. ' + achecker.i18n.get('No13') + '(frame)', - 'iframe', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Title'), minWidth: 50, className: 'lt'}, - {label: achecker.i18n.get('Contents'), maxWidth: 200} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var data = { - hidden: '', - el: '', - title: '', - url: '' - }; - var src = this.getAttribute('src'); - var title = this.getAttribute('title'); - data.el = 'iframe'; - - if (src) { - var $a = rdoc.createElement('a'); - $a.setAttribute('href', src); - $a.setAttribute('target', '_blank'); - $a.innerText = src; - $a.textContent = src; - data.url = $a; - } else { - data.url = achecker.i18n.get('NoSrc'); - } - data.title = title || achecker.i18n.get('NoTitle'); - return [ - data.hidden, - data.el, - data.title, - data.url - ]; - }, - function () { - var title = this.getAttribute('title'); - return title ? 'pass' : 'fail'; - } - ), - - blockTitle: new TableSection( - cwin, - rdoc, - '13. ' + achecker.i18n.get('No13') + '(<h1>~<h6>)', - 'h1,h2,h3,h4,h5,h6', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('RequireConfirmation'), - function () { - return [ - '', - this.tagName.toLowerCase(), - getTextContent(this) - ]; - } - ), - - linkText: new TableSection( - cwin, - rdoc, - '14. ' + achecker.i18n.get('No14'), - 'a,area', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var text = getTextContent(this); - var title = this.getAttribute('title'); - - return [ - '', - this.tagName.toLowerCase(), - (text || '-') + - (title ? ' (title: ' + title + ')' : '') - ]; - }, - function () { - var text = getTextContent(this); - - return text ? 'pass' : 'fail'; - } - ), - - pageLang: new ListSection( - cwin, - rdoc, - '15. ' + achecker.i18n.get('No15'), - 'html', - null, - isIncludeFrame, - frameDocs, - '-', - function (doc, url) { - var isXhtml = this.getAttribute('xmlns'); - var val = ''; - var $res = rdoc.createElement('span'); - - // ignore if protocol is not http(s)? or .html extension - if (url.substr(0, 4).toLowerCase() !== 'http' && - url.substr(-5).toLowerCase() !== '.html') { - return false; - } - if (isXhtml && this.getAttribute('xml:lang') && this.getAttribute('lang')) { - val = 'xml:lang=' + this.getAttribute('xml:lang') + ', lang=' + this.getAttribute('lang'); - } else if (isXhtml && this.getAttribute('xml:lang')) { - val = 'xml:lang=' + this.getAttribute('xml:lang'); - } else if (isXhtml && this.getAttribute('lang')) { - val = 'xml:lang=' + achecker.i18n.get('None') + ', lang=' + this.getAttribute('lang'); - } else if (!isXhtml && this.getAttribute('lang')) { - val = 'lang=' + this.getAttribute('lang'); - } else { - val = achecker.i18n.get('NoMainLang'); - } - $res.innerText = url + ': '; - $res.textContent = url + ': '; - - var $val = rdoc.createElement('strong'); - $val.innerText = val; - $val.textContent = val; - $res.appendChild($val); - return $res; - }, - function (doc, url) { - var isXhtml = this.getAttribute('xmlns'); - - if (isXhtml && this.getAttribute('xml:lang')) { - return 'pass'; - } - if (isXhtml && this.getAttribute('lang')) { - return 'warning'; - } - if (!isXhtml && this.getAttribute('lang')) { - return 'pass'; - } - return 'fail'; - } - ), - - unintendedFunction: new TableSection( - cwin, - rdoc, - '16. ' + achecker.i18n.get('No16'), - 'a,area,input,button', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Event'), width: 80}, - {label: achecker.i18n.get('Contents'), className: 'lt'}, - {label: achecker.i18n.get('TitleAttribute')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('RequireConfirmation'), - function (doc, url) { - var data = { - hidden: '', - event: '', - content: '', - title: '' - }; - var evtWrapper = this.wrappedJSObject || this; - var hasChangeEvent; - var hasWindowOpenEvent; - - try { - hasWindowOpenEvent = evtWrapper.onclick ? - evtWrapper.onclick.toString().indexOf('window.open') > -1 : false; - } catch (e) { - hasWindowOpenEvent = null; - } - - data.content = getTextContent(this); - if (this.getAttribute('title')) { - data.title = this.getAttribute('title'); - } else if (this.getAttribute('target') === '_blank') { - data.title = 'target="_blank"'; - } else { - data.title = '-'; - } - - if (hasWindowOpenEvent) { - data.event = 'window.open'; - } else { - return false; - } - - return [ - data.hidden, - data.event, - data.content, - data.title - ]; - }, - function () { - if (this.getAttribute('title')) { - return 'warning'; - } - if (this.getAttribute('target') === '_blank') { - return 'pass'; - } - return 'fail'; - } - ), - - tableTitle: new TableSection( - cwin, - rdoc, - '18. ' + achecker.i18n.get('No18') + '(caption, summary)', - 'table', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('CaptionContent'), className: 'lt'}, - {label: achecker.i18n.get('SummaryContent')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var childNodes = this.childNodes, - $caption = null, - data = { - hidden: '', - caption: '', - summary: '' - }, - i, - l; - for (i = 0; i < childNodes.length; i++) { - if (childNodes[i].tagName && - childNodes[i].tagName.toLowerCase() === 'caption') { - $caption = childNodes[i]; - break; - } - } - var hasCaption = !!$caption; - var hasSummary = !!this.getAttribute('summary'); - - data.caption = hasCaption ? getTextContent($caption) : achecker.i18n.get('None'); - data.summary = hasSummary ? this.getAttribute('summary') : achecker.i18n.get('None'); - - return [ - data.hidden, - data.caption, - data.summary - ]; - }, - function () { - var childNodes = this.childNodes, - $caption = null, - i, - l; - for (i = 0; i < childNodes.length; i++) { - if (childNodes[i].tagName && - childNodes[i].tagName.toLowerCase() === 'caption') { - $caption = childNodes[i]; - break; - } - } - var hasCaption = !!$caption; - var hasSummary = !!this.getAttribute('summary'); - - if (hasCaption) { - return 'pass'; - } else if (!hasCaption && !hasSummary) { - return 'warning'; - } else { - return 'fail'; - } - } - ), - - tableStructure: new TableSection( - cwin, - rdoc, - '18. ' + achecker.i18n.get('No18') + '(th)', - 'table', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Structure'), className: 'tb_str'} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var data = { - hidden: '', - structure: '' - }; - var $thead = getElsFromChildNodes(this, 'thead'); - var $tfoot = getElsFromChildNodes(this, 'tfoot'); - var $tbody = getElsFromChildNodes(this, 'tbody'); - var $theadTh = getElsFromChildNodes( - getElsFromChildNodes($thead, 'tr'), - 'th' - ); - var $tfootTh = getElsFromChildNodes( - getElsFromChildNodes($tfoot, 'tr'), - 'th' - ); - var $tbodyTh = getElsFromChildNodes( - getElsFromChildNodes($tbody, 'tr'), - 'th' - ).concat( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tr'), - 'th' - ) - ); - var hasTh = !!$theadTh.length || !!$tfootTh.length || $tbodyTh.length; - var $resultTable = rdoc.createElement('table'); - var $resultThead = rdoc.createElement('thead'); - var $resultTbody = rdoc.createElement('tbody'); - var $resultTheadTr = rdoc.createElement('tr'); - var $resultTheadTh1 = rdoc.createElement('th'); - var $resultTheadTh2 = rdoc.createElement('th'); - var $resultTheadTh3 = rdoc.createElement('th'); - $resultTheadTh1.innerText = '요소'; - $resultTheadTh1.textContent = '요소'; - $resultTheadTh2.innerText = '유무'; - $resultTheadTh2.textContent = '유무'; - $resultTheadTh3.innerText = '제목셀 정보 (scope 속성값)'; - $resultTheadTh3.textContent = '제목셀 정보 (scope 속성값)'; - $resultTheadTr.appendChild($resultTheadTh1); - $resultTheadTr.appendChild($resultTheadTh2); - $resultTheadTr.appendChild($resultTheadTh3); - $resultThead.appendChild($resultTheadTr); - $resultTable.appendChild($resultThead); - $resultTable.appendChild($resultTbody); - - var $resultTr = rdoc.createElement('tr'); - var $resultTd1 = rdoc.createElement('td'); - var $resultTd2 = rdoc.createElement('td'); - var $resultTd3 = rdoc.createElement('td'); - var $resultTd3Ul; - var i, l; - var $th; - var scope; - var $infoItem; - - if ($thead.length) { - $resultTd3Ul = rdoc.createElement('ul'); - $resultTd1.innerText = 'thead'; - $resultTd1.textContent = 'thead'; - $resultTd2.innerText = 'O'; - $resultTd2.textContent = 'O'; - for (i = 0, l = $theadTh.length; i < l; i++) { - $th = $theadTh[i]; - scope = $th.getAttribute('scope'); - $infoItem = rdoc.createElement('li'); - - $infoItem.innerText = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $infoItem.textContent = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $resultTd3Ul.appendChild($infoItem); - } - $resultTd3.appendChild($resultTd3Ul); - } else { - $resultTd1.innerText = 'thead'; - $resultTd1.textContent = 'thead'; - $resultTd2.innerText = 'X'; - $resultTd2.textContent = 'X'; - $resultTd3.innerText = '-'; - $resultTd3.textContent = '-'; - } - $resultTr.appendChild($resultTd1); - $resultTr.appendChild($resultTd2); - $resultTr.appendChild($resultTd3); - $resultTbody.appendChild($resultTr); - - $resultTr = rdoc.createElement('tr'); - $resultTd1 = rdoc.createElement('td'); - $resultTd2 = rdoc.createElement('td'); - $resultTd3 = rdoc.createElement('td'); - if ($tfoot.length) { - $resultTd3Ul = rdoc.createElement('ul'); - $resultTd1.innerText = 'tfoot'; - $resultTd1.textContent = 'tfoot'; - $resultTd2.innerText = 'O'; - $resultTd2.textContent = 'O'; - for (i = 0, l = $tfootTh.length; i < l; i++) { - $th = $tfootTh[i]; - scope = $th.getAttribute('scope'); - $infoItem = rdoc.createElement('li'); - - $infoItem.innerText = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $infoItem.textContent = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $resultTd3Ul.appendChild($infoItem); - } - $resultTd3.appendChild($resultTd3Ul); - } else { - $resultTd1.innerText = 'tfoot'; - $resultTd1.textContent = 'tfoot'; - $resultTd2.innerText = 'X'; - $resultTd2.textContent = 'X'; - $resultTd3.innerText = '-'; - $resultTd3.textContent = '-'; - } - $resultTr.appendChild($resultTd1); - $resultTr.appendChild($resultTd2); - $resultTr.appendChild($resultTd3); - $resultTbody.appendChild($resultTr); - - $resultTr = rdoc.createElement('tr'); - $resultTd1 = rdoc.createElement('td'); - $resultTd2 = rdoc.createElement('td'); - $resultTd3 = rdoc.createElement('td'); - if ($tbody.length) { - $resultTd3Ul = rdoc.createElement('ul'); - $resultTd1.innerText = 'tbody'; - $resultTd1.textContent = 'tbody'; - $resultTd2.innerText = 'O'; - $resultTd2.textContent = 'O'; - for (i = 0, l = $tbodyTh.length; i < l; i++) { - $th = $tbodyTh[i]; - scope = $th.getAttribute('scope'); - $infoItem = rdoc.createElement('li'); - - $infoItem.innerText = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $infoItem.textContent = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $resultTd3Ul.appendChild($infoItem); - } - $resultTd3.appendChild($resultTd3Ul); - } else { - $resultTd1.innerText = 'tbody'; - $resultTd1.textContent = 'tbody'; - $resultTd2.innerText = 'X'; - $resultTd2.textContent = 'X'; - $resultTd3.innerText = '-'; - $resultTd3.textContent = '-'; - } - $resultTr.appendChild($resultTd1); - $resultTr.appendChild($resultTd2); - $resultTr.appendChild($resultTd3); - $resultTbody.appendChild($resultTr); - - data.structure = $resultTable; - - return [ - data.hidden, - data.structure - ]; - }, - function () { - var $theadTh = getElsFromChildNodes( - getElsFromChildNodes( - getElsFromChildNodes(this, 'thead'), - 'tr' - ), - 'th' - ); - var $tfootTh = getElsFromChildNodes( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tfoot'), - 'tr' - ), - 'th' - ); - var $tbodyTh = getElsFromChildNodes( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tbody'), - 'tr' - ), - 'th' - ).concat( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tr'), - 'th' - ) - ); - var hasTh = $theadTh.length || $tfootTh.length || $tbodyTh.length; - var hasScope = function ($ths) { - var i, l; - for (i = 0, l = $ths.length; i < l; i++) { - if (!$ths[i].getAttribute('scope')) { - return false; - } - } - return true; - }; - - if (hasTh && hasScope($theadTh) && hasScope($tfootTh) && - hasScope($tbodyTh)) { - return 'pass'; - } else if (!hasTh && !$theadTh.length && !$tfootTh.length) { - return 'warning'; - } else { - return 'fail'; - } - } - ), - - label: new TableSection( - cwin, - rdoc, - '19. ' + achecker.i18n.get('No19'), - 'input,textarea,select', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('FormType'), width: 66}, - {label: achecker.i18n.get('LabelConnection'), className: 'lt'}, - {label: achecker.i18n.get('TitleAttribute')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var typeAttr = this.getAttribute('type') ? this.getAttribute('type').toLowerCase() : null; - if (this.tagName === 'INPUT' && - (typeAttr === 'submit' || - typeAttr === 'button' || - typeAttr === 'image' || - typeAttr === 'hidden' || - typeAttr === 'reset')) { - return false; - } - - var data = { - hidden: '', - el: '', - type: '', - label: '', - title: '' - }; - var _id = this.getAttribute('id'); - var $labels = doc.getElementsByTagName("label"); - var hasLabelElement = false, - $label = null, - i, - l; - - if (_id) { - for (i = 0, l = $labels.length; i < l; i++) { - if ($labels[i].getAttribute('for') === _id) { - hasLabelElement = true; - $label = $labels[i]; - break; - } - } - } - var hasTitle = !!this.getAttribute('title'); - - var hasImplicitLabel = false; - var parentEl = this.parentNode; - do { - parentEl = parentEl.parentNode; - if (parentEl.tagName === 'LABEL') { - hasImplicitLabel = true; - $label = parentEl; - break; - } - } while (parentEl.parentNode); - - data.el = this.tagName.toLowerCase(); - data.type = typeAttr || '-'; - data.label = $label ? getTextContent($label) : ''; - if (!data.label) { - data.label = 'X'; - } - data.title = this.getAttribute('title'); - if (!data.title) { - data.title = '-'; - } - - return [ - data.hidden, - data.el, - data.type, - data.label, - data.title - ]; - }, - function (doc, url) { - var _id = this.getAttribute('id'); - var $labels = doc.getElementsByTagName("label"); - var hasLabelElement = false, i, l; - if (_id) { - for (i = 0, l = $labels.length; i < l; i++) { - if ($labels[i].getAttribute('for') === _id) { - hasLabelElement = true; - break; - } - } - } - var hasTitle = !!this.getAttribute('title'); - var hasImplicitLabel = false; - var parentEl = this.parentNode; - do { - parentEl = parentEl.parentNode; - - if (parentEl.tagName === 'LABEL') { - hasImplicitLabel = true; - } - } while (parentEl.parentNode); - - if (hasLabelElement) { - return 'pass'; - } - if (hasImplicitLabel) { - return 'pass'; - } - if (hasTitle) { - return 'warning'; - } - return 'fail'; - } - ), - - validation: new ToolSection( - cwin, - rdoc, - 'w3c_validation', - '21. ' + achecker.i18n.get('No21'), - function (win, rdoc) { - var isChromeAddon = typeof chrome === "object" && chrome.extension; - var isFirefoxAddon = typeof Components === "object" && Components.classes; - if (!isChromeAddon && !isFirefoxAddon) { - var $res = rdoc.createElement('p'); - $res.className = 'comment'; - $res.innerText = 'Not Supported.'; - $res.textContent = 'Not Supported.'; - return $res; - } - - var filterValidationResult = function (res) { - var msgs = res.messages, newmsgs = []; - var filters = [ - // /^unterminated comment: .*/, - // /^literal is missing closing delimiter.*/, - // /^unknown declaration type .*/, - /^document type does not allow element .* here; missing one of .* start\-tag.*/, - // /^end tag for .* omitted, but its declaration does not permit this.*/, - /^end tag for .* which is not finished.*/, - /^end tag for element .* which is not open.*/, - // /^an attribute value must be a literal unless it contains only name characters.*/, - // /^an attribute value literal can occur in an attribute specification list only after a VI delimiter.*/, - // /^normalized length of attribute value literal must not exceed.*/, - // /^syntax of attribute value does not conform to declared value.*/, - // /^value of attribute .* must be a single token.*/, - // /^value of attribute .* cannot be .*; must be one of .*/, - // /^invalid comment declaration:.*/, - /^ID .* already defined.*/, - // /^no document type declaration; will parse without validation.*/, - /^unclosed start-tag requires SHORTTAG YES.*/, - /^unclosed end-tag requires SHORTTAG YES.*/, - // /^DTD did not contain element declaration for document type name.*/, - /^empty start-tag.*/, - /^empty end-tag.*/ - // /^no document type declaration; implying .*/, - // /^no system id specified.*/, - // /^.* separator in comment declaration.*/, - ]; - var i, j; - - for (i = 0; i < msgs.length; i++) { - if (msgs[i].type === 'error') { - for (j = 0; j < filters.length; j++) { - if (filters[j].test(msgs[i].message)) { - newmsgs.push(msgs[i]); - break; - } - } - } - } - - res.messages = newmsgs; - return res; - }; - - var getResultDetailEl = function (messages, url) { - var $res = rdoc.createElement('div'); - $res.className = 'validationResult'; - var $errhead = rdoc.createElement('h3'); - $errhead.innerText = 'Error'; - $errhead.textContent = 'Error'; - $errhead.className = 'fail'; - var $errul = rdoc.createElement('ul'); - var $warninghead = rdoc.createElement('h3'); - $warninghead.innerText = 'Warning'; - $warninghead.textContent = 'Warning'; - $warninghead.className = 'warning'; - var $warningul = rdoc.createElement('ul'); - var onClickMessageLink = function (e) { - e.preventDefault(); - e.stopPropagation(); - openDialog("chrome://global/content/viewSource.xul", - "achecker_sourceView", - "scrollbars,resizable,chrome,dialog=no", - url, null, null, this.getAttribute('data-line'), - false); - }, i; - - for (i = 0; i < messages.length; i++) { - var msg = messages[i]; - var $li = rdoc.createElement('li'); - var $msg = rdoc.createElement('div'); - var $msga = rdoc.createElement('a'); - $msga.innerText = msg.message; - $msga.textContent = msg.message; - $msga.setAttribute('href', '#'); - $msga.setAttribute('data-line', msg.lastLine); - addEvent($msga, 'click', onClickMessageLink); - $msg.appendChild($msga); - var $subinfo = rdoc.createElement('div'); - $subinfo.className = 'subinfo'; - $subinfo.innerText = msg.lastLine + ' line, ' + msg.lastColumn + ' column'; - $subinfo.textContent = msg.lastLine + ' line, ' + msg.lastColumn + ' column'; - $li.appendChild($msg); - $li.appendChild($subinfo); - switch (msg.type) { - case 'error': - $errul.appendChild($li); - break; - case 'info': - $warningul.appendChild($li); - break; - } - } - $res.appendChild($errhead); - $res.appendChild($errul); - $res.appendChild($warninghead); - $res.appendChild($warningul); - return $res; - }; - - var doValidation = function (url, doc) { - var sourceUrl = url; - var req = new XMLHttpRequest(); - req.onreadystatechange = function () { - if (req.readyState === 4) { - if (req.status === 200) { - // IT WORKS! - var html = req.responseText; - var req2 = new XMLHttpRequest(); - var charset = html.indexOf('euc-kr') > 0 ? 'euc-kr' : 'utf-8'; - req2.onreadystatechange = function () { - try { - var i; - var onClickItem = function () { - var $res = this.getElementsByTagName("div")[0]; - $res.style.display = $res.style.display === 'none' ? 'block' : 'none'; - }; - - 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 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; - } - } - } - } - } catch (e) { - } - }; - - try { - req2.open("POST", "http://validator.w3.org/check", true); - - // Firefox < 4 - if (typeof FormData !== "object") { - req2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - req2.send('fragment=' + global.escape(html) + - '&doctype=Inline' + - '&output=json'); - } else { - var formData = new FormData(); - formData.append('fragment', html); - formData.append('doctype', 'Inline'); - formData.append('output', 'json'); - req2.send(formData); - } - } catch (e) { - } - } else { - global.alert(achecker.i18n.get('ValidationFail')); - } - } - }; - req.open("GET", sourceUrl, true); - req.send(null); - }; - - var urls = [], docs = [], i, l; - if (win.location.href.substr(0, 7) === 'http://' || - win.location.href.substr(0, 8) === 'https://') { - urls.push(win.location.href); - docs.push(win.document); - } - if (isIncludeFrame) { - for (i = 0, l = frameDocs.length; i < l; i++) { - var _url = frameDocs[i].src; - if (_url.substr(0, 7) === 'http://' || _url.substr(0, 8) === 'https://') { - urls.push(_url); - docs.push(frameDocs[i]); - } - } - } - - var $output = rdoc.createElement('ul'); - for (i = 0, l = urls.length; i < l; i++) { - doValidation(urls[i], docs[i]); - var $item = rdoc.createElement('li'); - $item.className = 'validationItem'; - var $_url = rdoc.createElement('span'); - $_url.className = 'url'; - $_url.innerText = urls[i]; - $_url.textContent = urls[i]; - var $_errcnt = rdoc.createElement('b'); - $_errcnt.className = 'errcnt'; - $_errcnt.innerText = achecker.i18n.get('Loading'); - $_errcnt.textContent = achecker.i18n.get('Loading'); - $item.appendChild($_url); - $item.appendChild(rdoc.createTextNode(': ')); - $item.appendChild($_errcnt); - $output.appendChild($item); - } - return $output; - } - ) - } - }; - }; -}(window, window.document)); diff --git a/owax_bookmarklet/lib/Sections.js b/owax_bookmarklet/lib/Sections.js new file mode 120000 index 0000000..cba219c --- /dev/null +++ b/owax_bookmarklet/lib/Sections.js @@ -0,0 +1 @@ +../../lib/Sections.js \ No newline at end of file diff --git a/owax_ch/app.zip b/owax_ch/app.zip index 95f6cc0..65b2a45 100644 Binary files a/owax_ch/app.zip and b/owax_ch/app.zip differ diff --git a/owax_ch/app/_locales/en/messages.json b/owax_ch/app/_locales/en/messages.json index 8327a63..46891c4 100644 --- a/owax_ch/app/_locales/en/messages.json +++ b/owax_ch/app/_locales/en/messages.json @@ -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", diff --git a/owax_ch/app/_locales/ko/messages.json b/owax_ch/app/_locales/ko/messages.json index 20570c7..4f12880 100644 --- a/owax_ch/app/_locales/ko/messages.json +++ b/owax_ch/app/_locales/ko/messages.json @@ -266,6 +266,14 @@ "message": "프레임셋 페이지는 검사할 수 없습니다. 프레임셋에 포함된 URL로 이동하여 재시도하실 수 있습니다.", "description": "" }, + "ValidationTimeout": { + "message": "시간초과", + "description": "" + }, + "ValidateManually": { + "message": "수동 검사", + "description": "" + }, "No1": { "message": "적절한 대체 텍스트", diff --git a/owax_ch/app/lib/Section.js b/owax_ch/app/lib/Section.js index 0359b2b..b5a32c4 100644 --- a/owax_ch/app/lib/Section.js +++ b/owax_ch/app/lib/Section.js @@ -63,6 +63,44 @@ } }; + var Xpath = {}; + + // ********************************************************************************************* // + // XPATH + + /** + * Gets an XPath for an element which describes its hierarchical location. + */ + Xpath.getElementXPath = function (element) { + if (element && element.id) { + return '//*[@id="' + element.id + '"]'; + } + return Xpath.getElementTreeXPath(element); + }; + + Xpath.getElementTreeXPath = function (element) { + var paths = []; + var DOCUMENT_TYPE_NODE = 10; + var sibling; + + // Use nodeName (instead of localName) so namespace prefix is included (if any). + for (element; element && element.nodeType === 1; element = element.parentNode) { + var index = 0; + for (sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) { + // Ignore document type declaration. + if (sibling.nodeType !== DOCUMENT_TYPE_NODE && sibling.nodeName === element.nodeName) { + ++index; + } + } + + var tagName = element.nodeName.toLowerCase(); + var pathIndex = (index ? "[" + (index + 1) + "]" : ""); + paths.splice(0, 0, tagName + pathIndex); + } + + return paths.length ? "/" + paths.join("/") : null; + }; + g.achecker = g.achecker || {}; g.achecker.Wax = g.achecker.Wax || {}; g.achecker.Wax.Section = function () { @@ -196,7 +234,7 @@ // compatible with firebug 1.9.x parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); } else if (g.console && g.console.log && $targetEl) { - g.console.log('OpenWAX Info: ', $targetEl); + g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); } }; @@ -381,7 +419,7 @@ // compatible with firebug 1.9.x parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); } else if (g.console && g.console.log && $targetEl) { - g.console.log('OpenWAX Info: ', $targetEl); + g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); } }; diff --git a/owax_ch/app/lib/Sections.js b/owax_ch/app/lib/Sections.js index 59f2bed..63df259 100644 --- a/owax_ch/app/lib/Sections.js +++ b/owax_ch/app/lib/Sections.js @@ -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(); @@ -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; @@ -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) { diff --git a/owax_ch/app/manifest.json b/owax_ch/app/manifest.json index ffefdd8..9369767 100644 --- a/owax_ch/app/manifest.json +++ b/owax_ch/app/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "OpenWAX", - "version": "1.9.5", + "version": "1.9.6", "description": "OpenWAX(Open Web Accessibility eXtension) is a tool that can help diagnose and fix the accessibility problem.", "browser_action": { "default_icon": "logo_19.png", diff --git a/owax_ff/app.xpi b/owax_ff/app.xpi index 9e7b8bd..f34061f 100644 Binary files a/owax_ff/app.xpi and b/owax_ff/app.xpi differ diff --git a/owax_ff/app/content/scripts/Score.js b/owax_ff/app/content/scripts/Score.js deleted file mode 100644 index 8510e93..0000000 --- a/owax_ff/app/content/scripts/Score.js +++ /dev/null @@ -1,128 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is N-WAX(NHN Web Accessibility eXtension). - * - * The Initial Developer of the Original Code is - * Goonoo Kim (http://miya.pe.kr). - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -(function (g) { - "use strict"; - - var sectionWeights = { - "altText": 30, - "kbdFocus": 10, - "frame": 10, - "linkText": 10, - "pageLang": 10, - "unintendedFunction": 10, - "label": 20 - }; - - var getLevel = function (score) { - if (score >= 95) { - return "perfect"; - } else if (score > 80) { - return "good"; - } else if (score > 60) { - return "bad"; - } else { - return "fail"; - } - }; - - var canonicalUrl = function (win) { - var url = win.location.href; - var linkEls = win.document.getElementsByTagName("link"); - var i, l = linkEls.length; - for (i = 0; i < l; i++) { - if (linkEls[i].getAttribute("rel") === "canonical" && - linkEls[i].getAttribute("href")) { - url = linkEls[i].getAttribute("href"); - } - } - // remove fragment identifier from URL - url = url.replace(/\#.*$/, ''); - return url; - }; - - g.achecker = g.achecker || {}; - g.achecker.Wax = g.achecker.Wax || {}; - g.achecker.Wax.score = function (waxSections) { - var score = 0, info; - - for (var key in sectionWeights) { - if (sectionWeights.hasOwnProperty(key)) { - info = waxSections[key] ? waxSections[key].getScore() : null; - if (info && info.all > 0) { - score += parseInt(info.pass / info.all * sectionWeights[key] * 10, 10) / 10; - } else { - score += parseInt(sectionWeights[key], 10); - } - } - } - - return parseInt(score * 10, 10) / 10; - }; - g.achecker.Wax.scoreAsElement = function (cwin, rdoc, waxSections, allowLogging) { - var score = g.achecker.Wax.score(waxSections); - var $div = rdoc.createElement('div'); - $div.className = 'waxScore ' + getLevel(score); - - var $title = rdoc.createElement('h2'); - var $label = rdoc.createElement('a'); - $label.setAttribute('href', 'http://openwax.miya.pe.kr/#guide_score'); - $label.setAttribute('target', '_blank'); - $label.innerText = "WAX Score: "; - $label.textContent = "WAX Score: "; - var $score = rdoc.createElement('strong'); - $score.innerText = score; - $score.textContent = score; - - $label.appendChild($score); - $title.appendChild($label); - $div.appendChild($title); - - if (allowLogging) { - var $logger = rdoc.createElement('img'); - $logger.style.position = 'absolute'; - $logger.style.top = '-9999px'; - $logger.style.left = '-9999px'; - $logger.setAttribute('src', 'http://openwax.miya.pe.kr/log?' + - 'url=' + encodeURIComponent(canonicalUrl(cwin)) + '&' + - 'title=' + encodeURIComponent(cwin.document.title) + '&' + - 'score=' + score + '&'); - $div.appendChild($logger); - } - - return $div; - }; -}(window)); diff --git a/owax_ff/app/content/scripts/Score.js b/owax_ff/app/content/scripts/Score.js new file mode 120000 index 0000000..0cdbf6f --- /dev/null +++ b/owax_ff/app/content/scripts/Score.js @@ -0,0 +1 @@ +../../../../lib/Score.js \ No newline at end of file diff --git a/owax_ff/app/content/scripts/Section.js b/owax_ff/app/content/scripts/Section.js deleted file mode 100644 index b5a32c4..0000000 --- a/owax_ff/app/content/scripts/Section.js +++ /dev/null @@ -1,613 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is N-WAX(NHN Web Accessibility eXtension). - * - * The Initial Developer of the Original Code is - * Goonoo Kim (NHN). - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -(function (g) { - "use strict"; - - var addEvent = function (obj, type, fn) { - if (obj.addEventListener) { - obj.addEventListener(type, fn, false); - } else if (obj.attachEvent) { - obj["e" + type + fn] = fn; - obj[type + fn] = function () { - obj["e" + type + fn](g.event); - }; - obj.attachEvent("on" + type, obj[type + fn]); - } - }; - var getStyle = function (el, style) { - if (el.currentStyle) { - return el.currentStyle.style; - } - return g.getComputedStyle(el, null)[style]; - }; - var toggleFoldedClass = function (el) { - el.className = el.className.indexOf('folded') > -1 ? el.className.replace(/folded/g, '') : el.className + ' folded'; - - // fix bug: IE8 won't reflow when set data-* attribute - if (document && document.all) { - document.body.className = document.body.getAttribute("className"); - } - }; - - var Xpath = {}; - - // ********************************************************************************************* // - // XPATH - - /** - * Gets an XPath for an element which describes its hierarchical location. - */ - Xpath.getElementXPath = function (element) { - if (element && element.id) { - return '//*[@id="' + element.id + '"]'; - } - return Xpath.getElementTreeXPath(element); - }; - - Xpath.getElementTreeXPath = function (element) { - var paths = []; - var DOCUMENT_TYPE_NODE = 10; - var sibling; - - // Use nodeName (instead of localName) so namespace prefix is included (if any). - for (element; element && element.nodeType === 1; element = element.parentNode) { - var index = 0; - for (sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) { - // Ignore document type declaration. - if (sibling.nodeType !== DOCUMENT_TYPE_NODE && sibling.nodeName === element.nodeName) { - ++index; - } - } - - var tagName = element.nodeName.toLowerCase(); - var pathIndex = (index ? "[" + (index + 1) + "]" : ""); - paths.splice(0, 0, tagName + pathIndex); - } - - return paths.length ? "/" + paths.join("/") : null; - }; - - g.achecker = g.achecker || {}; - g.achecker.Wax = g.achecker.Wax || {}; - g.achecker.Wax.Section = function () { - throw 'not implemented'; - }; - g.achecker.Wax.Section.prototype = { - getAsElement : function () { - throw 'not implemented'; - } - }; - - g.achecker.Wax.isElHidden = function (el) { - if (el && el.tagName && (el.tagName === 'TITLE' || el.tagName === 'BODY' || el.tagName === 'HTML')) { - return false; - } - do { - if (el.tagName && getStyle(el, 'display') === 'none') { - return true; - } - el = el.parentNode; - } while (el); - return false; - }; - - g.achecker.Wax.ListSection = g.achecker.Wax.Section; - g.achecker.Wax.ListSection = function (cwin, rdoc, title, targetSelector, - limit, isIncludeFrame, frameDocs, emptyMessage, - content, validStatus, eventHandlers) { - var this_ = this; - this.cwin = cwin; - this.rdoc = rdoc; - this.title = title; - this.emptyMessage = emptyMessage; - this.contents = this._getContents(cwin, isIncludeFrame, frameDocs, - targetSelector, content, validStatus, eventHandlers, limit); - }; - g.achecker.Wax.ListSection.prototype._getContentsFromDocument = function (doc, url, - targetSelector, content, validStatus, eventHandlers, limit) { - if (!limit) { - limit = 99999; - } - - var $target = doc.querySelectorAll(targetSelector); - var contents = [], i; - - for (i = 0; i < $target.length; i++) { - if (limit <= 0) { - break; - } - - var $el = $target[i]; - var _content = typeof content === 'function' ? content.apply($el, [doc, url]) : content; - if (_content !== false) { - contents.push({ - el: $el, - doc: $el.ownerDocument, - validStatus: typeof validStatus === 'function' ? validStatus.apply($el, [doc, url]) : (typeof validStatus === 'string' ? validStatus : ''), - content: typeof content === 'function' ? content.apply($el, [doc, url]) : content, - eventHandlers: eventHandlers - }); - limit--; - } - } - return contents; - }; - g.achecker.Wax.ListSection.prototype._getContents = function (win, isIncludeFrame, - frameDocs, targetSelector, content, validStatus, - eventHandlers, limit) { - if (!limit) { - limit = 99999; - } - var contents = this._getContentsFromDocument(win.document, win.location.href, - targetSelector, content, validStatus, eventHandlers, limit), i, l; - - limit -= contents.length; - if (isIncludeFrame && limit > 0) { - for (i = 0, l = frameDocs.length; i < l; i++) { - if (limit <= 0) { - break; - } - - var _contents = this._getContentsFromDocument( - frameDocs[i].doc, - frameDocs[i].src, - targetSelector, - content, - validStatus, - eventHandlers, - limit - ); - contents = contents.concat(_contents); - limit -= _contents.length; - } - } - return contents; - }; - g.achecker.Wax.ListSection.prototype.getAsElement = function () { - var this_ = this; - var doc = this.rdoc; - var $contentList = doc.createElement("ul"), i; - var hasWarning = false; - var hasError = false; - var onClickItem = function (e) { - if (parent.Firebug) { - parent.Firebug.Inspector.clearAllHighlights(); - } - - var $targetEl = this['data-el']; - var isHidden = g.achecker.Wax.isElHidden($targetEl); - if ($targetEl.tagName === 'TITLE') { - while ($targetEl) { - if ($targetEl.tagName === 'HTML') { - break; - } - $targetEl = $targetEl.parentNode; - } - } - - if (!isHidden) { - var oldTabindex = $targetEl.getAttribute('tabindex'); - $targetEl.setAttribute('tabindex', 0); - $targetEl.focus(); - if (oldTabindex === null) { - $targetEl.removeAttribute('tabindex'); - } else { - $targetEl.setAttribute('tabindex', oldTabindex); - } - } - if (parent.Firebug && $targetEl) { - parent.Firebug.Inspector.inspectFromContextMenu($targetEl); - // compatible with firebug 1.9.x - parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); - } else if (g.console && g.console.log && $targetEl) { - g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); - } - }; - - for (i = 0; i < this.contents.length; i++) { - var info = this.contents[i]; - var hiddenClass = g.achecker.Wax.isElHidden(info.el) ? ' hidden_el' : ''; - var $item = doc.createElement('li'); - var key; - - $item.className = info.validStatus + ' ' + hiddenClass; - if (typeof info.content === 'string') { - $item.innerText = info.content; - $item.textContent = info.content; - } else { - $item.appendChild(info.content); - } - $item['data-el'] = info.el; - if (info.eventHandlers) { - for (key in info.eventHandlers) { - if (info.eventHandlers.hasOwnProperty(key)) { - addEvent($item, key, info.eventHandlers[key]); - } - } - } - if (info.validStatus === 'fail') { - hasError = true; - } else if (info.validStatus === 'warning') { - hasWarning = true; - } - addEvent($item, 'click', onClickItem); - $contentList.appendChild($item); - } - - var $section = doc.createElement('div'); - $section.className = 'waxSection'; - var $title = doc.createElement('h2'); - var $count = doc.createElement('span'); - $title.innerText = this.title + " "; - $title.textContent = this.title + " "; - $title.className = 'folded'; - if (hasError) { - $title.className += ' fail'; - } else if (hasWarning) { - $title.className += ' warning'; - } - $count.innerText = "(" + this.contents.length + ")"; - $count.textContent = "(" + this.contents.length + ")"; - $title.appendChild($count); - /* - var $titleLink = doc.createElement('a'); - $titleLink.setAttribute('target', '_blank'); - $titleLink.setAttribute('href', - 'http://html.nhncorp.com/a11y/guide.php?no='+ - this.title.split(' ')[0] + ''); - $titleLink.innerText = 'Guide'; - $titleLink.textContent = 'Guide'; - $title.appendChild($titleLink); - */ - $section.appendChild($title); - - if ($contentList.childNodes.length <= 0) { - var $emptyItem = doc.createElement('p'); - $emptyItem.className = 'comment'; - $emptyItem.innerText = this.emptyMessage; - $emptyItem.textContent = this.emptyMessage; - $section.appendChild($emptyItem); - } else { - $section.appendChild($contentList); - } - - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - /* - addEvent($titleLink, 'click', function (e) { - e.stopPropagation(); - }); - */ - return $section; - }; - g.achecker.Wax.ListSection.prototype.getScore = function () { - var count = this.contents.length, - pass = 0; - - for (var i = 0; i < count; i++) { - if (this.contents[i].validStatus !== 'fail') { - pass++; - } - } - - return { - all: count, - pass: pass - }; - }; - - g.achecker.Wax.TableSection = g.achecker.Wax.Section; - g.achecker.Wax.TableSection = function (cwin, rdoc, title, targetSelector, - colInfo, isIncludeFrame, frameDocs, emptyMessage, - content, validStatus, eventHandlers) { - var this_ = this; - this.cwin = cwin; - this.rdoc = rdoc; - this.title = title; - this.colInfo = colInfo; - this.emptyMessage = emptyMessage; - this.contents = this._getContents(cwin, isIncludeFrame, frameDocs, - targetSelector, content, validStatus, eventHandlers); - }; - g.achecker.Wax.TableSection.prototype._getContentsFromDocument = function (doc, url, - targetSelector, content, validStatus, eventHandlers) { - var $target = doc.querySelectorAll(targetSelector); - var contents = [], i; - - for (i = 0; i < $target.length; i++) { - var $el = $target[i]; - var _content = typeof content === 'function' ? content.apply($el, [doc, url]) : content; - if (_content !== false) { - contents.push({ - el: $el, - doc: $el.ownerDocument, - validStatus: typeof validStatus === 'function' ? validStatus.apply($el, [doc, url]) : (typeof validStatus === 'string' ? validStatus : ''), - content: typeof content === 'function' ? content.apply($el, [doc, url]) : content, - eventHandlers: eventHandlers - }); - } - } - return contents; - }; - g.achecker.Wax.TableSection.prototype._getContents = function (win, isIncludeFrame, - frameDocs, targetSelector, content, validStatus, - eventHandlers) { - var contents = this._getContentsFromDocument(win.document, win.location.href, - targetSelector, content, validStatus, eventHandlers), i, l; - - if (isIncludeFrame) { - for (i = 0, l = frameDocs.length; i < l; i++) { - var _contents = this._getContentsFromDocument(frameDocs[i].doc, frameDocs[i].src, - targetSelector, content, validStatus, eventHandlers); - contents = contents.concat(_contents); - } - } - return contents; - }; - g.achecker.Wax.TableSection.prototype.getAsElement = function () { - var this_ = this; - var doc = this.rdoc; - var $table = doc.createElement('table'); - var $thead = doc.createElement('thead'); - var $theadTr = doc.createElement('tr'); - var hasWarning = false; - var hasError = false; - var i; - var onClickTr = function (e) { - if (parent.Firebug) { - parent.Firebug.Inspector.clearAllHighlights(); - } - - var $targetEl = this['data-el']; - var isHidden = g.achecker.Wax.isElHidden($targetEl); - if ($targetEl.tagName === 'TITLE') { - while ($targetEl) { - if ($targetEl.tagName === 'HTML') { - break; - } - $targetEl = $targetEl.parentNode; - } - } - - if (!isHidden) { - var oldTabindex = $targetEl.getAttribute('tabindex'); - $targetEl.setAttribute('tabindex', 0); - $targetEl.focus(); - if (oldTabindex === null) { - $targetEl.removeAttribute('tabindex'); - } else { - $targetEl.setAttribute('tabindex', oldTabindex); - } - } - if (parent.Firebug && $targetEl) { - parent.Firebug.Inspector.inspectFromContextMenu($targetEl); - // compatible with firebug 1.9.x - parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); - } else if (g.console && g.console.log && $targetEl) { - g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); - } - }; - - for (i = 0; i < this.colInfo.length; i++) { - var $theadTh = doc.createElement('th'); - $theadTh.setAttribute('scope', 'col'); - $theadTh.innerText = this.colInfo[i].label; - $theadTh.textContent = this.colInfo[i].label; - if (this.colInfo[i].width) { - $theadTh.style.width = this.colInfo[i].width + 'px'; - } - if (this.colInfo[i].minWidth) { - $theadTh.style.minWidth = this.colInfo[i].minWidth + 'px'; - } - if (this.colInfo[i].maxWidth) { - $theadTh.style.maxWidth = this.colInfo[i].maxWidth + 'px'; - } - if (this.colInfo[i].className) { - $theadTh.className = this.colInfo[i].className; - } - $theadTr.appendChild($theadTh); - } - $thead.appendChild($theadTr); - $table.appendChild($thead); - - var $tbody = doc.createElement('tbody'); - for (i = 0; i < this.contents.length; i++) { - var info = this.contents[i]; - var hiddenClass = g.achecker.Wax.isElHidden(info.el) ? ' hidden_el' : ''; - var $tr = doc.createElement('tr'); - var j, key; - - $tr.className = info.validStatus + ' ' + hiddenClass; - for (j in info.content) { - if (info.content.hasOwnProperty(j)) { - var _content = info.content[j]; - var $td = doc.createElement('td'); - if (typeof _content === 'string') { - $td.innerText = _content; - $td.textContent = _content; - $td.innerHTML = (_content - .replace(/</g, '<') - .replace(/>/g, '>') - ) - .replace(/\[__\[/g, '<span style="color:#777!important;text-decoration:line-through">') - .replace(/\]__\]/g, '</span>'); - } else { - $td.appendChild(_content); - } - if (this.colInfo[j].className) { - $td.className = this.colInfo[j].className; - } - $tr.appendChild($td); - } - } - $tr['data-el'] = info.el; - if (info.eventHandlers) { - for (key in info.eventHandlers) { - if (info.eventHandlers.hasOwnProperty(key)) { - addEvent($tr, key, info.eventHandlers[key]); - } - } - } - if (info.validStatus === 'fail') { - hasError = true; - } else if (info.validStatus === 'warning') { - hasWarning = true; - } - addEvent($tr, 'click', onClickTr); - $tbody.appendChild($tr); - $table.appendChild($tbody); - } - - var $section = doc.createElement('div'); - $section.className = 'waxSection'; - var $title = doc.createElement('h2'); - var $count = doc.createElement('span'); - $title.innerText = this.title + " "; - $title.textContent = this.title + " "; - $title.className = 'folded'; - if (hasError) { - $title.className += ' fail'; - } else if (hasWarning) { - $title.className += ' warning'; - } - $count.innerText = "(" + this.contents.length + ")"; - $count.textContent = "(" + this.contents.length + ")"; - $title.appendChild($count); - /* - var $titleLink = doc.createElement('a'); - $titleLink.setAttribute('target', '_blank'); - $titleLink.setAttribute('href', - 'http://html.nhncorp.com/a11y/guide.php?no='+ - this.title.split(' ')[0] + ''); - $titleLink.innerText = 'Guide'; - $titleLink.textContent = 'Guide'; - $title.appendChild($titleLink); - */ - $section.appendChild($title); - - if ($tbody.childNodes.length <= 0) { - var $emptyItem = doc.createElement('p'); - $emptyItem.className = 'comment'; - $emptyItem.innerText = this.emptyMessage; - $emptyItem.textContent = this.emptyMessage; - $section.appendChild($emptyItem); - } else { - $section.appendChild($table); - } - - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - /* - addEvent($titleLink, 'click', function (e) { - e.stopPropagation(); - }); - */ - return $section; - }; - g.achecker.Wax.TableSection.prototype.getScore = function () { - var count = this.contents.length, - pass = 0; - - for (var i = 0; i < count; i++) { - if (this.contents[i].validStatus !== 'fail') { - pass++; - } - } - - return { - all: count, - pass: pass - }; - }; - - g.achecker.Wax.ToolSection = function (cwin, rdoc, id, title, content, eventHandlers) { - var this_ = this; - this.cwin = cwin; - this.rdoc = rdoc; - this.id = id; - this.title = title; - this.content = typeof content === 'function' ? content.apply(this, [this.cwin, this.rdoc]) : content; - this.eventHandlers = eventHandlers; - }; - g.achecker.Wax.ToolSection.prototype.getAsElement = function () { - var doc = this.rdoc; - - var $section = doc.createElement('div'); - $section.id = this.id; - $section.className = 'waxSection'; - var $title = doc.createElement('h2'); - $title.className = 'folded'; - $title.innerText = this.title; - $title.textContent = this.title; - /* - var $titleLink = doc.createElement('a'); - $titleLink.setAttribute('target', '_blank'); - $titleLink.setAttribute('href', - 'http://html.nhncorp.com/a11y/guide.php?no='+ - this.title.split(' ')[0] + ''); - $titleLink.innerText = 'Guide'; - $titleLink.textContent = 'Guide'; - $title.appendChild($titleLink); - */ - - var $content = doc.createElement('div'); - if (typeof this.content === 'string') { - $content.innerText = this.content; - $content.textContent = this.content; - } else { - $content.appendChild(this.content); - } - $section.appendChild($title); - $section.appendChild($content); - - $title.setAttribute('tabindex', 0); - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - /* - addEvent($titleLink, 'click', function (e) { - e.stopPropagation(); - }); - */ - return $section; - }; - g.achecker.Wax.ToolSection.prototype.getScore = function () { - return null; - }; -}(window)); diff --git a/owax_ff/app/content/scripts/Section.js b/owax_ff/app/content/scripts/Section.js new file mode 120000 index 0000000..9d966e4 --- /dev/null +++ b/owax_ff/app/content/scripts/Section.js @@ -0,0 +1 @@ +../../../../lib/Section.js \ No newline at end of file diff --git a/owax_ff/app/content/scripts/Sections.js b/owax_ff/app/content/scripts/Sections.js deleted file mode 100644 index 59f2bed..0000000 --- a/owax_ff/app/content/scripts/Sections.js +++ /dev/null @@ -1,1750 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is N-WAX(NHN Web Accessibility eXtension). - * - * The Initial Developer of the Original Code is - * Goonoo Kim (NHN). - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/*jslint browser: true */ -/*global chrome, Components, openDialog, XMLHttpRequest, FormData */ - -(function (global, document) { - "use strict"; - - var achecker = global.achecker || {}; - achecker.Wax = achecker.Wax || {}; - var addEvent = function (obj, type, fn) { - if (obj.addEventListener) { - obj.addEventListener(type, fn, false); - } else if (obj.attachEvent) { - obj["e" + type + fn] = fn; - obj[type + fn] = function () { - obj["e" + type + fn](global.event); - }; - obj.attachEvent("on" + type, obj[type + fn]); - } - }; - var ListSection = achecker.Wax.ListSection; - var TableSection = achecker.Wax.TableSection; - var ToolSection = achecker.Wax.ToolSection; - var getElsFromChildNodes = function (pEl, tagName) { - var els = [], i = 0; - if (pEl.length && pEl.push) { - for (i = 0; i < pEl.length; i++) { - els = els.concat(getElsFromChildNodes(pEl[i], tagName)); - } - return els; - } - var n = pEl.childNodes; - if (n && n.length) { - for (i = 0; i < n.length; i++) { - if (n[i].tagName && n[i].tagName.toLowerCase() === tagName.toLowerCase()) { - els.push(n[i]); - } - } - return els; - } - return []; - }; - var toggleFoldedClass = function (el) { - el.className = el.className === 'folded' ? '' : 'folded'; - - // fix bug: IE8 won't reflow when set data-* attribute - if (document && document.all) { - document.body.className = document.body.getAttribute('className'); - } - }; - - var getContrastRatio = function (color1, color2) { - var l1; // higher value - var l2; // lower value - var contrast; - var l1R, l1G, l1B, l2R, l2G, l2B; - - // error check, check if pound sign was put in field value - if (color2.indexOf('#') === 0) { - color2 = color2.substr(1, color2.length - 1); - } - if (color1.indexOf('#') === 0) { - color1 = color1.substr(1, color1.length - 1); - } - - //Linearised R (for example) = (R/FS)^2.2 where FS is full scale value (255 - //for 8 bit color channels). L1 is the higher value (of text or background) - //alert(parseInt("0x"+color1.substr(0, 2))); - //Math.pow(n,x); - l1R = parseInt(color1.substr(0, 2), 16) / 255; - if (l1R <= 0.03928) { - l1R = l1R / 12.92; - } else { - l1R = Math.pow(((l1R + 0.055) / 1.055), 2.4); - } - l1G = parseInt(color1.substr(2, 2), 16) / 255; - if (l1G <= 0.03928) { - l1G = l1G / 12.92; - } else { - l1G = Math.pow(((l1G + 0.055) / 1.055), 2.4); - } - l1B = parseInt(color1.substr(4, 2), 16) / 255; - if (l1B <= 0.03928) { - l1B = l1B / 12.92; - } else { - l1B = Math.pow(((l1B + 0.055) / 1.055), 2.4); - } - l2R = parseInt(color2.substr(0, 2), 16) / 255; - if (l2R <= 0.03928) { - l2R = l2R / 12.92; - } else { - l2R = Math.pow(((l2R + 0.055) / 1.055), 2.4); - } - l2G = parseInt(color2.substr(2, 2), 16) / 255; - if (l2G <= 0.03928) { - l2G = l2G / 12.92; - } else { - l2G = Math.pow(((l2G + 0.055) / 1.055), 2.4); - } - l2B = parseInt(color2.substr(4, 2), 16) / 255; - if (l2B <= 0.03928) { - l2B = l2B / 12.92; - } else { - l2B = Math.pow(((l2B + 0.055) / 1.055), 2.4); - } - //where L is luminosity and is defined as - l1 = (0.2126 * l1R) + (0.7152 * l1G) + (0.0722 * l1B); //using linearised R, G, and B value - l2 = (0.2126 * l2R) + (0.7152 * l2G) + (0.0722 * l2B); //using linearised R, G, and B value - //and L2 is the lower value. - l1 = l1 + 0.05; - l2 = l2 + 0.05; - if (l1 < l2) { - var temp = l1; - l1 = l2; - l2 = temp; - } - l1 = l1 / l2; - l1 = l1.toFixed(1); - return l1; - }; - - var getLabel = function (element) { - var currentLabel = ""; - var currentLabelElement; - var doc = element.ownerDocument; - var labelElement, labelChilds, i, l, _i, _l; - -labelLoop: - for (i = 0, l = doc.getElementsByTagName("label").length; i < l; i++) { - labelElement = doc.getElementsByTagName("label")[i]; - labelChilds = labelElement.childNodes; - - if (labelElement.htmlFor && labelElement.htmlFor === element.id) { - currentLabelElement = labelElement; - break labelLoop; - } - for (_i = 0, _l = labelChilds.length; _i < _l; _i++) { - if (labelChilds[_i] === element) { - currentLabelElement = labelElement; - break labelLoop; - } - } - } - - if (currentLabelElement) { - labelChilds = currentLabelElement.childNodes; - for (i = 0, l = labelChilds.length; i < l; i++) { - if (!labelChilds[i].tagName) { // check is text node - currentLabel += labelChilds[i].nodeValue.replace(/^\s+/, "").replace(/\s+$/, ""); - } - } - } - if (!currentLabel) { - if (element.title) { - currentLabel = element.title; - } else if (element.id) { - currentLabel = element.id; - } else if (element.name) { - currentLabel = element.name; - } else { - currentLabel = ""; - } - } - return currentLabel; - }; - - var getTextContent = function (el) { - var ELEMENT_NODE = 1; - var txt = ''; - var nodeType = el.nodeType; - var tagName = el.tagName ? el.tagName.toUpperCase() : ''; - var attrType = el.getAttribute ? el.getAttribute('type') : ''; - var styleDisplay; - - try { - var computedStyle = el.currentStyle || el.ownerDocument.defaultView.getComputedStyle(el, null); - styleDisplay = computedStyle.display; - } catch (e) { - styleDisplay = ""; - } - - if (nodeType === ELEMENT_NODE && - styleDisplay === 'none') { - txt += '[__['; - } - - if (nodeType === ELEMENT_NODE && - tagName === "IMG") { - txt += el.getAttribute('alt'); - } else if (nodeType === ELEMENT_NODE && - tagName === "AREA") { - txt += el.getAttribute('alt'); - } else if (nodeType === ELEMENT_NODE && - tagName === "INPUT" && - attrType === 'image') { - txt += el.getAttribute('alt'); - } else if (nodeType === ELEMENT_NODE && - tagName === "INPUT" && - (attrType === 'submit' || - attrType === 'reset' || - attrType === 'button')) { - txt += el.value; - } else if (nodeType === ELEMENT_NODE && - tagName === "INPUT") { - txt += getLabel(el); - } else if (nodeType === ELEMENT_NODE && - (tagName === "TEXTAREA" || tagName === "SELECT")) { - txt += getLabel(el); - } else if (nodeType !== ELEMENT_NODE || - (tagName !== "SCRIPT" && tagName !== "STYLE")) { - var cNodes = el.childNodes; - var TEXT_NODE = 3; - var i, l; - for (i = 0, l = cNodes.length; i < l; i++) { - if (cNodes[i].nodeType === TEXT_NODE) { - txt += cNodes[i].nodeValue; - } else { - txt += getTextContent(cNodes[i]); - } - } - } - - if (nodeType === ELEMENT_NODE && - styleDisplay === 'none') { - txt += ']__]'; - } - txt = txt ? txt.replace(/^\s+/, '').replace(/\s+$/, '') : ''; - return txt; - }; - - var getAbsolutePath = function (src, url) { - var newpath, orgPath; - - // remove url querystring - url = url.replace(/\?.*$/, ''); - - if (src && src.indexOf('//') === -1) { - if (src.substr(0, 3) === '../') { - newpath = url.substr(0, url.lastIndexOf('/') > 10 ? url.lastIndexOf('/') : url.length); - while (src.substr(0, 3) === '../') { - newpath = newpath.substr(0, newpath.lastIndexOf('/') > 10 ? newpath.lastIndexOf('/') : newpath.length); - src = src.substr(3); - } - src = newpath + '/' + src; - } else if (src.substr(0, 1) === '/') { - orgPath = url.replace(/^((?:https?\:\/\/|file\:\/\/\/)[^\/]+)\/.*$/, '$1'); - src = orgPath + '/' + src; - } else { - orgPath = url.substr(0, url.lastIndexOf('/')); - src = orgPath + '/' + src; - } - } - return src; - }; - - achecker.Wax.run = function (cwin, rdoc, isIncludeFrame, frameDocs, discardFrameUrls) { - return { - header: (function () { - var $div = rdoc.createElement('div'); - $div.className = 'waxFrames'; - - var $fold = rdoc.createElement('div'); - var $foldBtn = rdoc.createElement('button'); - - $fold.className = 'toggleAll'; - $foldBtn.className = 'fold'; - $foldBtn.setAttribute('data-folded', 'folded'); - $foldBtn.title = achecker.i18n.get('UnfoldAll'); - $foldBtn.setAttribute('type', 'button'); - $foldBtn.innerText = 'Toggle All'; - $foldBtn.textContent = 'Toggle All'; - $foldBtn.onclick = function () { - var $headings = rdoc.querySelectorAll('.waxSection h2,.waxFrames h2'); - var foldedClass = this.getAttribute('data-folded') === 'folded' ? '' : 'folded'; - var i, l; - - for (i = 0, l = $headings.length; i < l; i++) { - $headings[i].className = $headings[i].className.replace('folded', '') + ' ' + foldedClass; - } - - if (foldedClass) { - this.className = 'unfold'; - this.title = achecker.i18n.get('UnfoldAll'); - } else { - this.className = 'fold'; - this.title = achecker.i18n.get('FoldAll'); - } - this.setAttribute('data-folded', foldedClass); - // fix bug: IE8 won't reflow when set data-* attribute - rdoc.body.className = rdoc.body.getAttribute("className"); - }; - $fold.appendChild($foldBtn); - $div.appendChild($fold); - - var $title = rdoc.createElement('h2'); - $title.className = ''; - $title.innerText = achecker.i18n.get('TargetPage'); - $title.textContent = achecker.i18n.get('TargetPage'); - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - var $pages = rdoc.createElement('ul'), $pageLink; - var $topPage = rdoc.createElement('li'); - var $topPageLink = rdoc.createElement('a'); - var i, l, $page; - - $topPageLink.setAttribute('href', cwin.location.href); - $topPageLink.setAttribute('target', '_blank'); - $topPageLink.innerText = cwin.location.href; - $topPageLink.textContent = cwin.location.href; - $topPage.appendChild($topPageLink); - $pages.appendChild($topPage); - if (isIncludeFrame) { - for (i = 0, l = frameDocs.length; i < l; i++) { - $page = rdoc.createElement('li'); - $pageLink = rdoc.createElement('a'); - $pageLink.setAttribute('href', frameDocs[i].src); - $pageLink.setAttribute('target', '_blank'); - $pageLink.innerText = frameDocs[i].src; - $pageLink.textContent = frameDocs[i].src; - $page.appendChild($pageLink); - $pages.appendChild($page); - } - } - $div.appendChild($title); - $div.appendChild($pages); - - if (discardFrameUrls && discardFrameUrls.length) { - $title = rdoc.createElement('h2'); - $title.innerText = achecker.i18n.get('NoneTargetPage'); - $title.textContent = achecker.i18n.get('NoneTargetPage'); - $title.className = 'folded'; - addEvent($title, 'click', function (e) { - toggleFoldedClass(this); - }); - $pages = rdoc.createElement('ul'); - for (i = 0, l = discardFrameUrls.length; i < l; i++) { - $page = rdoc.createElement('li'); - $pageLink = rdoc.createElement('a'); - $pageLink.setAttribute('href', discardFrameUrls[i]); - $pageLink.setAttribute('target', '_blank'); - $pageLink.innerText = discardFrameUrls[i]; - $pageLink.textContent = discardFrameUrls[i]; - $page.appendChild($pageLink); - $pages.appendChild($page); - } - } - $div.appendChild($title); - $div.appendChild($pages); - return $div; - }()), - sections: { - altText: new TableSection( - cwin, - rdoc, - '1. ' + achecker.i18n.get('No1') + ' (img)', - 'input[type=image],img,area', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Preview'), width: 106}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var tagName = this.tagName.toLowerCase(); - var data = { - hidden: '', - preview: '', - el: '', - alt: '' - }; - var self = this; - - var handleImg = function () { - var hasAlt = self.getAttribute('alt') !== null; - data.alt = rdoc.createElement('span'); - if (!hasAlt) { - data.alt.innerText = 'alt ' + achecker.i18n.get('Undefined'); - data.alt.textContent = 'alt ' + achecker.i18n.get('Undefined'); - } else if (!self.getAttribute('alt')) { - data.alt.innerText = 'alt=""'; - data.alt.textContent = 'alt=""'; - } else { - data.alt.innerText = self.getAttribute('alt'); - data.alt.textContent = self.getAttribute('alt'); - } - data.el = tagName; - - if (self.getAttribute('longdesc')) { - var $longdesc = rdoc.createElement('a'); - $longdesc.setAttribute('href', - getAbsolutePath(self.getAttribute('longdesc'), url)); - $longdesc.setAttribute('target', '_blank'); - $longdesc.innerText = 'longdesc link'; - $longdesc.textContent = 'longdesc link'; - data.alt.innerText += ' '; - data.alt.textContent += ' '; - data.alt.appendChild($longdesc); - } - - var src = self.getAttribute('src'); - - var $container = rdoc.createElement('div'); - $container.style.width = "100px"; - $container.style.margin = "0 auto"; - $container.style.overflow = "hidden"; - var $img = rdoc.createElement('img'); - $img.setAttribute('alt', ''); - $img.setAttribute('src', getAbsolutePath(src, url)); - $container.appendChild($img); - data.preview = $container; - - return [ - data.hidden, - data.preview, - data.el, - data.alt - ]; - }; - - switch (tagName) { - case "input": - if (this.type.toLowerCase() !== 'image') { - break; - } - return handleImg(); - - case "img": - return handleImg(); - - case "area": - var hasAlt = this.getAttribute('alt') !== null; - data.alt = rdoc.createElement('span'); - if (!hasAlt) { - data.alt.innerText = 'alt ' + achecker.i18n.get('Undefined'); - data.alt.textContent = 'alt ' + achecker.i18n.get('Undefined'); - } else if (!this.getAttribute('alt')) { - data.alt.innerText = 'alt=""'; - data.alt.textContent = 'alt=""'; - } else { - data.alt.innerText = this.getAttribute('alt'); - data.alt.textContent = this.getAttribute('alt'); - } - data.el = tagName; - - return [ - data.hidden, - data.preview, - data.el, - data.alt - ]; - } - - return false; - }, - function () { - var tagName = this.tagName; - switch (tagName) { - case "IMG": - case "INPUT": - case "AREA": - var hasAlt = this.getAttribute('alt') !== null; - - if (!hasAlt) { - return 'fail'; - } - if (!this.getAttribute('alt')) { - return 'warning'; - } - return 'pass'; - } - } - ), - - altTextBG: new TableSection( - cwin, - rdoc, - '1. ' + achecker.i18n.get('No1') + ' (bg)', - 'body *', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Preview'), width: 106}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var data = { - hidden: '', - preview: '', - content: '' - }; - var computedStyle = this.currentStyle || cwin.getComputedStyle(this, null); - var bgImage = computedStyle.backgroundImage; - if (bgImage !== 'none' && - this.getElementsByTagName('*').length < 10) { - var $bg = rdoc.createElement('span'); - url = bgImage.replace(/^url\("?/, '').replace(/"?\)$/, ''); - - try { - $bg.style.backgroundImage = bgImage; - $bg.style.backgroundPosition = computedStyle.backgroundPosition; - $bg.style.backgroundRepeat = computedStyle.backgroundRepeat; - $bg.style.width = computedStyle.width; - $bg.style.height = computedStyle.height; - } catch (e) { - } - $bg.style.maxWidth = '100px'; - $bg.style.maxHeight = '200px'; - $bg.style.display = 'inline-block'; - $bg.style.overflow = 'hidden'; - - data.preview = $bg; - data.content = getTextContent(this); - - return [ - data.hidden, - data.preview, - data.content - ]; - } - - return false; - } - ), - - altTextEmbed: new TableSection( - cwin, - rdoc, - '1. ' + achecker.i18n.get('No1') + ' (object)', - 'object,embed,video,audio,canvas,svg', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var tagName = this.tagName; - switch (tagName) { - case "OBJECT": - if (this.parentNode && this.parentNode.tagName && - (this.parentNode.tagName === 'OBJECT' || - this.parentNode.tagName === 'EMBED')) { - return false; - } - return [ - '', - '<object>' - ]; - case "EMBED": - if (this.parentNode && this.parentNode.tagName && - (this.parentNode.tagName === 'OBJECT' || - this.parentNode.tagName === 'EMBED')) { - return false; - } - return [ - '', - '<embed>' - ]; - } - - return false; - } - ), - - contrast: new ToolSection( - cwin, - rdoc, - 'contrast', - '5. ' + achecker.i18n.get('No5'), - function (win, rdoc) { - if (!achecker.colorInspector) { - var $res = rdoc.createElement('p'); - $res.className = 'comment'; - $res.innerText = 'Not Supported.'; - $res.textContent = 'Not Supported.'; - return $res; - } - - var $ul = rdoc.createElement('ul'); - $ul.className = 'contrast'; - var $color1 = rdoc.createElement('li'); - var $color2 = rdoc.createElement('li'); - var $result = rdoc.createElement('li'); - - $color1.className = 'color1'; - var $color1_label = rdoc.createElement('span'); - $color1_label.innerText = achecker.i18n.get('Foreground') + ': '; - $color1_label.textContent = achecker.i18n.get('Foreground') + ': '; - var $color1_color = rdoc.createElement('span'); - $color1_color.className = 'color'; - $color1_color.style.backgroundColor = '#000'; - var $color1_val = rdoc.createElement('span'); - $color1_val.className = 'val'; - $color1_val.innerText = '#000000'; - $color1_val.textContent = '#000000'; - var $color1_btn = rdoc.createElement('button'); - $color1_btn.innerText = achecker.i18n.get('SelectForegroundColor'); - $color1_btn.textContent = achecker.i18n.get('SelectForegroundColor'); - $color1.appendChild($color1_label); - $color1.appendChild($color1_color); - $color1.appendChild(rdoc.createTextNode(' ')); - $color1.appendChild($color1_val); - $color1.appendChild(rdoc.createTextNode(' ')); - $color1.appendChild($color1_btn); - $color1.onclick = function () { - achecker.showOverlay(); - achecker.colorInspector.startInspect(function (color) { - achecker.hideOverlay(); - $color1.getElementsByClassName('color')[0].style.backgroundColor = color; - $color1.getElementsByClassName('val')[0].innerText = color; - $color1.getElementsByClassName('val')[0].textContent = color; - var contrastRatio = getContrastRatio(color, $color2.getElementsByClassName('val')[0].innerText); - if (contrastRatio >= 4.5) { - $result.className = 'pass'; - } else if (contrastRatio >= 3) { - $result.className = 'warning'; - } else { - $result.className = 'fail'; - } - $result.getElementsByClassName('result')[0].innerText = contrastRatio + ':1'; - $result.getElementsByClassName('result')[0].textContent = contrastRatio + ':1'; - $result.getElementsByClassName('resultText')[0].style.color = color; - }); - }; - - $color2.className = 'color2'; - var $color2_label = rdoc.createElement('span'); - $color2_label.innerText = achecker.i18n.get('Background') + ': '; - $color2_label.textContent = achecker.i18n.get('Background') + ': '; - var $color2_color = rdoc.createElement('span'); - $color2_color.className = 'color'; - $color2_color.style.backgroundColor = '#FFF'; - var $color2_val = rdoc.createElement('span'); - $color2_val.className = 'val'; - $color2_val.innerText = '#FFFFFF'; - $color2_val.textContent = '#FFFFFF'; - var $color2_btn = rdoc.createElement('button'); - $color2_btn.innerText = achecker.i18n.get('SelectBackgroundColor'); - $color2_btn.textContent = achecker.i18n.get('SelectBackgroundColor'); - $color2.appendChild($color2_label); - $color2.appendChild($color2_color); - $color2.appendChild(rdoc.createTextNode(' ')); - $color2.appendChild($color2_val); - $color2.appendChild(rdoc.createTextNode(' ')); - $color2.appendChild($color2_btn); - $color2.onclick = function () { - achecker.showOverlay(); - achecker.colorInspector.startInspect(function (color) { - achecker.hideOverlay(); - $color2.getElementsByClassName('color')[0].style.backgroundColor = color; - $color2.getElementsByClassName('val')[0].innerText = color; - $color2.getElementsByClassName('val')[0].textContent = color; - var contrastRatio = getContrastRatio(color, $color1.getElementsByClassName('val')[0].innerText); - if (contrastRatio >= 4.5) { - $result.className = 'pass'; - } else if (contrastRatio >= 3) { - $result.className = 'warning'; - } else { - $result.className = 'fail'; - } - $result.getElementsByClassName('result')[0].innerText = contrastRatio + ':1'; - $result.getElementsByClassName('result')[0].textContent = contrastRatio + ':1'; - $result.getElementsByClassName('resultText')[0].style.backgroundColor = color; - }); - }; - - $result.className = 'pass'; - var $result_label = rdoc.createElement('span'); - $result_label.innerText = achecker.i18n.get('Result') + ': '; - $result_label.textContent = achecker.i18n.get('Result') + ': '; - var $result_result = rdoc.createElement('span'); - $result_result.className = 'result'; - $result_result.innerText = '21:1'; - $result_result.textContent = '21:1'; - var $result_resultText = rdoc.createElement('span'); - $result_resultText.className = 'resultText'; - $result_resultText.innerText = achecker.i18n.get('Test'); - $result_resultText.textContent = achecker.i18n.get('Test'); - $result.appendChild($result_label); - $result.appendChild($result_result); - $result.appendChild(rdoc.createTextNode(' ')); - $result.appendChild($result_resultText); - - $ul.appendChild($color1); - $ul.appendChild($color2); - $ul.appendChild($result); - - return $ul; - } - ), - - kbdFocus: new TableSection( - cwin, - rdoc, - '8. ' + achecker.i18n.get('No8'), - '*', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('ErrorType'), width: 65}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('RequireConfirmation'), - function (doc, url) { - try { - var evtWrapper = this.wrappedJSObject || this; - var hasBlurEvent = false; - if (evtWrapper.onfocus && evtWrapper.onfocus.toString().indexOf('blur()') > -1) { - hasBlurEvent = true; - } else if (evtWrapper.onclick && evtWrapper.onclick.toString().indexOf('blur()') > -1) { - hasBlurEvent = true; - } - var outlineWidth = this.style.getPropertyValue('outline-width'); - var zeroOutlineWidth = outlineWidth === '0' || outlineWidth === '0pt' || outlineWidth === '0px'; - - if (hasBlurEvent) { - return [ - '', - 'blur()', - getTextContent(this) - ]; - } - if (zeroOutlineWidth) { - return [ - '', - 'outline:0', - getTextContent(this) - ]; - } - return false; - } catch (e) { - return false; - } - }, - function (doc, url) { - try { - var evtWrapper = this.wrappedJSObject || this; - var hasBlurEvent = evtWrapper.onfocus ? - evtWrapper.onfocus.toString().indexOf('blur()') > -1 : false; - var outlineWidth = this.style.getPropertyValue('outline-width'); - var zeroOutlineWidth = outlineWidth === '0' || outlineWidth === '0pt' || outlineWidth === '0px'; - - if (hasBlurEvent) { - return 'fail'; - } - if (zeroOutlineWidth) { - return 'fail'; - } - return 'pass'; - } catch (e) { - return false; - } - } - ), - - skipNav: new TableSection( - cwin, - rdoc, - '12. ' + achecker.i18n.get('No12'), - 'a[href^="#"]', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('No'), width: 65}, - {label: achecker.i18n.get('Contents')}, - {label: achecker.i18n.get('Connected'), width: 45} - ], - isIncludeFrame, - frameDocs, - '-', - function (doc, url) { - if (cwin.document !== doc) { - return false; - } - - var href = this.getAttribute('href'); - var isConnectedLink = href === '#' ? false : - !!doc.getElementById(href.replace('#', '')) || - doc.getElementsByName(href.replace('#', '')).length > 0; - var linkIdx, i, l; - - for (i = 0, l = doc.getElementsByTagName('a').length; i < l; i++) { - if (doc.getElementsByTagName('a')[i] === this) { - linkIdx = i + 1; - if (linkIdx > 20) { - return false; - } - - break; - } - } - - return [ - '', - linkIdx + achecker.i18n.get('ThLink'), - '(' + href + ') ' + getTextContent(this), - (isConnectedLink ? 'O' : 'X') - ]; - }, - function (doc, url) { - var href = this.getAttribute('href'); - var isConnectedLink = href === '#' ? false : - !!doc.getElementById(href.replace('#', '')) || - doc.getElementsByName(href.replace('#', '')).length > 0; - return isConnectedLink ? 'pass' : 'fail'; - } - ), - - pageTitle: new ListSection( - cwin, - rdoc, - '13. ' + achecker.i18n.get('No13') + '(<title>)', - 'title', - null, - isIncludeFrame, - frameDocs, - '-', - function (doc, url) { - var $res = rdoc.createElement('span'); - var $val = rdoc.createElement('strong'); - var val = this.textContent || this.innerText || achecker.i18n.get('NoPageTitle'); - - $res.innerText = url + ': '; - $res.textContent = url + ': '; - $val.innerText = val; - $val.textContent = val; - $res.appendChild($val); - - return $res; - }, - function () { - var title = this.textContent || this.innerText || ''; - var dupCharacters = [ - '::', '||', '--', '@@', '##', '$$', '%%', '&&', '**', '((', '))', '++', '==', '~~', - ';;', '<<', '>>', '[[', ']]', '★★', '☆☆', '◎◎', '●●', '◆◆', '◇◇', '□□', '■■', '△△', - '▲▲', '▽▽', '▼▼', '◁◁', '◀◀', '▷▷', '▶▶', '♠♠', '♤♤', '♡♡', '♥♥', '♧♧', '♣♣', '⊙⊙', - '◈◈', '▣▣', '◐◐', '◑◑', '▒▒', '▤▤', '▥▥', '▨▨', '▧▧', '▦▦', '▩▩', '♨♨', '☏☏', '☎☎' - ]; - var hasTitle = !!title; - var hasSpecialCharactersDup = false; - for (var i = 0; i < dupCharacters.length; i++) { - if (title.indexOf(dupCharacters[i]) > -1) { - hasSpecialCharactersDup = true; - break; - } - } - - return hasTitle && !hasSpecialCharactersDup ? 'pass' : 'fail'; - } - ), - - frame: new TableSection( - cwin, - rdoc, - '13. ' + achecker.i18n.get('No13') + '(frame)', - 'iframe', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Title'), minWidth: 50, className: 'lt'}, - {label: achecker.i18n.get('Contents'), maxWidth: 200} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var data = { - hidden: '', - el: '', - title: '', - url: '' - }; - var src = this.getAttribute('src'); - var title = this.getAttribute('title'); - data.el = 'iframe'; - - if (src) { - var $a = rdoc.createElement('a'); - $a.setAttribute('href', src); - $a.setAttribute('target', '_blank'); - $a.innerText = src; - $a.textContent = src; - data.url = $a; - } else { - data.url = achecker.i18n.get('NoSrc'); - } - data.title = title || achecker.i18n.get('NoTitle'); - return [ - data.hidden, - data.el, - data.title, - data.url - ]; - }, - function () { - var title = this.getAttribute('title'); - return title ? 'pass' : 'fail'; - } - ), - - blockTitle: new TableSection( - cwin, - rdoc, - '13. ' + achecker.i18n.get('No13') + '(<h1>~<h6>)', - 'h1,h2,h3,h4,h5,h6', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('RequireConfirmation'), - function () { - return [ - '', - this.tagName.toLowerCase(), - getTextContent(this) - ]; - } - ), - - linkText: new TableSection( - cwin, - rdoc, - '14. ' + achecker.i18n.get('No14'), - 'a,area', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('Contents')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var text = getTextContent(this); - var title = this.getAttribute('title'); - - return [ - '', - this.tagName.toLowerCase(), - (text || '-') + - (title ? ' (title: ' + title + ')' : '') - ]; - }, - function () { - var text = getTextContent(this); - - return text ? 'pass' : 'fail'; - } - ), - - pageLang: new ListSection( - cwin, - rdoc, - '15. ' + achecker.i18n.get('No15'), - 'html', - null, - isIncludeFrame, - frameDocs, - '-', - function (doc, url) { - var isXhtml = this.getAttribute('xmlns'); - var val = ''; - var $res = rdoc.createElement('span'); - - // ignore if protocol is not http(s)? or .html extension - if (url.substr(0, 4).toLowerCase() !== 'http' && - url.substr(-5).toLowerCase() !== '.html') { - return false; - } - if (isXhtml && this.getAttribute('xml:lang') && this.getAttribute('lang')) { - val = 'xml:lang=' + this.getAttribute('xml:lang') + ', lang=' + this.getAttribute('lang'); - } else if (isXhtml && this.getAttribute('xml:lang')) { - val = 'xml:lang=' + this.getAttribute('xml:lang'); - } else if (isXhtml && this.getAttribute('lang')) { - val = 'xml:lang=' + achecker.i18n.get('None') + ', lang=' + this.getAttribute('lang'); - } else if (!isXhtml && this.getAttribute('lang')) { - val = 'lang=' + this.getAttribute('lang'); - } else { - val = achecker.i18n.get('NoMainLang'); - } - $res.innerText = url + ': '; - $res.textContent = url + ': '; - - var $val = rdoc.createElement('strong'); - $val.innerText = val; - $val.textContent = val; - $res.appendChild($val); - return $res; - }, - function (doc, url) { - var isXhtml = this.getAttribute('xmlns'); - - if (isXhtml && this.getAttribute('xml:lang')) { - return 'pass'; - } - if (isXhtml && this.getAttribute('lang')) { - return 'warning'; - } - if (!isXhtml && this.getAttribute('lang')) { - return 'pass'; - } - return 'fail'; - } - ), - - unintendedFunction: new TableSection( - cwin, - rdoc, - '16. ' + achecker.i18n.get('No16'), - 'a,area,input,button', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Event'), width: 80}, - {label: achecker.i18n.get('Contents'), className: 'lt'}, - {label: achecker.i18n.get('TitleAttribute')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('RequireConfirmation'), - function (doc, url) { - var data = { - hidden: '', - event: '', - content: '', - title: '' - }; - var evtWrapper = this.wrappedJSObject || this; - var hasChangeEvent; - var hasWindowOpenEvent; - - try { - hasWindowOpenEvent = evtWrapper.onclick ? - evtWrapper.onclick.toString().indexOf('window.open') > -1 : false; - } catch (e) { - hasWindowOpenEvent = null; - } - - data.content = getTextContent(this); - if (this.getAttribute('title')) { - data.title = this.getAttribute('title'); - } else if (this.getAttribute('target') === '_blank') { - data.title = 'target="_blank"'; - } else { - data.title = '-'; - } - - if (hasWindowOpenEvent) { - data.event = 'window.open'; - } else { - return false; - } - - return [ - data.hidden, - data.event, - data.content, - data.title - ]; - }, - function () { - if (this.getAttribute('title')) { - return 'warning'; - } - if (this.getAttribute('target') === '_blank') { - return 'pass'; - } - return 'fail'; - } - ), - - tableTitle: new TableSection( - cwin, - rdoc, - '18. ' + achecker.i18n.get('No18') + '(caption, summary)', - 'table', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('CaptionContent'), className: 'lt'}, - {label: achecker.i18n.get('SummaryContent')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var childNodes = this.childNodes, - $caption = null, - data = { - hidden: '', - caption: '', - summary: '' - }, - i, - l; - for (i = 0; i < childNodes.length; i++) { - if (childNodes[i].tagName && - childNodes[i].tagName.toLowerCase() === 'caption') { - $caption = childNodes[i]; - break; - } - } - var hasCaption = !!$caption; - var hasSummary = !!this.getAttribute('summary'); - - data.caption = hasCaption ? getTextContent($caption) : achecker.i18n.get('None'); - data.summary = hasSummary ? this.getAttribute('summary') : achecker.i18n.get('None'); - - return [ - data.hidden, - data.caption, - data.summary - ]; - }, - function () { - var childNodes = this.childNodes, - $caption = null, - i, - l; - for (i = 0; i < childNodes.length; i++) { - if (childNodes[i].tagName && - childNodes[i].tagName.toLowerCase() === 'caption') { - $caption = childNodes[i]; - break; - } - } - var hasCaption = !!$caption; - var hasSummary = !!this.getAttribute('summary'); - - if (hasCaption) { - return 'pass'; - } else if (!hasCaption && !hasSummary) { - return 'warning'; - } else { - return 'fail'; - } - } - ), - - tableStructure: new TableSection( - cwin, - rdoc, - '18. ' + achecker.i18n.get('No18') + '(th)', - 'table', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Structure'), className: 'tb_str'} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function () { - var data = { - hidden: '', - structure: '' - }; - var $thead = getElsFromChildNodes(this, 'thead'); - var $tfoot = getElsFromChildNodes(this, 'tfoot'); - var $tbody = getElsFromChildNodes(this, 'tbody'); - var $theadTh = getElsFromChildNodes( - getElsFromChildNodes($thead, 'tr'), - 'th' - ); - var $tfootTh = getElsFromChildNodes( - getElsFromChildNodes($tfoot, 'tr'), - 'th' - ); - var $tbodyTh = getElsFromChildNodes( - getElsFromChildNodes($tbody, 'tr'), - 'th' - ).concat( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tr'), - 'th' - ) - ); - var hasTh = !!$theadTh.length || !!$tfootTh.length || $tbodyTh.length; - var $resultTable = rdoc.createElement('table'); - var $resultThead = rdoc.createElement('thead'); - var $resultTbody = rdoc.createElement('tbody'); - var $resultTheadTr = rdoc.createElement('tr'); - var $resultTheadTh1 = rdoc.createElement('th'); - var $resultTheadTh2 = rdoc.createElement('th'); - var $resultTheadTh3 = rdoc.createElement('th'); - $resultTheadTh1.innerText = '요소'; - $resultTheadTh1.textContent = '요소'; - $resultTheadTh2.innerText = '유무'; - $resultTheadTh2.textContent = '유무'; - $resultTheadTh3.innerText = '제목셀 정보 (scope 속성값)'; - $resultTheadTh3.textContent = '제목셀 정보 (scope 속성값)'; - $resultTheadTr.appendChild($resultTheadTh1); - $resultTheadTr.appendChild($resultTheadTh2); - $resultTheadTr.appendChild($resultTheadTh3); - $resultThead.appendChild($resultTheadTr); - $resultTable.appendChild($resultThead); - $resultTable.appendChild($resultTbody); - - var $resultTr = rdoc.createElement('tr'); - var $resultTd1 = rdoc.createElement('td'); - var $resultTd2 = rdoc.createElement('td'); - var $resultTd3 = rdoc.createElement('td'); - var $resultTd3Ul; - var i, l; - var $th; - var scope; - var $infoItem; - - if ($thead.length) { - $resultTd3Ul = rdoc.createElement('ul'); - $resultTd1.innerText = 'thead'; - $resultTd1.textContent = 'thead'; - $resultTd2.innerText = 'O'; - $resultTd2.textContent = 'O'; - for (i = 0, l = $theadTh.length; i < l; i++) { - $th = $theadTh[i]; - scope = $th.getAttribute('scope'); - $infoItem = rdoc.createElement('li'); - - $infoItem.innerText = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $infoItem.textContent = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $resultTd3Ul.appendChild($infoItem); - } - $resultTd3.appendChild($resultTd3Ul); - } else { - $resultTd1.innerText = 'thead'; - $resultTd1.textContent = 'thead'; - $resultTd2.innerText = 'X'; - $resultTd2.textContent = 'X'; - $resultTd3.innerText = '-'; - $resultTd3.textContent = '-'; - } - $resultTr.appendChild($resultTd1); - $resultTr.appendChild($resultTd2); - $resultTr.appendChild($resultTd3); - $resultTbody.appendChild($resultTr); - - $resultTr = rdoc.createElement('tr'); - $resultTd1 = rdoc.createElement('td'); - $resultTd2 = rdoc.createElement('td'); - $resultTd3 = rdoc.createElement('td'); - if ($tfoot.length) { - $resultTd3Ul = rdoc.createElement('ul'); - $resultTd1.innerText = 'tfoot'; - $resultTd1.textContent = 'tfoot'; - $resultTd2.innerText = 'O'; - $resultTd2.textContent = 'O'; - for (i = 0, l = $tfootTh.length; i < l; i++) { - $th = $tfootTh[i]; - scope = $th.getAttribute('scope'); - $infoItem = rdoc.createElement('li'); - - $infoItem.innerText = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $infoItem.textContent = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $resultTd3Ul.appendChild($infoItem); - } - $resultTd3.appendChild($resultTd3Ul); - } else { - $resultTd1.innerText = 'tfoot'; - $resultTd1.textContent = 'tfoot'; - $resultTd2.innerText = 'X'; - $resultTd2.textContent = 'X'; - $resultTd3.innerText = '-'; - $resultTd3.textContent = '-'; - } - $resultTr.appendChild($resultTd1); - $resultTr.appendChild($resultTd2); - $resultTr.appendChild($resultTd3); - $resultTbody.appendChild($resultTr); - - $resultTr = rdoc.createElement('tr'); - $resultTd1 = rdoc.createElement('td'); - $resultTd2 = rdoc.createElement('td'); - $resultTd3 = rdoc.createElement('td'); - if ($tbody.length) { - $resultTd3Ul = rdoc.createElement('ul'); - $resultTd1.innerText = 'tbody'; - $resultTd1.textContent = 'tbody'; - $resultTd2.innerText = 'O'; - $resultTd2.textContent = 'O'; - for (i = 0, l = $tbodyTh.length; i < l; i++) { - $th = $tbodyTh[i]; - scope = $th.getAttribute('scope'); - $infoItem = rdoc.createElement('li'); - - $infoItem.innerText = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $infoItem.textContent = getTextContent($th) + - (!!scope ? '(' + scope + ')' : '(X)'); - $resultTd3Ul.appendChild($infoItem); - } - $resultTd3.appendChild($resultTd3Ul); - } else { - $resultTd1.innerText = 'tbody'; - $resultTd1.textContent = 'tbody'; - $resultTd2.innerText = 'X'; - $resultTd2.textContent = 'X'; - $resultTd3.innerText = '-'; - $resultTd3.textContent = '-'; - } - $resultTr.appendChild($resultTd1); - $resultTr.appendChild($resultTd2); - $resultTr.appendChild($resultTd3); - $resultTbody.appendChild($resultTr); - - data.structure = $resultTable; - - return [ - data.hidden, - data.structure - ]; - }, - function () { - var $theadTh = getElsFromChildNodes( - getElsFromChildNodes( - getElsFromChildNodes(this, 'thead'), - 'tr' - ), - 'th' - ); - var $tfootTh = getElsFromChildNodes( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tfoot'), - 'tr' - ), - 'th' - ); - var $tbodyTh = getElsFromChildNodes( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tbody'), - 'tr' - ), - 'th' - ).concat( - getElsFromChildNodes( - getElsFromChildNodes(this, 'tr'), - 'th' - ) - ); - var hasTh = $theadTh.length || $tfootTh.length || $tbodyTh.length; - var hasScope = function ($ths) { - var i, l; - for (i = 0, l = $ths.length; i < l; i++) { - if (!$ths[i].getAttribute('scope')) { - return false; - } - } - return true; - }; - - if (hasTh && hasScope($theadTh) && hasScope($tfootTh) && - hasScope($tbodyTh)) { - return 'pass'; - } else if (!hasTh && !$theadTh.length && !$tfootTh.length) { - return 'warning'; - } else { - return 'fail'; - } - } - ), - - label: new TableSection( - cwin, - rdoc, - '19. ' + achecker.i18n.get('No19'), - 'input,textarea,select', - [ {label: achecker.i18n.get('Hidden'), width: 45}, - {label: achecker.i18n.get('Element'), width: 45}, - {label: achecker.i18n.get('FormType'), width: 66}, - {label: achecker.i18n.get('LabelConnection'), className: 'lt'}, - {label: achecker.i18n.get('TitleAttribute')} - ], - isIncludeFrame, - frameDocs, - achecker.i18n.get('NotApplicable'), - function (doc, url) { - var typeAttr = this.getAttribute('type') ? this.getAttribute('type').toLowerCase() : null; - if (this.tagName === 'INPUT' && - (typeAttr === 'submit' || - typeAttr === 'button' || - typeAttr === 'image' || - typeAttr === 'hidden' || - typeAttr === 'reset')) { - return false; - } - - var data = { - hidden: '', - el: '', - type: '', - label: '', - title: '' - }; - var _id = this.getAttribute('id'); - var $labels = doc.getElementsByTagName("label"); - var hasLabelElement = false, - $label = null, - i, - l; - - if (_id) { - for (i = 0, l = $labels.length; i < l; i++) { - if ($labels[i].getAttribute('for') === _id) { - hasLabelElement = true; - $label = $labels[i]; - break; - } - } - } - var hasTitle = !!this.getAttribute('title'); - - var hasImplicitLabel = false; - var parentEl = this.parentNode; - do { - parentEl = parentEl.parentNode; - if (parentEl.tagName === 'LABEL') { - hasImplicitLabel = true; - $label = parentEl; - break; - } - } while (parentEl.parentNode); - - data.el = this.tagName.toLowerCase(); - data.type = typeAttr || '-'; - data.label = $label ? getTextContent($label) : ''; - if (!data.label) { - data.label = 'X'; - } - data.title = this.getAttribute('title'); - if (!data.title) { - data.title = '-'; - } - - return [ - data.hidden, - data.el, - data.type, - data.label, - data.title - ]; - }, - function (doc, url) { - var _id = this.getAttribute('id'); - var $labels = doc.getElementsByTagName("label"); - var hasLabelElement = false, i, l; - if (_id) { - for (i = 0, l = $labels.length; i < l; i++) { - if ($labels[i].getAttribute('for') === _id) { - hasLabelElement = true; - break; - } - } - } - var hasTitle = !!this.getAttribute('title'); - var hasImplicitLabel = false; - var parentEl = this.parentNode; - do { - parentEl = parentEl.parentNode; - - if (parentEl.tagName === 'LABEL') { - hasImplicitLabel = true; - } - } while (parentEl.parentNode); - - if (hasLabelElement) { - return 'pass'; - } - if (hasImplicitLabel) { - return 'pass'; - } - if (hasTitle) { - return 'warning'; - } - return 'fail'; - } - ), - - validation: new ToolSection( - cwin, - rdoc, - 'w3c_validation', - '21. ' + achecker.i18n.get('No21'), - function (win, rdoc) { - var isChromeAddon = typeof chrome === "object" && chrome.extension; - var isFirefoxAddon = typeof Components === "object" && Components.classes; - if (!isChromeAddon && !isFirefoxAddon) { - var $res = rdoc.createElement('p'); - $res.className = 'comment'; - $res.innerText = 'Not Supported.'; - $res.textContent = 'Not Supported.'; - return $res; - } - - var filterValidationResult = function (res) { - var msgs = res.messages, newmsgs = []; - var filters = [ - // /^unterminated comment: .*/, - // /^literal is missing closing delimiter.*/, - // /^unknown declaration type .*/, - /^document type does not allow element .* here; missing one of .* start\-tag.*/, - // /^end tag for .* omitted, but its declaration does not permit this.*/, - /^end tag for .* which is not finished.*/, - /^end tag for element .* which is not open.*/, - // /^an attribute value must be a literal unless it contains only name characters.*/, - // /^an attribute value literal can occur in an attribute specification list only after a VI delimiter.*/, - // /^normalized length of attribute value literal must not exceed.*/, - // /^syntax of attribute value does not conform to declared value.*/, - // /^value of attribute .* must be a single token.*/, - // /^value of attribute .* cannot be .*; must be one of .*/, - // /^invalid comment declaration:.*/, - /^ID .* already defined.*/, - // /^no document type declaration; will parse without validation.*/, - /^unclosed start-tag requires SHORTTAG YES.*/, - /^unclosed end-tag requires SHORTTAG YES.*/, - // /^DTD did not contain element declaration for document type name.*/, - /^empty start-tag.*/, - /^empty end-tag.*/ - // /^no document type declaration; implying .*/, - // /^no system id specified.*/, - // /^.* separator in comment declaration.*/, - ]; - var i, j; - - for (i = 0; i < msgs.length; i++) { - if (msgs[i].type === 'error') { - for (j = 0; j < filters.length; j++) { - if (filters[j].test(msgs[i].message)) { - newmsgs.push(msgs[i]); - break; - } - } - } - } - - res.messages = newmsgs; - return res; - }; - - var getResultDetailEl = function (messages, url) { - var $res = rdoc.createElement('div'); - $res.className = 'validationResult'; - var $errhead = rdoc.createElement('h3'); - $errhead.innerText = 'Error'; - $errhead.textContent = 'Error'; - $errhead.className = 'fail'; - var $errul = rdoc.createElement('ul'); - var $warninghead = rdoc.createElement('h3'); - $warninghead.innerText = 'Warning'; - $warninghead.textContent = 'Warning'; - $warninghead.className = 'warning'; - var $warningul = rdoc.createElement('ul'); - var onClickMessageLink = function (e) { - e.preventDefault(); - e.stopPropagation(); - openDialog("chrome://global/content/viewSource.xul", - "achecker_sourceView", - "scrollbars,resizable,chrome,dialog=no", - url, null, null, this.getAttribute('data-line'), - false); - }, i; - - for (i = 0; i < messages.length; i++) { - var msg = messages[i]; - var $li = rdoc.createElement('li'); - var $msg = rdoc.createElement('div'); - var $msga = rdoc.createElement('a'); - $msga.innerText = msg.message; - $msga.textContent = msg.message; - $msga.setAttribute('href', '#'); - $msga.setAttribute('data-line', msg.lastLine); - addEvent($msga, 'click', onClickMessageLink); - $msg.appendChild($msga); - var $subinfo = rdoc.createElement('div'); - $subinfo.className = 'subinfo'; - $subinfo.innerText = msg.lastLine + ' line, ' + msg.lastColumn + ' column'; - $subinfo.textContent = msg.lastLine + ' line, ' + msg.lastColumn + ' column'; - $li.appendChild($msg); - $li.appendChild($subinfo); - switch (msg.type) { - case 'error': - $errul.appendChild($li); - break; - case 'info': - $warningul.appendChild($li); - break; - } - } - $res.appendChild($errhead); - $res.appendChild($errul); - $res.appendChild($warninghead); - $res.appendChild($warningul); - return $res; - }; - - var doValidation = function (url, doc) { - var sourceUrl = url; - var req = new XMLHttpRequest(); - req.onreadystatechange = function () { - if (req.readyState === 4) { - if (req.status === 200) { - // IT WORKS! - var html = req.responseText; - var req2 = new XMLHttpRequest(); - var charset = html.indexOf('euc-kr') > 0 ? 'euc-kr' : 'utf-8'; - req2.onreadystatechange = function () { - try { - var i; - var onClickItem = function () { - var $res = this.getElementsByTagName("div")[0]; - $res.style.display = $res.style.display === 'none' ? 'block' : 'none'; - }; - - 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 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; - } - } - } - } - } catch (e) { - } - }; - - try { - req2.open("POST", "http://validator.w3.org/check", true); - - // Firefox < 4 - if (typeof FormData !== "object") { - req2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - req2.send('fragment=' + global.escape(html) + - '&doctype=Inline' + - '&output=json'); - } else { - var formData = new FormData(); - formData.append('fragment', html); - formData.append('doctype', 'Inline'); - formData.append('output', 'json'); - req2.send(formData); - } - } catch (e) { - } - } else { - global.alert(achecker.i18n.get('ValidationFail')); - } - } - }; - req.open("GET", sourceUrl, true); - req.send(null); - }; - - var urls = [], docs = [], i, l; - if (win.location.href.substr(0, 7) === 'http://' || - win.location.href.substr(0, 8) === 'https://') { - urls.push(win.location.href); - docs.push(win.document); - } - if (isIncludeFrame) { - for (i = 0, l = frameDocs.length; i < l; i++) { - var _url = frameDocs[i].src; - if (_url.substr(0, 7) === 'http://' || _url.substr(0, 8) === 'https://') { - urls.push(_url); - docs.push(frameDocs[i]); - } - } - } - - var $output = rdoc.createElement('ul'); - for (i = 0, l = urls.length; i < l; i++) { - doValidation(urls[i], docs[i]); - var $item = rdoc.createElement('li'); - $item.className = 'validationItem'; - var $_url = rdoc.createElement('span'); - $_url.className = 'url'; - $_url.innerText = urls[i]; - $_url.textContent = urls[i]; - var $_errcnt = rdoc.createElement('b'); - $_errcnt.className = 'errcnt'; - $_errcnt.innerText = achecker.i18n.get('Loading'); - $_errcnt.textContent = achecker.i18n.get('Loading'); - $item.appendChild($_url); - $item.appendChild(rdoc.createTextNode(': ')); - $item.appendChild($_errcnt); - $output.appendChild($item); - } - return $output; - } - ) - } - }; - }; -}(window, window.document)); diff --git a/owax_ff/app/content/scripts/Sections.js b/owax_ff/app/content/scripts/Sections.js new file mode 120000 index 0000000..c753e6e --- /dev/null +++ b/owax_ff/app/content/scripts/Sections.js @@ -0,0 +1 @@ +../../../../lib/Sections.js \ No newline at end of file diff --git a/owax_ff/app/install.rdf b/owax_ff/app/install.rdf index 52b2764..49f6ea9 100644 --- a/owax_ff/app/install.rdf +++ b/owax_ff/app/install.rdf @@ -6,7 +6,7 @@ <em:id>owax@tenshi</em:id> <em:type>2</em:type> <em:name>OpenWAX</em:name> - <em:version>1.9.5</em:version> + <em:version>1.9.6</em:version> <em:creator>Goonoo Kim</em:creator> <em:targetApplication> <Description> diff --git a/owax_ff/app/locale/en-US/achecker.properties b/owax_ff/app/locale/en-US/achecker.properties index 98a8150..4a1eb88 100644 --- a/owax_ff/app/locale/en-US/achecker.properties +++ b/owax_ff/app/locale/en-US/achecker.properties @@ -68,6 +68,8 @@ LabelConnection=label connection CannotCheckFrameset=Cannot check frameset page. AllowLogging=Provide inspection result to OpenWAX? You can change this option in preferences window later. +ValidationTimeout=Timeout +ValidateManually=Validate Manually No1=Alternative text No5=Contrast diff --git a/owax_ff/app/locale/ko-KR/achecker.properties b/owax_ff/app/locale/ko-KR/achecker.properties index a58eb6f..483dbdb 100644 --- a/owax_ff/app/locale/ko-KR/achecker.properties +++ b/owax_ff/app/locale/ko-KR/achecker.properties @@ -68,6 +68,8 @@ LabelConnection=label 연결 CannotCheckFrameset=프레임셋이 포함된 페이지는 검사할 수 없습니다. AllowLogging=사이트별 접근성 통계 수집을 위해 검사 결과를 OpenWAX에 제공하시겠습니까? 검사 결과 제공 여부는 이후에도 앱 환경설정에서 변경 가능합니다. +ValidationTimeout=시간초과 +ValidateManually=수동 검사 No1=적절한 대체 텍스트 No5=텍스트 콘텐츠의 명도 대비 diff --git a/package.json b/package.json index 5ea5c00..e6cd8f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "OpenWAX", - "version": "1.9.5", + "version": "1.9.6", "author": "mctenshi <mctenshi@gmail.com>", "private": true, "scripts": { @@ -11,7 +11,7 @@ "grunt-contrib-jshint": "latest", "grunt-contrib-concat": "latest", "grunt-contrib-uglify": "latest", - "grunt-contrib-qunit": "latest", + "grunt-contrib-qunit": "0.1.1", "grunt-json": "https://github.com/mctenshi/grunt-json/tarball/master", "uglify-js": "1", "grunt-exec": "latest" diff --git a/OpenWAX-1.9.5.js b/release/OpenWAX-1.9.5.js similarity index 100% rename from OpenWAX-1.9.5.js rename to release/OpenWAX-1.9.5.js diff --git a/release/OpenWAX-1.9.6.js b/release/OpenWAX-1.9.6.js new file mode 100644 index 0000000..702e473 --- /dev/null +++ b/release/OpenWAX-1.9.6.js @@ -0,0 +1,2408 @@ +/*! OpenWAX - v1.9.6 - 2013-03-30 */ +(function (g) { + "use strict"; + + var addEvent = function (obj, type, fn) { + if (obj.addEventListener) { + obj.addEventListener(type, fn, false); + } else if (obj.attachEvent) { + obj["e" + type + fn] = fn; + obj[type + fn] = function () { + obj["e" + type + fn](g.event); + }; + obj.attachEvent("on" + type, obj[type + fn]); + } + }; + var getStyle = function (el, style) { + if (el.currentStyle) { + return el.currentStyle.style; + } + return g.getComputedStyle(el, null)[style]; + }; + var toggleFoldedClass = function (el) { + el.className = el.className.indexOf('folded') > -1 ? el.className.replace(/folded/g, '') : el.className + ' folded'; + + // fix bug: IE8 won't reflow when set data-* attribute + if (document && document.all) { + document.body.className = document.body.getAttribute("className"); + } + }; + + var Xpath = {}; + + // ********************************************************************************************* // + // XPATH + + /** + * Gets an XPath for an element which describes its hierarchical location. + */ + Xpath.getElementXPath = function (element) { + if (element && element.id) { + return '//*[@id="' + element.id + '"]'; + } + return Xpath.getElementTreeXPath(element); + }; + + Xpath.getElementTreeXPath = function (element) { + var paths = []; + var DOCUMENT_TYPE_NODE = 10; + var sibling; + + // Use nodeName (instead of localName) so namespace prefix is included (if any). + for (element; element && element.nodeType === 1; element = element.parentNode) { + var index = 0; + for (sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) { + // Ignore document type declaration. + if (sibling.nodeType !== DOCUMENT_TYPE_NODE && sibling.nodeName === element.nodeName) { + ++index; + } + } + + var tagName = element.nodeName.toLowerCase(); + var pathIndex = (index ? "[" + (index + 1) + "]" : ""); + paths.splice(0, 0, tagName + pathIndex); + } + + return paths.length ? "/" + paths.join("/") : null; + }; + + g.achecker = g.achecker || {}; + g.achecker.Wax = g.achecker.Wax || {}; + g.achecker.Wax.Section = function () { + throw 'not implemented'; + }; + g.achecker.Wax.Section.prototype = { + getAsElement : function () { + throw 'not implemented'; + } + }; + + g.achecker.Wax.isElHidden = function (el) { + if (el && el.tagName && (el.tagName === 'TITLE' || el.tagName === 'BODY' || el.tagName === 'HTML')) { + return false; + } + do { + if (el.tagName && getStyle(el, 'display') === 'none') { + return true; + } + el = el.parentNode; + } while (el); + return false; + }; + + g.achecker.Wax.ListSection = g.achecker.Wax.Section; + g.achecker.Wax.ListSection = function (cwin, rdoc, title, targetSelector, + limit, isIncludeFrame, frameDocs, emptyMessage, + content, validStatus, eventHandlers) { + var this_ = this; + this.cwin = cwin; + this.rdoc = rdoc; + this.title = title; + this.emptyMessage = emptyMessage; + this.contents = this._getContents(cwin, isIncludeFrame, frameDocs, + targetSelector, content, validStatus, eventHandlers, limit); + }; + g.achecker.Wax.ListSection.prototype._getContentsFromDocument = function (doc, url, + targetSelector, content, validStatus, eventHandlers, limit) { + if (!limit) { + limit = 99999; + } + + var $target = doc.querySelectorAll(targetSelector); + var contents = [], i; + + for (i = 0; i < $target.length; i++) { + if (limit <= 0) { + break; + } + + var $el = $target[i]; + var _content = typeof content === 'function' ? content.apply($el, [doc, url]) : content; + if (_content !== false) { + contents.push({ + el: $el, + doc: $el.ownerDocument, + validStatus: typeof validStatus === 'function' ? validStatus.apply($el, [doc, url]) : (typeof validStatus === 'string' ? validStatus : ''), + content: typeof content === 'function' ? content.apply($el, [doc, url]) : content, + eventHandlers: eventHandlers + }); + limit--; + } + } + return contents; + }; + g.achecker.Wax.ListSection.prototype._getContents = function (win, isIncludeFrame, + frameDocs, targetSelector, content, validStatus, + eventHandlers, limit) { + if (!limit) { + limit = 99999; + } + var contents = this._getContentsFromDocument(win.document, win.location.href, + targetSelector, content, validStatus, eventHandlers, limit), i, l; + + limit -= contents.length; + if (isIncludeFrame && limit > 0) { + for (i = 0, l = frameDocs.length; i < l; i++) { + if (limit <= 0) { + break; + } + + var _contents = this._getContentsFromDocument( + frameDocs[i].doc, + frameDocs[i].src, + targetSelector, + content, + validStatus, + eventHandlers, + limit + ); + contents = contents.concat(_contents); + limit -= _contents.length; + } + } + return contents; + }; + g.achecker.Wax.ListSection.prototype.getAsElement = function () { + var this_ = this; + var doc = this.rdoc; + var $contentList = doc.createElement("ul"), i; + var hasWarning = false; + var hasError = false; + var onClickItem = function (e) { + if (parent.Firebug) { + parent.Firebug.Inspector.clearAllHighlights(); + } + + var $targetEl = this['data-el']; + var isHidden = g.achecker.Wax.isElHidden($targetEl); + if ($targetEl.tagName === 'TITLE') { + while ($targetEl) { + if ($targetEl.tagName === 'HTML') { + break; + } + $targetEl = $targetEl.parentNode; + } + } + + if (!isHidden) { + var oldTabindex = $targetEl.getAttribute('tabindex'); + $targetEl.setAttribute('tabindex', 0); + $targetEl.focus(); + if (oldTabindex === null) { + $targetEl.removeAttribute('tabindex'); + } else { + $targetEl.setAttribute('tabindex', oldTabindex); + } + } + if (parent.Firebug && $targetEl) { + parent.Firebug.Inspector.inspectFromContextMenu($targetEl); + // compatible with firebug 1.9.x + parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); + } else if (g.console && g.console.log && $targetEl) { + g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); + } + }; + + for (i = 0; i < this.contents.length; i++) { + var info = this.contents[i]; + var hiddenClass = g.achecker.Wax.isElHidden(info.el) ? ' hidden_el' : ''; + var $item = doc.createElement('li'); + var key; + + $item.className = info.validStatus + ' ' + hiddenClass; + if (typeof info.content === 'string') { + $item.innerText = info.content; + $item.textContent = info.content; + } else { + $item.appendChild(info.content); + } + $item['data-el'] = info.el; + if (info.eventHandlers) { + for (key in info.eventHandlers) { + if (info.eventHandlers.hasOwnProperty(key)) { + addEvent($item, key, info.eventHandlers[key]); + } + } + } + if (info.validStatus === 'fail') { + hasError = true; + } else if (info.validStatus === 'warning') { + hasWarning = true; + } + addEvent($item, 'click', onClickItem); + $contentList.appendChild($item); + } + + var $section = doc.createElement('div'); + $section.className = 'waxSection'; + var $title = doc.createElement('h2'); + var $count = doc.createElement('span'); + $title.innerText = this.title + " "; + $title.textContent = this.title + " "; + $title.className = 'folded'; + if (hasError) { + $title.className += ' fail'; + } else if (hasWarning) { + $title.className += ' warning'; + } + $count.innerText = "(" + this.contents.length + ")"; + $count.textContent = "(" + this.contents.length + ")"; + $title.appendChild($count); + /* + var $titleLink = doc.createElement('a'); + $titleLink.setAttribute('target', '_blank'); + $titleLink.setAttribute('href', + 'http://html.nhncorp.com/a11y/guide.php?no='+ + this.title.split(' ')[0] + ''); + $titleLink.innerText = 'Guide'; + $titleLink.textContent = 'Guide'; + $title.appendChild($titleLink); + */ + $section.appendChild($title); + + if ($contentList.childNodes.length <= 0) { + var $emptyItem = doc.createElement('p'); + $emptyItem.className = 'comment'; + $emptyItem.innerText = this.emptyMessage; + $emptyItem.textContent = this.emptyMessage; + $section.appendChild($emptyItem); + } else { + $section.appendChild($contentList); + } + + addEvent($title, 'click', function (e) { + toggleFoldedClass(this); + }); + /* + addEvent($titleLink, 'click', function (e) { + e.stopPropagation(); + }); + */ + return $section; + }; + g.achecker.Wax.ListSection.prototype.getScore = function () { + var count = this.contents.length, + pass = 0; + + for (var i = 0; i < count; i++) { + if (this.contents[i].validStatus !== 'fail') { + pass++; + } + } + + return { + all: count, + pass: pass + }; + }; + + g.achecker.Wax.TableSection = g.achecker.Wax.Section; + g.achecker.Wax.TableSection = function (cwin, rdoc, title, targetSelector, + colInfo, isIncludeFrame, frameDocs, emptyMessage, + content, validStatus, eventHandlers) { + var this_ = this; + this.cwin = cwin; + this.rdoc = rdoc; + this.title = title; + this.colInfo = colInfo; + this.emptyMessage = emptyMessage; + this.contents = this._getContents(cwin, isIncludeFrame, frameDocs, + targetSelector, content, validStatus, eventHandlers); + }; + g.achecker.Wax.TableSection.prototype._getContentsFromDocument = function (doc, url, + targetSelector, content, validStatus, eventHandlers) { + var $target = doc.querySelectorAll(targetSelector); + var contents = [], i; + + for (i = 0; i < $target.length; i++) { + var $el = $target[i]; + var _content = typeof content === 'function' ? content.apply($el, [doc, url]) : content; + if (_content !== false) { + contents.push({ + el: $el, + doc: $el.ownerDocument, + validStatus: typeof validStatus === 'function' ? validStatus.apply($el, [doc, url]) : (typeof validStatus === 'string' ? validStatus : ''), + content: typeof content === 'function' ? content.apply($el, [doc, url]) : content, + eventHandlers: eventHandlers + }); + } + } + return contents; + }; + g.achecker.Wax.TableSection.prototype._getContents = function (win, isIncludeFrame, + frameDocs, targetSelector, content, validStatus, + eventHandlers) { + var contents = this._getContentsFromDocument(win.document, win.location.href, + targetSelector, content, validStatus, eventHandlers), i, l; + + if (isIncludeFrame) { + for (i = 0, l = frameDocs.length; i < l; i++) { + var _contents = this._getContentsFromDocument(frameDocs[i].doc, frameDocs[i].src, + targetSelector, content, validStatus, eventHandlers); + contents = contents.concat(_contents); + } + } + return contents; + }; + g.achecker.Wax.TableSection.prototype.getAsElement = function () { + var this_ = this; + var doc = this.rdoc; + var $table = doc.createElement('table'); + var $thead = doc.createElement('thead'); + var $theadTr = doc.createElement('tr'); + var hasWarning = false; + var hasError = false; + var i; + var onClickTr = function (e) { + if (parent.Firebug) { + parent.Firebug.Inspector.clearAllHighlights(); + } + + var $targetEl = this['data-el']; + var isHidden = g.achecker.Wax.isElHidden($targetEl); + if ($targetEl.tagName === 'TITLE') { + while ($targetEl) { + if ($targetEl.tagName === 'HTML') { + break; + } + $targetEl = $targetEl.parentNode; + } + } + + if (!isHidden) { + var oldTabindex = $targetEl.getAttribute('tabindex'); + $targetEl.setAttribute('tabindex', 0); + $targetEl.focus(); + if (oldTabindex === null) { + $targetEl.removeAttribute('tabindex'); + } else { + $targetEl.setAttribute('tabindex', oldTabindex); + } + } + if (parent.Firebug && $targetEl) { + parent.Firebug.Inspector.inspectFromContextMenu($targetEl); + // compatible with firebug 1.9.x + parent.Firebug.Inspector.highlightObject($targetEl, parent.Firebug.currentContext); + } else if (g.console && g.console.log && $targetEl) { + g.console.log('OpenWAX Info: ', Xpath.getElementXPath($targetEl)); + } + }; + + for (i = 0; i < this.colInfo.length; i++) { + var $theadTh = doc.createElement('th'); + $theadTh.setAttribute('scope', 'col'); + $theadTh.innerText = this.colInfo[i].label; + $theadTh.textContent = this.colInfo[i].label; + if (this.colInfo[i].width) { + $theadTh.style.width = this.colInfo[i].width + 'px'; + } + if (this.colInfo[i].minWidth) { + $theadTh.style.minWidth = this.colInfo[i].minWidth + 'px'; + } + if (this.colInfo[i].maxWidth) { + $theadTh.style.maxWidth = this.colInfo[i].maxWidth + 'px'; + } + if (this.colInfo[i].className) { + $theadTh.className = this.colInfo[i].className; + } + $theadTr.appendChild($theadTh); + } + $thead.appendChild($theadTr); + $table.appendChild($thead); + + var $tbody = doc.createElement('tbody'); + for (i = 0; i < this.contents.length; i++) { + var info = this.contents[i]; + var hiddenClass = g.achecker.Wax.isElHidden(info.el) ? ' hidden_el' : ''; + var $tr = doc.createElement('tr'); + var j, key; + + $tr.className = info.validStatus + ' ' + hiddenClass; + for (j in info.content) { + if (info.content.hasOwnProperty(j)) { + var _content = info.content[j]; + var $td = doc.createElement('td'); + if (typeof _content === 'string') { + $td.innerText = _content; + $td.textContent = _content; + $td.innerHTML = (_content + .replace(/</g, '<') + .replace(/>/g, '>') + ) + .replace(/\[__\[/g, '<span style="color:#777!important;text-decoration:line-through">') + .replace(/\]__\]/g, '</span>'); + } else { + $td.appendChild(_content); + } + if (this.colInfo[j].className) { + $td.className = this.colInfo[j].className; + } + $tr.appendChild($td); + } + } + $tr['data-el'] = info.el; + if (info.eventHandlers) { + for (key in info.eventHandlers) { + if (info.eventHandlers.hasOwnProperty(key)) { + addEvent($tr, key, info.eventHandlers[key]); + } + } + } + if (info.validStatus === 'fail') { + hasError = true; + } else if (info.validStatus === 'warning') { + hasWarning = true; + } + addEvent($tr, 'click', onClickTr); + $tbody.appendChild($tr); + $table.appendChild($tbody); + } + + var $section = doc.createElement('div'); + $section.className = 'waxSection'; + var $title = doc.createElement('h2'); + var $count = doc.createElement('span'); + $title.innerText = this.title + " "; + $title.textContent = this.title + " "; + $title.className = 'folded'; + if (hasError) { + $title.className += ' fail'; + } else if (hasWarning) { + $title.className += ' warning'; + } + $count.innerText = "(" + this.contents.length + ")"; + $count.textContent = "(" + this.contents.length + ")"; + $title.appendChild($count); + /* + var $titleLink = doc.createElement('a'); + $titleLink.setAttribute('target', '_blank'); + $titleLink.setAttribute('href', + 'http://html.nhncorp.com/a11y/guide.php?no='+ + this.title.split(' ')[0] + ''); + $titleLink.innerText = 'Guide'; + $titleLink.textContent = 'Guide'; + $title.appendChild($titleLink); + */ + $section.appendChild($title); + + if ($tbody.childNodes.length <= 0) { + var $emptyItem = doc.createElement('p'); + $emptyItem.className = 'comment'; + $emptyItem.innerText = this.emptyMessage; + $emptyItem.textContent = this.emptyMessage; + $section.appendChild($emptyItem); + } else { + $section.appendChild($table); + } + + addEvent($title, 'click', function (e) { + toggleFoldedClass(this); + }); + /* + addEvent($titleLink, 'click', function (e) { + e.stopPropagation(); + }); + */ + return $section; + }; + g.achecker.Wax.TableSection.prototype.getScore = function () { + var count = this.contents.length, + pass = 0; + + for (var i = 0; i < count; i++) { + if (this.contents[i].validStatus !== 'fail') { + pass++; + } + } + + return { + all: count, + pass: pass + }; + }; + + g.achecker.Wax.ToolSection = function (cwin, rdoc, id, title, content, eventHandlers) { + var this_ = this; + this.cwin = cwin; + this.rdoc = rdoc; + this.id = id; + this.title = title; + this.content = typeof content === 'function' ? content.apply(this, [this.cwin, this.rdoc]) : content; + this.eventHandlers = eventHandlers; + }; + g.achecker.Wax.ToolSection.prototype.getAsElement = function () { + var doc = this.rdoc; + + var $section = doc.createElement('div'); + $section.id = this.id; + $section.className = 'waxSection'; + var $title = doc.createElement('h2'); + $title.className = 'folded'; + $title.innerText = this.title; + $title.textContent = this.title; + /* + var $titleLink = doc.createElement('a'); + $titleLink.setAttribute('target', '_blank'); + $titleLink.setAttribute('href', + 'http://html.nhncorp.com/a11y/guide.php?no='+ + this.title.split(' ')[0] + ''); + $titleLink.innerText = 'Guide'; + $titleLink.textContent = 'Guide'; + $title.appendChild($titleLink); + */ + + var $content = doc.createElement('div'); + if (typeof this.content === 'string') { + $content.innerText = this.content; + $content.textContent = this.content; + } else { + $content.appendChild(this.content); + } + $section.appendChild($title); + $section.appendChild($content); + + $title.setAttribute('tabindex', 0); + addEvent($title, 'click', function (e) { + toggleFoldedClass(this); + }); + /* + addEvent($titleLink, 'click', function (e) { + e.stopPropagation(); + }); + */ + return $section; + }; + g.achecker.Wax.ToolSection.prototype.getScore = function () { + return null; + }; +}(window)); + +/*jslint browser: true */ +/*global chrome, Components, openDialog, XMLHttpRequest, FormData */ + +(function (global, document) { + "use strict"; + + var achecker = global.achecker || {}; + achecker.Wax = achecker.Wax || {}; + var addEvent = function (obj, type, fn) { + if (obj.addEventListener) { + obj.addEventListener(type, fn, false); + } else if (obj.attachEvent) { + obj["e" + type + fn] = fn; + obj[type + fn] = function () { + obj["e" + type + fn](global.event); + }; + obj.attachEvent("on" + type, obj[type + fn]); + } + }; + var ListSection = achecker.Wax.ListSection; + var TableSection = achecker.Wax.TableSection; + var ToolSection = achecker.Wax.ToolSection; + var getElsFromChildNodes = function (pEl, tagName) { + var els = [], i = 0; + if (pEl.length && pEl.push) { + for (i = 0; i < pEl.length; i++) { + els = els.concat(getElsFromChildNodes(pEl[i], tagName)); + } + return els; + } + var n = pEl.childNodes; + if (n && n.length) { + for (i = 0; i < n.length; i++) { + if (n[i].tagName && n[i].tagName.toLowerCase() === tagName.toLowerCase()) { + els.push(n[i]); + } + } + return els; + } + return []; + }; + var toggleFoldedClass = function (el) { + el.className = el.className === 'folded' ? '' : 'folded'; + + // fix bug: IE8 won't reflow when set data-* attribute + if (document && document.all) { + document.body.className = document.body.getAttribute('className'); + } + }; + + var getContrastRatio = function (color1, color2) { + var l1; // higher value + var l2; // lower value + var contrast; + var l1R, l1G, l1B, l2R, l2G, l2B; + + // error check, check if pound sign was put in field value + if (color2.indexOf('#') === 0) { + color2 = color2.substr(1, color2.length - 1); + } + if (color1.indexOf('#') === 0) { + color1 = color1.substr(1, color1.length - 1); + } + + //Linearised R (for example) = (R/FS)^2.2 where FS is full scale value (255 + //for 8 bit color channels). L1 is the higher value (of text or background) + //alert(parseInt("0x"+color1.substr(0, 2))); + //Math.pow(n,x); + l1R = parseInt(color1.substr(0, 2), 16) / 255; + if (l1R <= 0.03928) { + l1R = l1R / 12.92; + } else { + l1R = Math.pow(((l1R + 0.055) / 1.055), 2.4); + } + l1G = parseInt(color1.substr(2, 2), 16) / 255; + if (l1G <= 0.03928) { + l1G = l1G / 12.92; + } else { + l1G = Math.pow(((l1G + 0.055) / 1.055), 2.4); + } + l1B = parseInt(color1.substr(4, 2), 16) / 255; + if (l1B <= 0.03928) { + l1B = l1B / 12.92; + } else { + l1B = Math.pow(((l1B + 0.055) / 1.055), 2.4); + } + l2R = parseInt(color2.substr(0, 2), 16) / 255; + if (l2R <= 0.03928) { + l2R = l2R / 12.92; + } else { + l2R = Math.pow(((l2R + 0.055) / 1.055), 2.4); + } + l2G = parseInt(color2.substr(2, 2), 16) / 255; + if (l2G <= 0.03928) { + l2G = l2G / 12.92; + } else { + l2G = Math.pow(((l2G + 0.055) / 1.055), 2.4); + } + l2B = parseInt(color2.substr(4, 2), 16) / 255; + if (l2B <= 0.03928) { + l2B = l2B / 12.92; + } else { + l2B = Math.pow(((l2B + 0.055) / 1.055), 2.4); + } + //where L is luminosity and is defined as + l1 = (0.2126 * l1R) + (0.7152 * l1G) + (0.0722 * l1B); //using linearised R, G, and B value + l2 = (0.2126 * l2R) + (0.7152 * l2G) + (0.0722 * l2B); //using linearised R, G, and B value + //and L2 is the lower value. + l1 = l1 + 0.05; + l2 = l2 + 0.05; + if (l1 < l2) { + var temp = l1; + l1 = l2; + l2 = temp; + } + l1 = l1 / l2; + l1 = l1.toFixed(1); + return l1; + }; + + var getLabel = function (element) { + var currentLabel = ""; + var currentLabelElement; + var doc = element.ownerDocument; + var labelElement, labelChilds, i, l, _i, _l; + +labelLoop: + for (i = 0, l = doc.getElementsByTagName("label").length; i < l; i++) { + labelElement = doc.getElementsByTagName("label")[i]; + labelChilds = labelElement.childNodes; + + if (labelElement.htmlFor && labelElement.htmlFor === element.id) { + currentLabelElement = labelElement; + break labelLoop; + } + for (_i = 0, _l = labelChilds.length; _i < _l; _i++) { + if (labelChilds[_i] === element) { + currentLabelElement = labelElement; + break labelLoop; + } + } + } + + if (currentLabelElement) { + labelChilds = currentLabelElement.childNodes; + for (i = 0, l = labelChilds.length; i < l; i++) { + if (!labelChilds[i].tagName) { // check is text node + currentLabel += labelChilds[i].nodeValue.replace(/^\s+/, "").replace(/\s+$/, ""); + } + } + } + if (!currentLabel) { + if (element.title) { + currentLabel = element.title; + } else if (element.id) { + currentLabel = element.id; + } else if (element.name) { + currentLabel = element.name; + } else { + currentLabel = ""; + } + } + return currentLabel; + }; + + var getTextContent = function (el) { + var ELEMENT_NODE = 1; + var txt = ''; + var nodeType = el.nodeType; + var tagName = el.tagName ? el.tagName.toUpperCase() : ''; + var attrType = el.getAttribute ? el.getAttribute('type') : ''; + var styleDisplay; + + try { + var computedStyle = el.currentStyle || el.ownerDocument.defaultView.getComputedStyle(el, null); + styleDisplay = computedStyle.display; + } catch (e) { + styleDisplay = ""; + } + + if (nodeType === ELEMENT_NODE && + styleDisplay === 'none') { + txt += '[__['; + } + + if (nodeType === ELEMENT_NODE && + tagName === "IMG") { + txt += el.getAttribute('alt'); + } else if (nodeType === ELEMENT_NODE && + tagName === "AREA") { + txt += el.getAttribute('alt'); + } else if (nodeType === ELEMENT_NODE && + tagName === "INPUT" && + attrType === 'image') { + txt += el.getAttribute('alt'); + } else if (nodeType === ELEMENT_NODE && + tagName === "INPUT" && + (attrType === 'submit' || + attrType === 'reset' || + attrType === 'button')) { + txt += el.value; + } else if (nodeType === ELEMENT_NODE && + tagName === "INPUT") { + txt += getLabel(el); + } else if (nodeType === ELEMENT_NODE && + (tagName === "TEXTAREA" || tagName === "SELECT")) { + txt += getLabel(el); + } else if (nodeType !== ELEMENT_NODE || + (tagName !== "SCRIPT" && tagName !== "STYLE")) { + var cNodes = el.childNodes; + var TEXT_NODE = 3; + var i, l; + for (i = 0, l = cNodes.length; i < l; i++) { + if (cNodes[i].nodeType === TEXT_NODE) { + txt += cNodes[i].nodeValue; + } else { + txt += getTextContent(cNodes[i]); + } + } + } + + if (nodeType === ELEMENT_NODE && + styleDisplay === 'none') { + txt += ']__]'; + } + txt = txt ? txt.replace(/^\s+/, '').replace(/\s+$/, '') : ''; + return txt; + }; + + var getAbsolutePath = function (src, url) { + var newpath, orgPath; + + // remove url querystring + url = url.replace(/\?.*$/, ''); + + if (src && src.indexOf('//') === -1) { + if (src.substr(0, 3) === '../') { + newpath = url.substr(0, url.lastIndexOf('/') > 10 ? url.lastIndexOf('/') : url.length); + while (src.substr(0, 3) === '../') { + newpath = newpath.substr(0, newpath.lastIndexOf('/') > 10 ? newpath.lastIndexOf('/') : newpath.length); + src = src.substr(3); + } + src = newpath + '/' + src; + } else if (src.substr(0, 1) === '/') { + orgPath = url.replace(/^((?:https?\:\/\/|file\:\/\/\/)[^\/]+)\/.*$/, '$1'); + src = orgPath + '/' + src; + } else { + orgPath = url.substr(0, url.lastIndexOf('/')); + src = orgPath + '/' + src; + } + } + return src; + }; + + achecker.Wax.run = function (cwin, rdoc, isIncludeFrame, frameDocs, discardFrameUrls) { + return { + header: (function () { + var $div = rdoc.createElement('div'); + $div.className = 'waxFrames'; + + var $fold = rdoc.createElement('div'); + var $foldBtn = rdoc.createElement('button'); + + $fold.className = 'toggleAll'; + $foldBtn.className = 'fold'; + $foldBtn.setAttribute('data-folded', 'folded'); + $foldBtn.title = achecker.i18n.get('UnfoldAll'); + $foldBtn.setAttribute('type', 'button'); + $foldBtn.innerText = 'Toggle All'; + $foldBtn.textContent = 'Toggle All'; + $foldBtn.onclick = function () { + var $headings = rdoc.querySelectorAll('.waxSection h2,.waxFrames h2'); + var foldedClass = this.getAttribute('data-folded') === 'folded' ? '' : 'folded'; + var i, l; + + for (i = 0, l = $headings.length; i < l; i++) { + $headings[i].className = $headings[i].className.replace('folded', '') + ' ' + foldedClass; + } + + if (foldedClass) { + this.className = 'unfold'; + this.title = achecker.i18n.get('UnfoldAll'); + } else { + this.className = 'fold'; + this.title = achecker.i18n.get('FoldAll'); + } + this.setAttribute('data-folded', foldedClass); + // fix bug: IE8 won't reflow when set data-* attribute + rdoc.body.className = rdoc.body.getAttribute("className"); + }; + $fold.appendChild($foldBtn); + $div.appendChild($fold); + + var $title = rdoc.createElement('h2'); + $title.className = ''; + $title.innerText = achecker.i18n.get('TargetPage'); + $title.textContent = achecker.i18n.get('TargetPage'); + addEvent($title, 'click', function (e) { + toggleFoldedClass(this); + }); + var $pages = rdoc.createElement('ul'), $pageLink; + var $topPage = rdoc.createElement('li'); + var $topPageLink = rdoc.createElement('a'); + var i, l, $page; + + $topPageLink.setAttribute('href', cwin.location.href); + $topPageLink.setAttribute('target', '_blank'); + $topPageLink.innerText = cwin.location.href; + $topPageLink.textContent = cwin.location.href; + $topPage.appendChild($topPageLink); + $pages.appendChild($topPage); + if (isIncludeFrame) { + for (i = 0, l = frameDocs.length; i < l; i++) { + $page = rdoc.createElement('li'); + $pageLink = rdoc.createElement('a'); + $pageLink.setAttribute('href', frameDocs[i].src); + $pageLink.setAttribute('target', '_blank'); + $pageLink.innerText = frameDocs[i].src; + $pageLink.textContent = frameDocs[i].src; + $page.appendChild($pageLink); + $pages.appendChild($page); + } + } + $div.appendChild($title); + $div.appendChild($pages); + + if (discardFrameUrls && discardFrameUrls.length) { + $title = rdoc.createElement('h2'); + $title.innerText = achecker.i18n.get('NoneTargetPage'); + $title.textContent = achecker.i18n.get('NoneTargetPage'); + $title.className = 'folded'; + addEvent($title, 'click', function (e) { + toggleFoldedClass(this); + }); + $pages = rdoc.createElement('ul'); + for (i = 0, l = discardFrameUrls.length; i < l; i++) { + $page = rdoc.createElement('li'); + $pageLink = rdoc.createElement('a'); + $pageLink.setAttribute('href', discardFrameUrls[i]); + $pageLink.setAttribute('target', '_blank'); + $pageLink.innerText = discardFrameUrls[i]; + $pageLink.textContent = discardFrameUrls[i]; + $page.appendChild($pageLink); + $pages.appendChild($page); + } + } + $div.appendChild($title); + $div.appendChild($pages); + return $div; + }()), + sections: { + altText: new TableSection( + cwin, + rdoc, + '1. ' + achecker.i18n.get('No1') + ' (img)', + 'input[type=image],img,area', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Preview'), width: 106}, + {label: achecker.i18n.get('Element'), width: 45}, + {label: achecker.i18n.get('Contents')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function (doc, url) { + var tagName = this.tagName.toLowerCase(); + var data = { + hidden: '', + preview: '', + el: '', + alt: '' + }; + var self = this; + + var handleImg = function () { + var hasAlt = self.getAttribute('alt') !== null; + data.alt = rdoc.createElement('span'); + if (!hasAlt) { + data.alt.innerText = 'alt ' + achecker.i18n.get('Undefined'); + data.alt.textContent = 'alt ' + achecker.i18n.get('Undefined'); + } else if (!self.getAttribute('alt')) { + data.alt.innerText = 'alt=""'; + data.alt.textContent = 'alt=""'; + } else { + data.alt.innerText = self.getAttribute('alt'); + data.alt.textContent = self.getAttribute('alt'); + } + data.el = tagName; + + if (self.getAttribute('longdesc')) { + var $longdesc = rdoc.createElement('a'); + $longdesc.setAttribute('href', + getAbsolutePath(self.getAttribute('longdesc'), url)); + $longdesc.setAttribute('target', '_blank'); + $longdesc.innerText = 'longdesc link'; + $longdesc.textContent = 'longdesc link'; + data.alt.innerText += ' '; + data.alt.textContent += ' '; + data.alt.appendChild($longdesc); + } + + var src = self.getAttribute('src'); + + var $container = rdoc.createElement('div'); + $container.style.width = "100px"; + $container.style.margin = "0 auto"; + $container.style.overflow = "hidden"; + var $img = rdoc.createElement('img'); + $img.setAttribute('alt', ''); + $img.setAttribute('src', getAbsolutePath(src, url)); + $container.appendChild($img); + data.preview = $container; + + return [ + data.hidden, + data.preview, + data.el, + data.alt + ]; + }; + + switch (tagName) { + case "input": + if (this.type.toLowerCase() !== 'image') { + break; + } + return handleImg(); + + case "img": + return handleImg(); + + case "area": + var hasAlt = this.getAttribute('alt') !== null; + data.alt = rdoc.createElement('span'); + if (!hasAlt) { + data.alt.innerText = 'alt ' + achecker.i18n.get('Undefined'); + data.alt.textContent = 'alt ' + achecker.i18n.get('Undefined'); + } else if (!this.getAttribute('alt')) { + data.alt.innerText = 'alt=""'; + data.alt.textContent = 'alt=""'; + } else { + data.alt.innerText = this.getAttribute('alt'); + data.alt.textContent = this.getAttribute('alt'); + } + data.el = tagName; + + return [ + data.hidden, + data.preview, + data.el, + data.alt + ]; + } + + return false; + }, + function () { + var tagName = this.tagName; + switch (tagName) { + case "IMG": + case "INPUT": + case "AREA": + var hasAlt = this.getAttribute('alt') !== null; + + if (!hasAlt) { + return 'fail'; + } + if (!this.getAttribute('alt')) { + return 'warning'; + } + return 'pass'; + } + } + ), + + altTextBG: new TableSection( + cwin, + rdoc, + '1. ' + achecker.i18n.get('No1') + ' (bg)', + 'body *', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Preview'), width: 106}, + {label: achecker.i18n.get('Contents')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function (doc, url) { + var data = { + hidden: '', + preview: '', + content: '' + }; + var computedStyle = this.currentStyle || cwin.getComputedStyle(this, null); + var bgImage = computedStyle.backgroundImage; + if (bgImage !== 'none' && + this.getElementsByTagName('*').length < 10) { + var $bg = rdoc.createElement('span'); + url = bgImage.replace(/^url\("?/, '').replace(/"?\)$/, ''); + + try { + $bg.style.backgroundImage = bgImage; + $bg.style.backgroundPosition = computedStyle.backgroundPosition; + $bg.style.backgroundRepeat = computedStyle.backgroundRepeat; + $bg.style.width = computedStyle.width; + $bg.style.height = computedStyle.height; + } catch (e) { + } + $bg.style.maxWidth = '100px'; + $bg.style.maxHeight = '200px'; + $bg.style.display = 'inline-block'; + $bg.style.overflow = 'hidden'; + + data.preview = $bg; + data.content = getTextContent(this); + + return [ + data.hidden, + data.preview, + data.content + ]; + } + + return false; + } + ), + + altTextEmbed: new TableSection( + cwin, + rdoc, + '1. ' + achecker.i18n.get('No1') + ' (object)', + 'object,embed,video,audio,canvas,svg', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Element')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function (doc, url) { + var tagName = this.tagName; + switch (tagName) { + case "OBJECT": + if (this.parentNode && this.parentNode.tagName && + (this.parentNode.tagName === 'OBJECT' || + this.parentNode.tagName === 'EMBED')) { + return false; + } + return [ + '', + '<object>' + ]; + case "EMBED": + if (this.parentNode && this.parentNode.tagName && + (this.parentNode.tagName === 'OBJECT' || + this.parentNode.tagName === 'EMBED')) { + return false; + } + return [ + '', + '<embed>' + ]; + } + + return false; + } + ), + + contrast: new ToolSection( + cwin, + rdoc, + 'contrast', + '5. ' + achecker.i18n.get('No5'), + function (win, rdoc) { + if (!achecker.colorInspector) { + var $res = rdoc.createElement('p'); + $res.className = 'comment'; + $res.innerText = 'Not Supported.'; + $res.textContent = 'Not Supported.'; + return $res; + } + + var $ul = rdoc.createElement('ul'); + $ul.className = 'contrast'; + var $color1 = rdoc.createElement('li'); + var $color2 = rdoc.createElement('li'); + var $result = rdoc.createElement('li'); + + $color1.className = 'color1'; + var $color1_label = rdoc.createElement('span'); + $color1_label.innerText = achecker.i18n.get('Foreground') + ': '; + $color1_label.textContent = achecker.i18n.get('Foreground') + ': '; + var $color1_color = rdoc.createElement('span'); + $color1_color.className = 'color'; + $color1_color.style.backgroundColor = '#000'; + var $color1_val = rdoc.createElement('span'); + $color1_val.className = 'val'; + $color1_val.innerText = '#000000'; + $color1_val.textContent = '#000000'; + var $color1_btn = rdoc.createElement('button'); + $color1_btn.innerText = achecker.i18n.get('SelectForegroundColor'); + $color1_btn.textContent = achecker.i18n.get('SelectForegroundColor'); + $color1.appendChild($color1_label); + $color1.appendChild($color1_color); + $color1.appendChild(rdoc.createTextNode(' ')); + $color1.appendChild($color1_val); + $color1.appendChild(rdoc.createTextNode(' ')); + $color1.appendChild($color1_btn); + $color1.onclick = function () { + achecker.showOverlay(); + achecker.colorInspector.startInspect(function (color) { + achecker.hideOverlay(); + $color1.getElementsByClassName('color')[0].style.backgroundColor = color; + $color1.getElementsByClassName('val')[0].innerText = color; + $color1.getElementsByClassName('val')[0].textContent = color; + var contrastRatio = getContrastRatio(color, $color2.getElementsByClassName('val')[0].innerText); + if (contrastRatio >= 4.5) { + $result.className = 'pass'; + } else if (contrastRatio >= 3) { + $result.className = 'warning'; + } else { + $result.className = 'fail'; + } + $result.getElementsByClassName('result')[0].innerText = contrastRatio + ':1'; + $result.getElementsByClassName('result')[0].textContent = contrastRatio + ':1'; + $result.getElementsByClassName('resultText')[0].style.color = color; + }); + }; + + $color2.className = 'color2'; + var $color2_label = rdoc.createElement('span'); + $color2_label.innerText = achecker.i18n.get('Background') + ': '; + $color2_label.textContent = achecker.i18n.get('Background') + ': '; + var $color2_color = rdoc.createElement('span'); + $color2_color.className = 'color'; + $color2_color.style.backgroundColor = '#FFF'; + var $color2_val = rdoc.createElement('span'); + $color2_val.className = 'val'; + $color2_val.innerText = '#FFFFFF'; + $color2_val.textContent = '#FFFFFF'; + var $color2_btn = rdoc.createElement('button'); + $color2_btn.innerText = achecker.i18n.get('SelectBackgroundColor'); + $color2_btn.textContent = achecker.i18n.get('SelectBackgroundColor'); + $color2.appendChild($color2_label); + $color2.appendChild($color2_color); + $color2.appendChild(rdoc.createTextNode(' ')); + $color2.appendChild($color2_val); + $color2.appendChild(rdoc.createTextNode(' ')); + $color2.appendChild($color2_btn); + $color2.onclick = function () { + achecker.showOverlay(); + achecker.colorInspector.startInspect(function (color) { + achecker.hideOverlay(); + $color2.getElementsByClassName('color')[0].style.backgroundColor = color; + $color2.getElementsByClassName('val')[0].innerText = color; + $color2.getElementsByClassName('val')[0].textContent = color; + var contrastRatio = getContrastRatio(color, $color1.getElementsByClassName('val')[0].innerText); + if (contrastRatio >= 4.5) { + $result.className = 'pass'; + } else if (contrastRatio >= 3) { + $result.className = 'warning'; + } else { + $result.className = 'fail'; + } + $result.getElementsByClassName('result')[0].innerText = contrastRatio + ':1'; + $result.getElementsByClassName('result')[0].textContent = contrastRatio + ':1'; + $result.getElementsByClassName('resultText')[0].style.backgroundColor = color; + }); + }; + + $result.className = 'pass'; + var $result_label = rdoc.createElement('span'); + $result_label.innerText = achecker.i18n.get('Result') + ': '; + $result_label.textContent = achecker.i18n.get('Result') + ': '; + var $result_result = rdoc.createElement('span'); + $result_result.className = 'result'; + $result_result.innerText = '21:1'; + $result_result.textContent = '21:1'; + var $result_resultText = rdoc.createElement('span'); + $result_resultText.className = 'resultText'; + $result_resultText.innerText = achecker.i18n.get('Test'); + $result_resultText.textContent = achecker.i18n.get('Test'); + $result.appendChild($result_label); + $result.appendChild($result_result); + $result.appendChild(rdoc.createTextNode(' ')); + $result.appendChild($result_resultText); + + $ul.appendChild($color1); + $ul.appendChild($color2); + $ul.appendChild($result); + + return $ul; + } + ), + + kbdFocus: new TableSection( + cwin, + rdoc, + '8. ' + achecker.i18n.get('No8'), + '*', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('ErrorType'), width: 65}, + {label: achecker.i18n.get('Contents')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('RequireConfirmation'), + function (doc, url) { + try { + var evtWrapper = this.wrappedJSObject || this; + var hasBlurEvent = false; + if (evtWrapper.onfocus && evtWrapper.onfocus.toString().indexOf('blur()') > -1) { + hasBlurEvent = true; + } else if (evtWrapper.onclick && evtWrapper.onclick.toString().indexOf('blur()') > -1) { + hasBlurEvent = true; + } + var outlineWidth = this.style.getPropertyValue('outline-width'); + var zeroOutlineWidth = outlineWidth === '0' || outlineWidth === '0pt' || outlineWidth === '0px'; + + if (hasBlurEvent) { + return [ + '', + 'blur()', + getTextContent(this) + ]; + } + if (zeroOutlineWidth) { + return [ + '', + 'outline:0', + getTextContent(this) + ]; + } + return false; + } catch (e) { + return false; + } + }, + function (doc, url) { + try { + var evtWrapper = this.wrappedJSObject || this; + var hasBlurEvent = evtWrapper.onfocus ? + evtWrapper.onfocus.toString().indexOf('blur()') > -1 : false; + var outlineWidth = this.style.getPropertyValue('outline-width'); + var zeroOutlineWidth = outlineWidth === '0' || outlineWidth === '0pt' || outlineWidth === '0px'; + + if (hasBlurEvent) { + return 'fail'; + } + if (zeroOutlineWidth) { + return 'fail'; + } + return 'pass'; + } catch (e) { + return false; + } + } + ), + + skipNav: new TableSection( + cwin, + rdoc, + '12. ' + achecker.i18n.get('No12'), + 'a[href^="#"]', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('No'), width: 65}, + {label: achecker.i18n.get('Contents')}, + {label: achecker.i18n.get('Connected'), width: 45} + ], + isIncludeFrame, + frameDocs, + '-', + function (doc, url) { + if (cwin.document !== doc) { + return false; + } + + var href = this.getAttribute('href'); + var isConnectedLink = href === '#' ? false : + !!doc.getElementById(href.replace('#', '')) || + doc.getElementsByName(href.replace('#', '')).length > 0; + var linkIdx, i, l; + + for (i = 0, l = doc.getElementsByTagName('a').length; i < l; i++) { + if (doc.getElementsByTagName('a')[i] === this) { + linkIdx = i + 1; + if (linkIdx > 20) { + return false; + } + + break; + } + } + + return [ + '', + linkIdx + achecker.i18n.get('ThLink'), + '(' + href + ') ' + getTextContent(this), + (isConnectedLink ? 'O' : 'X') + ]; + }, + function (doc, url) { + var href = this.getAttribute('href'); + var isConnectedLink = href === '#' ? false : + !!doc.getElementById(href.replace('#', '')) || + doc.getElementsByName(href.replace('#', '')).length > 0; + return isConnectedLink ? 'pass' : 'fail'; + } + ), + + pageTitle: new ListSection( + cwin, + rdoc, + '13. ' + achecker.i18n.get('No13') + '(<title>)', + 'title', + null, + isIncludeFrame, + frameDocs, + '-', + function (doc, url) { + var $res = rdoc.createElement('span'); + var $val = rdoc.createElement('strong'); + var val = this.textContent || this.innerText || achecker.i18n.get('NoPageTitle'); + + $res.innerText = url + ': '; + $res.textContent = url + ': '; + $val.innerText = val; + $val.textContent = val; + $res.appendChild($val); + + return $res; + }, + function () { + var title = this.textContent || this.innerText || ''; + var dupCharacters = [ + '::', '||', '--', '@@', '##', '$$', '%%', '&&', '**', '((', '))', '++', '==', '~~', + ';;', '<<', '>>', '[[', ']]', '★★', '☆☆', '◎◎', '●●', '◆◆', '◇◇', '□□', '■■', '△△', + '▲▲', '▽▽', '▼▼', '◁◁', '◀◀', '▷▷', '▶▶', '♠♠', '♤♤', '♡♡', '♥♥', '♧♧', '♣♣', '⊙⊙', + '◈◈', '▣▣', '◐◐', '◑◑', '▒▒', '▤▤', '▥▥', '▨▨', '▧▧', '▦▦', '▩▩', '♨♨', '☏☏', '☎☎' + ]; + var hasTitle = !!title; + var hasSpecialCharactersDup = false; + for (var i = 0; i < dupCharacters.length; i++) { + if (title.indexOf(dupCharacters[i]) > -1) { + hasSpecialCharactersDup = true; + break; + } + } + + return hasTitle && !hasSpecialCharactersDup ? 'pass' : 'fail'; + } + ), + + frame: new TableSection( + cwin, + rdoc, + '13. ' + achecker.i18n.get('No13') + '(frame)', + 'iframe', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Element'), width: 45}, + {label: achecker.i18n.get('Title'), minWidth: 50, className: 'lt'}, + {label: achecker.i18n.get('Contents'), maxWidth: 200} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function () { + var data = { + hidden: '', + el: '', + title: '', + url: '' + }; + var src = this.getAttribute('src'); + var title = this.getAttribute('title'); + data.el = 'iframe'; + + if (src) { + var $a = rdoc.createElement('a'); + $a.setAttribute('href', src); + $a.setAttribute('target', '_blank'); + $a.innerText = src; + $a.textContent = src; + data.url = $a; + } else { + data.url = achecker.i18n.get('NoSrc'); + } + data.title = title || achecker.i18n.get('NoTitle'); + return [ + data.hidden, + data.el, + data.title, + data.url + ]; + }, + function () { + var title = this.getAttribute('title'); + return title ? 'pass' : 'fail'; + } + ), + + blockTitle: new TableSection( + cwin, + rdoc, + '13. ' + achecker.i18n.get('No13') + '(<h1>~<h6>)', + 'h1,h2,h3,h4,h5,h6', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Element'), width: 45}, + {label: achecker.i18n.get('Contents')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('RequireConfirmation'), + function () { + return [ + '', + this.tagName.toLowerCase(), + getTextContent(this) + ]; + } + ), + + linkText: new TableSection( + cwin, + rdoc, + '14. ' + achecker.i18n.get('No14'), + 'a,area', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Element'), width: 45}, + {label: achecker.i18n.get('Contents')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function () { + var text = getTextContent(this); + var title = this.getAttribute('title'); + + return [ + '', + this.tagName.toLowerCase(), + (text || '-') + + (title ? ' (title: ' + title + ')' : '') + ]; + }, + function () { + var text = getTextContent(this); + + return text ? 'pass' : 'fail'; + } + ), + + pageLang: new ListSection( + cwin, + rdoc, + '15. ' + achecker.i18n.get('No15'), + 'html', + null, + isIncludeFrame, + frameDocs, + '-', + function (doc, url) { + var isXhtml = this.getAttribute('xmlns'); + var val = ''; + var $res = rdoc.createElement('span'); + + // ignore if protocol is not http(s)? or .html extension + if (url.substr(0, 4).toLowerCase() !== 'http' && + url.substr(-5).toLowerCase() !== '.html') { + return false; + } + if (isXhtml && this.getAttribute('xml:lang') && this.getAttribute('lang')) { + val = 'xml:lang=' + this.getAttribute('xml:lang') + ', lang=' + this.getAttribute('lang'); + } else if (isXhtml && this.getAttribute('xml:lang')) { + val = 'xml:lang=' + this.getAttribute('xml:lang'); + } else if (isXhtml && this.getAttribute('lang')) { + val = 'xml:lang=' + achecker.i18n.get('None') + ', lang=' + this.getAttribute('lang'); + } else if (!isXhtml && this.getAttribute('lang')) { + val = 'lang=' + this.getAttribute('lang'); + } else { + val = achecker.i18n.get('NoMainLang'); + } + $res.innerText = url + ': '; + $res.textContent = url + ': '; + + var $val = rdoc.createElement('strong'); + $val.innerText = val; + $val.textContent = val; + $res.appendChild($val); + return $res; + }, + function (doc, url) { + var isXhtml = this.getAttribute('xmlns'); + + if (isXhtml && this.getAttribute('xml:lang')) { + return 'pass'; + } + if (isXhtml && this.getAttribute('lang')) { + return 'warning'; + } + if (!isXhtml && this.getAttribute('lang')) { + return 'pass'; + } + return 'fail'; + } + ), + + unintendedFunction: new TableSection( + cwin, + rdoc, + '16. ' + achecker.i18n.get('No16'), + 'a,area,input,button', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Event'), width: 80}, + {label: achecker.i18n.get('Contents'), className: 'lt'}, + {label: achecker.i18n.get('TitleAttribute')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('RequireConfirmation'), + function (doc, url) { + var data = { + hidden: '', + event: '', + content: '', + title: '' + }; + var evtWrapper = this.wrappedJSObject || this; + var hasChangeEvent; + var hasWindowOpenEvent; + + try { + hasWindowOpenEvent = evtWrapper.onclick ? + evtWrapper.onclick.toString().indexOf('window.open') > -1 : false; + } catch (e) { + hasWindowOpenEvent = null; + } + + data.content = getTextContent(this); + if (this.getAttribute('title')) { + data.title = this.getAttribute('title'); + } else if (this.getAttribute('target') === '_blank') { + data.title = 'target="_blank"'; + } else { + data.title = '-'; + } + + if (hasWindowOpenEvent) { + data.event = 'window.open'; + } else { + return false; + } + + return [ + data.hidden, + data.event, + data.content, + data.title + ]; + }, + function () { + if (this.getAttribute('title')) { + return 'warning'; + } + if (this.getAttribute('target') === '_blank') { + return 'pass'; + } + return 'fail'; + } + ), + + tableTitle: new TableSection( + cwin, + rdoc, + '18. ' + achecker.i18n.get('No18') + '(caption, summary)', + 'table', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('CaptionContent'), className: 'lt'}, + {label: achecker.i18n.get('SummaryContent')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function () { + var childNodes = this.childNodes, + $caption = null, + data = { + hidden: '', + caption: '', + summary: '' + }, + i, + l; + for (i = 0; i < childNodes.length; i++) { + if (childNodes[i].tagName && + childNodes[i].tagName.toLowerCase() === 'caption') { + $caption = childNodes[i]; + break; + } + } + var hasCaption = !!$caption; + var hasSummary = !!this.getAttribute('summary'); + + data.caption = hasCaption ? getTextContent($caption) : achecker.i18n.get('None'); + data.summary = hasSummary ? this.getAttribute('summary') : achecker.i18n.get('None'); + + return [ + data.hidden, + data.caption, + data.summary + ]; + }, + function () { + var childNodes = this.childNodes, + $caption = null, + i, + l; + for (i = 0; i < childNodes.length; i++) { + if (childNodes[i].tagName && + childNodes[i].tagName.toLowerCase() === 'caption') { + $caption = childNodes[i]; + break; + } + } + var hasCaption = !!$caption; + var hasSummary = !!this.getAttribute('summary'); + + if (hasCaption) { + return 'pass'; + } else if (!hasCaption && !hasSummary) { + return 'warning'; + } else { + return 'fail'; + } + } + ), + + tableStructure: new TableSection( + cwin, + rdoc, + '18. ' + achecker.i18n.get('No18') + '(th)', + 'table', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Structure'), className: 'tb_str'} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function () { + var data = { + hidden: '', + structure: '' + }; + var $thead = getElsFromChildNodes(this, 'thead'); + var $tfoot = getElsFromChildNodes(this, 'tfoot'); + var $tbody = getElsFromChildNodes(this, 'tbody'); + var $theadTh = getElsFromChildNodes( + getElsFromChildNodes($thead, 'tr'), + 'th' + ); + var $tfootTh = getElsFromChildNodes( + getElsFromChildNodes($tfoot, 'tr'), + 'th' + ); + var $tbodyTh = getElsFromChildNodes( + getElsFromChildNodes($tbody, 'tr'), + 'th' + ).concat( + getElsFromChildNodes( + getElsFromChildNodes(this, 'tr'), + 'th' + ) + ); + var hasTh = !!$theadTh.length || !!$tfootTh.length || $tbodyTh.length; + var $resultTable = rdoc.createElement('table'); + var $resultThead = rdoc.createElement('thead'); + var $resultTbody = rdoc.createElement('tbody'); + var $resultTheadTr = rdoc.createElement('tr'); + var $resultTheadTh1 = rdoc.createElement('th'); + var $resultTheadTh2 = rdoc.createElement('th'); + var $resultTheadTh3 = rdoc.createElement('th'); + $resultTheadTh1.innerText = '요소'; + $resultTheadTh1.textContent = '요소'; + $resultTheadTh2.innerText = '유무'; + $resultTheadTh2.textContent = '유무'; + $resultTheadTh3.innerText = '제목셀 정보 (scope 속성값)'; + $resultTheadTh3.textContent = '제목셀 정보 (scope 속성값)'; + $resultTheadTr.appendChild($resultTheadTh1); + $resultTheadTr.appendChild($resultTheadTh2); + $resultTheadTr.appendChild($resultTheadTh3); + $resultThead.appendChild($resultTheadTr); + $resultTable.appendChild($resultThead); + $resultTable.appendChild($resultTbody); + + var $resultTr = rdoc.createElement('tr'); + var $resultTd1 = rdoc.createElement('td'); + var $resultTd2 = rdoc.createElement('td'); + var $resultTd3 = rdoc.createElement('td'); + var $resultTd3Ul; + var i, l; + var $th; + var scope; + var $infoItem; + + if ($thead.length) { + $resultTd3Ul = rdoc.createElement('ul'); + $resultTd1.innerText = 'thead'; + $resultTd1.textContent = 'thead'; + $resultTd2.innerText = 'O'; + $resultTd2.textContent = 'O'; + for (i = 0, l = $theadTh.length; i < l; i++) { + $th = $theadTh[i]; + scope = $th.getAttribute('scope'); + $infoItem = rdoc.createElement('li'); + + $infoItem.innerText = getTextContent($th) + + (!!scope ? '(' + scope + ')' : '(X)'); + $infoItem.textContent = getTextContent($th) + + (!!scope ? '(' + scope + ')' : '(X)'); + $resultTd3Ul.appendChild($infoItem); + } + $resultTd3.appendChild($resultTd3Ul); + } else { + $resultTd1.innerText = 'thead'; + $resultTd1.textContent = 'thead'; + $resultTd2.innerText = 'X'; + $resultTd2.textContent = 'X'; + $resultTd3.innerText = '-'; + $resultTd3.textContent = '-'; + } + $resultTr.appendChild($resultTd1); + $resultTr.appendChild($resultTd2); + $resultTr.appendChild($resultTd3); + $resultTbody.appendChild($resultTr); + + $resultTr = rdoc.createElement('tr'); + $resultTd1 = rdoc.createElement('td'); + $resultTd2 = rdoc.createElement('td'); + $resultTd3 = rdoc.createElement('td'); + if ($tfoot.length) { + $resultTd3Ul = rdoc.createElement('ul'); + $resultTd1.innerText = 'tfoot'; + $resultTd1.textContent = 'tfoot'; + $resultTd2.innerText = 'O'; + $resultTd2.textContent = 'O'; + for (i = 0, l = $tfootTh.length; i < l; i++) { + $th = $tfootTh[i]; + scope = $th.getAttribute('scope'); + $infoItem = rdoc.createElement('li'); + + $infoItem.innerText = getTextContent($th) + + (!!scope ? '(' + scope + ')' : '(X)'); + $infoItem.textContent = getTextContent($th) + + (!!scope ? '(' + scope + ')' : '(X)'); + $resultTd3Ul.appendChild($infoItem); + } + $resultTd3.appendChild($resultTd3Ul); + } else { + $resultTd1.innerText = 'tfoot'; + $resultTd1.textContent = 'tfoot'; + $resultTd2.innerText = 'X'; + $resultTd2.textContent = 'X'; + $resultTd3.innerText = '-'; + $resultTd3.textContent = '-'; + } + $resultTr.appendChild($resultTd1); + $resultTr.appendChild($resultTd2); + $resultTr.appendChild($resultTd3); + $resultTbody.appendChild($resultTr); + + $resultTr = rdoc.createElement('tr'); + $resultTd1 = rdoc.createElement('td'); + $resultTd2 = rdoc.createElement('td'); + $resultTd3 = rdoc.createElement('td'); + if ($tbody.length) { + $resultTd3Ul = rdoc.createElement('ul'); + $resultTd1.innerText = 'tbody'; + $resultTd1.textContent = 'tbody'; + $resultTd2.innerText = 'O'; + $resultTd2.textContent = 'O'; + for (i = 0, l = $tbodyTh.length; i < l; i++) { + $th = $tbodyTh[i]; + scope = $th.getAttribute('scope'); + $infoItem = rdoc.createElement('li'); + + $infoItem.innerText = getTextContent($th) + + (!!scope ? '(' + scope + ')' : '(X)'); + $infoItem.textContent = getTextContent($th) + + (!!scope ? '(' + scope + ')' : '(X)'); + $resultTd3Ul.appendChild($infoItem); + } + $resultTd3.appendChild($resultTd3Ul); + } else { + $resultTd1.innerText = 'tbody'; + $resultTd1.textContent = 'tbody'; + $resultTd2.innerText = 'X'; + $resultTd2.textContent = 'X'; + $resultTd3.innerText = '-'; + $resultTd3.textContent = '-'; + } + $resultTr.appendChild($resultTd1); + $resultTr.appendChild($resultTd2); + $resultTr.appendChild($resultTd3); + $resultTbody.appendChild($resultTr); + + data.structure = $resultTable; + + return [ + data.hidden, + data.structure + ]; + }, + function () { + var $theadTh = getElsFromChildNodes( + getElsFromChildNodes( + getElsFromChildNodes(this, 'thead'), + 'tr' + ), + 'th' + ); + var $tfootTh = getElsFromChildNodes( + getElsFromChildNodes( + getElsFromChildNodes(this, 'tfoot'), + 'tr' + ), + 'th' + ); + var $tbodyTh = getElsFromChildNodes( + getElsFromChildNodes( + getElsFromChildNodes(this, 'tbody'), + 'tr' + ), + 'th' + ).concat( + getElsFromChildNodes( + getElsFromChildNodes(this, 'tr'), + 'th' + ) + ); + var hasTh = $theadTh.length || $tfootTh.length || $tbodyTh.length; + var hasScope = function ($ths) { + var i, l; + for (i = 0, l = $ths.length; i < l; i++) { + if (!$ths[i].getAttribute('scope')) { + return false; + } + } + return true; + }; + + if (hasTh && hasScope($theadTh) && hasScope($tfootTh) && + hasScope($tbodyTh)) { + return 'pass'; + } else if (!hasTh && !$theadTh.length && !$tfootTh.length) { + return 'warning'; + } else { + return 'fail'; + } + } + ), + + label: new TableSection( + cwin, + rdoc, + '19. ' + achecker.i18n.get('No19'), + 'input,textarea,select', + [ {label: achecker.i18n.get('Hidden'), width: 45}, + {label: achecker.i18n.get('Element'), width: 45}, + {label: achecker.i18n.get('FormType'), width: 66}, + {label: achecker.i18n.get('LabelConnection'), className: 'lt'}, + {label: achecker.i18n.get('TitleAttribute')} + ], + isIncludeFrame, + frameDocs, + achecker.i18n.get('NotApplicable'), + function (doc, url) { + var typeAttr = this.getAttribute('type') ? this.getAttribute('type').toLowerCase() : null; + if (this.tagName === 'INPUT' && + (typeAttr === 'submit' || + typeAttr === 'button' || + typeAttr === 'image' || + typeAttr === 'hidden' || + typeAttr === 'reset')) { + return false; + } + + var data = { + hidden: '', + el: '', + type: '', + label: '', + title: '' + }; + var _id = this.getAttribute('id'); + var $labels = doc.getElementsByTagName("label"); + var hasLabelElement = false, + $label = null, + i, + l; + + if (_id) { + for (i = 0, l = $labels.length; i < l; i++) { + if ($labels[i].getAttribute('for') === _id) { + hasLabelElement = true; + $label = $labels[i]; + break; + } + } + } + var hasTitle = !!this.getAttribute('title'); + + var hasImplicitLabel = false; + var parentEl = this.parentNode; + do { + parentEl = parentEl.parentNode; + if (parentEl.tagName === 'LABEL') { + hasImplicitLabel = true; + $label = parentEl; + break; + } + } while (parentEl.parentNode); + + data.el = this.tagName.toLowerCase(); + data.type = typeAttr || '-'; + data.label = $label ? getTextContent($label) : ''; + if (!data.label) { + data.label = 'X'; + } + data.title = this.getAttribute('title'); + if (!data.title) { + data.title = '-'; + } + + return [ + data.hidden, + data.el, + data.type, + data.label, + data.title + ]; + }, + function (doc, url) { + var _id = this.getAttribute('id'); + var $labels = doc.getElementsByTagName("label"); + var hasLabelElement = false, i, l; + if (_id) { + for (i = 0, l = $labels.length; i < l; i++) { + if ($labels[i].getAttribute('for') === _id) { + hasLabelElement = true; + break; + } + } + } + var hasTitle = !!this.getAttribute('title'); + var hasImplicitLabel = false; + var parentEl = this.parentNode; + do { + parentEl = parentEl.parentNode; + + if (parentEl.tagName === 'LABEL') { + hasImplicitLabel = true; + } + } while (parentEl.parentNode); + + if (hasLabelElement) { + return 'pass'; + } + if (hasImplicitLabel) { + return 'pass'; + } + if (hasTitle) { + return 'warning'; + } + return 'fail'; + } + ), + + validation: new ToolSection( + cwin, + rdoc, + 'w3c_validation', + '21. ' + achecker.i18n.get('No21'), + function (win, rdoc) { + var isChromeAddon = typeof chrome === "object" && chrome.extension; + var isFirefoxAddon = typeof Components === "object" && Components.classes; + if (!isChromeAddon && !isFirefoxAddon) { + var $res = rdoc.createElement('p'); + $res.className = 'comment'; + $res.innerText = 'Not Supported.'; + $res.textContent = 'Not Supported.'; + return $res; + } + + var filterValidationResult = function (res) { + var msgs = res.messages, newmsgs = []; + var filters = [ + // /^unterminated comment: .*/, + // /^literal is missing closing delimiter.*/, + // /^unknown declaration type .*/, + /^document type does not allow element .* here; missing one of .* start\-tag.*/, + // /^end tag for .* omitted, but its declaration does not permit this.*/, + /^end tag for .* which is not finished.*/, + /^end tag for element .* which is not open.*/, + // /^an attribute value must be a literal unless it contains only name characters.*/, + // /^an attribute value literal can occur in an attribute specification list only after a VI delimiter.*/, + // /^normalized length of attribute value literal must not exceed.*/, + // /^syntax of attribute value does not conform to declared value.*/, + // /^value of attribute .* must be a single token.*/, + // /^value of attribute .* cannot be .*; must be one of .*/, + // /^invalid comment declaration:.*/, + /^ID .* already defined.*/, + // /^no document type declaration; will parse without validation.*/, + /^unclosed start-tag requires SHORTTAG YES.*/, + /^unclosed end-tag requires SHORTTAG YES.*/, + // /^DTD did not contain element declaration for document type name.*/, + /^empty start-tag.*/, + /^empty end-tag.*/ + // /^no document type declaration; implying .*/, + // /^no system id specified.*/, + // /^.* separator in comment declaration.*/, + ]; + var i, j; + + for (i = 0; i < msgs.length; i++) { + if (msgs[i].type === 'error') { + for (j = 0; j < filters.length; j++) { + if (filters[j].test(msgs[i].message)) { + newmsgs.push(msgs[i]); + break; + } + } + } + } + + res.messages = newmsgs; + return res; + }; + + var getResultDetailEl = function (messages, url) { + var $res = rdoc.createElement('div'); + $res.className = 'validationResult'; + var $errhead = rdoc.createElement('h3'); + $errhead.innerText = 'Error'; + $errhead.textContent = 'Error'; + $errhead.className = 'fail'; + var $errul = rdoc.createElement('ul'); + var $warninghead = rdoc.createElement('h3'); + $warninghead.innerText = 'Warning'; + $warninghead.textContent = 'Warning'; + $warninghead.className = 'warning'; + var $warningul = rdoc.createElement('ul'); + var onClickMessageLink = function (e) { + e.preventDefault(); + e.stopPropagation(); + openDialog("chrome://global/content/viewSource.xul", + "achecker_sourceView", + "scrollbars,resizable,chrome,dialog=no", + url, null, null, this.getAttribute('data-line'), + false); + }, i; + + for (i = 0; i < messages.length; i++) { + var msg = messages[i]; + var $li = rdoc.createElement('li'); + var $msg = rdoc.createElement('div'); + var $msga = rdoc.createElement('a'); + $msga.innerText = msg.message; + $msga.textContent = msg.message; + $msga.setAttribute('href', '#'); + $msga.setAttribute('data-line', msg.lastLine); + addEvent($msga, 'click', onClickMessageLink); + $msg.appendChild($msga); + var $subinfo = rdoc.createElement('div'); + $subinfo.className = 'subinfo'; + $subinfo.innerText = msg.lastLine + ' line, ' + msg.lastColumn + ' column'; + $subinfo.textContent = msg.lastLine + ' line, ' + msg.lastColumn + ' column'; + $li.appendChild($msg); + $li.appendChild($subinfo); + switch (msg.type) { + case 'error': + $errul.appendChild($li); + break; + case 'info': + $warningul.appendChild($li); + break; + } + } + $res.appendChild($errhead); + $res.appendChild($errul); + $res.appendChild($warninghead); + $res.appendChild($warningul); + 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(); + req.onreadystatechange = function () { + if (req.readyState === 4) { + if (req.status === 200) { + // IT WORKS! + 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; + var onClickItem = function () { + var $res = this.getElementsByTagName("div")[0]; + $res.style.display = $res.style.display === 'none' ? 'block' : 'none'; + }; + + 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 itemEl = getItemEl(url); + var errcnt = 0; + for (i = 0; i < res.messages.length; i++) { + if (res.messages[i].type === 'error') { + errcnt++; + } + } + + 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) { + } + }; + + try { + req2.open("POST", "http://validator.w3.org/check", true); + + // Firefox < 4 + if (typeof FormData !== "object") { + req2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + req2.send('fragment=' + global.escape(html) + + '&doctype=Inline' + + '&output=json'); + } else { + var formData = new FormData(); + formData.append('fragment', html); + formData.append('doctype', 'Inline'); + formData.append('output', 'json'); + req2.send(formData); + } + } catch (e) { + } + } else { + global.alert(achecker.i18n.get('ValidationFail')); + } + } + }; + req.open("GET", sourceUrl, true); + req.send(null); + }; + + var urls = [], docs = [], i, l; + if (win.location.href.substr(0, 7) === 'http://' || + win.location.href.substr(0, 8) === 'https://') { + urls.push(win.location.href); + docs.push(win.document); + } + if (isIncludeFrame) { + for (i = 0, l = frameDocs.length; i < l; i++) { + var _url = frameDocs[i].src; + if (_url.substr(0, 7) === 'http://' || _url.substr(0, 8) === 'https://') { + urls.push(_url); + docs.push(frameDocs[i]); + } + } + } + + var $output = rdoc.createElement('ul'); + for (i = 0, l = urls.length; i < l; i++) { + doValidation(urls[i], docs[i]); + var $item = rdoc.createElement('li'); + $item.className = 'validationItem'; + var $_url = rdoc.createElement('span'); + $_url.className = 'url'; + $_url.innerText = urls[i]; + $_url.textContent = urls[i]; + var $_errcnt = rdoc.createElement('b'); + $_errcnt.className = 'errcnt'; + $_errcnt.innerText = achecker.i18n.get('Loading'); + $_errcnt.textContent = achecker.i18n.get('Loading'); + $item.appendChild($_url); + $item.appendChild(rdoc.createTextNode(': ')); + $item.appendChild($_errcnt); + $output.appendChild($item); + } + return $output; + } + ) + } + }; + }; +}(window, window.document)); + +(function (g) { + "use strict"; + + var sectionWeights = { + "altText": 30, + "kbdFocus": 10, + "frame": 10, + "linkText": 10, + "pageLang": 10, + "unintendedFunction": 10, + "label": 20 + }; + + var getLevel = function (score) { + if (score >= 95) { + return "perfect"; + } else if (score > 80) { + return "good"; + } else if (score > 60) { + return "bad"; + } else { + return "fail"; + } + }; + + var canonicalUrl = function (win) { + var url = win.location.href; + var linkEls = win.document.getElementsByTagName("link"); + var i, l = linkEls.length; + for (i = 0; i < l; i++) { + if (linkEls[i].getAttribute("rel") === "canonical" && + linkEls[i].getAttribute("href")) { + url = linkEls[i].getAttribute("href"); + } + } + // remove fragment identifier from URL + url = url.replace(/\#.*$/, ''); + return url; + }; + + g.achecker = g.achecker || {}; + g.achecker.Wax = g.achecker.Wax || {}; + g.achecker.Wax.score = function (waxSections) { + var score = 0, info; + + for (var key in sectionWeights) { + if (sectionWeights.hasOwnProperty(key)) { + info = waxSections[key] ? waxSections[key].getScore() : null; + if (info && info.all > 0) { + score += parseInt(info.pass / info.all * sectionWeights[key] * 10, 10) / 10; + } else { + score += parseInt(sectionWeights[key], 10); + } + } + } + + return parseInt(score * 10, 10) / 10; + }; + g.achecker.Wax.scoreAsElement = function (cwin, rdoc, waxSections, allowLogging) { + var score = g.achecker.Wax.score(waxSections); + var $div = rdoc.createElement('div'); + $div.className = 'waxScore ' + getLevel(score); + + var $title = rdoc.createElement('h2'); + var $label = rdoc.createElement('a'); + $label.setAttribute('href', 'http://openwax.miya.pe.kr/#guide_score'); + $label.setAttribute('target', '_blank'); + $label.innerText = "WAX Score: "; + $label.textContent = "WAX Score: "; + var $score = rdoc.createElement('strong'); + $score.innerText = score; + $score.textContent = score; + + $label.appendChild($score); + $title.appendChild($label); + $div.appendChild($title); + + if (allowLogging) { + var $logger = rdoc.createElement('img'); + $logger.style.position = 'absolute'; + $logger.style.top = '-9999px'; + $logger.style.left = '-9999px'; + $logger.setAttribute('src', 'http://openwax.miya.pe.kr/log?' + + 'url=' + encodeURIComponent(canonicalUrl(cwin)) + '&' + + 'title=' + encodeURIComponent(cwin.document.title) + '&' + + 'score=' + score + '&'); + $div.appendChild($logger); + } + + return $div; + }; +}(window)); diff --git a/site/app.js b/site/app.js index 75e5f85..18a6b7d 100644 --- a/site/app.js +++ b/site/app.js @@ -1,5 +1,4 @@ /*jshint node: true */ -/*global __ */ "use strict"; var step = require('step');