Skip to content

Instantly share code, notes, and snippets.

@robinsonkwame
Created April 18, 2016 12:16
Show Gist options
  • Save robinsonkwame/5059d5e4c54f5f3c659e79bd92b8ca66 to your computer and use it in GitHub Desktop.
Save robinsonkwame/5059d5e4c54f5f3c659e79bd92b8ca66 to your computer and use it in GitHub Desktop.
<script>
// Adapted from http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
// Works for fast typers (90+ wpm), no node.js
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
};
if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 100);
};
}
// Forward search box to another frame
document.addEventListener("DOMContentLoaded", function(){
var searchbox = document.getElementById('searchbox').children[0];// angular input box
var searchframe = document.getElementById('searchframe');
var src_frame= "http://www.arcgis.com/home/search.html?q="
function framesearch(e){
if(searchbox.value){
searchframe.src = src_frame + searchbox.value
}
}
search.addEventListener('keyup', debounce(framesearch, 500, false));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment