Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
67 changes: 2 additions & 65 deletions javascript/commons/Countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ liquipedia.countdown = {
);
},
setCountdownString: function( timerObjectNode ) {
const streamsarr = [ ];
let datestr = '', live = 'LIVE!';
if ( typeof timerObjectNode.dataset.countdownEndText !== 'undefined' ) {
live = timerObjectNode.dataset.countdownEndText;
Expand Down Expand Up @@ -106,75 +105,13 @@ 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.streams.length > 0 ) {
html += ' - ';
}
if ( timerObjectNode.dataset.finished !== 'finished' ) {
html += streamsarr.join( ' ' );
html += timerObjectNode.dataset.streams;
}
Comment thread
hjpalpha marked this conversation as resolved.
Outdated
timerObjectNode.querySelector( '.timer-object-countdown' ).innerHTML = html;
},
getStreamName: function( url ) {
return url.replace( /\s/g, '_' );
},
timeZoneAbbr: new Map( [
[ 'Acre Time', 'ACT' ],
[ 'Afghanistan Time', 'AFT' ],
Expand Down
59 changes: 59 additions & 0 deletions standard/countdown.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
-- @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 StreamLinks = require('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
if Logic.readBool(args.finished) then
wrapper:attr('data-finished', 'finished')
elseif not Logic.readBool(args.nostreams) then
wrapper:attr('data-streams', StreamLinks.display(StreamLinks.filterStreams(args), {addSpace = true}))
end

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

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)

return tostring(wrapper:done())
end

return Countdown
Loading