Added a status bar with char/line display

master
Jordi Boggiano 14 years ago
parent f54dc12911
commit 59d1c9f489
  1. 1
      README.mdown
  2. 1
      index.php
  3. 19
      php-console.js
  4. 38
      styles.css

@ -32,6 +32,7 @@ Changelog
- 1.1.0 - 1.1.0
- Script execution is now done via an async js request, preventing die() and exception to mess up the entire console - Script execution is now done via an async js request, preventing die() and exception to mess up the entire console
- Added a status bar with char/line display
- Added a toggle button to expand/collapse all krumo sub-trees at once - Added a toggle button to expand/collapse all krumo sub-trees at once
- 1.0.0 - 1.0.0
- Initial Public Release - Initial Public Release

@ -73,6 +73,7 @@ if (isset($_POST['code'])) {
<div class="output"><?php echo $debugOutput ?></div> <div class="output"><?php echo $debugOutput ?></div>
<form method="POST" action=""> <form method="POST" action="">
<textarea cols="100" rows="20" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : null) ?></textarea> <textarea cols="100" rows="20" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : null) ?></textarea>
<div class="statusbar">Line: 1, Column: 1</div>
<input type="submit" name="subm" value="Try this!" /> <input type="submit" name="subm" value="Try this!" />
</form> </form>
<div class="help"> <div class="help">

@ -12,6 +12,19 @@
* Source on Github http://github.com/Seldaek/php-console * Source on Github http://github.com/Seldaek/php-console
*/ */
$(function() { $(function() {
var updateStatusBar;
// updates the text of the status bar
updateStatusBar = function() {
var caret, part, matches;
caret = $('textarea[name="code"]').getCaret();
part = $('textarea[name="code"]').val().substring(0, caret);
matches = part.match(/(\r?\n)?([^\r\n]*)/g);
part = matches.length > 1 ? matches[matches.length - 2] : matches[0];
$('.statusbar').text('Line: ' + Math.max(1, matches.length-1) + ', Column: ' + (matches.length > 2 ? part.length : part.length + 1));
};
$('textarea[name="code"]') $('textarea[name="code"]')
.keydown(function(e) { .keydown(function(e) {
var caret, part, matches; var caret, part, matches;
@ -46,9 +59,15 @@ $(function() {
} }
break; break;
} }
updateStatusBar();
}) })
.keyup(updateStatusBar)
.click(updateStatusBar)
.focus(); .focus();
updateStatusBar();
$('input[name="subm"]').keyup(function(e) { $('input[name="subm"]').keyup(function(e) {
// set the focus back to the textarea if pressing tab moved // set the focus back to the textarea if pressing tab moved
// the focus to the submit button (opera bug) // the focus to the submit button (opera bug)

@ -1,17 +1,11 @@
body, textarea, input { body, textarea, input {
font: 12px monospace; font: 12px monospace;
} }
body { body {
background: #eee; background: #eee;
} }
textarea {
width: 99%;
height: 400px;
margin: auto;
display: block;
}
input { input {
width: 99%; width: 99%;
margin: auto; margin: auto;
@ -24,21 +18,41 @@ a {
color: #88f; color: #88f;
} }
.output, textarea {
border: 1px solid #aaa;
background: #fff;
}
textarea {
width: 99%;
height: 400px;
margin: auto;
display: block;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
}
.output { .output {
padding: 5px 10px; padding: 5px 10px;
margin: 10px .4%; margin: 10px .4%;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
} }
.output img.loader { .output img.loader {
margin-bottom: -4px; margin-bottom: -4px;
} }
.output, textarea { .statusbar {
-moz-border-radius: 5px; margin: 0 .5% 10px;
-webkit-border-radius: 5px; padding: 2px 5px;
border-radius: 5px; -moz-border-radius: 0 0 5px 5px;
-webkit-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
border: 1px solid #aaa; border: 1px solid #aaa;
background: #fff; border-top: 0;
} }
.help { .help {

Loading…
Cancel
Save