Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 3 additions & 66 deletions javascript/commons/Countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ liquipedia.countdown = {

liquipedia.countdown.setupCountdownsIfSwitchToggleExists();

// Only run when the window is actually in the front, not in background tabs (on browsers that support it)
// Only run when the window is actually in the front,
// not in background tabs (on browsers that support it)
mw.loader.using( 'mediawiki.visibleTimeout' ).then( ( require ) => {
liquipedia.countdown.timeoutFunctions = require( 'mediawiki.visibleTimeout' );
liquipedia.countdown.runCountdown();
Expand Down Expand Up @@ -96,7 +97,6 @@ liquipedia.countdown = {
);
},
setCountdownString: function ( timerObjectNode ) {
const streamsarr = [];
const countdownElem = timerObjectNode.querySelector( '.timer-object-countdown' );
let datestr = '', live = 'LIVE';

Expand Down Expand Up @@ -143,75 +143,12 @@ liquipedia.countdown = {
} else {
datestr = ''; // DATE ERROR!
}
if ( timerObjectNode.dataset.streamTwitch ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/twitch/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamTwitch ) + '"><i class="lp-icon lp-icon-21 lp-twitch"></i></a>' );
}
if ( timerObjectNode.dataset.streamTwitch2 ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/twitch/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamTwitch2 ) + '"><i class="lp-icon lp-icon-21 lp-twitch"></i></a>' );
}
if ( timerObjectNode.dataset.streamYoutube ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/youtube/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamYoutube ) + '"><i class="lp-icon lp-icon-21 lp-youtube"></i></a>' );
}
if ( timerObjectNode.dataset.streamAfreeca ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/afreeca/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamAfreeca ) + '"><i class="lp-icon lp-icon-21 lp-afreeca"></i></a>' );
}
if ( timerObjectNode.dataset.streamAfreecatv ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/afreecatv/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamAfreecatv ) + '"><i class="lp-icon lp-icon-21 lp-afreeca"></i></a>' );
}
if ( timerObjectNode.dataset.streamBilibili ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/bilibili/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamBilibili ) + '"><i class="lp-icon lp-icon-21 lp-bilibili"></i></a>' );
}
if ( timerObjectNode.dataset.streamBooyah ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/booyah/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamBooyah ) + '"><i class="lp-icon lp-icon-21 lp-booyah"></i></a>' );
}
if ( timerObjectNode.dataset.streamCc163 ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/cc163/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamCc163 ) + '"><i class="lp-icon lp-icon-21 lp-cc"></i></a>' );
}
if ( timerObjectNode.dataset.streamDailymotion ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/dailymotion/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamDailymotion ) + '"><i class="lp-icon lp-icon-21 lp-dailymotion"></i></a>' );
}
if ( timerObjectNode.dataset.streamDouyu ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/douyu/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamDouyu ) + '"><i class="lp-icon lp-icon-21 lp-douyutv"></i></a>' );
}
if ( timerObjectNode.dataset.streamFacebook ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/facebook/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamFacebook ) + '"><i class="lp-icon lp-icon-21 lp-facebook"></i></a>' );
}
if ( timerObjectNode.dataset.streamHuomao ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/huomao/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamHuomao ) + '"><i class="lp-icon lp-icon-21 lp-huomaotv"></i></a>' );
}
if ( timerObjectNode.dataset.streamHuya ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/huya/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamHuya ) + '"><i class="lp-icon lp-icon-21 lp-huyatv"></i></a>' );
}
if ( timerObjectNode.dataset.streamKick ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/kick/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamKick ) + '"><i class="lp-icon lp-icon-21 lp-kick"></i></a>' );
}
if ( timerObjectNode.dataset.streamLoco ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/loco/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamLoco ) + '"><i class="lp-icon lp-icon-21 lp-loco"></i></a>' );
}
if ( timerObjectNode.dataset.streamMildom ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/mildom/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamMildom ) + '"><i class="lp-icon lp-icon-21 lp-mildom"></i></a>' );
}
if ( timerObjectNode.dataset.streamNimo ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/nimo/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamNimo ) + '"><i class="lp-icon lp-icon-21 lp-nimotv"></i></a>' );
}
if ( timerObjectNode.dataset.streamTrovo ) {
streamsarr.push( '<a href="' + mw.config.get( 'wgScriptPath' ) + '/Special:Stream/trovo/' + liquipedia.countdown.getStreamName( timerObjectNode.dataset.streamTrovo ) + '"><i class="lp-icon lp-icon-21 lp-trovo"></i></a>' );
}
if ( timerObjectNode.dataset.streamTl ) {
streamsarr.push( '<a href="https://tl.net/video/streams/' + timerObjectNode.dataset.streamTl + '" target="_blank"><i class="lp-icon lp-icon-21 lp-stream"></i></a>' );
}
let html = '<span class="timer-object-countdown-time">' + datestr + '</span>';
if ( datestr.length > 0 && streamsarr.length > 0 ) {
if ( datestr.length > 0 && timerObjectNode.dataset.hasstreams === 'true' ) {
html += ' - ';
}
if ( timerObjectNode.dataset.finished !== 'finished' ) {
html += streamsarr.join( ' ' );
}
countdownElem.innerHTML = html;
},
getStreamName: function ( url ) {
return url.replace( /\s/g, '_' );
},
timeZoneAbbr: new Map( [
[ 'Acre Time', 'ACT' ],
[ 'Afghanistan Time', 'AFT' ],
Expand Down
76 changes: 76 additions & 0 deletions standard/countdown.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
-- @Liquipedia
-- wiki=commons
-- page=Module:Countdown
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Arguments = require('Module:Arguments')
local DateExt = require('Module:Date/Ext')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')

local StreamLinks = Lua.import('Module:Links/Stream')

local Countdown = {}

---@param frame Frame
---@return string
function Countdown.create(frame)
return Countdown._create(Arguments.getArgs(frame))
end

---@param args table
---@return string
function Countdown._create(args)
if Logic.isEmpty(args.date) and not args.timestamp then
return ''
end

local wrapper = mw.html.create('span')
:addClass('timer-object')

if Logic.readBool(args.rawcountdown) then
wrapper:addClass('timer-object-countdown-only')
end
if Logic.readBool(args.rawdatetime) then
wrapper:addClass('timer-object-datetime-only')
end

-- Timestamp
local timestamp = args.timestamp or DateExt.readTimestampOrNil(args.date) or 'error'
wrapper:attr('data-timestamp', timestamp)

local streams
if Logic.readBool(args.finished) then
wrapper:attr('data-finished', 'finished')
elseif not Logic.readBool(args.nostreams) then
streams = StreamLinks.buildDisplays(StreamLinks.filterStreams(args))
end
if streams then
streams = table.concat(streams, ' ')
wrapper:attr('data-hasstreams', 'true')
end


if args.text then
wrapper:attr('data-countdown-end-text', args.text)
end
if args.separator then
wrapper:attr('data-separator', args.separator)
end

wrapper:wikitext(args.date)

if Logic.isEmpty(streams) then
return tostring(wrapper)
end

return tostring(mw.html.create()
:node(wrapper)
:wikitext(streams)
)
end

return Countdown
Loading