- 1
https://pikabu.ru/story/bez_lokha_i_zhizn_plokha_6096016
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
https://pikabu.ru/story/bez_lokha_i_zhizn_plokha_6096016
−1
restrictions = restrictions.filter(restriction =>
_.find(solution, item => (
(item.from === restriction.from) && (item.to === restriction.to)
))
).map(restriction => {
const solutionTransmission = _.find(
solution,
item => ((item.from === restriction.from) && (item.to === restriction.to))
);
if (solutionTransmission) {
return restriction;
}
return null;
}).filter(restriction => restriction);
0
document.querySelector('.button').onmousemove = function (e) {
var x = e.pageX - e.target.offsetLeft;
var y = e.pageY - e.target.offsetTop;
e.target.style.setProperty('--x', x + 'px');
e.target.style.setProperty('--y', y + 'px');
};
+1
let suffix = '';
if (search) {
if (filters.length) {
suffix = ' found:';
} else {
suffix = ' found';
}
} else {
if (filters.length) {
suffix = ' found:';
}
}
Когда не уверен, нужно двоеточие или нет.
0
https://javascript.ru/forum/events/74655-peredacha-parametrov-v-funkciyu.html
https://javascript.ru/forum/events/74576-mozhno-li-ispolzovat-funkciyu-odnogo-diva-v-drugom.html
https://javascript.ru/forum/events/74553-kalkulyaciya-ceny-na-sajjte.html
−1
import Router from 'koa-router';
import pmongo from 'promised-mongo';
const router = new Router();
const db = new pmongo('localhost/my-app');
const dataRequired = function *(next) {
if (typeof this.request.body['data'] === 'object') {
yield next;
} else {
this.throw(400, 'Request data is required');
}
};
Валидация, js-way
https://github.com/axept/open-parse
> Our developers have higher professional education and are experts in any of those technology
−1
Долго не мог понять что за фреймворк такой "Vanilla JS".
−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>
Капча. Обсирайте как можете.