Skip to content

Instantly share code, notes, and snippets.

@hdon
Created July 12, 2017 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdon/e58f13b0eda76421b806d404f055f469 to your computer and use it in GitHub Desktop.
Save hdon/e58f13b0eda76421b806d404f055f469 to your computer and use it in GitHub Desktop.
var ll = new LazyLoad({
container: document.body
});
document.querySelector('#search').addEventListener('keypress', (ev) => {
var query = ev.target.value;
setTimeout(() => {
Array.prototype.forEach.call(document.querySelectorAll('body > a'), a => {
a.style.display =
( query.length == 0
|| a.getAttribute('href').indexOf(query) >= 0
|| a.getAttribute('data-tags').indexOf(query) >= 0)
? 'inline-block'
: 'none'
;
});
}, 0);
});
document.addEventListener('onkeydown', ev => {
console.log(ev);
});
#!/usr/bin/env python
import os, random
print('''<!doctype>
<html>
<head>
<style>
img {
width: 300px;
height: 225px;
}
#search {
position: absolute;
width: 600px;
height: 125px;
margin-left: -300px;
margin-top: -62.5px;
left: 50%;
top: 50%;
z-index: 1;
border: 3px solid black;
font-size: 48px;
}
</style>
</head>
<body>
<input type="text" id="search">
''')
for filename in os.listdir('/var/www/html/shots'):
if not filename.endswith('.png'):
continue
print('<a href="http://%s/" data-tags="%s"><img data-original="/shots-300x225/%s"></a>' % (
filename[:-4]
, filename + random.choice(('realestate', 'real estate', 'home business', 'mlm'))
, filename
))
print('''<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/7.2.0/lazyload.min.js"></script>
<script src="/foo.js"></script>
''')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment