Lexin

Post Reply
User avatar
andrey
Posts: 2423
Joined: Sat Aug 24, 2013 3:27 pm

Lexin

Post by andrey »

Версия от 28.03.2017(18:27)

Image

Ссылка на ресурс:
http://lexin.nada.kth.se/lexin/

Код lexin.html:

Code: Select all

<html><head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>

<style>
lexin .removedlink{
	display: none;
}	

lexin br{
	display:none;
}

lexin ul{
	margin:6px 4px;
}


lexin p{
	margin: 8px 0px 0px 8px;
	color: brown;
}

lexin .lexingwt-LookupContent{
	margin-top:2px;
}

</style>

<script>
(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;
	}
}


var ready = function(div)
{

	div.find('img').remove();

	div.find('a').each(function(i, elem) {

		$(this).contents().unwrap().wrap('<span class="removedlink"></span>');

	});


	div.find('td').each(function(i, elem) {

		$(this).contents().unwrap().wrap('<span class="td"></span>');

	});

	div.find('tr').each(function(i, elem) {

		$(this).contents().unwrap().wrap('<span class="tr"></span>');

	});

	div.find('tbody').unwrap();

	var content = div.html();

	if (content!==undefined)
	{
		
		var span = document.getElementById("gdfrom-" + artid);
		span.getElementsByTagName('lexin')[0].innerHTML = content;
		span.getElementsByClassName('gddictname')[0].style.display = 'block';

	}


}


var onframeload = function()
{

	
		var body = $('#iframe_' + artid).contents().find('body');
		var div = body.find('.lexingwt-LookupContent');

		if (div.html() === undefined)
		{
			
			if (window["timer_" + artid] > 3000)
			{
				return false;
			}
			
			
			setTimeout(function(){
	
				window["timer_" + artid] += 300;
				console.log(window["timer_" + artid]);
				onframeload();
				
			}, 300);	
		}
		else
		{
			ready(div);
			
		}

	
}


var word = urlParam('word');

if ((word) && (word.trim().length > 0) && (!/\s/.test(word.trim())) && (word.trim().length < 30))
{

	window["timer_" + artid] = 0;

	var iframe = document.createElement('iframe');
	iframe.id = "iframe_" + artid;
	iframe.src = "http://lexin.nada.kth.se/lexin/#searchinfo=both,swe_swe," + word.trim() + ";";
	iframe.width = 400;
	iframe.height = 100;
	iframe.onload = onframeload;
	iframe.style.display = 'none';

	document.getElementsByTagName("body")[0].appendChild(iframe);

}

})(); 

</script>


<title>Lexin</title>
</head>
<body>
<lexin></lexin>
</body>
</html>
Для подключения в настройках GoldenDict-а в разделе Websites нужно добавить ссылку такого рода:

Code: Select all

file:///path/to/lexin.html?word=%GDWORD%
Чекбокс в колонке "As link" должен быть оставлен пустым.

Иконка:
Image
Post Reply