= semantic_form_for [:admin,@video_file], :remote => true do |form| 
  .content
    =form.inputs do
      = form.input :image_file_id, :label => "Poster :" , :as => :qi_image_select
      =form.input :video_folder, :collection => VideoFolder.order(:name).all
      =form.input :title
      =form.input :youtube_code, :input_html => {:id => "youtube_id", :onkeydown => "youtube_parser($(this).val());",  :onchange => "youtube_parser($(this).val());", :onkeyup => "youtube_parser($(this).val());"}
      %p
        Collez directement l'url de la vidéo youtube (https://www.youtube.com/watch?v=p00mU0LsSIg ou https://youtu.be/p00mU0LsSIg par exemple) et l'ID sera automatiquement détecté.

    .clear
    
    :javascript
      function youtube_parser(url){
          var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
          var match = url.match(regExp);
          if (match&&match[7].length==11){

              $("#youtube_id").val(match[7]);
          }else{
              //alert("Url incorrecta");
          }
      }
   
  
  .actions=form.submit "Sauvegarder", :class => "btn btn-primary"
  
-#:url => admin_video_files_path( :video_folder_id => params[:video_folder_id], :manager => params[:manager], :multiple => params[:multiple])