forked from gdkraus/web-evaluation-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Headings.js
58 lines (33 loc) · 1.28 KB
/
Headings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var Headings = Tool.extend({
name: "Headings",
CSSString: ".heading-highlight{background:#afff00;outline: 3px #0f0 solid;border: 3px #0f0 solid;position:relative;width:auto;left:auto;top:auto;} p.heading-highlight-note{background:#0f0;font-weight:bold;margin:3px;padding:3px;font-size:1em;}",
constructor: function(name) {
self = this;
},
TotalCount: 0,
count: function(fr) {
self.TotalCount = parseInt(self.TotalCount) + fr.find('h1,h2,h3,h4,h5,h6').length;
},
getNumOf: function(fr) {
recurseFrames(jQuery('html'), self.count);
return self.TotalCount;
},
addStyle: function(fr) {
fr.find('head').append("<style type='text/css'>" + self.CSSString + "</style>");
},
removeStyle: function(fr) {
fr.find('style:contains(' + self.CSSString + ')').remove();
},
addNotes: function(fr) {
fr.find('h1,h2,h3,h4,h5,h6').each(function() {
jQuery(this).addClass('heading-highlight')
jQuery(this).prepend("<p class='heading-highlight-note'>" + jQuery(this).prop("tagName") + ':' + jQuery(this).text() + "</p>")
});
},
removeNotes: function(fr) {
fr.find('.heading-highlight-note').remove();
fr.find('h1,h2,h3,h4,h5,h6').each(function() {
jQuery(this).removeClass('heading-highlight')
});
}
});