- 1
Math.min(Math.max(asd, 350), 350);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+145
Math.min(Math.max(asd, 350), 350);
и почему размер всегда 350?
+158
<!--//
calendar = new Date();
day = calendar.getDay();
document.write("<table width=100 border=1><tr><td><center><font size=2>")
if (day == 0) {
document.write("<font color=#ff0000>Воскресенье</font>")
}
if (day == 1) {
document.write("Понедельник")
}
if (day == 2) {
document.write("Вторник")
}
if (day == 3) {
document.write("Среда")
}
if (day == 4) {
document.write("Четверг")
}
if (day == 5) {
document.write("Пятница")
}
if (day == 6) {
document.write("<font color=#ff0000>Суббота</font>")
}
document.write("</font></center></td></tr><tr><td><center><font size=2>")
month = calendar.getMonth();
if (month == 0) {
document.write("Январь")
}
if (month == 1) {
document.write("Февраль")
}
if (month == 2) {
document.write("Март")
}
if (month == 3) {
document.write("Апрель")
}
if (month == 4) {
document.write("Май")
}
if (month == 5) {
document.write("Июнь")
}
if (month == 6) {
document.write("Июль")
}
if (month == 7) {
document.write("Август")
}
if (month == 8) {
document.write("Сентябрь")
}
if (month == 9) {
document.write("Октябрь")
}
if (month == 10) {
document.write("Ноябрь")
}
if (month == 11) {
document.write("Декабрь")
}
document.write("</font></center></td></tr><tr><td><center><font size=6>")
date = calendar.getDate();
document.write(date)
document.write("</font></center></td></tr><tr><td><center><font size=2>")
year = calendar.getYear();
if (year < 100) {
document.write("19" + year + "")
}
else if (year > 1999) {
document.write(year)
}
document.write("</font></center></td></tr></table>")
//-->
Вывод даты в человеко-понятном формате. Найдено в коде одного украинского МВДшного сайта.
+150
function fixPNG(element)
{
if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
var src;
src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
if(src){
src = src[1];
element.runtimeStyle.backgroundImage = "none";
}
if(src){
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src = '" +
src + "',sizingMethod = 'scale')";
}
}
}
+166
var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function isValid(parm,val) {
if (parm == "") return true;
for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}
http://javascript.about.com/library/blvalid02.htm
Вырезка из шапки:
Javascript does not contain functions that test specifically for alphabetic or numeric content but we can easily provide these functions for ourselves...
+159
notify: function(evt) {
var state = this.prevFirst === null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');
// Load items
this.callback('itemLoadCallback', evt, state);
if (this.prevFirst !== this.first) {
this.callback('itemFirstInCallback', evt, state, this.first);
this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
}
if (this.prevLast !== this.last) {
this.callback('itemLastInCallback', evt, state, this.last);
this.callback('itemLastOutCallback', evt, state, this.prevLast);
}
this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
},
Популярный jQuery плагин - "jCarousel"
http://sorgalla.com/projects/jcarousel/
2 часа пытался реализовать инициализацию элементов "конвеера" до появления их на экране.
Но не тут-то было. Все 7 событий, регулирующих смену позиции - вызываются в один момент времени (при занятии элементом итогового положения).
• itemLoadCallback
• itemFirstInCallback
• itemFirstOutCallback
• itemLastInCallback
• itemLastOutCallback
• itemVisibleInCallback
• itemVisibleOutCallback
*this.callback сводится до fn.call()
+169
<img onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor=''">
+169
function moveup() {
if (document.all.menuedit.menuitemslist.selectedIndex > 0) {
var addt = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).text;
var addv = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).value;
var addtold = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex - 1).text;
var addvold = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex - 1).value;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex - 1).text = addt;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex - 1).value = addv;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).text = addtold;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).value = addvold;
document.all.menuedit.menuitemslist.selectedIndex = document.all.menuedit.menuitemslist.selectedIndex - 1;
}
}
function movedown() {
if ((document.all.menuedit.menuitemslist.selectedIndex > -1) && (document.all.menuedit.menuitemslist.selectedIndex < (document.all.menuedit.menuitemslist.length - 1))) {
var addt = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).text;
var addv = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).value;
var addtold = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex + 1).text;
var addvold = document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex + 1).value;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex + 1).text = addt;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex + 1).value = addv;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).text = addtold;
document.all.menuedit.menuitemslist.options(document.all.menuedit.menuitemslist.selectedIndex).value = addvold;
document.all.menuedit.menuitemslist.selectedIndex = document.all.menuedit.menuitemslist.selectedIndex + 1;
}
}
код видимо осуществляет манипуляции с элементами меню.
написано в до-jQuer-ные времена иркутскими быдлокодерами.
+169
/*
Функция раскодирования символов кириллицы.
Исходные данные должны содержаться в строке $ToDecode.
Символы кириллицы раскодируются из: ^NN, где NN - номер символа (по очереди на клавиатуре, вначале заглавные буквы).
01 - Й, 02 - Ц, ... 31 - Б, 32 - Ю, 33 - Ё, 34 - й, 35 - ц, ..., 64 - б, 65 - ю, 66 - ё
Все символы, кроме раскодируемых данным образом остаются неизменными.
Добавлены украинские символы.
*/
function decoding (ToDecode)
{
var Result = ''
var len = ToDecode.length
var ch=''
var i = 0
while (i<len)
{
ch = ToDecode.charAt(i)
if (ch == '^')
{
ch=ch+ToDecode.charAt(i+1)+ToDecode.charAt(i+2)
if (ch=='^01') {ch = 'Й';} if (ch=='^02') {ch = 'Ц';} if (ch=='^03') {ch = 'У';}
if (ch=='^04') {ch = 'К';} if (ch=='^05') {ch = 'Е';} if (ch=='^06') {ch = 'Н';}
if (ch=='^07') {ch = 'Г';} if (ch=='^08') {ch = 'Ш';} if (ch=='^09') {ch = 'Щ';}
if (ch=='^10') {ch = 'З';} if (ch=='^11') {ch = 'Х';} if (ch=='^12') {ch = 'Ъ';}
if (ch=='^13') {ch = 'Ф';} if (ch=='^14') {ch = 'Ы';} if (ch=='^15') {ch = 'В';}
if (ch=='^16') {ch = 'А';} if (ch=='^17') {ch = 'П';} if (ch=='^18') {ch = 'Р';}
if (ch=='^19') {ch = 'О';} if (ch=='^20') {ch = 'Л';} if (ch=='^21') {ch = 'Д';}
if (ch=='^22') {ch = 'Ж';} if (ch=='^23') {ch = 'Э';} if (ch=='^24') {ch = 'Я';}
if (ch=='^25') {ch = 'Ч';} if (ch=='^26') {ch = 'С';} if (ch=='^27') {ch = 'М';}
if (ch=='^28') {ch = 'И';} if (ch=='^29') {ch = 'Т';} if (ch=='^30') {ch = 'Ь';}
if (ch=='^31') {ch = 'Б';} if (ch=='^32') {ch = 'Ю';} if (ch=='^33') {ch = 'Ё';}
if (ch=='^34') {ch = 'й';} if (ch=='^35') {ch = 'ц';} if (ch=='^36') {ch = 'у';}
if (ch=='^37') {ch = 'к';} if (ch=='^38') {ch = 'е';} if (ch=='^39') {ch = 'н';}
if (ch=='^40') {ch = 'г';} if (ch=='^41') {ch = 'ш';} if (ch=='^42') {ch = 'щ';}
if (ch=='^43') {ch = 'з';} if (ch=='^44') {ch = 'х';} if (ch=='^45') {ch = 'ъ';}
if (ch=='^46') {ch = 'ф';} if (ch=='^47') {ch = 'ы';} if (ch=='^48') {ch = 'в';}
if (ch=='^49') {ch = 'а';} if (ch=='^50') {ch = 'п';} if (ch=='^51') {ch = 'р';}
if (ch=='^52') {ch = 'о';} if (ch=='^53') {ch = 'л';} if (ch=='^54') {ch = 'д';}
if (ch=='^55') {ch = 'ж';} if (ch=='^56') {ch = 'э';} if (ch=='^57') {ch = 'я';}
if (ch=='^58') {ch = 'ч';} if (ch=='^59') {ch = 'с';} if (ch=='^60') {ch = 'м';}
if (ch=='^61') {ch = 'и';} if (ch=='^62') {ch = 'т';} if (ch=='^63') {ch = 'ь';}
if (ch=='^64') {ch = 'б';} if (ch=='^65') {ch = 'ю';} if (ch=='^66') {ch = 'ё';}
// украинские символы
if (ch=='^67') {ch = 'Ї';} if (ch=='^68') {ch = 'І';} if (ch=='^69') {ch = 'Є';}
if (ch=='^70') {ch = 'Ґ';} if (ch=='^71') {ch = 'ї';} if (ch=='^72') {ch = 'і';}
if (ch=='^73') {ch = 'є';} if (ch=='^74') {ch = 'ґ';}
i=i+2
}
i=i+1
Result=Result+ch
}
return Result
}
А я минут 10 ковырялся думая в каком виде они кириллицу пересылают.
+162
$('.tdiv').find('.cancel').parent().append('<span class="error">' + r.msg + '</span>')
чистая параноя
+148
eval(' ~ function ( __ , ___ ) { _ = __ ( ___ ( "__", "return __ ") ({}) ) } (eval, Function) , _[("_")] = _ ');
не могу понять как работает =(