Class: MerbFootnotes::Notes::QueriesNote
Constant Summary
collapse
- @@sql =
[]
Class Method Summary
collapse
Instance Method Summary
collapse
close!, #fieldset?, included?, #included?, #initialize, #legend, #link, #onclick, #row, title, #to_sym, #valid?
Class Method Details
.sql ⇒ Object
10
11
12
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 10
def self.sql
@@sql
end
|
.start!(controller) ⇒ Object
14
15
16
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 14
def self.start!(controller)
@@sql = []
end
|
.to_sym ⇒ Object
18
19
20
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 18
def self.to_sym
:queries
end
|
Instance Method Details
#content ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 45
def content
html = ''
@@sql.each_with_index do |item, i|
sql_links = []
sql_links << "<a href=\"#\" style=\"color:#A00;\" onclick=\"queries_toogle('table',#{i});return false\">explain</a>" if item.explain
sql_links << "<a href=\"#\" style=\"color:#00A;\" onclick=\"queries_toogle('trace',#{i});return false\">trace</a>" if item.trace
html << %{
<b id="qtitle_#{i}">#{escape(item.type.to_s.upcase)}</b> (#{sql_links.join(' | ')})<br />
#{print_name_and_time(item.name, item.time)}<br />
#{print_query(item.query)}<br />
#{print_explain(i, item.explain) if item.explain}
<p id="qtrace_#{i}" style="display:none;">#{parse_trace(item.trace) if item.trace}</p><br />
}
end
return "NOT WORKING"
end
|
#javascript ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 35
def javascript
%{
function queries_toogle(type, id){
s = document.getElementById('q'+type+'_'+id).style
s.display = (s.display != 'block') ? 'block' : 'none'
location.href = '#qtitle_'+id
}
}
end
|
#stylesheet ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 26
def stylesheet
%{
#queries_debug_info table td, #queries_debug_info table th{border:1px solid #A00; padding:0 3px; text-align:center;}
#queries_debug_info table thead, #queries_debug_info table tbody {color:#A00;}
#queries_debug_info p {background-color:#F3F3FF; border:1px solid #CCC; margin:12px; padding:4px 6px;}
#queries_debug_info a:hover {text-decoration:underline;}
}
end
|
#title ⇒ Object
22
23
24
|
# File 'lib/merb_footnotes/notes/queries_note.rb', line 22
def title
"Queries (#{@@sql.length})"
end
|