- 1
- 2
- 3
- 4
- 5
$.post("include/show_watching.php",
function(data) {
$('#content').empty().append(data);
}
);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
$.post("include/show_watching.php",
function(data) {
$('#content').empty().append(data);
}
);
Вот такой вот POST-запрос.
+161
function printf(format, value) {
return format.replace(/%s/, value.toString());
}
return {
updateProgressBar: function (percentage) {
console.log("update \"progressBar\" status");
progressBar.innerHTML = printf("<p>%s %</p>", percentage);
}
};
+164
$(document).ready(function(){
//50% прозрачность иконкам голосования
var minusBig = $(".photo-rate-block-minus"),
plusBig = $(".photo-rate-block-plus"),
minusSmall = $(".photo-rate-block-minus-small"),
plusSmall = $(".photo-rate-block-plus-small");
$(minusBig).css('opacity', '0.5');
$(plusBig).css('opacity', '0.5');
$(minusSmall).css('opacity', '0.5');
$(plusSmall).css('opacity', '0.5');
$(".photo-rate-block-minus, .photo-rate-block-plus, .photo-rate-block-minus-small, .photo-rate-block-plus-small").hover( function(){
$(this).css('opacity', '1');
}, function(){
$(this).css('opacity', '0.5');
});
});
CSS для слабаков
+153
var currentTime = (new Date()).getTime();
var diff = currentTime - this.startTime;
var min = Math.floor(Math.floor(diff/1000)/60);
if (min < 10)
min = "0"+min;
var sec = Math.floor(diff/1000)%60;
if (sec < 10)
sec = "0"+sec;
this.timeLabel.setString("TIME " + min + ":" + sec);
Классика практически, моего творения. Как это можно сделать по-человечески на JS? Всякие jQuary не катят, ибо js встраиваемый.
+151
function checked(obj) {
var undefined;
obj = '#'+obj;
if ($(obj+':checked').attr('id') == undefined) {
return 0;
}
else {
return 1;
}
}
можно встретить и такое
+167
http://habrahabr.ru/post/172015/
Наш клиент.
Не смотря на заголовок статьи, он упёрся в ограничение на количество параметров в функции.
+159
function validateForm(form){
if (isNotEmpty(form.fa)){
if (isColvo(form.fa,3)){
if (isNotEmpty(form.im)){
if (isColvo(form.im,2)){
if (isNotEmpty(form.ot)){
if (isColvo(form.ot,3)){
if(isNotEmpty(form.day)){
if(isNumbr(form.day)){
if(isNotEmpty(form.month)){
if(isNumbr(form.month)){
if(isNotEmpty(form.year)){
if (isColvo(form.year,4)){
if(isNumbr(form.year)){
if(isNotEmpty(form.city)){
if(isNotEmpty(form.road)){
if(isNotEmpty(form.house)){
if(isNumbr(form.house)){
return true;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return false;
};
http://национальныйзакон.рф
+179
$.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26));
Форматирование даты в жс. Без jQuery ясное дело не обойтись.
If you are already using jQuery UI in your project, you can use the built-in datepicker method for formatting your date object:
http://stackoverflow.com/a/7022296
Раз уж неделя стековерфловочки...
+155
//...
else if (data.indexOf('none') == -1)
{
// Экспорт в работе
// Повторять запрос раз в nSec секунд.
nSec = 3;
document.getElementById("export_loading").show();
setTimeout("loadFile({{subject_id}}, '')", nSec*1000);
}
//...
<div class='loader' id="export_loading" style="visibility: hidden; display: inline-block; text-align: center; margin-right: 13px;"><img src='/app/images/loading.gif'/> идёт формирование списка авторов</div>
<div id="messages_container" style="visibility: hidden; padding: 0px 30px 0 35px;">
</div>
Чувак вообще прикалывается)
+164
var num = 3;
var x1 = Math.floor(Math.random()*num + 1);
var x2 = Math.floor(Math.random()*num + 1);
var x3 = Math.floor(Math.random()*num + 1);
var x4 = Math.floor(Math.random()*num + 1);
var x5 = Math.floor(Math.random()*num + 1);
var x6 = Math.floor(Math.random()*num + 1);
var x7 = Math.floor(Math.random()*num + 1);
var x8 = Math.floor(Math.random()*num + 1);
var x9 = Math.floor(Math.random()*num + 1);
var x10 = Math.floor(Math.random()*num + 1);
var x11 = Math.floor(Math.random()*num + 1);
var x12 = Math.floor(Math.random()*num + 1);
var x13 = Math.floor(Math.random()*num + 1);
var x14 = Math.floor(Math.random()*num + 1);
var x15 = Math.floor(Math.random()*num + 1);
var x16 = Math.floor(Math.random()*num + 1);
var i = 0;
while (true) {
x1 = Math.floor(Math.random()*num + 1);
x2 = Math.floor(Math.random()*num + 1);
x3 = Math.floor(Math.random()*num + 1);
x4 = Math.floor(Math.random()*num + 1);
x5 = Math.floor(Math.random()*num + 1);
x6 = Math.floor(Math.random()*num + 1);
x7 = Math.floor(Math.random()*num + 1);
x8 = Math.floor(Math.random()*num + 1);
x9 = Math.floor(Math.random()*num + 1);
x10 = Math.floor(Math.random()*num + 1);
x11 = Math.floor(Math.random()*num + 1);
x12 = Math.floor(Math.random()*num + 1);
x13 = Math.floor(Math.random()*num + 1);
x14 = Math.floor(Math.random()*num + 1);
x15 = Math.floor(Math.random()*num + 1);
x16 = Math.floor(Math.random()*num + 1);
if (x1 === x2){
if (x2 === x3) {
if(x4 === x5){
if (x5 === x6) {
if (x6 === x7){
if (x7 === x8){
if (x8 === x9){
if (x9 === x10){
if (x10 === x11){
if (x11 === x12){
if (x12 === x13){
if (x13 === x14){
if (x14 === x15){
if (x15 === x16){
if (x1 === x16){
document.write('<h3>ЧИСЛО x1 - ' + x1 + ' и x2 - ' + x2 + " x3 - " + x3 + " x4 - " + x4 + " x5 - " + x5 + " x6 - " + x6 + " x7 - " + x7 + " x8 - " + x8 + " x9 - " + x9 + " x10 - " + x10 + " x11 - " + x11 + " x12 - " + x12 + " x13 - " + x13 + " x14 - " + x14 + " x15 - " + x15 + " x16 - " + x16 + "<b> i= </b> " + i);
break;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}else{
i++;
document.write('<b>x1: </b>' + x1 + ' <b> x2: </b> ' + x2 + " x3 - " + x3 + " x4 - " + x4 + " x5 - " + x5 + " x6 - " + x6 + " x7 - " + x7 + " x8 - " + x8 + " x9 - " + x9 + " x10 - " + x10 + " x11 - " + x11 + " x12 - " + x12 + " x13 - " + x13 + " x14 - " + x14 + " x15 - " + x15 + " x16 - " + x16 + " - " + i + "<br>");}
}
Генерируем 16 чисел в диапазоне 1-3, условие такое, что они должны быть равными, пока они не равны выводим каждое значение числа, и вот что каждый раз в цикле (генерируем новые случайные числа, в этом же диапазоне)