Skip to content

Instantly share code, notes, and snippets.

View walterdavis's full-sized avatar

Walter Lee Davis walterdavis

View GitHub Profile
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.9/scriptaculous.js?load=effects"></script>
<script type="text/javascript">
var shade = $('shade'), offset = shade.cumulativeOffset()['top'];
var marker = new Element('span');
var links = $$('#shade a');
links.each(function(link){
var target = $(link.href.split('#').last());
if(!!target) link['pane'] = target;
});
<?php
// only run this if the form has been submitted
if(isset($_POST['files'])){
// where are the PDFs stored on your server?
$source_directory = '/data/www/scripty/pdfs/';
$files = array();
// loop over the chosen PDFs
foreach($_POST['files'] as $key => $val){
// protect against malicious forms -- strip off anything besides a filename
$safe_val = array_pop(preg_split('/\//', $val, -1, PREG_SPLIT_NO_EMPTY));
var hasClassName = function(element, className) {
var elementClassName = element.className;
return (elementClassName.length > 0 && (elementClassName == className ||
new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
}
var addClassName = function(element, className) {
if (!hasClassName(element, className))
element.className += (element.className ? ' ' : '') + className;
return element;
}
var d = new Date('2014-01-30T19:19:26.224Z');
var t = new Template($('counter').innerHTML);
function tick(){
var time = {days_0: 0, days_1: 0, hours_0: 0, hours_1: 0, mins_0: 0, mins_1: 0, secs_0: 0, secs_1: 0};
var secs = Math.floor((d.getTime() - new Date().getTime()) / 1000);
if(secs > 0){
var days = Math.floor(secs / 86400);
time['days_0'] = (days.toString().length == 1) ? 0 : days.toString().slice(0,1);
time['days_1'] = days.toString().slice(-1);
secs -= days * 86400;
<a href="http://instagram.com/friendlyangel?ref=badge"><img src="//badges.instagram.com/static/images/ig-badge-32.png" alt="Instagram" /></a>
@walterdavis
walterdavis / autocomplete.js
Last active January 2, 2016 11:09
Autocompleter from scratch in Prototype. Mostly Scriptaculous-compliant, can use the same stylesheets, for example. The server must return a specially-formatted UL as the result of a search.
$$('input.autocomplete').each(function(elm){
var autocompleter = elm.clone().setValue('');
autocompleter.name = null;
autocompleter.id = null;
var wrap = elm.wrap('div', {'class': 'wrap', 'style': 'position: relative'});
wrap.insert(autocompleter);
elm.type = 'hidden';
elm.removeClassName('autocomplete');
var result = new Element('div', {'class': 'autocomplete-results', 'style': 'display:none'});
wrap.insert(result);
<action-encoding>UTF-8</action-encoding>
<library-action name="functions">
<action-javascript>
/**
* Create a CDN link to a JavaScript library.
* name: common filename for the library (prototype, scriptaculous, jquery)
* path: (optional) fully-qualified URL to the CDN-hosted file
* (path is not needed if you are linking to prototype or scriptaculous)
* WARNING! changes any existing link in the page to the library to the
<action-encoding>UTF-8</action-encoding>
// this section is just a bunch of helper functions that get called by the Action
// you don't need to read through them right away
// later, if you're interested, they provide some useful techniques
<library-action name="functions">
<action-javascript>
/**
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=6755637;
var sc_invisible=0;
var sc_security="a7a101f0";
var sc_text=2;
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter.js"></script>
<noscript><div class="statcounter"><a title="click tracking"
<div id="twitter-container">
<?php include_once('twitterinsert.php');?>
<div class="twitter-link">
<a href="https://twitter.com/creativeline69" target="_blank">Follow us on twitter <span>@creativeline69</span></a>
</div>
</div>