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

    0

    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
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    /**
     * Queries the DOM for the HTML element based on selector string passed.
     * @param {String} selector Selector we are querying for.
     * @param {String} [parent] Parent is optional, if passed the function will look for a child element of that parent.
     * @param {Boolean} [returnEmptyList] If set to true the function won't throw an error even if the element is not found.
     * @return {Array} HTML objects.
     */
    function getEl( selector, parent, returnEmptyList )
    {
        var classOnly,
            match,
            elPrefix,
            selPrefix,
            context,
            safeNode,
            nodes;
    
        classOnly = /^\.([\w\-]+)$/;
        match = classOnly.exec( selector );
        elPrefix = '.js-';
        selPrefix = selector.substring( 0, 4 );
    
        if ( ( selPrefix !== elPrefix || !typeCheck.isString( selector ) ) && match !== null )
        {
            throw new Error( 'Please make sure you input a valid class name that begins with a proper prefix.' );
        }
    
        if ( typeCheck.isString( parent ) )
        {
            context = document.getElementsByClassName( parent.substring( 1 ) )[ 0 ];
        }
        else if ( typeCheck.isElement( parent ) )
        {
            context = parent;
        }
        else
        {
            context = document;
        }
    
        nodes = match === null ? context.querySelectorAll( selector ) : context.getElementsByClassName( match[ 1 ] );
    
        safeNode = nodes.length > 0 && nodes;
    
        if ( safeNode || !safeNode && returnEmptyList )
        {
            return [].slice.call( nodes ); //converts it to a proper array.
        }
        else
        {
            throw new Error( 'Element with selector "' + selector + '" does not exist on the page.' );
        }
    }

    Koren, 13 Ноября 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function isLogged() {
              return '0';
              return '';
    }
    
    function getForumPrefix() {
             return 'forum/';
    }

    https://dota2.ru/forum/

    GreatMASTERcpp, 13 Ноября 2017

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

    0

    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
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    ;(function($) {
    	"use strict";
    
    	var rules = {
    		'~': 'Ё',
    		'`': 'ё',
    		'q': 'й',
    		'w': 'ц',
    		'e': 'у',
    		'r': 'к',
    		't': 'е',
    		'y': 'н',
    		'u': 'г',
    		'i': 'ш',
    		'o': 'щ',
    		'p': 'з',
    		'a': 'ф',
    		's': 'ы',
    		'd': 'в',
    		'f': 'а',
    		'g': 'п',
    		'h': 'р',
    		'j': 'о',
    		'k': 'л',
    		'l': 'д',
    		'z': 'я',
    		'x': 'ч',
    		'c': 'с',
    		'v': 'м',
    		'b': 'и',
    		'n': 'т',
    		'm': 'ь',
    		'Q': 'Й',
    		'W': 'Ц',
    		'E': 'У',
    		'R': 'К',
    		'T': 'Е',
    		'Y': 'Н',
    		'U': 'Г',
    		'I': 'Ш',
    		'O': 'Щ',
    		'P': 'З',
    		'A': 'Ф',
    		'S': 'Ы',
    		'D': 'В',
    		'F': 'А',
    		'G': 'П',
    		'H': 'Р',
    		'J': 'О',
    		'K': 'Л',
    		'L': 'Д',
    		'Z': 'Я',
    		'X': 'Ч',
    		'C': 'С',
    		'V': 'М',
    		'B': 'И',
    		'N': 'Т',
    		'M': 'Ь',
    		'[': 'х',
    		'{': 'Х',
    		']': 'ъ',
    		'}': 'Ъ',
    		';': 'ж',
    		':': 'Ж',
    		"'": 'э',
    		'"': 'Э',
    		',': 'б',
    		'<': 'Б',
    		'.': 'ю',
    		'>': 'Ю',
    	};

    На jcat.ru вот сие чудо

    unkwua, 07 Ноября 2017

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

    +2

    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
    // куча if и небольшой кусок логики
    // ...
                   } else {
                      response["message"] = "Access Denied";
                      response.shortlist = undefined;
                      callback(response);
                    }
                  } else {
                    response["message"] = "Access Denied";
                    response.shortlist = undefined;
                    callback(response);
                  }
                } else {
                  response["message"] = "Access Denied";
                  response.shortlist = undefined;
                  callback(response);
                }
              });
            } else {
              response["message"] = "Access Denied";
              response.shortlist = undefined;
              callback(response);
            }
          } else {
            response["message"] = "Access Denied";
            response.shortlist = undefined;
            callback(response);
          }
        } else {
          response["message"] = "Access Denied";
          response.shortlist = undefined;
          callback(response);
        }
      } else {
        response["message"] = "Invalid Method";
        response.shortlist = undefined;
        callback(response);
      }

    rkgrep, 04 Ноября 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public do(action: 'un' | 're'): void {
        const result = (<any>this._appApi.app.documentManager.current)[action + 'do']();
        if (!result.success) this._toastService.error(result.errorMessage, `Ошибка ${action}do`);
    }
    
     <button (click)="do('un')" title="Отменить"><i class="material-icons md-36">undo</i></button>
     <button (click)="do('re')" title="Повторить"><i class="material-icons md-36">redo</i></button>

    mazhuravlev, 01 Ноября 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var CodeMirror = require("codemirror");
    var Thrift = require("thrift.js");
    require("./src/my.css");
    include(`gen-js/test_types.js')
    include(`gen-js/TestServ.js')
    include(`src/main.js')

    Против m4 нет приёма.

    CHayT, 29 Октября 2017

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

    +1

    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
    function CountBack_slider(secs,iid,j_timer) {
    	if (secs < 0) {
    		document.getElementById(iid).innerHTML = FinishMessage;
    		document.getElementById('caption'+j_timer).style.display = "none";
    		document.getElementById('heading'+j_timer).style.display = "none";
    		return;
    	}
    	DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
    	DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
    	DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
    	DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));
    	
    	var elems = document.getElementsByTagName('*'), i;
    	for (i in elems) {
    		if((' ' + elems[i].className + ' ').indexOf(' ' + iid + ' ')
    				> -1) {
    			elems[i].innerHTML = DisplayStr;
    		}
    	}
    	
    	jQuery('.'+iid).innerHTML = DisplayStr;
    	  if (CountActive)
    		setTimeout(function(){CountBack_slider((secs+CountStepper),iid,j_timer)}, SetTimeOutPeriod);
    }

    Работаю с купленным html5-шаблоном.
    В шаблоне jq (и еще куча всякого хлама) подключен.
    Кодили с мыслью "работает и *уй с ним".

    Developer, 27 Октября 2017

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

    +1

    1. 1
    https://s1.postimg.org/9ay7hrf7fj/js-love-forever.png

    heart, heart, JavaScript!

    wvxvw, 26 Октября 2017

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    const screenCssPixelRatio = (window.outerWidth - 8) / window.innerWidth;
    const screenZoomed = screenCssPixelRatio !== 2.639089968976215;
    
    if (screenZoomed) {
       return scrollWidth + 4;
    }
    
    return scrollWidth;

    Когда важна точность

    prostohz, 24 Октября 2017

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

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Для кульминации ебаных тендеций ебаных информационных технологий,
    предлагаю выпустить новые процессоры интел со встроенным джаваскриптом.
    Никакого больше ассемблера, никаких ядер, драйверов, ничего не нужно, на
    каждом процессоре будет встроенный хардварный веб-сервер с нодежс,
    общение с видеокартой, памятью, периферией будет только с помощью
    API-вызовов, теперь каждый альтернативно интеллектуальный 
    жаваскрипт-разработчик сможет почувствовать себя системным программистом

    j123123, 22 Октября 2017

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