Anda dapat membuat halaman dokumentasi untuk buat pada modul Scribunto ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
localp={} localrandomModule=require('Modul:Random') p.main=function(frame) localparent=frame.getParent(frame) localparentArgs=parent.args localargs=cleanupArgs(parentArgs) localoutput=p._main(args) returnframe:preprocess(output) end functioncleanupArgs(argsTable) localcleanArgs={} forkey,valinpairs(argsTable)do iftype(val)=='string'then val=val:match('^%s*(.-)%s*$') ifval~=''then cleanArgs[key]=val end else cleanArgs[key]=val end end returncleanArgs end p._main=function(args) ifnotargs[1]then returnerror(linkedand'Tidak ada halaman yang ditentukan'or'Tidak ada halaman yang ditentukan',0) end locallines=makeGalleryLinesTable(args) returnmakeOutput(lines,args.overflow,args.maxheight,args.mode,args.croptop) end functionmakeGalleryLine(file,caption,link) localtitle=mw.title.new(file,"File") locallinktext=(linkand'{{!}}link='..linkor'') localmaxImageWidth='{{!}}800px' return'[['..title.prefixedText..(captionand'{{!}}'..captionor'')..maxImageWidth..linktext..']]'..(captionand'\n<div style="text-align:center;">'..caption..'</div>'or'\n') end functionmakeGalleryLineSlideshow(file,caption) localtitle=mw.title.new(file,"File") localcaptiontext='[[Berkas:OOjs_UI_icon_info-progressive.svg|link=:'..title.prefixedText..']] <span style="font-size:110%;">'..(captionor'')..'</span>' returntitle.prefixedText..'{{!}}'..captiontext end functionmakeGalleryLinesTable(args) localgalleryLinesTable={} locali=1 whileargs[i]do ifnotargs.modethen table.insert(galleryLinesTable,makeGalleryLine(args[i],args[i+1],args.link)) elseifargs.mode=='slideshow'then table.insert(galleryLinesTable,makeGalleryLineSlideshow(args[i],args[i+1],args.link)) else error('Mode tidak didukung') end end i=i+2 end returngalleryLinesTable end functionmakeOutput(imageLines,overflow,maxHeight,mode,croptop) localrandomiseArgs={['t']=imageLines} localrandomisedLines=randomModule.main('array',randomiseArgs) localoutput,galleryContent ifnotmodethen galleryContent=table.concat(randomisedLines,'\n',1,1) seperate=mw.text.split(galleryContent,'\n') output='<div class="portal-banner-image" style="max-height:'..(maxHeightor'initial')..'; overflow:'..(overflowor'auto').. ';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptopor'0')..'%;">'..seperate[1]..'</div></div>'..seperate[2] elseifmode=='slideshow'then galleryContent=table.concat(randomisedLines,'\n') output='<div class="portal-banner-image-slideshow nomobile" style="max-height:'..(maxHeightor'initial')..'; overflow:'..(overflowor'auto').. ';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptopor'0')..'%;">'..'{{#tag:gallery|'..galleryContent..'|mode=slideshow}}'..'</div></div>' else error('Mode tidak didukung') end end returnoutput end returnp