From aeb4baf7417147244b4dd982f2ad64c1e0cb8ee8 Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 4 Oct 2022 13:14:34 +0800 Subject: [PATCH] Fix bug. --- ad_banner.gemspec | 4 +-- app/controllers/ad_banners_controller.rb | 12 ++++--- app/views/admin/ad_images/_form.html.erb | 2 +- app/views/admin/ad_images/_jplayer.html.erb | 4 +-- .../_ad_banner_widget2_video.html.erb | 36 ++++++------------- 5 files changed, 24 insertions(+), 34 deletions(-) diff --git a/ad_banner.gemspec b/ad_banner.gemspec index c0de6c5..562dce7 100644 --- a/ad_banner.gemspec +++ b/ad_banner.gemspec @@ -34,9 +34,9 @@ if bundle_update_flag FileUtils.mkdir_p("#{ENV['PWD']}/tmp") require 'open-uri' if RUBY_VERSION.to_f >= 2.7 - download = URI.open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip') + download = URI.open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) else - download = open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip') + download = open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip',:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE) end save_zip_name = "#{ENV['PWD']}/tmp/ffmpeg-4.2-linux-64.zip" IO.copy_stream(download, save_zip_name) diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 6a6348b..e6bc2db 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -191,11 +191,15 @@ class AdBannersController < ApplicationController def format_url(url,index) uri = URI.parse(url) - ps = uri.query.to_s.split("&") url_params = {} - ps.each do |p| - x = p.split("=") - url_params[x.first] = x.last + if !uri.nil? && uri.host == "www.youtube.com" + if uri.path.start_with?('/embed/') + url_params['v'] = uri.path.split('/embed/').last + else + params = CGI.parse(uri.query.to_s) + v = params.blank? ? nil : params['v'].first + url_params['v'] = v + end end # url = "http://www.youtube.com/v/#{url_params["v"]}/?version=3&playerapiid=ytplayer#{index}" url = "https://www.youtube.com/embed/#{url_params["v"]}" diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 4447619..5ecce59 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -274,7 +274,7 @@ return true; } $(document).ready(function(){ - jplayer_ready_func(); + jplayer_ready_func_1(); $('#ad_image_video_file').change(function(){ var file = this.files ? this.files[0] : null; var value = this.value; diff --git a/app/views/admin/ad_images/_jplayer.html.erb b/app/views/admin/ad_images/_jplayer.html.erb index 690b36b..0ed98d2 100644 --- a/app/views/admin/ad_images/_jplayer.html.erb +++ b/app/views/admin/ad_images/_jplayer.html.erb @@ -383,7 +383,7 @@ <% else %> var jPlayer_<%= i %> = default_video_data; <% end %> - function jplayer_ready_func(){ + function jplayer_ready_func_<%= i %>(){ $("#jquery_jplayer_<%= i %>").jPlayer(jPlayer_<%= i %>); if ($("#jquery_jplayer_<%= i %>").parents("div.cycle-slideshow").length>0){ $("#jquery_jplayer_<%= i %>").addClass("hide-ui"); @@ -431,7 +431,7 @@ } <% if defined?(not_ready).nil? || !not_ready %> $(document).ready(function(){ - jplayer_ready_func(); + jplayer_ready_func_<%= i %>(); }) <% end %> diff --git a/modules/ad_banner/_ad_banner_widget2_video.html.erb b/modules/ad_banner/_ad_banner_widget2_video.html.erb index 4f4cb4b..5d45b10 100644 --- a/modules/ad_banner/_ad_banner_widget2_video.html.erb +++ b/modules/ad_banner/_ad_banner_widget2_video.html.erb @@ -283,21 +283,26 @@ delete yt_players[id][k]; }) iframes.each(function(i,iframe){ - var yt_id = $(iframe).attr("id"); - var yt_player = yt_players[id][$(iframe).attr("id")]; + var $iframe = $(iframe); + var yt_id = $iframe.attr("id"); + var yt_player = yt_players[id][yt_id]; if(yt_player){ }else{ - yt_player = new YT.Player($(iframe).attr("id"), { + yt_player = new YT.Player(yt_id, { events: { 'onReady': function(event){ var yt_player = event.target; var height = $(yt_player.getIframe()).height(); - var banner_wrap = $(iframe).parents('.w-ba-banner__wrap').eq(0); + var banner_wrap = $iframe.parents('.w-ba-banner__wrap').eq(0); var carousel_wrap = banner_wrap.find(".cycle-carousel-wrap"); if(carousel_wrap.length){ carousel_wrap.css("top","3em"); height += parseInt(carousel_wrap.css('font-size')) * 3; } + var overlay_in_slide = $iframe.parent().siblings('.ad-overlay,.banner-overlay'); + if(overlay_in_slide.length != 0){ + height += overlay_in_slide.outerHeight(true); + } banner_wrap.height(height).css({"padding-bottom":"","padding-top":""}); var init_key = find_out_yt_event_relation_key(yt_player, false); if(init_key){ @@ -330,8 +335,8 @@ 'onStateChange': onPlayerStateChange } }); - yt_players[id][$(iframe).attr("id")] = yt_player; - $(iframe).data("yt_player",yt_player); + yt_players[id][yt_id] = yt_player; + $iframe.data("yt_player",yt_player); } }) } @@ -401,18 +406,6 @@ $('[data-subpart-id="{{subpart-id}}"] .prev-button').click(function(){ $(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev"); }) - var resize_timeout_id; - $(window).resize(function(){ - if(resize_timeout_id){ - window.clearTimeout(resize_timeout_id); - } - resize_timeout_id = window.setTimeout(function(){ - var banner_wrap = $(".w-ba-banner__wrap[data-overlay=\".w-ad-banner__overlay_{{subpart-id}}\"]"); - var opts = banner_wrap.data('cycle.opts'); - var height = opts.slides.filter('.active').height() || opts.slides.height(); - banner_wrap.height(height).css("padding-bottom",""); - },300); - }) })