- 1
- 2
- 3
- 4
// eval both the numbers to remove quotes
// otherwise 4 + 5 will be "4" + "5" which in JS will equal 45
evalDisplay = eval(displayNum),
evalStored = eval(storedNum);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+3
// eval both the numbers to remove quotes
// otherwise 4 + 5 will be "4" + "5" which in JS will equal 45
evalDisplay = eval(displayNum),
evalStored = eval(storedNum);
Гениальный способ получить число из строки (вместо evalDisplay = +evalDisplay)
0
// oldman and pilul
$( "#draggable" ).draggable();
$( "#draggable1" ).draggable();
$( "#droppable" ).droppable({
drop: function() {
$("#droppable").attr("src","img/happy1.png");
$("#droppable1").attr("src","img/happy1.png");
$('#draggable').hide();
$('#draggable1').hide();
}
});
//buttons
$('#weekbtn').click(function(){
if ( $('#weekbtn').attr("src")== "img/week-pushed-button.png" ) {
$("#weekbtn").attr("src","img/week-button.png");
$("#weekbtn1").attr("src","img/week-button.png");
} else {
$("#weekbtn").attr("src","img/week-pushed-button.png");
$("#weekbtn1").attr("src","img/week-pushed-button.png");
}
});
$('#daybtn').click(function(){
if ( $('#daybtn').attr("src")== "img/day-pushed-button.png" ) {
$("#daybtn").attr("src","img/day-button.png");
$("#daybtn1").attr("src","img/day-button.png");
} else {
$("#daybtn").attr("src","img/day-pushed-button.png");
$("#daybtn1").attr("src","img/day-pushed-button.png");
}
});
$('#mounthbtn').click(function(){
if ( $('#mounthbtn').attr("src")== "img/mounth-pushed-button.png" ) {
$("#mounthbtn").attr("src","img/mounth-button.png");
$("#mounthbtn1").attr("src","img/mounth-button.png");
} else {
$("#mounthbtn").attr("src","img/mounth-pushed-button.png");
$("#mounthbtn1").attr("src","img/mounth-pushed-button.png");
}
});
//roller
function move(){
var rng = document.getElementById('scrol-line'),
rng1 = document.getElementById('scrol-line1'),
roll = document.getElementById('bgc'),
roll1 = document.getElementById('bgc1');
roll.value = rng.value;
rng1.value = rng.value;
roll1.value = rng1.value;
}
//slider
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("sliders");
if (n > slides.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = slides.length
}
for (i=0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideIndex-1].style.display = "block";
}
+2
$(document).ready(function(){
$('.field').click(function(){
$('.selected').removeClass('selected');
$(this).addClass('selected');
$(this).click(function(){
$('#move').attr('disabled', true);
$('.selected, .field').removeClass('visible');
$('.field').text('');
$('.selected').html('<span id="user"><img src="user.gif"></span>');
$('.selected').next().addClass('visible');
$('.selected').next().next().next().next().next().next().addClass('visible');
$('.selected').next().next().next().next().next().next().next().addClass('visible');
$('.selected').next().next().next().next().next().next().next().next().addClass('visible');
//$('.selected').addClass('visible');
$('.selected').prev().addClass('visible');
$('.selected').prev().prev().prev().prev().prev().prev().addClass('visible');
$('.selected').prev().prev().prev().prev().prev().prev().prev().addClass('visible');
$('.selected').prev().prev().prev().prev().prev().prev().prev().prev().addClass('visible');
});
...
Поле перемещения, написано около года назад :D не знал как можно по-другому
+1
sort((a, b) => 0 - (a.Bias > b.Bias ? 1 : -1))
+967
if (!ch.election) {
exec('date -R', function(error, stdout, stderr) {
if (stdout.search('Wed') > -1) {
ch.startElection();
}
});
} else {
exec('date -R', function(error, stdout, stderr) {
if (stdout.search('Wed') < 0) {
ch.stopElection();
}
});
}
В ноде видимо нет функций для работы с календарём...
https://github.com/birdlab/trigger/blob/master/src/node/trigger/channel.js#L783
+2004
// ==UserScript==
// @name GK refine
// @version 0.1
// @description opens comments on govnokod.ru... etc
// @match http://govnokod.ru/*
// @match http://www.govnokod.ru/*
// @grant none
// ==/UserScript==
// Показывает в стоке "new" около нового комментария
// и пишет, сколько времени назад его оставили
(function(){
if(location.pathname != '/comments') return;
var key = 'fcd0d66f-9ff0-4827-82f1-e183dc1ab98c-last-time';
var lastTime = localStorage[key] ? +localStorage[key] : 0;
var now = new Date();
$('abbr.published').each(function(){
var d = + new Date($(this).attr('title'));
$(this).text(((now-d) / 1000 / 60).toFixed(2) + 'm');
if(d > lastTime) $(this).after('<span style="color: red">NEW </span>');
});
localStorage[key] = +now;
})();
// Открывает скрытые комменты
$("div.entry-comment-hidden").removeClass('entry-comment-hidden');
Смотрю, а багры в стоке комментарий подменяют, чтобы пользователи не видели, где новый багор, а где старый.
Я только сейчас это понял потому, что у меня около непросмотренного в стоке пишется "NEW" уже несколько месяцев.
Запилил потому, что даже без багров не помнил, что открыл, а что нет. А тут в тему будет для тех, у кого платного аккаунта нет.
+267
//форма собственности
$('#sobst').change(function(){
var $radiouch = $('#uchred1, #uchred2');
var valip = 'ИП';
var $ip = $('#ip').attr('id');
var $obsch = $('.obschestvo').attr('class');
var $obsch2 = $('.obschestvo2').attr('class');
if($('option:selected', this).attr('id')==$ip){
$tab24.fadeOut(500);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
$novalid.removeAttr('required');
}
if($('option:selected', this).attr('class')==$obsch){
if($('#i').prop("checked")){
$tab24.fadeOut(500);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
$novalid.removeAttr('required');
}
else{
$tab24.fadeIn(1000);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('disabled').removeClass('err').attr('required','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
$novalid.removeAttr('required');
}
}
if($('option:selected', this).attr('class')==$obsch2){
if($('#i').prop("checked")){
$tab24.fadeOut(500);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('required').removeClass('err').attr('disabled','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
}
else{
$tab24.fadeIn(1000);
$tab24.find('input[type!=button][type!=submit], select, #Opis').removeAttr('disabled').removeClass('err').removeAttr('required','');
$tab24.find('input[type!=button][type!=submit][type!=radio], select, #Opis').val('');
$radiouch.prop('checked', false);
}
}
});
//Выбор учредителя
$('#uchrdiv1').find("input[type='radio']").click(function(){
var $dopuchr = $('#Familia, #Imia, #Otchestvo, #Dola');
var $uchr2elem = $('#uchrdiv2').find('input[type!=button][type!=submit][type!=radio], select, #Opis');
var $rad = $(this).attr('id');
if($rad==$('#uchred2').attr('id')){
$("#labfio").text("Форма собственности *");
$("#labname").text("Наименование *");
$("#labsur").text("УНП *");
$("#zagolovok").text("Наименование учредителя *");
$uchr2elem.removeAttr('required').removeClass('err').attr('disabled','');
$('#surname1').attr('required','');
$('#uchred1').removeClass('err');
$dopuchr.removeAttr('required');
}
else {
$("#labfio").text('Фамилия *');
$("#labname").text("Имя *");
$("#labsur").text("Отчество");
$("#zagolovok").text("Ф.И.О учредителя в именительном падеже *");
$uchr2elem.removeAttr('disabled').attr('required','').val('');
$('#table2').find('input[type!=radio]').removeAttr('disabled').attr('required','');
$('#surname1, #pomeschenieNum3').removeAttr('required','');
$('#uchred2').removeClass('err');
$dopuchr.removeAttr('required');
}
});
//Способ получения
$('.forms5').find("input[type='radio']").click(function(){
var $grd = $('#grd').find('input[id!=pomeschenieNum6], select');
var $ofs = $('#ofs').find('input, select');
var $posrad = $(this).attr('id');
if($posrad==$('#Ofis').attr('id')){
$grd.removeAttr('required').removeClass('err').attr('disabled','').val('');
$ofs.removeAttr('disabled').attr('required','').val('');
$('#Viezd').removeAttr('required').removeClass('err');
$('#Ofis').attr('required');
}
if($posrad==$('#Viezd').attr('id')){
$ofs.removeAttr('required').removeClass('err').attr('disabled','').val('');
$grd.removeAttr('disabled').attr('required','').val('');
$('#Ofis').removeAttr('required').removeClass('err');
$('#Viezd').attr('required');
}
});
//кнопка submit
$('#otpravit').on({
mousedown: function(){
$(this).css('background','linear-gradient(to bottom right, #D77024, #E49656)');
},
mouseup: function(){
$(this).css('background','linear-gradient(to bottom right, #EC841C, #EDA24E)');
страница с формами
название файла (ВНИМАНИЕ!): dubische_gaz
+270
$("#page1").click(function(){
$(".ag1").fadeIn(2500);
});
$("#page2").click(function(){
$(".ag2").fadeIn(2500);
});
$("#page3").click(function(){
$(".ag3").fadeIn(2500);
});
$("#page4").click(function(){
$(".ag4").fadeIn(2500);
});
$("#page5").click(function(){
$(".ag5").fadeIn(2500);
});
$("#page6").click(function(){
$(".ag6").fadeIn(2500);
});
$("#page7").click(function(){
$(".ag7").fadeIn(2500);
});
$("#page8").click(function(){
$(".ag8").fadeIn(2500);
});
$("#page9").click(function(){
$(".ag9").fadeIn(2500);
});
$("#page10").click(function(){
$(".ag10").fadeIn(2500);
});
$("#page11").click(function(){
$(".ag11").fadeIn(2500);
});
$("#page12").click(function(){
$(".ag12").fadeIn(2500);
});
$("#page13").click(function(){
$(".ag13").fadeIn(2500);
});
$("#page14").click(function(){
$(".ag14").fadeIn(2500);
});
$("#page15").click(function(){
$(".ag15").fadeIn(2500);
});
$("#page16").click(function(){
$(".ag16").fadeIn(2500);
});
$("#page17").click(function(){
$(".ag17").fadeIn(2500);
});
$("#page18").click(function(){
$(".ag18").fadeIn(2500);
});
$("#page19").click(function(){
$(".ag19").fadeIn(2500);
});
$("#page20").click(function(){
$(".ag20").fadeIn(2500);
});
$("#page21").click(function(){
$(".ag21").fadeIn(2500);
});
$("#page22").click(function(){
$(".ag22").fadeIn(2500);
});
$("#page23").click(function(){
$(".ag23").fadeIn(2500);
});
$("#page24").click(function(){
Из Азербайджана с любовью.
+8
function getEntryByName(name) {
var entries = [];
var ent;
while(ent = getNextDBEntry()) {
entries.push(ent);
}
for(var i = 0; i < entries.length; i++) {
if(entries[i].getName() == name) {
return entries[i];
}
}
return nullEntry;
}
ААА, мои глаза!!!
+5
function insertComment(comment) {
// todo: optimize this shit
for (var j = 0; j < $scope.comments.length; ++j) {
if ($scope.comments[j].thread_id == comment.thread_id) {
$scope.comments[j] = comment;
return;
}
if ($scope.comments[j].comment_id < comment.comment_id) {
$scope.comments.splice(j, 0, comment);
return;
}
}
$scope.comments.push(comment);
}
for (var i = 0; i < data.length; ++i) {
comment = data[i];
comment.text = $sce.trustAsHtml(comment.text);
comment.postedFuzzy = fuzzyDate(new Date(comment.posted), new Date());
insertComment(comment);
}
Оптимальное набивание комментов в сток за O(n^2).
http://146.185.130.46/ngk/