- 1
Почему "getElementById", а не "getElementByID"?
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
Почему "getElementById", а не "getElementByID"?
−2
function inhify(guest, inho = 'inho') {
guest = guest.replace(/[aeiou]$/ig, '');
return guest + inho;
}
function test(guest, guestinho) {
var res = inhify(guest);
if (res !== guestinho) {
console.error(`Expected ${res} to be ${guestinho}`);
} else {
console.log(`${guest} => ${guestinho}`);
}
}
test('guest', 'guestinho');
test('guesto', 'guestinho');
test('bormand', 'bormandinho');
test('barop', 'baropinho');
test('anus', 'anusinho');
test('viagra', 'viagrinho');
test('pohui', 'pohuinho');
−2
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<h3 > enter a capcha </h3>
<canvas id = "capchaGen" width="40" height="20"> </canvas>
<button id = "rst" onclick = "a()"> get</button>
<br />
<input type = "text" placeholder = "capcha" name = "capchaIn" class ="box" id="capchaIn"required>
<button
id ="end" onclick = "c()">
ok
</button>
<script>
var pass = '';
var capha = document.getElementById("capchaGen");
var cap = capha.getContext("2d");
function a(){
cap.clearRect(0, 0, 40, 20);
cap.strokeText(gen_pass() ,5,15);
}
function c(){
var val=document.getElementById("capchaIn").value;
if(val ==pass){
alert("accept")
///////site////site/////сайт
window.open("https://google.com","_self")
}
else{
alert("invalid capcha")
a();
}
}
chr = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',0,1,2,3,4,5,6,7,8,9);
function rnd(x,y,z) {
var num;
do {
num = parseInt(Math.random()*z);
if (num >= x && num <= y) break;
} while (true);
return(num);
}
function gen_pass() {
pass ='';
for (var i = 0; i < 5; i++) pass += chr[rnd(0,61,100)];
return pass;
}
a();
</script>
<style>
canvas{
border-style:solid;
background-color:#c7a956 ;
border-width:1px;
border-color: rgba(0,0,0,0.5)
}
.box{
color:red;
width:80px;
}
h3{
color:green;
}
</style>
</body>
Капча. Обсирайте как можете.
0
updateStateByHotkey(items, keyCode, isModifierPressed) {
const getNewState = stateGetter => items.every(item => stateGetter(item) !== isModifierPressed) === isModifierPressed;
// Под switch'ем для каждой горячей клавиши
this.setItemsX(items, getNewState(item => item.x));
}
ES6.
Нежелание подумать над менее запутанной реализацией заставило подумать над реализацией вот этого вот. Под Modifier'ом имеется в виду Ctrl или Command.
СПОЙЛЕР:
Горячие клавиши, переключающие состояние, идут парами - без Ctrl и с ним.
Если все элементы находятся в одном и том же состоянии, оба варианта делают одно и то же - переключают это состояние.
Если элементы в разных состояниях, то без Ctrl оно включает состояние во всех элементах, а с Ctrl - выключает.
Значения состояния и isModifierPressed, отличные от true или false, вроде бы, исключены.
0
function _random_key() {
return '_' + new Date().getTime();
}
Fucking random!
0
var comment = document.querySelector('textarea#formElm_text');
var info = comment.parentNode;
if(!comment || !info) return;
https://github.com/1024--/govnokod.ru-userscripts/blob/master/bbcode.user.js
0
list.forEach((element1) => {
if (element1.parent_id == null){
output.push(element1);
list.forEach((element2) => {
if (element2.parent_id == element1.id) {
output.push(element2);
list.forEach((element3) => {
if (element3.parent_id == element2.id) {
output.push(element3);
list.forEach((element4) => {
if (element4.parent_id == element3.id) {
output.push(element4);
}
})
}
})
}
})
}
})
Super forEach
−2
if (query) {
searchParams.area = query.area_from && query.area_from !== 'all' && query.area_from.length !== 0 && query.area_to && query.area_to !== 'all' && query.area_to.length !== 0 ? [query.area_from, query.area_to] : ['0', '100']
searchParams.price = query.price_from && query.price_from !== 'all' && query.price_from.length !== 0 && query.price_to && query.price_to !== 'all' && query.price_to.length !== 0 ? [query.price_from, query.price_to] : ['0', '10']
searchParams.floor = query.floor_from && query.floor_from !== 'all' && query.floor_from.length !== 0 && query.floor_to && query.floor_to !== 'all' && query.floor_to.length !== 0 ? [query.floor_from, query.floor_to] : ['0', '100']
searchParams.last_first = query.last_first && query.last_first !== 'all' && query.last_first.length !== 0 ? query.last_first : null
searchParams.promo = query.promo && query.promo !== 'all' && query.promo.length !== 0 ? query.promo : null
searchParams.assignment = query.assignment && query.assignment !== 'all' && query.assignment.length !== 0 ? query.assignment : null
no coments
+4
function isPalindrom1(str) {
if (str.toLowerCase().replace(/[^а-яА-ЯёЁ]/g, '') === str.toLowerCase().replace(/[^а-яА-ЯёЁ]/g,
'').split('').reverse().join('')) {
return true;
} else {
return false;
}
}
"Красиво, просто, изящно."
h: post/351874/
0
$(document).ready(function() {
console.log("Ready");
var
block_1 = document.getElementsByClassName('block_1')[0],
block_2 = document.getElementsByClassName('block_2')[0],
block_3 = document.getElementsByClassName('block_3')[0],
block_4 = document.getElementsByClassName('block_4')[0],
open_1 = document.getElementsByClassName('open-1')[0],
open_2 = document.getElementsByClassName('open-2')[0],
open_3 = document.getElementsByClassName('open-3')[0],
open_4 = document.getElementsByClassName('open-4')[0];
open_1.onclick = function(){
block_1.style.display = "block";
block_2.style.display = "none";
block_3.style.display = "none";
block_4.style.display = "none";
};
open_2.onclick = function() {
block_2.style.display = "block";
block_1.style.display = "none";
block_3.style.display = "none";
block_4.style.display = "none";
};
open_3.onclick = function() {
block_2.style.display = "none";
block_1.style.display = "none";
block_3.style.display = "block";
block_4.style.display = "none";
};
open_4.onclick = function() {
block_2.style.display = "none";
block_1.style.display = "none";
block_3.style.display = "none";
block_4.style.display = "block";
};
});