- 1
$('.eTag').attr('href',$('.eTag').attr('href').replace('/search/','/searchq?='));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
$('.eTag').attr('href',$('.eTag').attr('href').replace('/search/','/searchq?='));
http://usite.su/forum/3-1806-18538-16-1324092570
+181
<!--Начало сценария
var res="23342142"
function check_me()
{
var count=0
with(document.test)
{
if (!Q1[0].checked&&!Q1[1].checked&&!Q1[2].checked&&!Q1[3].checked) {count+=1};
if (!Q2[0].checked&&!Q2[1].checked&&!Q2[2].checked&&!Q2[3].checked) {count+=1};
if (!Q3[0].checked&&!Q3[1].checked&&!Q3[2].checked&&!Q3[3].checked) {count+=1};
if (!Q4[0].checked&&!Q4[1].checked&&!Q4[2].checked&&!Q4[3].checked) {count+=1};
if (!Q5[0].checked&&!Q5[1].checked&&!Q5[2].checked&&!Q5[3].checked) {count+=1};
if (!Q6[0].checked&&!Q6[1].checked&&!Q6[2].checked&&!Q6[3].checked) {count+=1};
if (!Q7[0].checked&&!Q7[1].checked&&!Q7[2].checked&&!Q7[3].checked) {count+=1};
if (!Q8[0].checked&&!Q8[1].checked&&!Q8[2].checked&&!Q8[3].checked) {count+=1};
if (count>0) {alert("Вы выполнили не все задания. Проверьте себя.")}
else answer()
}
}
function control(k,f1,f2,f3,f4,f5,f6,f7,f8)
{
if (k==1&&f1.checked) return true;
if (k==2&&f2.checked) return true;
if (k==3&&f3.checked) return true;
if (k==4&&f4.checked) return true;
if (k==5&&f5.checked) return true;
if (k==6&&f6.checked) return true;
if (k==7&&f7.checked) return true;
if (k==8&&f8.checked) return true;
return false;
}
function answer()
{
answ="";
with(document)
{
answ+=control(res.charAt(0),test.Q1[0],test.Q1[1],test.Q1[2],test.Q1[3])?"1":"0"
answ+=control(res.charAt(1),test.Q2[0],test.Q2[1],test.Q2[2],test.Q2[3])?"1":"0"
answ+=control(res.charAt(2),test.Q3[0],test.Q3[1],test.Q3[2],test.Q3[3])?"1":"0"
answ+=control(res.charAt(3),test.Q4[0],test.Q4[1],test.Q4[2],test.Q4[3])?"1":"0"
answ+=control(res.charAt(4),test.Q5[0],test.Q5[1],test.Q5[2],test.Q5[3])?"1":"0"
answ+=control(res.charAt(5),test.Q6[0],test.Q6[1],test.Q6[2],test.Q6[3])?"1":"0"
answ+=control(res.charAt(6),test.Q7[0],test.Q7[1],test.Q7[2],test.Q7[3])?"1":"0"
answ+=control(res.charAt(7),test.Q8[0],test.Q8[1],test.Q8[2],test.Q8[3])?"1":"0"
showResult();
}
}
function showResult()
{
var nok=0;
var i,s;
for (i=0;i<answ.length;i++) {nok+=answ.charAt(i)=="1"?1:0;}
if(nok<4) s='"НЕУДОВЛЕТВОРИТЕЛЬНО"';
if(nok==4) s='"УДОВЛЕТВОРИТЕЛЬНО"';
if(nok>4 && nok<6) s='"УДОВЛЕТВОРИТЕЛЬНО"';
if(nok==6) s='"ХОРОШО"';
if(nok>6 && nok<8) s='"ХОРОШО"';
if(nok==8) s='"ОТЛИЧНО"';
document.test.s1.value="Количество правильных ответов "+nok+". Ваша оценка "+s+". Загляните в окно рядом с номером задания. Если ответ правильный, то там (+). Если Вы ошиблись, там (-).";
with(document.test)
{
if (answ.charAt(0)=="1") {T1.value=" +"} else {T1.value=" -"};
if (answ.charAt(1)=="1") {T2.value=" +"} else {T2.value=" -"};
if (answ.charAt(2)=="1") {T3.value=" +"} else {T3.value=" -"};
if (answ.charAt(3)=="1") {T4.value=" +"} else {T4.value=" -"};
if (answ.charAt(4)=="1") {T5.value=" +"} else {T5.value=" -"};
if (answ.charAt(5)=="1") {T6.value=" +"} else {T6.value=" -"};
if (answ.charAt(6)=="1") {T7.value=" +"} else {T7.value=" -"};
if (answ.charAt(7)=="1") {T8.value=" +"} else {T8.value=" -"};
}
}
http://www.junior.ru/wwwexam/t_gig.htm
Тест по информатике.
+145
<script type = "text/javascript">
<!--
var m3_u = (location.protocol == "https:"?
"https://bk55.ru/openx/www/delivery/ajs.php": "http://bk55.ru/openx/www/delivery/ajs.php");
var m3_r = Math.floor(Math.random()*99999999999);
if(!document.MAX_used) document.MAX_used = ",";
document.write("<scr" + "ipt type = 'text/javascript' src = '" + m3_u);
document.write("?zoneid=8&source=main");
document.write("&cb=" + m3_r);
if(document.MAX_used != ",") document.write("&exclude=" + document.MAX_used);
document.write(document.charset? "&charset=" + document.charset:
(document.characterSet? "&charset=" + document.characterSet: ""));
document.write("&loc=" + escape(window.location));
if(document.referrer) document.write("&referer=" + escape(document.referrer));
if(document.context) document.write("&context=" + escape(document.context));
if(document.mmm_fo) document.write("&mmm_fo=1");
document.write("'><\/scr" + "ipt>");
--> // ajax не нужен)))))
</script>
Использование баннерного движка OpenX на сайте bk55.ru. Всего на странице около десятка таких кусков, которые отличаются только значением zoneid. Жесть)))
+146
aWidth = Math.min(Math.max(thisText*5+80, 150), 350);
aHeight = (thisText>610) ? 290 : (thisText>550) ? 270 : (thisText > 490) ? 250 : (thisText > 420) ? 230 : (thisText > 360) ? 210 : (thisText > 300) ? 190 : (thisText > 240) ? 170 : (thisText > 180) ? 150 : (thisText > 120) ? 130 : (thisText > 60)? 110 : 100;
обнаружил у себя в проекте, оказывается взяли тут http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/212610
+145
Math.min(Math.max(asd, 350), 350);
и почему размер всегда 350?
+158
<!--//
calendar = new Date();
day = calendar.getDay();
document.write("<table width=100 border=1><tr><td><center><font size=2>")
if (day == 0) {
document.write("<font color=#ff0000>Воскресенье</font>")
}
if (day == 1) {
document.write("Понедельник")
}
if (day == 2) {
document.write("Вторник")
}
if (day == 3) {
document.write("Среда")
}
if (day == 4) {
document.write("Четверг")
}
if (day == 5) {
document.write("Пятница")
}
if (day == 6) {
document.write("<font color=#ff0000>Суббота</font>")
}
document.write("</font></center></td></tr><tr><td><center><font size=2>")
month = calendar.getMonth();
if (month == 0) {
document.write("Январь")
}
if (month == 1) {
document.write("Февраль")
}
if (month == 2) {
document.write("Март")
}
if (month == 3) {
document.write("Апрель")
}
if (month == 4) {
document.write("Май")
}
if (month == 5) {
document.write("Июнь")
}
if (month == 6) {
document.write("Июль")
}
if (month == 7) {
document.write("Август")
}
if (month == 8) {
document.write("Сентябрь")
}
if (month == 9) {
document.write("Октябрь")
}
if (month == 10) {
document.write("Ноябрь")
}
if (month == 11) {
document.write("Декабрь")
}
document.write("</font></center></td></tr><tr><td><center><font size=6>")
date = calendar.getDate();
document.write(date)
document.write("</font></center></td></tr><tr><td><center><font size=2>")
year = calendar.getYear();
if (year < 100) {
document.write("19" + year + "")
}
else if (year > 1999) {
document.write(year)
}
document.write("</font></center></td></tr></table>")
//-->
Вывод даты в человеко-понятном формате. Найдено в коде одного украинского МВДшного сайта.
+150
function fixPNG(element)
{
if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
var src;
src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
if(src){
src = src[1];
element.runtimeStyle.backgroundImage = "none";
}
if(src){
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src = '" +
src + "',sizingMethod = 'scale')";
}
}
}
+166
var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function isValid(parm,val) {
if (parm == "") return true;
for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}
http://javascript.about.com/library/blvalid02.htm
Вырезка из шапки:
Javascript does not contain functions that test specifically for alphabetic or numeric content but we can easily provide these functions for ourselves...
+159
notify: function(evt) {
var state = this.prevFirst === null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');
// Load items
this.callback('itemLoadCallback', evt, state);
if (this.prevFirst !== this.first) {
this.callback('itemFirstInCallback', evt, state, this.first);
this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
}
if (this.prevLast !== this.last) {
this.callback('itemLastInCallback', evt, state, this.last);
this.callback('itemLastOutCallback', evt, state, this.prevLast);
}
this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
},
Популярный jQuery плагин - "jCarousel"
http://sorgalla.com/projects/jcarousel/
2 часа пытался реализовать инициализацию элементов "конвеера" до появления их на экране.
Но не тут-то было. Все 7 событий, регулирующих смену позиции - вызываются в один момент времени (при занятии элементом итогового положения).
• itemLoadCallback
• itemFirstInCallback
• itemFirstOutCallback
• itemLastInCallback
• itemLastOutCallback
• itemVisibleInCallback
• itemVisibleOutCallback
*this.callback сводится до fn.call()
+169
<img onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor=''">