Skip to content

Instantly share code, notes, and snippets.

@tj-commits
Last active September 26, 2024 01:05
Show Gist options
  • Save tj-commits/a8185e53b7310bed3e67bf66c9dede45 to your computer and use it in GitHub Desktop.
Save tj-commits/a8185e53b7310bed3e67bf66c9dede45 to your computer and use it in GitHub Desktop.
Really, really bad javascript

HAVE WE FORGOTteN HOw TO PROGrAM?!?!

function isGreaterThan5(value) {
  if (value > 5) {
    return true;
  } else {
    return false;
  }
}

function event_count_greater_than_5(eventCount) {
  return isGreaterThan5(eventCount);
}
const isNil = require('is-nil')
const spaceBar = " "
Object.prototype.getMember = function(member) {
  const thisMember = this[member]
  if (isNil(thisMember)) {
    throw new Error("Member" + spaceBar + member + spaceBar + "does not exist"))
  }
  return thisMember
}
var { noop } = require('node-noop');
var allowed = {
    '1': true,
    '2': true,
    '3': true,
    '4': true,
    '5': true,
    '6': true,
    '7': true,
    '8': true,
    '9': true,
    '0': true,
    'ArrowLeft': true,
    'ArrowDown': true,
    'ArrowRight': true,
    'ArrowUp': true,
    'Backspace': true,
    '.': true,
}

function isTrue(pp) {
  var notFalse = true;
  if ( pp != notFalse ) {
    notFalse = false;
  } else {
    notFalse = true;
  }
  return notFalse;
}

document.onkeypress = function(event) {
  if (event) {
    var key = event.key;
    var isValidKey = allowed[key];
    if (isTrue(isValidKey)) {
      pressKey(key);
    } else {
      noop();
    }
  } else {}
}
function down_visibility(id1,id2,id3,id4,id5,id6,id7,id8) {
  var e1 = document.getElementById(id1);
  var e2 = document.getElementById(id2);
  var e3 = document.getElementById(id3);
  var e4 = document.getElementById(id4);
  var e5 = document.getElementById(id5);
  var e6 = document.getElementById(id6);
  var e7 = document.getElementById(id7);
  var e8 = document.getElementById(id8);
  
  if (e1.style.display == 'none')
    e1.style.display = 'block';
  else if (e1.style.display == 'block')
    { e1.style.display = 'none'; }
  |
      e2.style.display = 'none';
      e3.style.display = 'none';
      e4.style.display = 'none';
      e5.style.display = 'none';
      e6.style.display = 'none';
      e7.style.display = 'none';
      e8.style.display = 'none';
      }
function set_opacity(id, showable) {
  var animationAlreadyImplemented = true
  var tempBool =
    showable == 'hidden' ? false : showable == 'visible' ? true : false
  if (tempBool === true)
    return (function ($id) {
      document.getElementById($id).style.opacity = 1
      return document.getElementById($id).style.opacity
    })(id)
  else {
    return (function ($id) {
      document.getElementById($id).style.opacity = 0
      return document.getElementById($id).style.opacity
    })(id)
  }
}
function showMessages(
  id,
  durationBetweenEachMessage,
  message1,
  message2,
  message3,
  message4,
  message5,
  message6,
  message7,
  message8
) {
  return new Promise((resolve) => {
    document.getElementById(id).innerText = message1
    setTimeout(function () {
      document.getElementById(id).style.opacity = set_opacity(
        document.getElementById(id).getAttribute('id'),
        'hidden'
      )
      setTimeout(function () {
        document.getElementById(id).innerText = message2
        document.getElementById(id).style.opacity = set_opacity(
          document.getElementById(id).getAttribute('id'),
          'visible'
        )
        setTimeout(function () {
          document.getElementById(id).style.opacity = set_opacity(
            document.getElementById(id).getAttribute('id'),
            'hidden'
          )
          setTimeout(function () {
            document.getElementById(id).innerText = message3
            document.getElementById(id).style.opacity = set_opacity(
              document.getElementById(id).getAttribute('id'),
              'visible'
            )
            setTimeout(function () {
              document.getElementById(id).style.opacity = set_opacity(
                document.getElementById(id).getAttribute('id'),
                'hidden'
              )
              setTimeout(function () {
                document.getElementById(id).innerText = message4
                document.getElementById(id).style.opacity = set_opacity(
                  document.getElementById(id).getAttribute('id'),
                  'visible'
                )
                setTimeout(function () {
                  document.getElementById(id).style.opacity = set_opacity(
                    document.getElementById(id).getAttribute('id'),
                    'hidden'
                  )
                  setTimeout(function () {
                    document.getElementById(id).innerText = message5
                    document.getElementById(id).style.opacity = set_opacity(
                      document.getElementById(id).getAttribute('id'),
                      'visible'
                    )
                    setTimeout(function () {
                      document.getElementById(id).style.opacity = set_opacity(
                        document.getElementById(id).getAttribute('id'),
                        'hidden'
                      )
                      setTimeout(function () {
                        document.getElementById(id).innerText = message6
                        document.getElementById(id).style.opacity = set_opacity(
                          document.getElementById(id).getAttribute('id'),
                          'visible'
                        )
                        setTimeout(function () {
                          document.getElementById(id).style.opacity =
                            set_opacity(
                              document.getElementById(id).getAttribute('id'),
                              'hidden'
                            )
                          setTimeout(function () {
                            document.getElementById(id).innerText = message7
                            document.getElementById(id).style.opacity =
                              set_opacity(
                                document.getElementById(id).getAttribute('id'),
                                'visible'
                              )
                            setTimeout(function () {
                              document.getElementById(id).style.opacity =
                                set_opacity(
                                  document
                                    .getElementById(id)
                                    .getAttribute('id'),
                                  'hidden'
                                )
                              setTimeout(function () {
                                document.getElementById(id).innerText = message8
                                document.getElementById(id).style.opacity =
                                  set_opacity(
                                    document
                                      .getElementById(id)
                                      .getAttribute('id'),
                                    'visible'
                                  )
                                setTimeout(function () {
                                  document.getElementById(id).style.opacity =
                                    set_opacity(
                                      document
                                        .getElementById(id)
                                        .getAttribute('id'),
                                      'hidden'
                                    )
                                  resolve()
                                }, durationBetweenEachMessage)
                              }, durationBetweenEachMessage)
                            }, durationBetweenEachMessage)
                          }, durationBetweenEachMessage)
                        }, durationBetweenEachMessage)
                      }, durationBetweenEachMessage)
                    }, durationBetweenEachMessage)
                  }, durationBetweenEachMessage)
                }, durationBetweenEachMessage)
              }, durationBetweenEachMessage)
            }, durationBetweenEachMessage)
          }, durationBetweenEachMessage)
        }, durationBetweenEachMessage)
      }, durationBetweenEachMessage)
    }, durationBetweenEachMessage)
  })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment