1 |
|
|
2 |
|
// fake firebug's console.* |
3 |
|
if (!window.console) { |
4 |
|
var names = [ "log", "debug", "info", "warn", "error" ]; |
5 |
|
window.console = {}; |
6 |
|
for (i in names) { |
7 |
|
window.console[names[i]] = function() {}; |
8 |
|
} |
9 |
|
} |
10 |
|
|
11 |
$(document).ready( function() { |
$(document).ready( function() { |
12 |
|
|
13 |
function click_on_cell(e) { |
function click_on_cell(e) { |
24 |
else |
else |
25 |
where_value = '%' + where_value + '%'; |
where_value = '%' + where_value + '%'; |
26 |
|
|
27 |
|
var type = column_type[col_nr]; |
28 |
|
|
29 |
console.debug('click on ', this, e, |
console.debug('click on ', this, e, |
30 |
e.originalTarget, |
e.originalTarget, |
31 |
column, where_operator, where_value |
column, type, where_operator, where_value |
32 |
); |
); |
33 |
|
|
34 |
$('form#sql .changed').removeClass('changed'); |
$('form#sql .changed').removeClass('changed'); |
49 |
.addClass('changed') |
.addClass('changed') |
50 |
.attr('options').selectedIndex = col_nr |
.attr('options').selectedIndex = col_nr |
51 |
; |
; |
52 |
$('form#sql input[name=add_group_by]') |
$('form#sql input[name=lookup_col]') |
53 |
.addClass('changed') |
.addClass('changed') |
54 |
.attr('value', column) |
.attr('value', column) |
55 |
.css('display','block') |
.css('display','block') |
56 |
.attr('disabled',0) |
.attr('disabled',0) |
57 |
; |
; |
58 |
|
$('select[name=where_operator]') |
59 |
|
.addClass('changed') |
60 |
|
.attr('selectedIndex', type < 0 ? 0 : 2) |
61 |
|
; |
62 |
} else { |
} else { |
63 |
console.error('unknown click on ', tag, e); |
console.error('unknown click on ', tag, e); |
64 |
} |
} |
65 |
|
|
66 |
$('form#sql').addClass('visible'); |
$('form#sql').addClass('visible').addClass('fixed'); |
67 |
}; |
}; |
68 |
|
|
69 |
$('table#results').bind('mouseup', click_on_cell); |
$('table#results').bind('mouseup', click_on_cell); |
70 |
|
|
71 |
$('#status').bind('click', function() { |
$('#status').bind('click', function() { |
72 |
$('form#sql').toggleClass('visible'); |
$('form#sql').toggleClass('visible').addClass('fixed'); |
73 |
}); |
}); |
74 |
|
|
75 |
$('input[name=add_group_by]').bind('click', function(e) { |
$('input[name=lookup_col]').bind('click', function(e) { |
76 |
var l = $('div#lookup'); |
var l = $('div#lookup'); |
77 |
l.css('display','block'); |
var column = $('form#sql input[name=lookup_col]').attr('value'); |
78 |
var column = $('form#sql input[name=add_group_by]').attr('value'); |
var col_nr = $('form#sql select[name=where_column]').attr('options').selectedIndex; |
79 |
console.debug( this, e, column, l ); |
var operator = $('select[name=where_operator]').attr('options').selectedIndex; |
80 |
|
|
81 |
$('input[name=add_group_by]') |
l.html('...loading lookup for '+column+'...').css('display','block'); |
82 |
|
|
83 |
|
console.debug( this, e, column, col_nr, l ); |
84 |
|
|
85 |
|
$('input[name=lookup_col]') |
86 |
.removeClass('changed') |
.removeClass('changed') |
87 |
.attr('disabled', 1); |
.attr('disabled', 1); |
88 |
|
|
89 |
l.load('?add_group_by='+column); |
$.get('', { lookup_col: column }, function(data,textStatus) { |
90 |
|
console.debug( data, textStatus ); |
91 |
|
l.addClass('changed'); |
92 |
|
l.html( data ); |
93 |
|
|
94 |
|
$('div#lookup a') |
95 |
|
.bind('click', function(e) { |
96 |
|
console.debug( 'lookup click', e ); |
97 |
|
$('form#sql input[name=where_value]') |
98 |
|
.attr('value', e.target.text ) |
99 |
|
; |
100 |
|
$('form#sql select[name=where_column]') |
101 |
|
.attr('options').selectedIndex = col_nr |
102 |
|
; |
103 |
|
$('select[name=where_operator]') |
104 |
|
.attr('options').selectedIndex = operator + 1 // remove not |
105 |
|
; |
106 |
|
return false; |
107 |
|
}); |
108 |
|
}); |
109 |
|
|
110 |
|
|
111 |
$('input[name=close_group_by]') |
$('input[name=close_group_by]') |
112 |
.addClass('changed') |
.addClass('changed') |
113 |
.attr('disabled', 0) |
.attr('disabled', 0) |