Template:VideoGallery/sandbox: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
m (Would spew error without 0 in early #expr if the legacy code was purged)
mNo edit summary
Line 1: Line 1:
<includeonly>{{#if:{{{1|}}}|{{#vardefine:tl_vg_videocount|{{#vardefineecho:tl_vg_currentvideo|{{#expr:0{{#regex:{{{1|}}}|/(.+)/|+1}}}}}}}}{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}>0|true}}|{{#vardefine:server{{#var:tl_vg_currentvideo}}|{{#regex:videolist
<includeonly>{{#if:{{{1|}}}|<!--
 
Parameterless mode begins
 
-->{{#vardefine:tl_vg_videocount|{{#vardefineecho:tl_vg_currentvideo|{{#expr:0{{#regex:{{{1|}}}|/(.+)/|+1}}}}}}}}<!--
 
  Counting completed, max video count is duplicated to two variables: tl_vg_videocount and tl_vg_currentvideo, their values will change later.
 
-->{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}>0|true}}|{{#vardefine:server{{#var:tl_vg_currentvideo}}|{{#regex:videolist


{{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))([\s\S]*)/|$2}}}}
{{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))([\s\S]*)/|$2}}}}
Line 7: Line 15:
{{#vardefine:caption{{#var:tl_vg_currentvideo}}|{{#regex:videolist
{{#vardefine:caption{{#var:tl_vg_currentvideo}}|{{#regex:videolist


{{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))(.......(?!\s)....{{!}}.......)(.*)([\s\S]*)/|{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}-1}}}}$6}}}}}}
{{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))(.......(?!\s)....{{!}}.......)(.*)([\s\S]*)/|{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}-1}}}}$6}}}}}}<!--
{{#vardefine:tl_vg_embedslots|{{#ifexpr:{{#var:tl_vg_videocount}}<3|{{#var:tl_vg_videocount}}|3}}}}
 
{{#while:|{{#ifexpr:{{#var:tl_vg_embedslots}}>0|true}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{Mod|{{#time:U}}+{{#vardefineecho:tl_vg_embedslots|{{#expr:{{#var:tl_vg_embedslots}}-1}}}}+{{#switch:{{#var:tl_vg_embedslots}}|0={{REVISIONSIZE}}|1={{NUMBEROFPAGES:R}}|2={{CurrentRevision}}}}|{{#var:tl_vg_videocount}}}}+1}}}}{{#while:|{{#if:{{#var:video{{#var:tl_vg_featuredvideo}}}}||used}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{#var:tl_vg_featuredvideo}}{{#ifexpr:{{#var:tl_vg_featuredvideo}}-1=0|+2|-1}}}}}}}}<div style="float:left; margin: .5em 0 1.3em 1.4em;">{{#ev:{{#regex:{{#var:server{{#var:tl_vg_featuredvideo}}}}|/.*(youtube{{!}}dailymotion).*/|$1}}|{{#var:video{{#var:tl_vg_featuredvideo}}}}|302||<span style="text-overflow: ellipsis; display: inline-block; width: 275px; white-space: nowrap; overflow: hidden; vertical-align: top;" title="{{#var:caption{{#var:tl_vg_featuredvideo}}}}">[{{#var:server{{#var:tl_vg_featuredvideo}}}}{{#var:video{{#var:tl_vg_featuredvideo}}}} {{#tag:nowiki|{{#var:caption{{#var:tl_vg_featuredvideo}}}}}}]</span>|frame}}</div>{{#vardefine:video{{#var:tl_vg_featuredvideo}}|}}}}
  Segregating strings to variables completed, variables are with self-explanatory names: server, video, and caption. The ultimate trick of picking value from each variables index-like is by having the increasing (decreasing in this case) number appended to variable names and then use the while-loop with number increasing/decreasing to iterate values from numbered variable names or call a numbered variable name index-like for its value. I'll learn from this for [[Template:Config required]] and some other templates.
 
-->
{{#vardefine:tl_vg_embedslots|{{#ifexpr:{{#var:tl_vg_videocount}}<3|{{#var:tl_vg_videocount}}|3}}}}<!--
 
  Max embed slots to a variable: tl_vg_embedslots, value will be subtracted each time a featuring video is selected for embedding. Next part is while-loop with our silly randomizer logic.
 
-->
{{#while:|{{#ifexpr:{{#var:tl_vg_embedslots}}>0|true}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{Mod|{{#time:U}}+{{#vardefineecho:tl_vg_embedslots|{{#expr:{{#var:tl_vg_embedslots}}-1}}}}+{{#switch:{{#var:tl_vg_embedslots}}|0={{REVISIONSIZE}}|1={{NUMBEROFPAGES:R}}|2={{CurrentRevision}}}}|{{#var:tl_vg_videocount}}}}+1}}}}{{#while:|{{#if:{{#var:video{{#var:tl_vg_featuredvideo}}}}||used}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{#var:tl_vg_featuredvideo}}{{#ifexpr:{{#var:tl_vg_featuredvideo}}-1=0|+2|-1}}}}}}}}<!--
 
  The key part where the video is being turned into an embed video. Notice the #ev used here.
 
--><div style="float:left; margin: .5em 0 1.3em 1.4em;">{{#ev:{{#regex:{{#var:server{{#var:tl_vg_featuredvideo}}}}|/.*(youtube{{!}}dailymotion).*/|$1}}|{{#var:video{{#var:tl_vg_featuredvideo}}}}|302||<span style="text-overflow: ellipsis; display: inline-block; width: 275px; white-space: nowrap; overflow: hidden; vertical-align: top;" title="{{#var:caption{{#var:tl_vg_featuredvideo}}}}">[{{#var:server{{#var:tl_vg_featuredvideo}}}}{{#var:video{{#var:tl_vg_featuredvideo}}}} {{#tag:nowiki|{{#var:caption{{#var:tl_vg_featuredvideo}}}}}}]</span>|frame}}</div><!--
 
 
 
-->{{#vardefine:video{{#var:tl_vg_featuredvideo}}|}}}}<!--
 
  While-loop completed. Ready to render the remaining non-featured videos to the page.
 
-->
<div style="clear:left"></div>
<div style="clear:left"></div>
{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}}
{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}}
{{#while:|{{#ifexpr:{{#var:tl_vg_videocount}}>0|true}}|{{#if:{{#var:video{{#vardefineecho:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}}}|{{#tag:ul|{{#tag:li|[{{#var:server{{#var:tl_vg_videocount}}}}{{#var:video{{#var:tl_vg_videocount}}}}{{#tag:nowiki|{{#var:caption{{#var:tl_vg_videocount}}}}}}]}}}}|}}}}|}}<!--
{{#while:|{{#ifexpr:{{#var:tl_vg_videocount}}>0|true}}|{{#if:{{#var:video{{#vardefineecho:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}}}|{{#tag:ul|{{#tag:li|[{{#var:server{{#var:tl_vg_videocount}}}}{{#var:video{{#var:tl_vg_videocount}}}}{{#tag:nowiki|{{#var:caption{{#var:tl_vg_videocount}}}}}}]}}}}|}}}}<!--
 
Parameterless mode ends
 
-->}}<!--


Legacy
Legacy


-->{{#vardefine:tl_vg_visible|true}}<div></div>{{#vardefine:tl_vg_videocount|1}}{{#vardefine:tl_vg_currentvideo|1}}{{#while:|{{{vid{{#var:tl_vg_videocount}}|}}}|{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}}}}{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}{{#ifexpr:{{#var:tl_vg_videocount}}>50|{{#vardefine:tl_vg_videocount|50}}}}{{#ifexpr:{{#var:tl_vg_videocount}}<4|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}<br style="clear:left"/>|{{#vardefine:tl_vg_thumbnail1|{{#expr:{{rand|{{#var:tl_vg_videocount}}|1}}+1}}}}{{#vardefine:tl_vg_thumbnail2|{{#expr:{{rand|{{#var:tl_vg_videocount}}|2}}+1}}}}{{#vardefine:tl_vg_thumbnail3|{{#expr:{{rand|{{#var:tl_vg_videocount}}|3}}+1}}}}{{{{{srv{{#var:tl_vg_thumbnail1}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail1}}|}}}|{{{cap{{#var:tl_vg_thumbnail1}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail2}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail2}}|}}}|{{{cap{{#var:tl_vg_thumbnail2}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail3}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail3}}|}}}|{{{cap{{#var:tl_vg_thumbnail3}}|}}}}}<div style="clear:left;"></div>{{#tag:ul|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{#ifeq:{{#var:tl_vg_thumbnail1}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail2}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail3}}|{{#var:tl_vg_currentvideo}}||{{#tag:li|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{#tag:nowiki|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}|link}}}}}}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}}}}}</includeonly><noinclude>{{documentation|Template:VideoGallery/sandbox/doc}}</noinclude>
-->{{#vardefine:tl_vg_visible|true}}<div></div>{{#vardefine:tl_vg_videocount|1}}{{#vardefine:tl_vg_currentvideo|1}}{{#while:|{{{vid{{#var:tl_vg_videocount}}|}}}|{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}}}}{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}{{#ifexpr:{{#var:tl_vg_videocount}}>50|{{#vardefine:tl_vg_videocount|50}}}}{{#ifexpr:{{#var:tl_vg_videocount}}<4|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}<br style="clear:left"/>|{{#vardefine:tl_vg_thumbnail1|{{#expr:{{rand|{{#var:tl_vg_videocount}}|1}}+1}}}}{{#vardefine:tl_vg_thumbnail2|{{#expr:{{rand|{{#var:tl_vg_videocount}}|2}}+1}}}}{{#vardefine:tl_vg_thumbnail3|{{#expr:{{rand|{{#var:tl_vg_videocount}}|3}}+1}}}}{{{{{srv{{#var:tl_vg_thumbnail1}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail1}}|}}}|{{{cap{{#var:tl_vg_thumbnail1}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail2}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail2}}|}}}|{{{cap{{#var:tl_vg_thumbnail2}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail3}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail3}}|}}}|{{{cap{{#var:tl_vg_thumbnail3}}|}}}}}<div style="clear:left;"></div>{{#tag:ul|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{#ifeq:{{#var:tl_vg_thumbnail1}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail2}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail3}}|{{#var:tl_vg_currentvideo}}||{{#tag:li|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{#tag:nowiki|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}|link}}}}}}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}}}}}</includeonly><noinclude>{{documentation|Template:VideoGallery/sandbox/doc}}</noinclude>
6,576

edits

Navigation menu