- 1
jQuery("body").trigger( F11 )
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
jQuery("body").trigger( F11 )
Попытка перейти в полноэкранный режим.. Найдено в недрах одного довольно серьезного проекта.
+169
if(navigator.appName == "Microsoft Internet Explorer") {
for(var i=0;i<$('.product_documents').length;i++) if( ( (firstLaunch_onChangeDocs) && ($('.product_documents')[i].selectedIndex==0)) || (!firstLaunch_onChangeDocs) )
{
document.getElementById($('.product_documents')[i].id).innerHTML = '';
document.getElementById($('.product_documents')[i].id).outerHTML = document.getElementById($('.product_documents')[i].id).outerHTML.replace("</SELECT>", jsInternalDocuments + '</select>')
}
} else
for(var i=0;i<$('.product_documents').length;i++) if( ( (firstLaunch_onChangeDocs) && ($('.product_documents')[i].selectedIndex==0)) || (!firstLaunch_onChangeDocs) )
$('.product_documents')[i].innerHTML = jsInternalDocuments;
Очень альтернативная техника использования jquery.
+160
for(var i = 0, l = requestParams.length; i < l; i++) {
var param_pair = requestParams[i];
key = encodeURIComponent(param_pair[0]);
val = param_pair[1];
if ( val && val.constructor.toString().match(/array/i) ) {
val = val.join('+');
}
// ...
}
Кусочек велосипеда, который заменяет функционал jQuery.ajax
Если вдруг наш параметр оказался массивом ... ну что ж еще с ним сделать кроме как соединить через "+". Обратите внимание на саму проверку.
+140
if (maxWidth < 96) {maxWidth = 96 }
Большой Брат следит за тобой, переменная.
+146
Object.prototype.merge = function(objects){
var newObj = this;
for(var key in objects){
key!='merge'?newObj[key] = objects[key]:void(0);
}
return newObj;
};
Выглядит ужасно, но ничего другого не придумал. Подскажите как правильно?)
P.S. Если убрать проверку "key!='merge'?" то в объекте становится на 1 ключ больше('merge')
+161
function toInt(number) {
return number && + number | 0 || 0;
}
http://ideone.com/igo7ag
Минут 10 назад меня ошарашили фразой о методе toInt(), который, якобы, есть в javascript. Гугл выдал всего одну ссылочку, в которой говорится о нем: http://javascript.ru/forum/misc/22100-funkciya-toint-razyasnite-pozhalujjsta-neskolko-momentov.html. Увидев данный код, я просто не мог не выложить его сюда.
+146
<input name="login" type="text" id="imageName" value="Image Name" onblur="if (this.value == ''){this.value = 'Image Name'; }" onfocus="if (this.value == 'Image Name') {this.value = '';}"/>
А вот так, нужно делать плейсхолдеры к инпутам.
+160
$('#info, #progress, #portfolio, #content1, #content2, #content3, #content4, #content5, #content6, #content7, #content8, #content9, #content10, #content11, #content12, #content13, #content14, #oneclick, #zoomer, #noback, #noinfo').fadeOut(0);
$('#abouticon').toggle(function(){
$('#pad, img[src*="line"]').fadeOut(500);
$('#abouticon').css({'background' : '#dae2e6'});
$('#info, #progress').delay(500).fadeIn(500);
$('img[src*="iDrugov.png"]').fadeOut(500);
//
$('#portfolio').fadeOut(500);
$('#icon3').css({'background' : '#83bdda'});
}, function(){
$('#pad, img[src*="line"]').delay(500).fadeIn(500);
$('#abouticon').css({'background' : '#a3c7da'});
$('#info, #progress').fadeOut(500);
$('img[src*="iDrugov.png"]').delay(500).fadeIn(500);
})
Много хорошего, годного jQuery!
+155
progressbar = function(o,opt){
opt = (opt==null)?{}:opt
...
}
function merge2 (arr1,arr2){
for (var t in arr2){
if (arr1[t]) {}
else {arr1[t]=arr2[t]}
}
return arr1;
}
автор явно не знает про знак логического отрицания, да и не только про него..
(jsclasses.org)
+150
(function($) {
core = {
verticalOffset: -390,
horizontalOffset: 0,
repositionOnResize: true,
overlayOpacity: 0.2,
overlayColor: '#ffffff',
draggable: true,
send: 'Отправить',
ok: 'Продолжить',
close: 'Закрыть',
save: 'Сохранить',
cancel: 'Отмена',
dialogClass: null,
alert: function(message, title, callback) {
if( title == null ) title = 'Alert';
this._show_mess(title, message, null, 'alert', function(result) {
if(callback) callback(result);
});
},
confirm: function(message, title, callback) {
if(title == null) title = 'Подтверждение действия';
this._show_mess(title, message, null, 'confirm', function(result) {
if(result) callback(result);
});
},
prompt: function(message, value, title, callback) {
if( title == null ) title = 'Prompt';
this._show_mess(title, message, value, 'prompt', function(result) {
if( callback ) callback(result);
});
},
message: function(title){
if(title == null) title = '';
this._show_mess(title, '', '', 'message');
},
box_close: function() {
$('#popup_container').fadeOut(200, function(){
$('#popup_overlay, #popup_container').remove();
});
},
_show_mess: function(title, msg, value, type, callback) {
if ($('#popup_container').length > 0) {
$('#popup_overlay, #popup_container').remove();
}
var html = "<div id='popup_container'>" +
"<table>" +
"<tbody>" +
"<tr>" +
"<td class='tl'/><td class='b'/><td class='tr'/>" +
"</tr>" +
"<tr>" +
"<td class='b'/>" +
"<td class='body'>" +
"<div class='popup_title_wrap'><div class='popup_x_button'/><div id='popup_title'/></div>" +
"<div id='popup_progress'><img src='/images/progress.gif' alt='Загрузка...' /></div>" +
"<div id='popup_content'/>" +
"<div id='popup_message'/>" +
"<div id='popup_panel'>" +
"<span class='ajax-loader'> </span>" +
"<div id='popup_info'/>" +
"<input id='popup_ok' type='button' class='button_yes' value='" + this.ok + "'/>" +
"<input id='popup_cancel' type='button' class='button_no' value='" + this.cancel + "'/>" +
"<input id='popup_close' type='button' class='button_no' value='" + this.close + "'/>" +
"</div>" +
"</td>" +
"<td class='b'/>" +
"</tr>" +
"<tr>" +
"<td class='bl'/><td class='b'/><td class='br'/>" +
"</tr>" +
"</tbody>" +
"</table>" +
"</div>";
this._overlay('show');
$('body').append(html);
$('#popup_panel input').hide();
if(this.dialogClass) {
$('#popup_container').addClass(this.dialogClass);
}
var pos = (($.browser.msie && parseInt($.browser.version) <= 6 )||(($(window).height()<480)||($(window).width()<700))) ? 'absolute' : 'fixed';
$('#popup_container').css({
position: pos,
zIndex: 999,
padding: 0,
margin: 0
});