Ссылка на ресурс:
http://www.urbandictionary.com/
Код urbandic.html:
Code: Select all
<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
urbandic-text .word{
margin: 4px;
font-size: 150%;
font-weight: bold;
}
urbandic-text .definition{
margin: 4px;
background-color: #F8F9FA;
border: 1px dotted #FFF;
padding: 4px;
}
urbandic-text .example{
margin: 4px;
font-style: italic;
padding: 4px;
}
urbandic-sound div.sound{
margin: 20px 4px;
}
urbandic-sound{
margin-top: 30px;
}
</style>
<script type="text/javascript">
(function () {
var scr = document.getElementsByTagName('script');
scr = scr[scr.length - 1];
var div = scr.parentNode.parentNode.parentNode;
var artid = div.id.replace(/gdfrom-/, "");
div = div.getElementsByClassName('gddictname')[0];
if (div.className === 'gddictname')
{
div.style.display = 'none';
}
var urlParam = function (name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results===null)
{
return undefined;
}
else
{
return results[1] || undefined;
}
}
function UrbanDictionary(word, artid)
{
var el = document.createElement("script");
el.src = 'http://api.urbandictionary.com/v0/define';
el.src += '?term=' + encodeURIComponent(word);
el.src += '&callback=window.UrbanDictionaryCallback' + artid;
document.getElementsByTagName('head')[0].appendChild (el);
}
window["getSoundType" + artid] = function(url)
{
var t = {"aac":"audio/aac",
"mp4":"audio/mp4",
"m4a":"audio/mp4",
"mp1":"audio/mpeg",
"mp2":"audio/mpeg",
"mp3":"audio/mpeg",
"mpg":"audio/mpeg",
"mpeg":"audio/mpeg",
"oga":"audio/ogg",
"ogg":"audio/ogg",
"wav":"audio/wav",
"webm":"audio/webm"};
url = url.trim();
var ext = (/^http.*\.[a-z\d]{3,4}$/i.test(url)) ? url.match(/^http.*\.([a-z\d]{3,4})$/i)[1] : "";
if ((ext !== "") && (t[ext] !== undefined))
{
return [true, t[ext]];
}
else
{
return [false];
}
}
window["UrbanDictionaryCallback" + artid] = function (result)
{
var withsound = 'no'; //yes - со звуковыми файлами, no - без
var text = "";
for (var i = 0; i < result.list.length; i++)
{
if (result.list[i].word)
{
text += "<div class=\"word\">" + result.list[i].word + "</div>";
}
if (result.list[i].definition)
{
text += "<div class=\"definition\">" + result.list[i].definition + "</div>";
}
if (result.list[i].example)
{
text += "<div class=\"example\">" + result.list[i].example + "</div>";
}
}
var span = document.getElementById("gdfrom-" + artid);
span.getElementsByTagName('urbandic-text')[0].innerHTML = text;
span.getElementsByClassName('gddictname')[0].style.display = 'block';
if (withsound === "yes")
{
var sound = "";
for (var i = 0; i < result.sounds.length; i++)
{
var type = window["getSoundType" + artid](result.sounds[i]);
if (type[0])
{
sound += "<div class=sound><audio controls><source src=\"" + result.sounds[i] + "\" type=\"" + type[1] + "\"></audio></div>";
}
}
span.getElementsByTagName('urbandic-sound')[0].innerHTML = sound;
}
}
var word = urlParam('word');
if ((word) && (word.trim().length > 0) && (word.trim().length < 30))
{
UrbanDictionary(word.trim(), artid);
}
})();
</script>
<title>Urban Dictionary</title>
</head>
<body>
<urbandic-text></urbandic-text>
<urbandic-sound></urbandic-sound>
</body>
</html>
Code: Select all
file:///path/to/urbandic.html?word=%GDWORD%
Иконка: