Погода с Михалком на вашем сайте
Заберите "Погоду с Михалком" к себе на сайт! Просто выберите подходящий формат информера, город и вставьте сгенерированный код к себе на сайт или блог! Теперь сам Сергей Михалок будет показывать вашим пользователям, как одеться по погоде.
Посмотрите, что получилось:
'+ ''+ ''; $('#banner_code').text(codeBanner); $('#test_code').html(codeBanner); $('#cityId').val(cityId); } $('#bannerType').change(function () {selectBanner()}); selectBanner(); $('#banner_code').click(function(el) { $(this).select(); }); (function() { $('').appendTo("div#csContainerInformer"); $("#cityName").keyup(function(e) { var eInput=$(this); var sVal=eInput.val(); var eInputOffset=eInput.offset(); var eCS=$("div#csBlockInformer"); var eIE=$("div#csIEInformer"); eInput.attr("autocomplete","off"); if(sVal.length < 3 || sVal.length <=1){ eIE.hide(); return } if(e.which==27){ eInput.val(""); sVal=""; eIE.hide(); return } if(e.which==40) { setTimeout(function(){ $("div.csBlock a:first").trigger("focus")},50); return; } if(e.which==13) { if ($("div.csBlock a").length == 1) { eInput.val($("div.csBlock a:first").text()); eIE.hide(); selectBanner($("div.csBlock a:first").attr('id')); return; } else return; } $.getJSON("http://pogoda.tut.by/export/suggest.php?callback=?",{ "str": sVal, "belOnly": "1", "lang": "rus" },function(data) { eCS.empty(); //if (console.log) console.log(data[0]); eIE.width(eInput.outerWidth()).css("top",eInput.outerHeight()-2); if (!$(data).length) { $('').text('Город не найден').appendTo(eCS) .focus(function() { $(this).addClass("afocus"); }) .blur(function() { $(this).removeClass("afocus"); }); } $.each(data, function(i,city) { $(''+city+'') .appendTo(eCS) .click(function(e) {e.preventDefault();eInput.val(city);eIE.hide();selectBanner(i)}) .focus(function() { $(this).addClass("afocus"); }) .blur(function() { $(this).removeClass("afocus"); }); }); $('div.csBlock a').keydown(function(e){ var el = $("div.csBlock a.afocus"); if(e.which==40) { if (el.next('a').length) el.removeClass("afocus").next('a').addClass("afocus").trigger("focus"); e.preventDefault(); } if(e.which==38) { if (el.prev('a').length) el.removeClass("afocus").prev('a').addClass("afocus").trigger("focus"); e.preventDefault(); } if(e.which==27){ eIE.hide(); eInput.trigger("focus"); } if(e.which==13) { eInput.val(el.text()); eIE.hide(); selectBanner(el.attr('id')); } e.stopPropagation(); }) eIE.show(); }); }) .focus(function() { var el = this; setTimeout(function(){el.select()},50); }) .parents("form").attr("autocomplete","off").submit(function(e) { e.preventDefault(); }); })();
