- 1
- 2
- 3
- 4
- 5
'пыщь' instanceof String //false
Object('пыщь') instanceof String //true
(function(){}) instanceof Function //true
Object(function(){}) instanceof Function //true
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
'пыщь' instanceof String //false
Object('пыщь') instanceof String //true
(function(){}) instanceof Function //true
Object(function(){}) instanceof Function //true
+3
function checkForm(form, mustform){
error=0;
if(mustform){
for(i in mustform) if(form.elements[mustform[i]]){
if(!form.elements[mustform[i]].value){
error=1;
jQuery(form.elements[mustform[i]]).next().remove();
jQuery(form.elements[mustform[i]]).parent().append('<div style="color:red">поле обязательно к заполнению</div>');
} else jQuery(form.elements[mustform[i]]).next('div').remove();
}
if(error>0) return false; else return true;
} else return true;
}
такого codestyle не встречал))
+4
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function get_acessories(id) {
document.form3.acessories.value = document.form3.acessories.value + id + " ";
}
вообще не знаю что эта штука делает О_о)
+2
entry.number = $('.info', this).text().split(';')[1].slice($('.info', this).text().split(';')[1].search(':'), $('.info', this).text().split(';')[1].search('/')).trim()
Регэкспы не нужны.
+5
params['query[accountable_of_' + usersRole.charAt(0).toUpperCase() + usersRole.slice(1) + '_type_super_user_id_eq]'] = vm.superUser.id;
Пацаны, нормальный же код?
+1
Главный хтмл файл:
<div id="load-script" style="display:none">
$(document).ready(function() {
$('.social-needs-container__slider-container').slick({
slidesToShow: 3,
slidesToScroll:1,
...
});
});
</div>
Директива:
link: function link($scope, iElement) {
Api.get({
...
}).$promise.then(function(data) {
$scope.getContentUrl = function() {
var template = 'http://localhost:1337/app/js/modules/core/templates/projects/types/';
...
return template;
}
...
var init = angular.element("#load-script");
var code = init.text();
init.remove();
var f = new Function(code);
$timeout(f, 350);
...
});
},
Суть в том, что нужно динамически подключать темплейт по урлу, попутно инициализировав сторонний плагин (slick slider).
Переписовать код слайдера под уже готовую slick-директиву видимо было лень.
+1
function windowSize(){
if (jQuery(window).width() <= '995'){
var pdiv = jQuery('#fw_c > div:nth-child(5) > div > div > div.vc_row.wpb_row.vc_inner.vc_row-fluid > div:nth-child(2)').parent('#fw_c > div:nth-child(5) > div > div > div.vc_row.wpb_row.vc_inner.vc_row-fluid > div:nth-child(2)');
pdiv.insertAfter(pdiv.next());
}
}
Верстаем адаптивно
http://ru.stackoverflow.com/questions/454209/
+1
function cashBonusCalculator(currentDepositValue, el) {
var $scope = el;
if (!currentDepositValue) {
currentDepositValue = 0;
}
var max_bonus_01 = $scope.find('[name="progr_step_01_max"]'),
max_bonus_02 = $scope.find('[name="progr_step_02_max"]'),
max_bonus_03 = $scope.find('[name="progr_step_03_max"]'),
bonus_start_01 = $scope.find('[name="progr_step_01_start"]'),
bonus_start_02 = $scope.find('[name="progr_step_02_start"]'),
bonus_start_03 = $scope.find('[name="progr_step_03_start"]'),
bonus_amount_01 = $scope.find('[name="progr_step_01_amount"]'),
bonus_amount_02 = $scope.find('[name="progr_step_02_amount"]'),
bonus_amount_03 = $scope.find('[name="progr_step_03_amount"]');
if (cash_bonuses_list[0]) {
max_bonus_01.text('max ' + cash_bonuses_list[0].maxbonus.toMonetaryString());
bonus_start_01.text(cash_bonuses_list[0].f.toMonetaryString());
bonus_amount_01.text(cash_bonuses_list[0].bonus + '%');
main_gift_conditions.text('x' + cash_bonuses_list[0].wager + ' ' + wagerType +'; ' + cash_bonuses_list[0].ttl + _('h'));
gift_progress.addClass('cash_gift_progress_level_01');
}
if (cash_bonuses_list[1]) {
max_bonus_02.text('max ' + cash_bonuses_list[1].maxbonus.toMonetaryString());
bonus_start_02.text(cash_bonuses_list[1].f.toMonetaryString());
bonus_amount_02.text(cash_bonuses_list[1].bonus + '%');
main_gift_conditions.text('x' + cash_bonuses_list[1].wager + ' ' + wagerType + '; ' + cash_bonuses_list[1].ttl + _('h'));
gift_progress.addClass('cash_gift_progress_level_02');
}
if (cash_bonuses_list[2]) {
max_bonus_03.text('max ' + cash_bonuses_list[2].maxbonus.toMonetaryString());
bonus_start_03.text(cash_bonuses_list[2].f.toMonetaryString());
bonus_amount_03.text(cash_bonuses_list[2].bonus + '%');
main_gift_conditions.text('x' + cash_bonuses_list[2].wager + ' ' + wagerType + '; ' + cash_bonuses_list[2].ttl + _('h'));
gift_progress.addClass('cash_gift_progress_level_03');
}
if (window.CASHBONUSES && window.CASHBONUSES.length > 0) {
var progressSteps = 3;
if (cash_bonuses_list[0]) {
progressSteps = 1;
}
if (cash_bonuses_list[1]) {
progressSteps = 2;
}
if (cash_bonuses_list[2]) {
progressSteps = 3;
}
if (cash_bonuses_list[0] && currentDepositValue <= cash_bonuses_list[0].t && currentDepositValue >= cash_bonuses_list[0].f) {
$scope.find('[name="cash_gift_progressbar"]').css({
width: (((main_progress_width / progressSteps) * ( (currentDepositValue - cash_bonuses_list[0].f) / (((cash_bonuses_list[0].t - cash_bonuses_list[0].f) / 100)) * 0.01))) + 'px'
});
main_gift_amount.text(cash_bonuses_list[0].c + ' ' + currentBonusSumm(cash_bonuses_list[0].bonus, cash_bonuses_list[0].maxbonus, fromCashDepositValue));
} else if (!cash_bonuses_list[1] && cash_bonuses_list[0] && currentDepositValue > cash_bonuses_list[0].t && currentDepositValue >= cash_bonuses_list[0].f){
$scope.find('[name="cash_gift_progressbar"]').css({
width: '100%'
});
main_gift_amount.text(cash_bonuses_list[0].c + ' ' + currentBonusSumm(cash_bonuses_list[0].bonus, cash_bonuses_list[0].maxbonus, fromCashDepositValue));
} else if (cash_bonuses_list[1] && currentDepositValue <= cash_bonuses_list[1].t && currentDepositValue >= cash_bonuses_list[1].f) {
$scope.find('[name="cash_gift_progressbar"]').css({
width: (((main_progress_width / progressSteps) * ( (currentDepositValue - cash_bonuses_list[1].f) / (((cash_bonuses_list[1].t - cash_bonuses_list[1].f) / 100)) * 0.01)) + (main_progress_width / progressSteps)) + 'px'
});
main_gift_amount.text(cash_bonuses_list[1].c + ' ' + currentBonusSumm(cash_bonuses_list[1].bonus, cash_bonuses_list[1].maxbonus, fromCashDepositValue));
} else if (!cash_bonuses_list[2] && cash_bonuses_list[1] && currentDepositValue > cash_bonuses_list[1].t && currentDepositValue >= cash_bonuses_list[1].f){
$scope.find('[name="cash_gift_progressbar"]').css({
width: '100%'
});
main_gift_amount.text(cash_bonuses_list[1].c + ' ' + currentBonusSumm(cash_bonuses_list[1].bonus, cash_bonuses_list[1].maxbonus, fromCashDepositValue));
} else if (cash_bonuses_list[2] && currentDepositValue <= cash_bonuses_list[2].maxbonus && currentDepositValue >= cash_bonuses_list[2].f){
$scope.find('[name="cash_gift_progressbar"]').css({
width: (((main_progress_width / progressSteps) * ( (currentDepositValue - cash_bonuses_list[2].f) / (((cash_bonuses_list[2].maxbonus - cash_bonuses_list[2].f) / 100)) * 0.01)) + ((main_progress_width / progressSteps) * 2)) + 'px'
});
+2
var date_match=time.split('.');
date_match=new Date(
date_match[1]+'-'+date_match[0]+'-'+/[\w\W]+(\d{4,4})\/(\d{4,4})[\w\W]+/.exec(document.title)[(date_match[1]>6)?1:2]//Gangsta
);
+4
/^.{0}$/.test('') // true
/^.{0,}$/.test('') // true
/^.{0,1}$/.test('') // true
/^.{,1}$/.test('') // false
http://www.ecma-international.org/ecma-262/5.1/#sec-15.10
/^.{,1}$/.test('.{,1}') // true