- 1
- 2
- 3
- 4
- 5
- 6
- 7
function showTimeToLive(doTranslation)
{
doTranslation = (doTranslation == undefined) ? true : doTranslation;
....
timer = window.setTimeout (doTranslation ? "turnOff(true)" : "turnOff(false)", secs)
....
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+137
function showTimeToLive(doTranslation)
{
doTranslation = (doTranslation == undefined) ? true : doTranslation;
....
timer = window.setTimeout (doTranslation ? "turnOff(true)" : "turnOff(false)", secs)
....
}
+152
if (!jQuery('#email').attr('value')){
jQuery('#email').css('border', '1px solid red');
jQuery('div.errors').append('<p>Не указан "E-Mail"</p>');
error=true;
}
else{
email=jQuery('#email').attr('value');
if ((email.length<8) || (email.search(/[а-яёЁ,~><|\/*#№`!"'$:;%^&?)(_=+]/i)+1) || (email.indexOf(' ')+1) || (email.indexOf('--')+1) || (email.indexOf('-.')+1) || (email.indexOf('.-')+1) || (email.indexOf('\\')+1) || (email.indexOf('..')+1) || (email.indexOf('.')==0) || (email.indexOf('-')==0) || (email.indexOf('@')==0) || (!(email.indexOf('@')+1)) || ((email.indexOf('@')!=email.lastIndexOf('@')) && (email.lastIndexOf('@')+1)) || (email.indexOf('@')>email.lastIndexOf('.')) || (!(email.lastIndexOf('.')<(email.length-2)))){
jQuery('#email').css('border', '1px solid red');
jQuery('div.errors').append('<p>E-mail указан некорректно</p>');
error=true;
}
else jQuery('#email').attr('style', null);
}
Функция проверки Email на валидность.
Regexp для слабых.
+158
this.startAdLoading = function(callback) {
this.adCallback = callback;
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
...
}
Очень полезный метод добавили массивам. Все тот же источник.
+145
$(function() {
// hardcore mode
"use strict";
"use paranoid";
// todo: string-to-functioName converter and more flexible injector
;(function() {
var ooStack = {
writeback: function() {
// main wrappers
var wrappers = $( 'html, body' );
var meta = $( 'head' );
var root = $( '#core' , wrappers );
var head = $( '#head', root );
var content = $( '#content' , root );
var sidebar = $( 'aside' , root );
var articles = $( 'article' , content );
// it can fuck your brain
var footway = {
root: root,
head: head,
content: content,
sidebar: sidebar,
articles: articles,
wrappers: wrappers,
// paginator
paginator: $( '.pager' , root ),
};
// return stack definition
return footway;
}
};
// New world
var appInstance = new world();
// Inject selectrors and methods
var app = appInstance.application;
app.dom = ooStack.writeback();
// Execute
app.init();
})();
});
Распедаль мои копыта -- наебнись мозги козла :D В Оригинале : робоцып, робокоп head и лопата
+147
getOffsetPosition: function( self, hash ) {
return $( '#' + hash, self.dom.root ).offset().top - 0;
},
// 27 is a magic fix number :: +5
getNumFromStrPx: function( pixels ) {
return ( pixels.replace( 'px' , '' ) - 0 ) - 22;
},
Magic Mashrooms ;) 1200 mics => non stop and sound sucks
+146
var passedLinks = new Array();
for( var lnk = 0; lnk <= aLinksCollection.length; lnk++ ) {
var AJAXLink = aLinksCollection[ lnk ];
// exclusions by DOM objects, filter external links and shuffle some extensions
if( typeof AJAXLink === 'undefined' ) continue;
var aLoc = AJAXLink.href;
if( AJAXLink.host.match( document.location.host ) &&
!self.filters.extensions.test( AJAXLink.pathname ) &&
!aLoc.match( self.filters.pathways[0] ) ) {
passedLinks.push( AJAXLink );
};
};
/* regExps constants */
filters: {
extensions: /\.(gif|jpg|jpeg|tiff|png|exe|pdf|txt|psd|rss|rdf|cpgz|tar\.gz|rar|zip|html|htm|test|tar|xml|msi|iso|swf)$/i,
trapzones: '#id1, #id2, #id3, .class1 pre:last, tags p:last',
pathways: [
'edit|add|reply|search|rss\.xml|#',
'contact|license|about|advertisement'
]
},
Выложу сам лучше ... отобрать хотели и сделать тоже самое ;) не серчайте
+146
$( self.filters.trapzones ).hover(function() {
if( garbage && !garbage.match(similar.id) ) {
$.Storage.set('SimNodes', garbage + similar.id + '*');
$('#similar').delay(550).show(550);
}
if( !garbage ) {
$.Storage.set('SimNodes', '0*' + similar.id + '*');
$('#similar').delay(550).show(550);
}
});
String Mach db
+144
(function() {
var appBase = function( appId ) {
appId = appId || Math.floor( Math.random() * ( 1000 - 1 ) + 1 );
this.stack = {
methods: [ ], extends: { },
init: function( cfg ) {
this.creator( cfg );
this.bootstrap();
},
bootstrap: function() {
this.methods.init = null;
var param = new Object();
param.app = this.methods,
param.opt = this.setup;
param.__proto__ = null;
for( var i in this.setup.inits ) {
this.methods[ this.setup.inits[i] ].apply( param );
};
},
creator: function( cfg ) {
for( var mtd in cfg ) {
var flag = cfg[ mtd ].options[ 1 ] || null,
name = cfg[ mtd ].options[ 0 ] + "",
func = cfg[ mtd ].func;
this.methods[ name ] = func;
this.methods[ name ].name = name;
if( flag ) {
flag = flag.split('|');
if( flag[0] ) {
switch( flag[0] ) {
case 'init': this.setup.inits.push( name ); break;
case 'defer':
this.setup.defer.push( name );
this.setupTimer( [ flag[ 1 ], name, flag[ 2 ] - 0 ] );
break;
};
};
};
};
},
setupTimer: function( opt ) {
var tf = this.setup.timer[ opt[1] ],
tt = this.methods[ opt[1] ],
tm = opt[ 2 ] || 500;
switch( opt[0] ) {
case 'interval': tf = setInterval( tt, tm ); break;
case 'timeout': tf = setTimeout( tt, tm ); break;
};
},
flushTimer: function( id ) {
clearInterval( this.setup.defer[ id ] );
console.log( 'Interval '+ id +' Stoped!');
},
setup: {
appId: 'BiO Kernel' + appId, param: [ ], inits: [ ], defer: [ ],timer: [ ], flags: { }
}
};
this.stack.__proto__ = null; this.__proto__ = null;
};
var application = new appBase();
var app = application.stack;
var cfg = [
{
func: function() {
console.log( 'RUN [mtd_1] AT [init stage] => force [mtd_3]' );
this.app['mtd_3'].apply(this);
},
options: [ 'mtd_1' , 'init' ]
},
{
func: function() {
console.log( 'RUN [mtd_2] AT [init stage]' );
},
options: [ 'mtd_2' , 'init' ]
},
{
func: function() {
console.log( 'RUN [mtd_3] BY [mtd_1] FROM [init stage]' );
},
options: [ 'mtd_3' ]
},
{
func: function() {
console.log( 'run defered method #1 in timeout' );
},
options: [ 'deferedMethod_1', 'defer|timeout|8500' ]
},
{
func: function( ) {
console.log( 'run defered method #2 in interval' );
},
options: [ 'deferedMethod_2', 'defer|interval|500' ]
},
];
app.init( cfg, true );
})();
Съебаться из страны не получилось ): Оно не взламывалось вообще ... лимон так и не дали, а в жопу выебали через кого-то.
+143
Plugin.prototype.builder = function ( gm, gsc, data, cntwrp, itmwrp, group, unify, pl, sp, st ) {
itms = lnks = '';
x = 0;
for( i = 1; i <= st; i++ ) {
if( group === 'grid' ) {
href = sp + gsc[x] +'.css'+ unify;
idm = gsc[x];
x++;
}
else {
href = sp +'st'+ i +'.css'+ unify;
idm = 'st'+ i +'_'+ group;
}
lnks += '<link href="'+ href +'" rel="relation" media="screen" data-st="'+ idm +'" data-gr="'+ group +'" />';
itms += '<'+ itmwrp +' id="'+ idm +'" data-gr="'+ group +'" data-st="'+ idm +'"'+'>'+'['+ i +']'+'</'+ itmwrp +'>';
}
$('head').append(lnks);
if( cntwrp === null ) {
cntwrp = $('<div style="display: inline" id="inline_merge_'+ group +'"></div>');
}
if( gm !== 'auto' ) {
$(pl).append( cntwrp );
cntwrp.attr({ 'class': '123', 'data-gr': group }).html( itms );
}
cntwrp = null;
itms = null;
lnks = null;
}
Эргономичный советский подход к тяжелой тригерной автоматике ... Пизданул и забылся ... Намертво нах
+144
function coolSerialize(object) {
var result;
if (object instanceof Array) {
result = [];
for (var i in object) {
result[i] = coolSerialize(object[i]);
}
} else if (object instanceof Object) {
result = {};
var fields = null;
if (object.serializableFields) {
fields = object.serializableFields;
}
else if (object.constuctor && object.constuctor.serializableFields) {
fields = object.constuctor.serializableFields;
}
if (fields) {
for (var i = 0, len = fields.length; i < len; ++i) {
var fieldName = fields[i];
var o = object[fieldName];
result[fieldName] = coolSerialize(o);
}
} else {
for (var fieldName in object) {
result[fieldName] = coolSerialize(object[fieldName]);
}
}
} else {
result = object;
}
return result;
}
Сишнику пришел звиздец, засветился, Молодец! (: