2010-11-25 2 views
2

Затмение givign мне ошибку синтаксиса вдоль этих линий, но я не вижу ничего плохого там:Хорошо, вы можете обнаружить здесь синтаксическую ошибку?

$('.addNewFolder').click(function() { 
    showModal('modal_div', 'Nový adresár'); 
    var id = '<?php echo ToHtml($idFolder); ?>'; 
    $('.folders .trow1').each(function() { 
     if ($(this).css('backgroundColor') == 'rgb(52, 108, 182)' || $(this).css('backgroundColor') == '#346cb6') { 
      id = $(this).attr('rel'); 
     } 
    }); 
    ajaxElementCall('modal_div', 'body/obsah/obrazy/folderAdd.php?idFolder='+id); 
}); 

После PHP разборе:

$('.addNewFolder').click(function() { 
    showModal('modal_div', 'Nový adresár'); 
    var id = ''; 
    $('.folders .trow1').each(function() { 
     if ($(this).css('backgroundColor') == 'rgb(52, 108, 182)' || $(this).css('backgroundColor') == '#346cb6') { 
      id = $(this).attr('rel'); 
     } 
    }); 
    ajaxElementCall('modal_div', 'body/obsah/obrazy/folderAdd.php?idFolder='+id); 
}); 

Это то, что говорит IDE:

Syntax error on token "}", invalid MethodHeaderName 

Я смотрю на этот код как минимум на полчаса. Я либо слепой, либо схожу с ума.

EDIT:

Весь Javascript на странице:

<script type="text/javascript"> 
    //<!-- 
$(document).ready(function() { 

    function in_array (needle, haystack, argStrict) { 
     var key = '', strict = !!argStrict; 
     if (strict) { 
      for (key in haystack) { 
       if (haystack[key] === needle) { 
        return true;   } 
      } 
     } else { 
      for (key in haystack) { 
       if (haystack[key] == needle) { 
        return true; 
       } 
      } 
     } 
     return false; 
    } 

    var openedFolders = new Array(); 
    <?php if (count($_SESSION['ECM']['openedSlideFolders']) > 0) : ?> 
    <?php $i = 0; foreach ($_SESSION['ECM']['openedSlideFolders'] as $aVal): ?> 
     <?php echo "openedFolders[$i] = '$aVal';\n"; ?> 
    <?php ++$i; endforeach; ?> 
    <?php endif; ?> 

    var start = 0; 
    var stop = 0; 
    $('.drag').each(function() { 
     var draggables = $(this).parents('table').find('.drag'); 
     var $next = draggables.filter(':gt(' + draggables.index(this) + ')').first(); 
     var width = $(this).css('width'); 
     var nextWidth = $next.css('width'); 
     if (nextWidth > width && 30 == parseInt(width)) { 
      $(this).removeClass('ordinaryFolderClosed'); 
      $(this).removeClass('ordinaryFolderOpened'); 
      if (in_array($(this).attr('rel'), openedFolders)) { 
       $(this).addClass('ordinaryFolderOpened'); 
      } else { 
       $(this).addClass('ordinaryFolderClosed'); 
      }    
     } 
     if (in_array($(this).attr('rel'), openedFolders)) { 
      start = 1; 
     } 
     if (1 == start && stop < 2) {    
      if (30 == parseInt(width)) { 
       stop++; 
      } 
     } else { 
      start = 0; 
      stop = 0; 
      if (parseInt(width) > 30) { 
       $(this).parent().parent().hide(); 
      } 
     } 
    }); 

    function dragDrop() 
    { 
     $('.folders .trow1').hover(
      function() { 
       if ($(this).css('backgroundColor') != 'rgb(52, 108, 182)' && $(this).css('backgroundColor') != '#346cb6') { 
        $(this).css('background', "#C2E3EF"); 
       } 
      }, 
      function() { 
       if ($(this).css('backgroundColor') != 'rgb(52, 108, 182)' && $(this).css('backgroundColor') != '#346cb6') { 
        $(this).css('background', 'transparent'); 
       } 
      } 
     ); 

     $('.drag').click(function() { 
      var draggables = $(this).parents('table').find('.drag'); 
      var $next = draggables.filter(':gt(' + draggables.index(this) + ')').first(); 
      var width = $(this).css('width'); 
      var nextWidth = $next.css('width'); 
      if (nextWidth > width && 30 == parseInt(width)) { 
       var isVisible = $next.is(':visible'); 
       if (isVisible) { 
        $(this).removeClass('ordinaryFolderClosed'); 
        $(this).removeClass('ordinaryFolderOpened'); 
        $(this).addClass('ordinaryFolderClosed'); 
       } else { 
        $(this).removeClass('ordinaryFolderClosed'); 
        $(this).removeClass('ordinaryFolderOpened'); 
        $(this).addClass('ordinaryFolderOpened'); 
       } 
       clickedId = $(this).attr('rel'); 
       $.ajax({ 
        type: 'POST', 
        url:  'body/obsah/obrazy/setOpenedFolder.php', 
        data: 'id='+clickedId, 
        success: function(msg){ 
         //alert(msg); 
        } 
       }); 
       var start = 0; 
       var stop = 0; 
       var i = 0; 
       $('.drag').each(function() { 
        if (0 == start) { 
         iteratedId = $(this).attr('rel'); 
         if (iteratedId == clickedId) { 
          start = 1; 
         } 
        } 
        if (1 == start && stop < 2) { 
         if ($(this).css('width') > width) { 
          if (isVisible) { 
           $(this).parent().parent().hide(); 
          } else { 
           $(this).parent().parent().show(); 
          }       
         } else { 
          stop++; 
         } 
        } 
        i++; 
       }); 
      } 
     }); 

     var dragId = 0; 
     var dropId = 0; 
     var isFile = false; 

     $('.drag').mousedown(function() { 
      if ($(this).attr('rel') !== undefined) { 
       dragId = $(this).attr('rel'); 
       dragId = dragId.split(','); 
       dragId = dragId[0]; 
      } 
      isFile = false; 
     }); 

     $('.drag2').mousedown(function() { 
      if ($(this).attr('rel') !== undefined) { 
       dragId = $(this).attr('rel'); 
       dragId = dragId.split(','); 
       dragId = dragId[0]; 
      } 
      isFile = true; 
     }); 

     $('.drag').draggable({ 
      revert: true, 
      cursorAt: {top: 0, left: 0} 
     }); 

     $('.drag2').draggable({ 
      revert: true, 
      cursorAt: {top: 0, left: 0} 
     }); 


     $('.drop').droppable({ 
      tolerance: 'pointer', 
      drop: function() { 
       if ($(this).attr('rel') !== undefined) { 
        dropId = $(this).attr('rel'); 
        dropId = dropId.split(','); 
        dropId = dropId[0]; 
        if (dropId != dragId) { 
         if (false == isFile) { 
          $.ajax({ 
           type: 'POST', 
           url:  'body/obsah/obrazy/folderMove.php', 
           data: 'nid='+dragId+'&pid='+dropId, 
           success: function(msg){ 
            <?php echo $aJsOnDrop; ?>; 
            dragDrop(); 
           } 
          }); 
         } else if (true == isFile) { 
          $.ajax({ 
           type: 'POST', 
           url:  'body/obsah/obrazy/slideMove.php', 
           data: 'fid='+dragId+'&did='+dropId, 
           success: function(msg){ 
            <?php echo $aJsOnDrop; ?>; 
            dragDrop(); 
           } 
          }); 
         } 
        } 
       }   
      } 
     }); 

    } 

    dragDrop(); 

    $('.folderListOnclick').click(function() { 
     var append = 'idFolder='+$(this).attr('rel')+'&browse=<?php echo $browse; ?>'; 
     ajaxElementCall('obrazy_list', '<?php echo $dirPrefixBody; ?>/listBase.php?'+append); 
     dragDrop(); 
     $('.trow1').css('background', 'transparent'); 
     $('.trow1').css('color', '#3e4245'); 
     $(this).parent().css('background', "#346cb6 url('img/menuButtonOver.png') left top repeat-x"); 
     $(this).parent().css('color', 'white'); 
    }); 

    $('.rootFolderListOnclick').click(function() { 
     window.location = 'navigator.php?kam=obrazy'; 
     dragDrop(); 
    }); 

    $('.folderEditOnclick').click(function() { 
     var append = 'idFolder='+$(this).attr('rel'); 
     showModal('modal_div', 'Editácia adresára'); 
     ajaxElementCall('modal_div', '<?php echo $dirPrefixBody; ?>/folderEdit.php?kam=edit1&'+append); 
    }); 

    $('.folderDeleteOnclick').click(function() { 
     var append = 'idFolder='+$(this).attr('rel'); 
     showModal('modal_div', 'Vymazanie adresára'); 
     // TODO 0 Nemam sajnu, aka chyba je tuna - Eclipse mi tu hadze syntax error 
     ajaxElementCall('modal_div', '<?php echo $dirPrefixBody; ?>/folderDelete.php?kam=del1&'+append); 
    }); 

    $('.addNewFolder').click(function() { 
     showModal('modal_div', 'Nový adresár'); 
     var id = '<?php echo ToHtml($idFolder); ?>'; 
     $('.folders .trow1').each(function() { 
      if ($(this).css('backgroundColor') == 'rgb(52, 108, 182)' || $(this).css('backgroundColor') == '#346cb6') { 
       id = $(this).attr('rel'); 
      } 
     }); 
     ajaxElementCall('modal_div', 'body/obsah/obrazy/folderAdd.php?idFolder='+id); 
    }); 

}); //--> 
</script> 

После PHP разбора:

<script type="text/javascript"> 
    //<!-- 
$(document).ready(function() { 

    function in_array (needle, haystack, argStrict) { 
     var key = '', strict = !!argStrict; 
     if (strict) { 
      for (key in haystack) { 
       if (haystack[key] === needle) { 
        return true;   } 
      } 
     } else { 
      for (key in haystack) { 
       if (haystack[key] == needle) { 
        return true; 
       } 
      } 
     } 
     return false; 
    } 

    var openedFolders = new Array(); 
       openedFolders[0] = '3'; 

    var start = 0; 
    var stop = 0; 
    $('.drag').each(function() { 
     var draggables = $(this).parents('table').find('.drag'); 
     var $next = draggables.filter(':gt(' + draggables.index(this) + ')').first(); 
     var width = $(this).css('width'); 
     var nextWidth = $next.css('width'); 
     if (nextWidth > width && 30 == parseInt(width)) { 
      $(this).removeClass('ordinaryFolderClosed'); 
      $(this).removeClass('ordinaryFolderOpened'); 
      if (in_array($(this).attr('rel'), openedFolders)) { 
       $(this).addClass('ordinaryFolderOpened'); 
      } else { 
       $(this).addClass('ordinaryFolderClosed'); 
      }    
     } 
     if (in_array($(this).attr('rel'), openedFolders)) { 
      start = 1; 
     } 
     if (1 == start && stop < 2) {    
      if (30 == parseInt(width)) { 
       stop++; 
      } 
     } else { 
      start = 0; 
      stop = 0; 
      if (parseInt(width) > 30) { 
       $(this).parent().parent().hide(); 
      } 
     } 
    }); 

    function dragDrop() 
    { 
     $('.folders .trow1').hover(
      function() { 
       if ($(this).css('backgroundColor') != 'rgb(52, 108, 182)' && $(this).css('backgroundColor') != '#346cb6') { 
        $(this).css('background', "#C2E3EF"); 
       } 
      }, 
      function() { 
       if ($(this).css('backgroundColor') != 'rgb(52, 108, 182)' && $(this).css('backgroundColor') != '#346cb6') { 
        $(this).css('background', 'transparent'); 
       } 
      } 
     ); 

     $('.drag').click(function() { 
      var draggables = $(this).parents('table').find('.drag'); 
      var $next = draggables.filter(':gt(' + draggables.index(this) + ')').first(); 
      var width = $(this).css('width'); 
      var nextWidth = $next.css('width'); 
      if (nextWidth > width && 30 == parseInt(width)) { 
       var isVisible = $next.is(':visible'); 
       if (isVisible) { 
        $(this).removeClass('ordinaryFolderClosed'); 
        $(this).removeClass('ordinaryFolderOpened'); 
        $(this).addClass('ordinaryFolderClosed'); 
       } else { 
        $(this).removeClass('ordinaryFolderClosed'); 
        $(this).removeClass('ordinaryFolderOpened'); 
        $(this).addClass('ordinaryFolderOpened'); 
       } 
       clickedId = $(this).attr('rel'); 
       $.ajax({ 
        type: 'POST', 
        url:  'body/obsah/obrazy/setOpenedFolder.php', 
        data: 'id='+clickedId, 
        success: function(msg){ 
         //alert(msg); 
        } 
       }); 
       var start = 0; 
       var stop = 0; 
       var i = 0; 
       $('.drag').each(function() { 
        if (0 == start) { 
         iteratedId = $(this).attr('rel'); 
         if (iteratedId == clickedId) { 
          start = 1; 
         } 
        } 
        if (1 == start && stop < 2) { 
         if ($(this).css('width') > width) { 
          if (isVisible) { 
           $(this).parent().parent().hide(); 
          } else { 
           $(this).parent().parent().show(); 
          }       
         } else { 
          stop++; 
         } 
        } 
        i++; 
       }); 
      } 
     }); 

     var dragId = 0; 
     var dropId = 0; 
     var isFile = false; 

     $('.drag').mousedown(function() { 
      if ($(this).attr('rel') !== undefined) { 
       dragId = $(this).attr('rel'); 
       dragId = dragId.split(','); 
       dragId = dragId[0]; 
      } 
      isFile = false; 
     }); 

     $('.drag2').mousedown(function() { 
      if ($(this).attr('rel') !== undefined) { 
       dragId = $(this).attr('rel'); 
       dragId = dragId.split(','); 
       dragId = dragId[0]; 
      } 
      isFile = true; 
     }); 

     $('.drag').draggable({ 
      revert: true, 
      cursorAt: {top: 0, left: 0} 
     }); 

     $('.drag2').draggable({ 
      revert: true, 
      cursorAt: {top: 0, left: 0} 
     }); 


     $('.drop').droppable({ 
      tolerance: 'pointer', 
      drop: function() { 
       if ($(this).attr('rel') !== undefined) { 
        dropId = $(this).attr('rel'); 
        dropId = dropId.split(','); 
        dropId = dropId[0]; 
        if (dropId != dragId) { 
         if (false == isFile) { 
          $.ajax({ 
           type: 'POST', 
           url:  'body/obsah/obrazy/folderMove.php', 
           data: 'nid='+dragId+'&pid='+dropId, 
           success: function(msg){ 
            ajaxElementCall('__folderList', 'body/obsah/obrazy/folders.php?browse=0&idFolder=', 'obrazy_list', 'body/obsah/obrazy/listBase.php?browse=0&idFolder='); 
            dragDrop(); 
           } 
          }); 
         } else if (true == isFile) { 
          $.ajax({ 
           type: 'POST', 
           url:  'body/obsah/obrazy/slideMove.php', 
           data: 'fid='+dragId+'&did='+dropId, 
           success: function(msg){ 
            ajaxElementCall('__folderList', 'body/obsah/obrazy/folders.php?browse=0&idFolder=', 'obrazy_list', 'body/obsah/obrazy/listBase.php?browse=0&idFolder='); 
            dragDrop(); 
           } 
          }); 
         } 
        } 
       }   
      } 
     }); 

    } 

    dragDrop(); 

    $('.folderListOnclick').click(function() { 
     var append = 'idFolder='+$(this).attr('rel')+'&browse=0'; 
     ajaxElementCall('obrazy_list', 'body/obsah/obrazy/listBase.php?'+append); 
     dragDrop(); 
     $('.trow1').css('background', 'transparent'); 
     $('.trow1').css('color', '#3e4245'); 
     $(this).parent().css('background', "#346cb6 url('img/menuButtonOver.png') left top repeat-x"); 
     $(this).parent().css('color', 'white'); 
    }); 

    $('.rootFolderListOnclick').click(function() { 
     window.location = 'navigator.php?kam=obrazy'; 
     dragDrop(); 
    }); 

    $('.folderEditOnclick').click(function() { 
     var append = 'idFolder='+$(this).attr('rel'); 
     showModal('modal_div', 'Editácia adresára'); 
     ajaxElementCall('modal_div', 'body/obsah/obrazy/folderEdit.php?kam=edit1&'+append); 
    }); 

    $('.folderDeleteOnclick').click(function() { 
     var append = 'idFolder='+$(this).attr('rel'); 
     showModal('modal_div', 'Vymazanie adresára'); 
     // TODO 0 Nemam sajnu, aka chyba je tuna - Eclipse mi tu hadze syntax error 
     ajaxElementCall('modal_div', 'body/obsah/obrazy/folderDelete.php?kam=del1&'+append); 
    }); 

    $('.addNewFolder').click(function() { 
     showModal('modal_div', 'Nový adresár'); 
     var id = ''; 
     $('.folders .trow1').each(function() { 
      if ($(this).css('backgroundColor') == 'rgb(52, 108, 182)' || $(this).css('backgroundColor') == '#346cb6') { 
       id = $(this).attr('rel'); 
      } 
     }); 
     ajaxElementCall('modal_div', 'body/obsah/obrazy/folderAdd.php?idFolder='+id); 
    }); 

}); //--> 
</script> 
+1

Какая строка является ошибкой? – Greg 2010-11-25 10:12:36

+0

Я склонен согласиться; ничего плохого в этом, Eclipse не позволяет ему работать? Он жалуется на что-то еще? Я не использую Eclipse лично, но я знаю, что иногда это неправильно ... – 2010-11-25 10:12:57

ответ

1

Посмотрев на весь код (и вставить его, минус содержание PHP, в The Online Lint), я бы еще сказать, что в Javascript нет синтаксической ошибки, и если если Eclipse сообщает вам, что есть, значит, Eclipse ошибочен. Иногда инструменты не идеальны.

Выполняется ли код в разных браузерах? Шансы относительно хорошие, если это так, то на самом деле там нет синтаксической ошибки.

(Отправлено в соответствии с запросом. Ta.)

0

Попробуйте удалить акцентированные символы в своих кавычках, вы можете еще выходные акценты, но используйте соответствующий код HTML.

список HTML кодов символов с диакритическими знаками находятся здесь:

http://www.w3schools.com/tags/ref_entities.asp

Смежные вопросы