kint-php / kint

Kint - Advanced PHP dumper
https://kint-php.github.io/kint/
MIT License
2.77k stars 291 forks source link

Ability to drag out kint output to a pop up window for future reference and whatnot #46

Closed raveren closed 10 years ago

raveren commented 11 years ago
window.open(
    'data:text/html;base64,'
    + window.btoa(
        unescape(
            encodeURIComponent(
                document.documentElement.innerHTML
            )
        )
    )
);

Instead of document.documentElement use needed Kint nodes along with something along the lines of document.querySelectorAll('script')[0].innerHTML.

aljinovic commented 10 years ago

I implemented this feature in my fork. Base64 was a bad idea because it breaks browser when there's a lot of debug data, so I implemented it this way:

newWindow = window.open();
if(newWindow) {
    newWindow.document.open();
    newWindow.document.write(html);
    newWindow.document.close();
}

I fixed some compatibility issues with older PHP versions that don't support "static::" and "$var::" static calls.

Also, I fixed the bug with _stepIsInternal() method: didn't detect call_user_func_array inside Kint class as internal when short functions were called.

Result: http://www.opengluco.com/demo/kint/demo.php

Raveren, I'll make a pull request in 1.0.0-wip branch if you think this is OK.

Could you just tell me which minifier script you're using for .js so I can minify it again before merge since there are some changes inside also. Thanks!

raveren commented 10 years ago

Wow, dude, that is terrific! Sure, please do a pull request, these changes are totally awesome.

I use a custom File Watchers Php storm plugin config, parameters of which are at the top of _kint.js (I know this sucks, I need to brush up contribution guidelines heavily).

You can however just use the online compiler on advanced settings and then wrap the output inside (function(){%output%})() - the online tool does not support this configuration option.

raveren commented 10 years ago

Even the dumped object in your demo is awesomely crafted to showcase most of Kint features, that's just wonderful :)

aljinovic commented 10 years ago

I was planing of making an interactive demo where you can switch themes and see the actual code behind, if you agree ;)

raveren commented 10 years ago

That would be stellar! :)

aljinovic commented 10 years ago

I've created a simple demo with theme switcher: http://www.opengluco.com/demo/kint/demo.php

Any suggestions?

raveren commented 10 years ago

Wow you even created a new theme :D Fucking A!

I'm finishing up with my own batch of changes and will comment further tomorrow.

aljinovic commented 10 years ago

My colleague did the theme, he'll make a pull request when it's done.

raveren commented 10 years ago

It's lovely, I can't wait to use it myself! :)

I'll be awaiting for the pull request and it would be great if you could put your demo in a new /examples folder and pull request it too, we'll work from there.

Thanks again!

aljinovic commented 10 years ago

Did you intentionally change the behavior of "open in new window"?

It dumps the parent if you click on some child (for example open some object and click on it's property to open it in new window and it opens all properties from the object).

Also, there's a small bug there (

  • element):

    bug

  • raveren commented 10 years ago

    Thanks, fixed!

    GlassGruber commented 8 years ago

    Hey there, sorry to bump a closed thread but was wondering if this could be the default behavior for Kint. Instead of being printed in the page directly, a new javascript window is opened with something like this

    window.open(
      '', 
      'Kint Window', 
      "height=500,width=500,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1",true
    ).document.write(kintOutput);

    Does it make sense?

    Btw is it possible to detach the already implemented pop out to a new window instead of a browser tab? Is there any config to allow this?