1. JavaScript / Говнокод #13667

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    /* mootools javascript */
    function animateCd() {
        $$('.countdown').each(function(el) {
            var inp = $(el).getElement('.ts');
            var time = +$(inp).get('text')-1;
            $(inp).set('text', time);
     
            var _time = Math.abs(time);
            var h = Math.floor(_time/3600);
            var _h = (h < 10 ? '0' : '') + h;
     
            var m = Math.floor(_time/60)-h*60;
            var _m = (m < 10 ? '0' : '') + m;
     
            var s = _time-(h*3600+m*60);
            var _s = (s < 10 ? '0' : '') + s;
     
            var timeStr = _h+' : '+_m+' : '+_s;
            if ( time < 0 ) {
                timeStr = '- '+timeStr;
            }
     
            $(el).getElement('.timer_cd').set('text', timeStr);
        });
        setTimeout(animateCd, 1000);
    }
    animateCd();
    
    <!-- html -->
    <div class="countdown">
        <div class="timer_cd"></div>
        <div style="display: none" class="ts">7200</div>
    </div>

    "Для создания таймера будем отталкиваться от стартового времени указанного в секундах, в примере 7200 (2 часа). Сначала из скрытого блока <div style="display: none" class="ts">7200</div> вытягиваем текущее значение счетчика в секундах, декрементируем его и возвращаем туда новое значение. Потом разбиваем значение счетчика на часы, минуты и секунды, при этом формируя значения в двухзначном формате. Собираем все в кучу и вставляем полученную строку в блок <div class="timer_cd"></div>. Данную операцию повторяем раз в секунду setTimeout(animateCd, 1000);."
    http://webbystep.ru/all-posts/16-js-clock/

    psycho-coder, 26 Августа 2013

    Комментарии (12)
  2. JavaScript / Говнокод #13655

    +141

    1. 1
    for (; b < d; b++)

    subj

    Stealth, 23 Августа 2013

    Комментарии (14)
  3. JavaScript / Говнокод #13654

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    <body style=margin:0 
    
    onload="for( 
    
    s=window.screen, 
    w=q.width=s.width, 
    h=q.height=s.height, 
    m=Math.random, 
    p=[], 
    i=0; i<256; 
    
    p[i++]=1 );
    
    setInterval('9Style=\'rgba(0,0,0,.05)\'9Rect(0,0,w,h)9Style=\'#0F0\';
    
    p.map(function(v,i){9Text(String.fromCharCode(3e4+m()*33),i*10,v);
    p[i]=v>758+m()*1e4?0:v+10})'.split(9).join(';q.getContext(\'2d\').fill'),33)">
    
    
    <canvas id=q>

    Найди утечку ( many many times i jerk -> ctx ;)

    Stealth, 23 Августа 2013

    Комментарии (1)
  4. JavaScript / Говнокод #13645

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    clientsize:function () {
    			if (window.innerWidth || window.innerHeight) {
    				return {"w":window.innerWidth,"h":window.innerHeight};
    			}
    			else if (_$$.$().documentElement && (_$$.$().documentElement.clientWidth || _$$.$().documentElement.clientHeight)) {
    				return {"w":_$$.$().documentElement.clientWidth,"h":_$$.$().documentElement.clientHeight};
    			}
    			else if (_$$.$().body.clientWidth || _$$.$().body.clientHeight) {
    				return {"w":_$$.$().body.clientWidth,"h":_$$.$().body.clientHeight};
    			}
    			else {
    				return {"w":0,"h":0};
    			}
    		},
    		scrollpos:function () {
    			if (window.innerWidth || window.innerHeight) {
    				return {"l":window.pageXOffset,"t":window.pageYOffset};
    			}
    			else if (_$$.$().documentElement && (_$$.$().documentElement.clientWidth || _$$.$().documentElement.clientHeight)) {
    				return {"l":_$$.$().documentElement.scrollLeft,"t":_$$.$().documentElement.scrollTop};
    			}
    			else if (_$$.$().body.clientWidth || _$$.$().body.clientHeight) {
    				return {"l":_$$.$().body.scrollLeft,"t":_$$.$().body.scrollTop};
    			}
    			else {
    				return {"l":0,"t":0};
    			}
    		},
    		scrollsize:function () {
    			if (_$$.$().documentElement && (_$$.$().documentElement.scrollWidth || _$$.$().documentElement.scrollHeight)) {
    				return {"w":_$$.$().documentElement.scrollWidth,"h":_$$.$().documentElement.scrollHeight};
    			}
    			else if (_$$.$().body.scrollWidth || _$$.$().body.scrollHeight) {
    				return {"w":_$$.$().body.scrollWidth,"h":_$$.$().body.scrollHeight};
    			}
    			else {
    				return {"w":0,"h":0};
    			}
    		},

    Йебанайтунг координатунг ...

    Stealth, 22 Августа 2013

    Комментарии (0)
  5. JavaScript / Говнокод #13644

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    movement_8: function() {
    			var d_param=effect.noeffect.winparam();
    			var main_left=Math.round(d_param[4]+(d_param[0]-this.width)/2);
    			var main_top=Math.round(d_param[5]+(d_param[1]-this.height)/2);
    			
    			document.getElementById('panel_p_el_1').style.left=parseInt(document.getElementById('panel_p_el_1').style.left)-this.step+'px';
    			document.getElementById('panel_p_el_1').style.top=main_top+'px';
    			
    			if(parseInt(document.getElementById('panel_p_el_1').style.left)>main_left+Math.round(this.width/2)) {
    				setTimeout('effect.panel.movement_8();',this.speed);
    			}
    			else {
    				document.getElementById('panel_p_el_1').style.left=main_left+Math.round(this.width/2)+'px';
    				document.getElementById('panel_p_el_1').style.top=main_top+'px';
    				this.key[1]=1;
    				
    				if(this.key[0]+this.key[1]+this.key[2]+this.key[3]==4) {
    					document.getElementById('panel_p_el_0').style.visibility='hidden';
    					document.getElementById('panel_p_el_1').style.visibility='hidden';
    					document.getElementById('panel_p_el_2').style.visibility='hidden';
    					document.getElementById('panel_p_el_3').style.visibility='hidden';
    					
    					document.getElementById('panel_p_el_m').style.visibility='visible';
    					document.getElementById('panel_p_el_m').style.left=main_left+'px';
    					document.getElementById('panel_p_el_m').style.top=main_top+'px';
    				}
    			}
    		},

    Зачем канвас и иксэмэл, давай нажарим цыэсэсом ... Вообще так оно и делается быстрее всего, геймдевы еще не расчухали толком :D Однако, HTML для этого избыточен ...

    Stealth, 22 Августа 2013

    Комментарии (0)
  6. JavaScript / Говнокод #13643

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    var cooker = {
    	set: function(cookie_name, cookie_value, cookie_expires, cookie_path, cookie_domain, cookie_secure) {
    		if(cookie_name!==undefined) {
    			cookie_expires=cookie_expires || 0;
    			var expire_date = new Date;
    			expire_date.setTime(expire_date.getTime() + (cookie_expires*1000));
    			document.cookie = cookie_name + "=" + escape(cookie_value)+'; ' + 
    			((cookie_expires === undefined) ? '' : 'expires=' + expire_date.toGMTString()+'; ') +
    			((cookie_path === undefined) ? 'path=/;' : 'path='+cookie_path+'; ') +
    			((cookie_domain === undefined) ? '' : 'domain='+cookie_domain+'; ') +
    			((cookie_secure === true) ? 'secure; ' : '');
    		}
    	},
    	get: function(cookie_name) {
    		var cookie = document.cookie, length = cookie.length;
    		if(length) {
    			var cookie_start = cookie.indexOf(cookie_name + '=');
    			if(cookie_start != -1) {
    				var cookie_end = cookie.indexOf(';', cookie_start);
    				if(cookie_end == -1) {
    					cookie_end = length;
    				}
    				cookie_start += cookie_name.length + 1;
    				return unescape(cookie.substring(cookie_start, cookie_end));
    			}
    		}
    	},
    	erase: function(cookie_name) {
    		cooker.set(cookie_name, '', -1);
    	},
    	test: function() {
    		cooker.set('test_cookie', 'test', 10);
    		var work = (cooker.get('test_cookie') === 'test') ? true : false;
    		cooker.erase('test_cookie');
    		return work;
    	}
    };

    Stealth, 22 Августа 2013

    Комментарии (2)
  7. JavaScript / Говнокод #13641

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    show: function () {
    		this.number_x++;
    		if(this.number_x-1>=this.frames_x) {
    			this.number_x=1;
    			this.number_y++;
    			if(this.number_y-1>=this.frames_y) {
    				this.number_y=1;
    				if(this.playandstop) {
    					this.stop();
    				}
    			}
    		}
    		if(this.key) {
    			var left;
    			var top;
    			(this.reverse)?left=(this.frames_x-this.number_x)*this.frame_x:left=(this.number_x-1)*this.frame_x;
    			(this.reverse)?top=(this.frames_y-this.number_y)*this.frame_y:top=(this.number_y-1)*this.frame_y;
    			$$(this.id).$$('marginLeft',''+-left+'px').$$('marginTop',''+-top+'px');
    			var th = this;
    			this.timer=setTimeout(function () { th.show(); },this.speed);
    		}
    		else {
    			this.next();
    		}
    	},

    фреймы: такие фреймы

    Stealth, 22 Августа 2013

    Комментарии (0)
  8. JavaScript / Говнокод #13637

    +149

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function cubeGalleryLayout(ob,cate)
    {
    	var obj = ob;
    	obj.empty();
    	if (cate=="all") obj.append('<div class="gallery_category"><ul><li class="on"><a href="#">All</a></li><li><a href="#">Exterior</a></li><li><a href="#">Interior</a></li><li><a href="#">Movies</a></li></ul></div>');
    	else if (cate=="exterior") obj.append('<div class="gallery_category"><ul><li><a href="#">All</a></li><li><a href="#" class="on">Exterior</a></li><li><a href="#">Interior</a></li><li><a href="#">Movies</a></li></ul></div>');
    	else if (cate=="interior") obj.append('<div class="gallery_category"><ul><li><a href="#">All</a></li><li><a href="#">Exterior</a></li><li><a href="#" class="on">Interior</a></li><li><a href="#">Movies</a></li></ul></div>');
    	else obj.append('<div class="gallery_category"><ul><li><a href="#">All</a></li><li><a href="#">Exterior</a></li><li><a href="#">Interior</a></li><li><a href="#" class="on">Movies</a></li></ul></div>');
    	obj.append('<ul class="gallerylist"></ul>');
    	obj.append('<div class="cube_shadow"><div><img src="/worldwide/images/common/bg/bg_cube_shadow.png" alt="" /></div></div>');
    }

    Тут ещё много веселья: view-source:http://worldwide.hyundai.com/WW/Showroom/Cars/i40/PIP/index.html

    varg242, 21 Августа 2013

    Комментарии (0)
  9. JavaScript / Говнокод #13630

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    var sym = new Array();
    sym["a"]=0;sym["c"]=1;sym["d"]=2;sym["e"]=3;sym["f"]=4;sym["g"]=5;sym["h"]=6;sym["k"]=7;sym["l"]=8;sym["m"]=9;sym["n"]=10;sym["p"]=11;sym["q"]=12;sym["r"]=13;sym["s"]=14;sym["t"]=15;sym["u"]=16;sym["w"]=17;sym["x"]=18;sym["z"]=19;sym["2"]=20;sym["3"]=21;sym["4"]=22;sym["5"]=23;sym["6"]=24;sym["7"]=25;
    
    function convertCode(field)
        {
            var code = $(field).val().toLowerCase();
            var convertedCode = sym[code.charAt(0)];
            
            for (var i = 1; i < code.length; i++)
                convertedCode += "_" + sym[code.charAt(i)];
    
            $(field).closest(".captcha-block").find("#captchaCode").val(convertedCode);
        }

    Я не осилил, что делает это говно? (Сбербанк-Онлайн)

    Там еще кодировка win-1251 и тег <head> открывается на 30й строке кода. Нет, я не фанат обфускации, но КАК?!

    CRRaD, 20 Августа 2013

    Комментарии (37)
  10. JavaScript / Говнокод #13615

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    Object.valuesNP = function(obj){
        var result = [];
        for (var i in obj)
            if (obj.hasOwnProperty(i))
                result.push(obj[i]);
        return result;
    };
    
    function findCSS(name){
        var css = document.styleSheets;
        var flag = false;
        var result = null;
        Object.valuesNP(css).each(function(content,index){
            if (!flag && content instanceof Object)
                Object.valuesNP(content.cssRules).each(function(content,index){
                    if (content instanceof Object && content.selectorText == name && !flag ){
                        flag = true;
                        result = content;
                    }
                })
            });
        return result;
    }

    Надо было поменять параметры некоторого класса(стиль). Ну и за пару минут было накидано вот енто.
    Самое смешное, что через неделю это уже не потребовалось.
    Вызывать так:
    var buttonClass = findCSS('.buttonClass') || console.log('CSS .buttonClass not found');

    Dart_Sergius, 16 Августа 2013

    Комментарии (4)