Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Не срабатывает скрипт. Unexpected end of input (https://javascript.ru/forum/misc/29952-ne-srabatyvaet-skript-unexpected-end-input.html)

zlodeeev 18.07.2012 18:04

Не срабатывает скрипт. Unexpected end of input
 
Играюсь с настройками своего скрипта, полностью рабит. То тут подкручу скорость анимации, то там что-нибудь не влияющее на работоспособность.
И на тебе, Unexpected end of input drag.js на последней строке. Причем ошибка появляется при очередном обновлении страницы и держится ~ 7-8 обновлений, потом опять всё норм. В любом браузере ситуация та же. Что это за ошибка такая? Как с ней бороться? А то в гугле самое лучшее решение - "добавь пустую строку в конец файла".

oneguy 18.07.2012 19:07

Можно ли посмотреть содержимое файла drag.js?

tadjik1 18.07.2012 19:07

телепаты в отпуске

скорее всего скобочку забыли где-то

zlodeeev 18.07.2012 22:23

Да в том то и дело, что файл не при чём. Т.е. он работает. Но с перебоями. Поэтому отбой телепатам, что за ошибка то? Чёрт его знает, почему он через раз работает.

lord2kim 18.07.2012 22:29

Цитата:

Сообщение от zlodeeev (Сообщение 189741)
Unexpected end of input drag.js

приведите, пожалуйста, содержимое файла drag.js и кусок HTML-кода, которым он опирирует...

bes 18.07.2012 23:18

Цитата:

Сообщение от zlodeeev
Причем ошибка появляется при очередном обновлении страницы и держится ~ 7-8 обновлений, потом опять всё норм

Можно посмотреть здесь http://code.google.com/p/chromium/is...etail?id=11037 (первая попавшаяся, там ещё про первую версию хрома), там три случая + немного в комментариях.
Смысл обычно в том, что что-то открыли ({, <, объект. и т.п.), но не закрыли и то, что где бы ни была ошибка, покажет, что в последней строке.

zlodeeev 19.07.2012 08:38

lord2kim,
Если вы так настаиваете, то пожалуста - узрите этот скрипт:
$(document).ready(function(){

function price(){
	var opt = $("input[name = options]:checked");
	var min =0;
	var max =0;
	var price =0;
	var i =0;
	while(opt[i]){
		if(Number($(opt[i]).attr('min')) > min) {min = Number($(opt[i]).attr('min'))};
		if(Number($(opt[i]).attr('max')) > max) {max = Number($(opt[i]).attr('max'))};
		price += Number($(opt[i]).attr('price'));
		i++;
	}
	refresh2(min+price, max+price);
};

function refresh(i,j){
	
	$('#credit').animate({'width':1.5*j/100+'px'}, 700);
	$('#footer').animate({'width':i/100+'px'}, 700);
};

function refresh2(i,j){
	$('div#ot').html("от "+i/1000+"тыс.");
	$('div#do').html("до "+j/1000+"тыс.");
	 
	$('.right-price').animate({'width':1.5*j/100+'px'}, 700);
	$('.left-price').animate({'width':i/100+'px'}, 700);
};

function tooltip(items, name){
 $(items).children('div').each(function(i){
 $("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+$(this).children('input').attr('text')+"</p></div>");
 var my_tooltip = $("#"+name+i);

 $(this).removeAttr("title").mouseover(function(){
 my_tooltip.css({opacity:0.8, display:"none"}).stop().fadeIn(1000);
 }).mousemove(function(kmouse){
 my_tooltip.css({left:kmouse.pageX+15, top:kmouse.pageY+15});
 }).mouseout(function(){
 my_tooltip.stop().fadeOut(100);
 });
 });
}

	$('.caption').click(function(){
		if(!$(this).hasClass('active')){
				var radio = $("input[name=type]")[$(this).index()];
				$('.caption').removeClass('active');
				$(this).addClass('active');
				$("input[name=type]").removeAttr('checked', 'checked');
				$(radio).attr('checked','checked');
				this_id = $(radio).attr('id');
				$('#about').animate({'height':0},700,function(){
					$("#options").load('content.php?id='+this_id,function(){
								$("#info").load('info.php?id='+this_id, function(){
									$('#about').animate({'height':$('#about').children('td').height()+40},1300,function(){
										price();
										tooltip('#options','tooltip');
										$('div#options').children('input').click(function(){price()});
										$('div.checkbox').click(function(){
											var cb = $(this).children('input');
											if($(cb).attr('checked')!='checked'){
												$(cb).attr('checked', 'checked');
												price();
												$(this).removeClass('unchecked');
												$(this).addClass('checked');
											} else {
												$(cb).removeAttr('checked');
												price();
												$(this).removeClass('checked');
												$(this).addClass('unchecked');
											}
										});
									});
								});
							});
				});
		}
	});

	$('input[name=type]').click(function(){
		this_id = $(this).attr('id');
			$("#options").load('content.php?id='+$(this).attr('id'),function(){
				$("#info").load('info.php?id='+this_id, function(){
					price();
					$('div#options').children('input').click(function(){price()});
				});
			});
	});
});


Часовой пояс GMT +3, время: 09:30.