Last active
December 23, 2015 06:49
-
-
Save cowboy/6596088 to your computer and use it in GitHub Desktop.
php: gyazo screengrab removal helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php?> | |
| <!doctype html> | |
| <html> | |
| <body> | |
| <link href="https://rawgithub.com/necolas/normalize.css/master/normalize.css" rel="stylesheet"> | |
| <style> | |
| body { | |
| padding: 1em; | |
| background-color: #ccc; | |
| } | |
| h1 { | |
| margin-top: 0; | |
| } | |
| h2 { | |
| border-top: 1px solid #777; | |
| margin: 0.5em 0; | |
| padding-top: 1em; | |
| } | |
| h2 a { | |
| color: #00f; | |
| } | |
| h2 a:hover { | |
| color: #0a0; | |
| } | |
| div { | |
| margin-bottom: 1em; | |
| } | |
| span, img { | |
| display: inline-block; | |
| margin: 0; | |
| padding: 0; | |
| cursor: pointer; | |
| } | |
| span.rm { | |
| background-color: #f00; | |
| } | |
| span.rm img { | |
| opacity: 0.5; | |
| } | |
| #p { | |
| display: none; | |
| position: fixed; | |
| z-index: 999; | |
| border: 4px solid #0a0; | |
| background: #afa; | |
| padding: 0.5em; | |
| bottom: 1em; | |
| left: 2em; | |
| right: 2em; | |
| } | |
| </style> | |
| <script src="http://bit.ly/jqsource"></script> | |
| <script> | |
| var imgs = {}; | |
| $(document).on("click", "span", function() { | |
| var src = $(this).find("img").attr("src"); | |
| $(this).toggleClass("rm", !imgs[src]); | |
| if (imgs[src]) { | |
| delete imgs[src]; | |
| } else { | |
| imgs[src] = true; | |
| } | |
| var srcs = Object.keys(imgs); | |
| $("#p").text(srcs.reduce(function(s, src) { | |
| return s + " '" + src + "'"; | |
| }, "rm -rf"))[srcs.length > 0 ? "show" : "hide"](); | |
| }); | |
| </script> | |
| <pre id="p"></pre> | |
| <? | |
| $files = array(); | |
| $handle = opendir('.'); | |
| while (false !== ($file = readdir($handle))) { | |
| if ($file != '.' && $file != '..' && preg_match('/\.png$/', $file)) { | |
| $files[filemtime($file)] = $file; | |
| } | |
| } | |
| closedir($handle); | |
| krsort($files); | |
| ?><h1><?= count($files) ?> images</h1><? | |
| foreach ($files as $mtime => $file) { | |
| ?> | |
| <h2><?= date('F d, Y h:i A', $mtime) ?> / <a href="<?= $file ?>"><?= $file ?></a></h2> | |
| <div> | |
| <span><img src="<?= $file ?>"></span> | |
| </div> | |
| <? | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment