Diferencia entre revisiones de «Widget:Slides»
(show / mostrar) |
|||
Línea 1: | Línea 1: | ||
− | <noinclude>Infrastructure for wiki-based "slide" presentations, based on [http://code.google.com/p/html5slides/ html5slides].</noinclude><includeonly> | + | <noinclude>Infrastructure for wiki-based "slide" presentations, based on [http://code.google.com/p/html5slides/ html5slides]. Idea original de Jim Tittsler http://wikieducator.org/index.php?title=Widget:Slide</noinclude><includeonly> |
− | <div id=" | + | <div id="MIslides"></div> |
<script type="text/javascript">/*<![CDATA[*/ | <script type="text/javascript">/*<![CDATA[*/ | ||
− | + | RLQ.push(['jquery', function () { | |
− | + | console.log('mw.loader and jQuery are available now', $); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | function MIslideshow() { | |
− | + | mw.loader.load(wgServer + '/w/extensions/WE/Slides/slides.js'); | |
+ | $('#MIslides').remove(); | ||
+ | $('.mw-editsection').remove(); | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | var weAPI = wgServer +'/w/api.php'; | ||
+ | var narration; | ||
− | + | $.each($('div.slides').attr('class').split(/\s+/), function(i, v) { | |
− | + | if (v.indexOf('narration:') === 0) { | |
− | + | narration = v.substr('narration:'.length).replace(',', '|'); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | |||
− | |||
− | |||
}); | }); | ||
− | + | if (narration !== undefined) { | |
+ | $.ajax({ | ||
+ | url: weAPI, | ||
+ | data: { | ||
+ | action: 'query', | ||
+ | format: 'json', | ||
+ | prop: 'imageinfo', | ||
+ | iiprop: 'url', | ||
+ | titles: narration | ||
+ | }, | ||
+ | async: true, | ||
+ | dataType: 'json', | ||
+ | type: 'POST', | ||
+ | success: function(data) { | ||
+ | var i, u; | ||
+ | var audiotag = '<div id="narrationdiv" style="float: right;"><audio id="narration" controls>'; | ||
+ | if (data && 'query' in data && 'pages' in data.query) { | ||
+ | for (i in data.query.pages) { | ||
+ | u = data.query.pages[i].imageinfo[0].url; | ||
+ | type = (u.substr(-3) === 'mp3') ? 'mpeg' : 'ogg'; | ||
+ | audiotag += '<source src="' + u + '" type="audio/' + type + '" />'; | ||
+ | } | ||
+ | } | ||
+ | audiotag += '</audio></div>'; | ||
+ | $('#MIslides').before(audiotag); | ||
+ | } | ||
+ | }); | ||
+ | } | ||
− | + | if (window.location.search.indexOf('present') >= 0) { MIslideshow(); } else { | |
− | + | $('#MIslides').html('<input type="submit" value="Ver presentación" href="#" /><br />'); | |
− | + | $('#MIslides > input').click(MIslideshow); | |
− | + | }; | |
− | }); | + | }]); |
/*]]>*/</script></includeonly> | /*]]>*/</script></includeonly> |
Revisión del 17:23 27 nov 2019
Infrastructure for wiki-based "slide" presentations, based on html5slides. Idea original de Jim Tittsler http://wikieducator.org/index.php?title=Widget:Slide