From e4b9f282ba69126b69fe4383627c8abcc4d222f1 Mon Sep 17 00:00:00 2001 From: j-bitmaker Date: Mon, 5 Jun 2023 13:31:28 +0300 Subject: [PATCH 1/7] video ads for peertube --- components/lenta/index.css | 3 + components/lenta/index.js | 233 +++++++++++++++++++------- components/lenta/index.less | 4 + components/lenta/templates/share.html | 2 + components/post/index.js | 200 ++++++++++++++-------- components/share/index.css | 28 ++++ components/share/index.js | 73 +++++++- components/share/index.less | 38 +++++ components/share/templates/body.html | 17 ++ components/share/templates/url.html | 22 ++- css/main.css | 13 +- css/main.less | 7 +- js/kit.js | 6 +- localization/en.js | 4 +- localization/ru.js | 4 +- 15 files changed, 495 insertions(+), 159 deletions(-) diff --git a/components/lenta/index.css b/components/lenta/index.css index 029b51ae66..6e3f9e69d9 100644 --- a/components/lenta/index.css +++ b/components/lenta/index.css @@ -35,6 +35,9 @@ #lenta .shareinlenta.rendered .sharecnt { display: block; } +#lenta .adsCheckbox { + padding-right: 1em; +} #lenta .optimizationTip { height: 150px; display: flex; diff --git a/components/lenta/index.js b/components/lenta/index.js index 2291a1eb62..558c43d7d4 100644 --- a/components/lenta/index.js +++ b/components/lenta/index.js @@ -16,7 +16,7 @@ var lenta = (function(){ var mid = p.mid; var making = false, ovf = false; var w, essenseData, recomended = [], initialized, recommended, mestate, initedcommentes = {}, canloadprev = false, - video = false, isotopeinited = false, videosVolume = 0, fullscreenvideoShowing = null, loadedcachedHeight, lwidth = 0, bannerComment = null; + video = false, isotopeinited = false, videosVolume = 0, fullscreenvideoShowing = null, loadedcachedHeight, lwidth = 0, adsShowed = false; var loadertimeout = null var lastcache = null var subloaded = false @@ -906,7 +906,6 @@ var lenta = (function(){ $(this).closest('.jsPlayerLoading').addClass('loading') $(this).closest('.js-player-dummy').addClass('js-player-ini') - actions.initVideo(share, function(v){ if (players[share.txid]) @@ -925,18 +924,19 @@ var lenta = (function(){ button = null }, - initVideo : function(share, clbk, shadow){ + initVideo : function(share, clbk, shadow, ads){ if(!share || !share.txid || !el.share[share.txid]) return var pels = el.share[share.txid].find('.js-player-ini'); var vel = el.share[share.txid].find('.videoWrapper') + var ended = false; if (pels.closest('.shareTable').attr('stxid') != (share.txid || '')) return if(!vel.length) return - if (shadow && !players[share.txid]){ + if (shadow){ players[share.txid] = { shadow : true, @@ -1015,7 +1015,7 @@ var lenta = (function(){ var startTime = 0; - if (self.app.platform.sdk.videos.historyget && share.itisvideo()){ + if (self.app.platform.sdk.videos.historyget && share.itisvideo() && !ads){ var pr = self.app.platform.sdk.videos.historyget(share.txid) @@ -1060,6 +1060,7 @@ var lenta = (function(){ fullscreenchange : self.app.mobile.fullscreenmode, play : function(){ + videopaused = false self.app.actions.playingvideo(players[share.txid].p) @@ -1100,6 +1101,12 @@ var lenta = (function(){ self.app.platform.sdk.activity.adduser('video', share.address, 6 * position / duration, share) } + if (playbackState === 'ended' && ads && !ended){ + + ended = true; + clbk(true, true); + } + }, error : function(error){ @@ -1142,6 +1149,7 @@ var lenta = (function(){ s.logoType = self.app.meta.fullname s.app = self.app s.light = true + PlyrEx(pels[0], s, callback, readyCallback) } @@ -1575,11 +1583,7 @@ var lenta = (function(){ fullScreenVideo : function(id, clbk, auto){ - if (fullscreenvideoShowing) { return } - if (fullscreenvideoShowed) { return } - if (essenseData.openapi){ return } - - fullscreenvideoShowing = id + console.log('fullscreenvideo'); var _el = el.share[id] var share = self.app.platform.sdk.node.shares.getWithTemp(id) @@ -1597,88 +1601,181 @@ var lenta = (function(){ share.address = self.app.platform.sdk.address.pnet().address }*/ + var initVideoClbk = function(ads){ + if (fullscreenvideoShowing) { return } + if (fullscreenvideoShowed) { return } + if (essenseData.openapi){ return } - actions.initVideo(share, function(res){ + fullscreenvideoShowing = id + + actions.initVideo(share, function(res, next){ - fullscreenvideoShowing = null + if (next){ - if(!res){ - return - } - - if(!players[id]) return; + players[share.txid] = null; - self.app.actions.closepip() + actions.exitFullScreenVideo(id); - fullscreenvideoShowed = id; + renders.url(urlWrapper, share.url, share, function(){ - self.app.mobile.reload.destroyparallax() + renders.urlContent(share, function(){ + + if(!video) actions.initVideoLight(share, null, null, true); + + if(isotopeinited) el.shares.isotope() + + shareInitingMap[share.txid] = false; + + initVideoClbk(); + + }); + + }) - self.app.pseudofullscreenmode = true + return; + } - _el.addClass('fullScreenVideo') - - actions.videoPosition(id) + if (!res){ + return; + } - actions.fullScreenVideoParallax(_el, id) + fullscreenvideoShowing = null; - self.app.mobile.statusbar.gallerybackground() + self.app.actions.closepip() - self.app.nav.api.history.addParameters({ - v : id - }) + fullscreenvideoShowed = id; - var player = players[id] + self.app.mobile.reload.destroyparallax() - player.p.prepare().then(() => { + self.app.pseudofullscreenmode = true - if(!essenseData.openapi && !essenseData.second){ + _el.addClass('fullScreenVideo') + + actions.videoPosition(id) - lastscroll = self.app.lastScrollTop - self.app.actions.offScroll() + actions.fullScreenVideoParallax(_el, id) - - if(!player.p.playing && !auto){ - player.p.play() - } + self.app.mobile.statusbar.gallerybackground() + + self.app.nav.api.history.addParameters({ + v : id + }) + + var player = players[id] + + player.p.prepare().then(() => { + + if(!essenseData.openapi && !essenseData.second){ + + lastscroll = self.app.lastScrollTop + self.app.actions.offScroll() - if (player.p.enableHotKeys) player.p.enableHotKeys() - - actions.addRecommendationsFullScreenVideo(id) - } + if(!player.p.playing && !auto){ + player.p.play() + } - actions.setVolume(players[id], videosVolume || 0.5) + if (player.p.enableHotKeys) player.p.enableHotKeys() + + + actions.addRecommendationsFullScreenVideo(id) + } - if(!essenseData.comments && !share.temp && !share.relay){ + actions.setVolume(players[id], videosVolume || 0.5) - retry(function(){ - return initedcommentes[id] || !el.c - }, function(){ + if(!essenseData.comments && !share.temp && !share.relay){ - if(el.c){ - if (initedcommentes[id]){ - initedcommentes[id].destroy() - initedcommentes[id] = null - } - - renders.comments(id, false, true) - } + retry(function(){ + return initedcommentes[id] || !el.c + }, function(){ + + if(el.c){ + if (initedcommentes[id]){ + initedcommentes[id].destroy() + initedcommentes[id] = null + } + + renders.comments(id, false, true) + } + + }) + } + + + + + if (clbk) + clbk() + + }) + + }, false, ads) + + } + + var adsCount = localStorage.getItem('adsCount') || 0; + + if (share.settings.ads && !adsShowed && adsCount < 3){ + + adsCount++; + + adsShowed = true; + + players[share.txid] = null; + + var ads = share.settings.ads; + + var urlWrapper = el.share[share.txid].find('.url'); + + renders.url(urlWrapper, ads, share, function(){ + + renders.urlContent(share, function(){ + + if(!video) actions.initVideoLight(share, null, null, true); + + if(isotopeinited) el.shares.isotope() + + shareInitingMap[share.txid] = false; + + urlWrapper.find('.skip-ads').on('click', function(){ + + players[share.txid] = null; + + var id = el.share[share.txid].attr('id'); + + actions.exitFullScreenVideo(id); + + renders.url(urlWrapper, share.url, share, function(){ + + renders.urlContent(share, function(){ + + if(!video) actions.initVideoLight(share, null, null, true); + + if(isotopeinited) el.shares.isotope() + + shareInitingMap[share.txid] = false; + + initVideoClbk(); + + }); + + }) }) - - } + initVideoClbk(true); + }); + + }, ads) + } else { - if (clbk) - clbk() + initVideoClbk(); + } - }) - }) }, @@ -3254,7 +3351,6 @@ var lenta = (function(){ promises.push(new Promise((resolve, reject) => { - renders.url(p.el.find('.url'), share.url, share, function(){ renders.urlContent(share, function(){ @@ -3606,6 +3702,8 @@ var lenta = (function(){ shares : function(shares, clbk, p){ + console.log('shares', shares); + if(!p) p = {}; @@ -3954,7 +4052,12 @@ var lenta = (function(){ } }, - url : function(el, url, share, clbk){ + url : function(el, url, share, clbk, ads){ + + // debugger; + + // url = 'peertube://peertube6new.pocketnet.app/8acd9ab2-2159-476e-be14-a2ba4aaeb655'; + // share.url = 'peertube://peertube6new.pocketnet.app/8acd9ab2-2159-476e-be14-a2ba4aaeb655'; if (essenseData.nourlload){ @@ -3978,8 +4081,9 @@ var lenta = (function(){ el : el, mid : 'sharelenta', data : { - url : url, + url : ads || url, og : og, + ads: ads, share : share, video : video, preview : video ? true : false, @@ -3994,6 +4098,7 @@ var lenta = (function(){ }, function(_p){ + var images = _p.el.find('img'); self.app.nav.api.links(null, _p.el, function(event){ diff --git a/components/lenta/index.less b/components/lenta/index.less index ad19c3220f..9c41dd701e 100644 --- a/components/lenta/index.less +++ b/components/lenta/index.less @@ -36,6 +36,10 @@ } } + .adsCheckbox{ + padding-right: 1em; + } + .optimizationTip{ height: 150px; display: flex; diff --git a/components/lenta/templates/share.html b/components/lenta/templates/share.html index ac2fb0f8f8..839d09fbb7 100644 --- a/components/lenta/templates/share.html +++ b/components/lenta/templates/share.html @@ -47,6 +47,8 @@ var deletedaccount = typeof app.platform.sdk.user.deletedaccount != 'undefined' ? app.platform.sdk.user.deletedaccount(share.address) : false +if (typeof adv == undefined) var adv = ''; + var metadisplay = function(){ %> diff --git a/components/post/index.js b/components/post/index.js index eb2900bbc3..03eb8123c3 100644 --- a/components/post/index.js +++ b/components/post/index.js @@ -13,7 +13,7 @@ var post = (function () { var primary = (p.history && !p.inWnd) || p.primary; - var el = {}, share, ed = {}, recommendationsenabled = false, inicomments, eid = '', _repost = null, level = 0, external = null, recommendations = null, bannerComment; + var el = {}, share, ed = {}, recommendationsenabled = false, inicomments, eid = '', _repost = null, level = 0, external = null, recommendations = null, adsShowed = false; var progressInterval; @@ -402,7 +402,7 @@ var post = (function () { }, - initVideoLight: function(clbk){ + initVideoLight: function(clbk, ads){ //js-player-dummy var button = el.c.find('.initvideoplayer'); @@ -430,23 +430,23 @@ var post = (function () { }) } else { - actions.initVideo(clbk) + actions.initVideo(clbk, ads) } button = null }, - initVideo: function (clbk) { - + initVideo: function (clbk, ads) { if(!el.c) return + var ended; + if (self.app.platform.sdk.usersettings.meta.embedvideo && ! self.app.platform.sdk.usersettings.meta.embedvideo.value) return var pels = el.c.find('.js-player-ini'); - var wa = !share.repost && !ed.repost && (((share.itisvideo() && isMobile() && !ed.openapi) || (ed.autoplay && pels.length <= 1))) ? true : false if (pels.length) { @@ -533,6 +533,11 @@ var post = (function () { if(playbackState == 'playing' && duration < 120 && position / duration > 0.2){ self.app.platform.sdk.activity.adduser('video', share.address, 6 * position / duration, share) } + + if (playbackState === 'ended' && ads && !ended){ + ended = true; + clbk(true, true); + } }, error : function(error){ @@ -569,6 +574,7 @@ var post = (function () { enableHotkeys : !p.pip }; + $.each(pels, function (key, el2) { var videoId = el2.getAttribute('data-plyr-video-id'); @@ -579,7 +585,6 @@ var post = (function () { PlyrEx(el2, options, (_player) => { - if(!el.c) { _player.destroy() return @@ -1427,105 +1432,152 @@ var post = (function () { if(!el.share) return - renders.mystars(function () { }); - renders.url(function () { + var adsCount = localStorage.getItem('adsCount') || 0; - if(!el.share) return + var ads + if (share.settings.ads && !adsShowed && adsCount < 3){ + adsCount++; - if(!el.share.find('.showMore').length) renders.repost(); + localStorage.setItem('adsCount', adsCount); + + adsShowed = true; - actions.position(); + ads = share.settings.ads; - renders.urlContent(function () { + } + + player = null; + + var initVideoClbk = function(showAds){ + + renders.url(function () { if(!el.share) return - actions.position(); + if(!el.share.find('.showMore').length) renders.repost(); - if(ed.repost){ - actions.initVideoLight(); - } - else{ - actions.initVideo(); - } + actions.position(); - renders.images(function () { + renders.urlContent(function () { if(!el.share) return + actions.position(); - if (!ed.repost) { + if(ed.repost){ + actions.initVideoLight(function(res, next){ - actions.position(); + if (next){ + initVideoClbk(); + } + - el.share.find('.complain').on('click', events.complain); + }, true); + } + else{ + actions.initVideo(function(res, next){ - el.share.on( - 'click', - '.imagePostOpent', - events.openGallery, - ); - el.share.on('click', '.forrepost', events.repost); + if (next){ + initVideoClbk(); + } - el.share.find('.shareSave').on('click', events.shareSave); - el.share.find('.piptest').on('click', function(){ - - - }); + }, true); + } - el.share.find('.toregistration').on('click', events.toregistration) + renders.images(function () { - el.share.find('.txid').on('click', events.getTransaction); - el.share.find('.donate').on('click', events.donate); - - el.share - .find('.asubscribe') - .on('click', events.subscribe); - el.share - .find('.aunsubscribe') - .on('click', events.unsubscribe); - el.share.find('.metmenu').on('click', events.metmenu); - - - el.share - .find('.notificationturn') - .on('click', events.subscribePrivate); - } + if(!el.share) return - el.share.find('.sharesocial').on('click', events.sharesocial); - el.share.find('.postscoresshow').on('click', events.postscores); + if (!ed.repost) { - el.share.find('.postcontent').on('click', function(){ - $(this).addClass('allshowed') - }) + actions.position(); - el.share.find('.openetc').on('click', function(){ - + el.share.find('.complain').on('click', events.complain); + + el.share.on( + 'click', + '.imagePostOpent', + events.openGallery, + ); + el.share.on('click', '.forrepost', events.repost); + + el.share.find('.shareSave').on('click', events.shareSave); - self.closeContainer() + el.share.find('.piptest').on('click', function(){ + + + }); - self.nav.api.load({ - open : true, - href : 'post?s=' + $(this).attr('share'), - inWnd : true, - history : true + el.share.find('.toregistration').on('click', events.toregistration) + + el.share.find('.txid').on('click', events.getTransaction); + el.share.find('.donate').on('click', events.donate); + + el.share + .find('.asubscribe') + .on('click', events.subscribe); + el.share + .find('.aunsubscribe') + .on('click', events.unsubscribe); + el.share.find('.metmenu').on('click', events.metmenu); + + + el.share + .find('.notificationturn') + .on('click', events.subscribePrivate); + } + + el.share.find('.sharesocial').on('click', events.sharesocial); + + el.share.find('.postscoresshow').on('click', events.postscores); + + el.share.find('.postcontent').on('click', function(){ + $(this).addClass('allshowed') + }) + + el.share.find('.openetc').on('click', function(){ + + + self.closeContainer() + + self.nav.api.load({ + open : true, + href : 'post?s=' + $(this).attr('share'), + inWnd : true, + history : true + }) }) - }) - el.share.closest('.wndcontent').on('click', events.clickOut); + el.share.closest('.wndcontent').on('click', events.clickOut); + + if (clbk) clbk(); + }); - if (clbk) clbk(); }); - - }); - }); + el.c.find('.skip-ads').on('click', function(){ + + initVideoClbk(); + + }); + + }, showAds); + + } + + initVideoClbk(ads); + + + + + + }); if (share.itisarticle()){ @@ -1660,7 +1712,7 @@ var post = (function () { ); } }, - url: function (clbk) { + url: function (clbk, ads) { var url = share.url; var og = self.app.platform.sdk.remote.storage[url]; @@ -1672,7 +1724,8 @@ var post = (function () { name: 'url', el: el.c.find('.url'), data: { - url: url, + url: ads || url, + ads: ads, og: og, share: share, fullplayer : !ed.repost @@ -1780,7 +1833,6 @@ var post = (function () { var initEvents = function () { - self.app.platform.matrixchat.clbks.SHOWING.post = function(v){ if(v && player){ diff --git a/components/share/index.css b/components/share/index.css index a15b38fa2f..a4e6f68609 100644 --- a/components/share/index.css +++ b/components/share/index.css @@ -49,6 +49,9 @@ background: rgb(var(--background-main)); box-shadow: none; } +#share .settingsWrapper .advCheckbox label { + padding-right: 1em; +} #share .settingsWrapper .visibilityWrapper .vc_valuecustom { width: auto; /*font-size: 0.8em; @@ -251,6 +254,28 @@ min-height: 78px; border-radius: 6px; } +#share .adsCheckboxWrapper { + margin-bottom: 0.5em; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0.5em; +} +#share .adsCheckboxWrapper .peertube-server-hint { + bottom: auto; +} +#share .adsCheckboxWrapper .adsCheckboxLabel { + font-weight: 600; + padding-right: 0.5em; +} +#share .adsVideo { + display: none; + position: relative; + margin-bottom: 3em; +} +#share .adsVideo.active { + display: block; +} #share .wallpaperUpload { margin-bottom: 0.5em; padding: 1em 0; @@ -972,6 +997,9 @@ html.mobileview .wnd.wndsharepost .wndcontent #share .absolutetxwrapper { #share .iconWrapper { display: none; } + #share .adsWrapper .adsCheckboxLabel { + padding-left: 0.5em; + } #share .cntwrk { margin-left: 0; padding-left: 0; diff --git a/components/share/index.js b/components/share/index.js index f412db0864..73e40f1dfb 100644 --- a/components/share/index.js +++ b/components/share/index.js @@ -20,6 +20,8 @@ var share = (function(){ var clickOnCreateHappened = false; + var defaultAds = "peertube://peertube4new.pocketnet.app/4d99f4f5-8466-4bce-8be7-97774c236931" + var loadedimages = {} var loadingimages = {} var player = null @@ -1727,6 +1729,7 @@ var share = (function(){ p.el.find('.cancelediting').on('click', function(){ + self.closeContainer(); if(external && external.cancel){ @@ -1779,19 +1782,20 @@ var share = (function(){ }) + + self.shell({ name : 'settings', el : el.settings, data : { share : currentShare, essenseData : essenseData, - selector : selector + selector : selector, }, }, function(p){ - ParametersLive([selector], p.el) - + ParametersLive([selector], p.el); selector._onChange = function(){ @@ -1985,7 +1989,6 @@ var share = (function(){ url : function(clbk){ - destroyPlayer() var url = currentShare.url.v; @@ -2383,13 +2386,23 @@ var share = (function(){ }, - body : function(clbk){ + body : function(clbk){ + + var checkbox = new Parameter({ + type : "BOOLEAN", + name : "Ads", + id : 'adsCheckbox', + value: Boolean(currentShare.settings.ads) + }) + + self.shell({ name : 'body', el : el.body, data : { share : currentShare, - ed : essenseData + ed : essenseData, + checkbox : checkbox }, @@ -2407,6 +2420,27 @@ var share = (function(){ el.updateWallpaperInput = el.c.find('.wallpaperShareInput'); el.wallpaperStatusIcon = el.c.find('.wallpaperStatusIcon'); + var og = self.app.platform.sdk.remote.storage[url]; + + var elAdsVideo = p.el.find('.adsVideo'); + + self.shell({ + name : 'url', + inner : html, + el : elAdsVideo, + data : { + url : currentShare.url.v, + og : og, + remove : true, + fullplayer : true, + share : currentShare, + video : true, + ads : defaultAds, + adsPreview : true + }, + + }) + el.eMessage.emojioneArea({ pickerPosition : 'bottom', @@ -2527,6 +2561,28 @@ var share = (function(){ el.caption.on('keyup', events.caption) + ParametersLive([checkbox], p.el); + + checkbox._onChange = function(value){ + + var ads = ''; + if (value) ads = defaultAds; + + currentShare.settings.ads = ads; + + if (ads && !elAdsVideo.hasClass('active')){ + + elAdsVideo.addClass('active'); + + } else { + + elAdsVideo.removeClass('active'); + + } + + state.save() + } + renders.makesortable() actions.autoFilled() @@ -2771,7 +2827,7 @@ var share = (function(){ }, init : function(p){ - + loadedimages = {} loadingimages = {} @@ -2843,8 +2899,7 @@ var share = (function(){ wnd : { close : function(){ - - + if (essenseData.close){ essenseData.close() } diff --git a/components/share/index.less b/components/share/index.less index 32c1d18ce2..fab1fbc436 100644 --- a/components/share/index.less +++ b/components/share/index.less @@ -65,6 +65,13 @@ } .settingsWrapper{ + + .advCheckbox{ + label{ + padding-right: @rhythm * 2; + } + } + .visibilityWrapper{ .vc_valuecustom{ width: auto; @@ -324,6 +331,33 @@ } } + .adsCheckboxWrapper{ + margin-bottom: @rhythm; + display: flex; + justify-content: space-between; + align-items: center; + padding: @rhythm; + + .peertube-server-hint{ + bottom: auto; + } + + .adsCheckboxLabel{ + font-weight: 600; + padding-right: @rhythm; + } + } + + .adsVideo{ + display: none; + position: relative; + margin-bottom: @rhythm * 6; + + &.active{ + display: block; + } + } + .wallpaperUpload { margin-bottom: @rhythm; @@ -1274,6 +1308,10 @@ html.mobileview{ display: none; } + .adsWrapper .adsCheckboxLabel{ + padding-left: @rhythm; + } + .cntwrk{ margin-left: 0; padding-left : 0; diff --git a/components/share/templates/body.html b/components/share/templates/body.html index eb10ca45a8..f0f8927041 100644 --- a/components/share/templates/body.html +++ b/components/share/templates/body.html @@ -13,6 +13,23 @@
+ + <% if (share.itisvideo()){ %> + +
+ + + <%= checkbox.input() %> + +
+
+ +
+ + <% } %> + <% }, diff --git a/components/share/templates/url.html b/components/share/templates/url.html index bc6c099c92..d5ee6be054 100644 --- a/components/share/templates/url.html +++ b/components/share/templates/url.html @@ -1,4 +1,10 @@ <% if(url){ + + if (typeof ads == undefined) var ads = ''; + if (typeof adsPreview == undefined) var adsPreview = false; + + if (ads) url = ads; + var meta = app.platform.parseUrl(url); if(typeof share == 'undefined') share = {}; @@ -61,7 +67,15 @@ <% } %> - + + <% if (ads && !adsPreview) { %> + +
+ <%- e('skip') %> +
+ <% } %> + +
<% if(typeof preview != 'undefined' && preview) { @@ -128,7 +142,7 @@
- <% if((typeof video == 'undefined' || !video) && share.itisaudio() != true) { %> + <% if((typeof video == 'undefined' || !video) && share.itisaudio() != true && !ads) { %>
<%=e('expandvideo')%> @@ -136,7 +150,7 @@
<% } %> - <% if(typeof remove != 'undefined' && share && (share.itisvideo() || share.itisaudio())) { %> + <% if(typeof remove != 'undefined' && share && (share.itisvideo() || share.itisaudio()) && !adsPreview) { %>
@@ -168,7 +182,7 @@
- <% if(meta.type == 'peertube' && (fullplayer || app.platform.sdk.usersettings.meta.embedvideo.value || (meta.type != 'youtube' && !window.cordova))) {%> + <% if(meta.type == 'peertube' && (fullplayer || app.platform.sdk.usersettings.meta.embedvideo.value || (meta.type != 'youtube' && !window.cordova)) && !adsPreview) {%> <% if((typeof preview == 'undefined' || !preview) && info.data) {%> diff --git a/css/main.css b/css/main.css index c00cc1cdc4..83582f5900 100644 --- a/css/main.css +++ b/css/main.css @@ -6808,7 +6808,8 @@ html.pipmode #content, html.pipmode .matrixchatwrapper { display: none; } -.peertube-server-hint { +.peertube-server-hint, +.skip-ads { z-index: 3; position: absolute; margin: 10px; @@ -6819,16 +6820,22 @@ html.pipmode .matrixchatwrapper { background: #000000bb; color: #fff; } -.peertube-server-hint i.fa { +.peertube-server-hint i.fa, +.skip-ads i.fa { font-size: 0.8em; margin-top: 1px; margin-right: 5px; } -.peertube-server-hint a { +.peertube-server-hint a, +.skip-ads a { display: flex; flex-direction: row; align-items: center; } +.skip-ads { + right: 0; + cursor: pointer; +} #application.default-scroll { overflow-x: visible; } diff --git a/css/main.less b/css/main.less index 9a852e1af9..170d45d41f 100644 --- a/css/main.less +++ b/css/main.less @@ -8442,7 +8442,7 @@ html.pipmode{ } } -.peertube-server-hint { +.peertube-server-hint, .skip-ads { z-index: 3; position: absolute; margin: 10px; @@ -8466,6 +8466,11 @@ html.pipmode{ } } +.skip-ads{ + right: 0; + cursor: pointer; +} + /////////// #application{ diff --git a/js/kit.js b/js/kit.js index 4d1d1950b1..a1f2b227e5 100644 --- a/js/kit.js +++ b/js/kit.js @@ -1337,7 +1337,8 @@ Share = function(lang){ v : '', videos : [], image : '', - f : '0' + f : '0', + ads: '' } @@ -2297,7 +2298,8 @@ pShare = function(){ v : '', videos : [], image : '', - f : '0' + f : '0', + ads : '' } self.isEmpty = function(){ diff --git a/localization/en.js b/localization/en.js index 2b31b547a6..43a7bfda83 100644 --- a/localization/en.js +++ b/localization/en.js @@ -669,7 +669,7 @@ _l.refresh = "Refresh" _l.e13111 = "Add your email to get the latest "+appname+" updates" _l.e13112 = "Enter email" _l.e13113 = "Add email" -_l.skip = "Skip" +_l.skip = "Continue watch" _l.e13114 = "There is some problem with your registration due to strange activity." _l.e13115 = "Please email" _l.e13116 = "to receive coins and open your account." @@ -2610,3 +2610,5 @@ _l.howToBuy = "How to buy PKOIN"; _l.clearLocal = 'Clear Local Storage'; _l.clearLocalQuestion = 'Do you really want to clear Local Storage?'; + +_l.showAds = 'Show info about boost at the beginning of the video'; diff --git a/localization/ru.js b/localization/ru.js index ebc48f313f..e937339a06 100644 --- a/localization/ru.js +++ b/localization/ru.js @@ -630,7 +630,7 @@ _l.refresh = "Обновить" _l.e13111 = "Добавьте свой адрес электронной почты, чтобы получать последние обновления "+appname+"" _l.e13112 = "Введите адрес электронной почты" _l.e13113 = "Добавить адрес электронной почты" -_l.skip = "Пропустить" +_l.skip = "Продолжить просмотр" _l.e13114 = "Возникла проблема с вашей регистрацией из-за странной активности вашего ip адреса." _l.e13115 = "Пожалуйста, напишите нам на" _l.e13116 = "для того, чтобы получить монеты и открыть свой счет." @@ -2398,3 +2398,5 @@ _l.howToBuy = "Как купить PKOIN"; _l.clearLocal = 'Очистить Local Storage'; _l.clearLocalQuestion = 'Вы действительно хотите очистить Local Storage?'; + +_l.showAds = 'Показать информацию о продвижении в начале видео'; From f9fc903974d707767b8f404e84833465cfe6f004 Mon Sep 17 00:00:00 2001 From: j-bitmaker Date: Tue, 27 Jun 2023 09:13:10 +0300 Subject: [PATCH 2/7] ads --- components/share/index.js | 67 ++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/components/share/index.js b/components/share/index.js index 73e40f1dfb..63f30bb605 100644 --- a/components/share/index.js +++ b/components/share/index.js @@ -20,7 +20,7 @@ var share = (function(){ var clickOnCreateHappened = false; - var defaultAds = "peertube://peertube4new.pocketnet.app/4d99f4f5-8466-4bce-8be7-97774c236931" + var defaultAds = "peertube://peertube33.pocketnet.app/0344af51-ed23-4de7-bb18-6d2794d74fb0" var loadedimages = {} var loadingimages = {} @@ -1915,6 +1915,7 @@ var share = (function(){ renders.repost(); + renders.ads() }); @@ -2012,7 +2013,6 @@ var share = (function(){ }, function(p){ - if(currentShare.url.v && !og){ if (meta.type == 'youtube' || meta.type == 'vimeo' || meta.type == 'bitchute' || meta.type == 'peertube' || meta.type == 'ipfs') { @@ -2137,6 +2137,42 @@ var share = (function(){ }, + ads : function(clbk){ + + destroyPlayer(); + + var og = self.app.platform.sdk.remote.storage[defaultAds]; + + var videoWrapper = el.adsVideo.find('.videoWrapper'); + console.log('videoWrapper!!!', videoWrapper, el.adsVideo, currentShare); + + self.shell({ + name : 'url', + inner : html, + el : el.adsVideo, + data : { + url : currentShare.url.v, + og : og, + remove : true, + fullplayer : true, + share : currentShare, + video : true, + ads : defaultAds, + adsPreview : true + + }, + + }, function(p){ + + console.log('p!!!', p); + + destroyPlayer() + + if (clbk) + clbk(); + }) + }, + images : function(clbk){ self.shell({ @@ -2413,6 +2449,7 @@ var share = (function(){ el.message = el.c.find('.message'); el.eMessage = el.c.find('#emjcontainer'); el.urlWrapper = el.c.find('.urlWrapper') + el.adsVideo = el.c.find('.adsVideo'); el.caption = el.c.find('.captionshare'); el.cpt = el.c.find('.cpt') el.images = el.c.find('.imagesWrapper') @@ -2420,26 +2457,6 @@ var share = (function(){ el.updateWallpaperInput = el.c.find('.wallpaperShareInput'); el.wallpaperStatusIcon = el.c.find('.wallpaperStatusIcon'); - var og = self.app.platform.sdk.remote.storage[url]; - - var elAdsVideo = p.el.find('.adsVideo'); - - self.shell({ - name : 'url', - inner : html, - el : elAdsVideo, - data : { - url : currentShare.url.v, - og : og, - remove : true, - fullplayer : true, - share : currentShare, - video : true, - ads : defaultAds, - adsPreview : true - }, - - }) el.eMessage.emojioneArea({ pickerPosition : 'bottom', @@ -2570,13 +2587,13 @@ var share = (function(){ currentShare.settings.ads = ads; - if (ads && !elAdsVideo.hasClass('active')){ + if (ads && !el.adsVideo.hasClass('active')){ - elAdsVideo.addClass('active'); + el.adsVideo.addClass('active'); } else { - elAdsVideo.removeClass('active'); + el.adsVideo.removeClass('active'); } From 975590c92798da0b7d7ea345f96be6e41729c765 Mon Sep 17 00:00:00 2001 From: j-bitmaker Date: Tue, 27 Jun 2023 09:21:36 +0300 Subject: [PATCH 3/7] ads only ru --- components/share/index.js | 9 +++++---- components/share/templates/body.html | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/share/index.js b/components/share/index.js index 63f30bb605..bb6c7bd15e 100644 --- a/components/share/index.js +++ b/components/share/index.js @@ -1915,7 +1915,10 @@ var share = (function(){ renders.repost(); - renders.ads() + if (self.app.localization.key === 'ru'){ + renders.ads(); + } + }); @@ -2160,12 +2163,10 @@ var share = (function(){ ads : defaultAds, adsPreview : true - }, + } }, function(p){ - console.log('p!!!', p); - destroyPlayer() if (clbk) diff --git a/components/share/templates/body.html b/components/share/templates/body.html index f0f8927041..dfca3af4ee 100644 --- a/components/share/templates/body.html +++ b/components/share/templates/body.html @@ -14,7 +14,7 @@
- <% if (share.itisvideo()){ %> + <% if (share.itisvideo() && app.localization.key == 'ru'){ %>