1function showFrame(anchor) { 2 var tbid = anchor.getAttribute('tbid'); 3 var expanded = anchor.expanded; 4 if (expanded) { 5 MochiKit.DOM.hideElement(anchor.expandedElement); 6 anchor.expanded = false; 7 _swapImage(anchor); 8 return false; 9 } 10 anchor.expanded = true; 11 if (anchor.expandedElement) { 12 MochiKit.DOM.showElement(anchor.expandedElement); 13 _swapImage(anchor); 14 $('debug_input_'+tbid).focus(); 15 return false; 16 } 17 var url = debug_base 18 + '/show_frame?tbid=' + tbid 19 + '&debugcount=' + debug_count; 20 var d = MochiKit.Async.doSimpleXMLHttpRequest(url); 21 d.addCallbacks(function (data) { 22 var el = MochiKit.DOM.DIV({}); 23 anchor.parentNode.insertBefore(el, anchor.nextSibling); 24 el.innerHTML = data.responseText; 25 anchor.expandedElement = el; 26 _swapImage(anchor); 27 $('debug_input_'+tbid).focus(); 28 }, function (error) { 29 showError(error.req.responseText); 30 }); 31 return false; 32} 33 34function _swapImage(anchor) { 35 var el = anchor.getElementsByTagName('IMG')[0]; 36 if (anchor.expanded) { 37 var img = 'minus.jpg'; 38 } else { 39 var img = 'plus.jpg'; 40 } 41 el.src = debug_base + '/media/' + img; 42} 43 44function submitInput(button, tbid) { 45 var input = $(button.getAttribute('input-from')); 46 var output = $(button.getAttribute('output-to')); 47 var url = debug_base 48 + '/exec_input'; 49 var history = input.form.history; 50 input.historyPosition = 0; 51 if (! history) { 52 history = input.form.history = []; 53 } 54 history.push(input.value); 55 var vars = { 56 tbid: tbid, 57 debugcount: debug_count, 58 input: input.value 59 }; 60 MochiKit.DOM.showElement(output); 61 var d = MochiKit.Async.doSimpleXMLHttpRequest(url, vars); 62 d.addCallbacks(function (data) { 63 var result = data.responseText; 64 output.innerHTML += result; 65 input.value = ''; 66 input.focus(); 67 }, function (error) { 68 showError(error.req.responseText); 69 }); 70 return false; 71} 72 73function showError(msg) { 74 var el = $('error-container'); 75 if (el.innerHTML) { 76 el.innerHTML += '<hr noshade>\n' + msg; 77 } else { 78 el.innerHTML = msg; 79 } 80 MochiKit.DOM.showElement('error-area'); 81} 82 83function clearError() { 84 var el = $('error-container'); 85 el.innerHTML = ''; 86 MochiKit.DOM.hideElement('error-area'); 87} 88 89function expandInput(button) { 90 var input = button.form.elements.input; 91 stdops = { 92 name: 'input', 93 style: 'width: 100%', 94 autocomplete: 'off' 95 }; 96 if (input.tagName == 'INPUT') { 97 var newEl = MochiKit.DOM.TEXTAREA(stdops); 98 var text = 'Contract'; 99 } else { 100 stdops['type'] = 'text'; 101 stdops['onkeypress'] = 'upArrow(this)'; 102 var newEl = MochiKit.DOM.INPUT(stdops); 103 var text = 'Expand'; 104 } 105 newEl.value = input.value; 106 newEl.id = input.id; 107 MochiKit.DOM.swapDOM(input, newEl); 108 newEl.focus(); 109 button.value = text; 110 return false; 111} 112 113function upArrow(input, event) { 114 if (window.event) { 115 event = window.event; 116 } 117 if (event.keyCode != 38 && event.keyCode != 40) { 118 // not an up- or down-arrow 119 return true; 120 } 121 var dir = event.keyCode == 38 ? 1 : -1; 122 var history = input.form.history; 123 if (! history) { 124 history = input.form.history = []; 125 } 126 var pos = input.historyPosition || 0; 127 if (! pos && dir == -1) { 128 return true; 129 } 130 if (! pos && input.value) { 131 history.push(input.value); 132 pos = 1; 133 } 134 pos += dir; 135 if (history.length-pos < 0) { 136 pos = 1; 137 } 138 if (history.length-pos > history.length-1) { 139 input.value = ''; 140 return true; 141 } 142 input.historyPosition = pos; 143 var line = history[history.length-pos]; 144 input.value = line; 145} 146 147function expandLong(anchor) { 148 var span = anchor; 149 while (span) { 150 if (span.style && span.style.display == 'none') { 151 break; 152 } 153 span = span.nextSibling; 154 } 155 if (! span) { 156 return false; 157 } 158 MochiKit.DOM.showElement(span); 159 MochiKit.DOM.hideElement(anchor); 160 return false; 161} 162