mootools
We've all inherited rubbish websites from webmasters that couldn't master valid HTML. You know the horrid markup: paragraph tags with align attributes and body tags with background attributes. It's almost a sin what they do. That's where dwMarkupMarine comes in. dwMarkupMarine is a small MooTools plugin you can bring into those awful pages to help highlight the mistakes you need to correct.
我们都从无法掌握有效HTML的网站管理员那里继承了垃圾网站。 您知道可怕的标记:带有align属性的段落标签和带有background属性的正文标签。 他们所做的几乎是一种罪过。 这就是dwMarkupMarine出现的地方。dwMarkupMarine是一个小的MooTools插件,您可以将其插入这些糟糕的页面中,以帮助突出显示您需要纠正的错误。
MooTools 1.2 JavaScript (The MooTools 1.2 JavaScript)
var dwMarkupMarine = new Class({
//implements
Implements: [Options],
//options
options: {
tags: 'b, i, u, font, basefont, center, applet, dir, isindex, menu, s, strike, layer, xmp',
attributes: 'caption[align!=""], iframe[align!=""], image[align!=""], input[align!=""], object[align!=""], legend[align!=""], table[align!=""], hr[align!=""], div[align!=""], p[align!=""], h1[align!=""], h2[align!=""], h3[align!=""], h4[align!=""], h5[align!=""], h6[align!=""], body[alink!=""], body[background!=""], table[bgcolor!=""], tr[bgcolor!=""], td[bgcolor!=""], th[bgcolor!=""], img[border!=""], object[border!=""], br[clear!=""], *[compact!=""], td[height!=""], tr[height!=""], *[hspace!=""], script[language!=""], body[link!=""], hr[noshade!=""], td[nowrap!=""], th[nowrap!=""], isindex[prompt!=""], hr[size!=""], *[start!=""], li[type!=""], ol[type!=""], ul[type!=""], li[value!=""], body[vlink!=""], *[vspace!=""], hr[width!=""], td[width!=""], th[width!=""], pre[width!=""]',
mootools: '*[onblur!=""], *[onclick!=""], *[ondblclick!=""], *[onfocus!=""], *[onkeydown!=""], *[onkeypress!=""], *[onkeyup!=""], *[onload!=""], *[onmouseover!=""], *[onmousedown!=""], *[onmouseup!=""], *[onmouseout!=""], *[onmousemove!=""], *[onselect!=""], *[onsubmit!=""], *[onunload!=""]',
checkTags: true,
checkAttributes: true,
checkMoo: true,
custom: [],
weapon: 'bad'
},
//initialization
initialize: function(options) {
this.setOptions(options);
this.search();
},
//a method that does whatever you want
search: function() {
if(this.options.checkTags) { this.beat(this.options.tags); }
if(this.options.checkAttributes) { this.beat(this.options.attributes); }
if(this.options.checkMoo) { this.beat(this.options.mootools); }
if(this.options.custom) { this.beat(this.options.custom); }
},
//tag the baddies
beat: function(collection) {
$$(collection).each(function(el) {
el.addClass(this.options.weapon);
}.bind(this));
}
});
Here are the class options:
以下是课程选项:
tags: a string of HTML tags to look for.
tags :要查找HTML字符串字符串。
attributes: a string of element/attribute combinations to look for.
attribute :要查找的元素/属性组合的字符串。
mootools: a string of "on" events to look for. You're using Moo -- there's no need for those.
mootools :要查找的“ on”事件的字符串。 您正在使用Moo-不需要这些。
checkTags: should the class look for bad tags?
checkTags :该类是否应寻找不良标签?
checkAttributes: should the class look for bad attributes?
checkAttributes :类应查找不良属性吗?
checkMoo: should the class look for "on" event attributes?
checkMoo :类是否应在事件属性上查找“ on”事件?
custom: a string of custom selectors to look for.
custom :要查找的自定义选择器的字符串。
weapon: class to tag onto matches.
武器 :用于标记比赛的类。
Moo 1.2用法 (The Moo 1.2 Usage)
//make it happen!
window.addEvent('load',function() {
var mm = new dwMarkupMarine({
weapon: 'bad'
});
});
Do you have any use for this? Any ideas for improvement? Share them!
你有什么用吗? 有什么改善的想法吗? 分享他们!
翻译自: https://davidwalsh.name/mootools-html-police-dwmarkupmarine
mootools