Skip to content

Commit

Permalink
basic cli support, validHtml option
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalnature committed Nov 15, 2015
1 parent 19be18c commit 6aa68f4
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 95 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ Currently available options and their default values:
| `'scriptPath'` | `'{:dir}/ref.js'` | Local path to a custom javascript (HTML only); `FALSE` means no javascript (tooltips / toggle / kbd shortcuts require JS)
| `'showUrls'` | `FALSE` | Gets information about URLs. Setting to false can improve performance (requires showStringMatches to be TRUE)
| `'timeout'` | `10` | Stop execution after this amount of seconds, forcing an incomplete listing. Applies to all calls

| `'validHtml'` | `FALSE` | For HTML mode only. Whether to produce W3C-valid HTML (larger code output) or unintelligible, potentially browser-incompatible but much smaller code output

## Similar projects

- [Kint](http://raveren.github.io/kint/)
- [dump_r](https://github.com/leeoniya/dump_r.php)
- [Krumo](http://sourceforge.net/projects/krumo/)
- [dBug](http://dbug.ospinto.com/)
- [symfony-vardumper] (http://www.sitepoint.com/var_dump-introducing-symfony-vardumper/)
- [symfony-vardumper](http://www.sitepoint.com/var_dump-introducing-symfony-vardumper/)


## TODOs
Expand Down
60 changes: 41 additions & 19 deletions ref.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* reset default styles for these elements */
.ref i,
.ref span,
.ref r,
.ref a{
font-style: inherit;
font-weight: inherit;
Expand All @@ -19,17 +20,20 @@
}

/* meta content (used to generate tooltips) */
.ref > div{
.ref > div,
.ref > t{
display: none;
}

/* show help cursor when mouse is over an entity with a tooltip */
.ref [data-tip]{
.ref [data-tip],
.ref [h]{
cursor: help;
}

/* pointer if inside a link */
.ref a > [data-tip]{
.ref a > [data-tip],
.ref a > [h]{
cursor: pointer;
}

Expand Down Expand Up @@ -70,7 +74,8 @@
margin: 20px 0 0 25px;
}

#rTip [data-cell]{
#rTip [data-cell],
#rTip [c]{
padding: 2px 7px;
}

Expand All @@ -85,7 +90,8 @@
color: #777;
}

#rTip [data-cell][data-varType]{
#rTip [data-cell][data-varType],
#rTip [c][data-varType]{
padding: 10px;
background: #333;
box-shadow: inset -1px 0 0 #444;
Expand All @@ -94,7 +100,8 @@
border-bottom-left-radius: 4px;
}

#rTip [data-cell][data-sub]{
#rTip [data-cell][data-sub],
#rTip [c][data-sub]{
padding: 8px 10px 10px 10px;
background: #333;
box-shadow: inset 0 1px 0 #444;
Expand All @@ -103,20 +110,22 @@
border-bottom-left-radius: 4px;
}

#rTip [data-table] [data-cell]:first-child{
#rTip [data-table] [data-cell]:first-child,
#rTip [t] [c]:first-child{
font: bold 11px Helvetica, Arial;
color: #888;
}

#rTip [data-table] [data-cell]:nth-child(2){
#rTip [data-table] [data-cell]:nth-child(2),
#rTip [t] [c]:nth-child(2){
color: #edd078;
}




/* base entity - can be nested */
.ref span{
.ref span, .ref r{
white-space: pre;
display: inline;
}
Expand Down Expand Up @@ -178,16 +187,19 @@
transform: rotate(90deg);
}

.ref [data-group]{
.ref [data-group],
.ref [g]{
display: none;
}

.ref [data-toggle][data-exp] ~ [data-group]{
.ref [data-toggle][data-exp] ~ [data-group],
.ref [data-toggle][data-exp] ~ [g]{
display: block;
}

/* group sections */
.ref [data-table]{
.ref [data-table],
.ref [t]{
display: table;
}

Expand All @@ -202,16 +214,20 @@

/* emulate a table for displaying array & object members */
/* section row */
.ref [data-row]{
.ref [data-row],
.ref [r]{
display: table-row;
}

/* zebra-like rows */
.ref [data-output] [data-row]:nth-child(odd){background: #f4f4f4;}
.ref [data-output] [data-row]:nth-child(even){background: #f9f9f9;}
.ref [data-output] [r]:nth-child(odd){background: #f4f4f4;}
.ref [data-output] [r]:nth-child(even){background: #f9f9f9;}

/* section cells */
.ref [data-cell]{
.ref [data-cell],
.ref [c]{
display: table-cell;
width: auto;
vertical-align: top;
Expand All @@ -220,7 +236,9 @@

/* last cell of a row (forces table to adjust width like we want to) */
.ref [data-output] [data-table],
.ref [data-output] [data-cell]:last-child{
.ref [data-output] [t],
.ref [data-output] [data-cell]:last-child,
.ref [data-output] [c]:last-child{
width: 100%;
}

Expand All @@ -232,7 +250,8 @@
.ref [data-null],
.ref [data-unknown],
.ref [data-resource],
.ref [data-match]{
.ref [data-match],
.ref [m]{
font: bold 11px Helvetica, Arial;
color: #fff;
padding: 1px 3px;
Expand All @@ -246,7 +265,8 @@
}

/* string matches */
.ref [data-match]{
.ref [data-match],
.ref [m]{
background-color: #d78035;
}

Expand Down Expand Up @@ -356,7 +376,8 @@
}

/* group info prefix */
.ref [data-gLabel]{
.ref [data-gLabel],
.ref [gl]{
font: bold 11px Helvetica, Arial;
padding: 0 3px;
color: #333;
Expand All @@ -373,7 +394,8 @@
color: #444;
}

.ref [data-mod] span{
.ref [data-mod] span,
.ref [data-mod] r{
display: inline-block;
margin: 0 2px;
width: 14px;
Expand Down
49 changes: 23 additions & 26 deletions ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,29 @@ window.addEventListener('load', function(){

tip.id = 'rTip';
document.body.appendChild(tip);
});

window.addEventListener('keydown', function(e){

var tt = e.target.tagName.toLowerCase();
if((e.keyCode != 88) || (tt == 'input') || (tt == 'textarea') || (tt == 'select'))
return;

var kbds = document.querySelectorAll('.ref [data-toggle]'),
partlyExp = document.querySelectorAll('.ref [data-toggle][data-exp]').length !== kbds.length,
_ref = document.querySelectorAll('.ref');


e.preventDefault();

if( e.ctrlKey && e.keyCode == 88 ){
for(var i = 0, m = _ref.length; i < m; i++){
if( _ref[i].style.display == 'none' ){
_ref[i].style.display = 'block';
}else{
_ref[i].style.display = 'none';
}
}
}else{
for(var i = 0, m = kbds.length; i < m; i++)
window.addEventListener('keydown', function(e){
if((e.keyCode != 88) || (['input', 'textarea', 'select'].indexOf(e.target.tagName.toLowerCase()) > -1))
return;

e.preventDefault();

if(e.ctrlKey && e.keyCode == 88){
var d = refs[0].style.display !== 'none' ? 'none' : 'block';
for(var i = 0, n = refs.length; i < n; i++)
refs[i].style.display = d;

return;
}

var kbds = document.querySelectorAll('.ref [data-toggle]'),
m = kbds.length,
partlyExp = document.querySelectorAll('.ref [data-toggle][data-exp]').length !== m;

for(var i = 0; i < m; i++)
partlyExp ? (kbds[i].dataset.exp = 1) : (delete kbds[i].dataset.exp);
}


});

});

Loading

0 comments on commit 6aa68f4

Please sign in to comment.