Created
August 10, 2014 12:40
-
-
Save tony2nite/759c4464ed19db210ee3 to your computer and use it in GitHub Desktop.
GoT Contact Form Bookmarklet :: Overwrites a form's title dropdown with GoT character titles
This file contains 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
var $title = $('option').filter(function () { return $(this).html().indexOf('Mr.') != -1; }); | |
if ($title) { | |
window.kimonoCallback = function(data) { | |
// do something with the data | |
// please make sure the scope of this function is global | |
var options = jQuery.map( data.results.collection1, function( title ) { | |
var t = title.characterTitle.text; | |
return "<option value='" + t + "'>" + t + "</option>"; | |
}); | |
var $selected = $title.parent().find('option:selected'); | |
if ($selected && $selected.length) { | |
options.unshift($selected[0].outerHTML); | |
} | |
$title.parent().html(options.join()); | |
} | |
$.ajax({ | |
"url":"https://www.kimonolabs.com/api/240igmnu?apikey=6ebc1faf86f65f8e6410e84b6d381de5&callback=kimonoCallback", | |
"crossDomain":true, | |
"dataType":"jsonp" | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment