Diferencia entre revisiones de «Widget:Slides»

De Vitalinux
Saltar a: navegación, buscar
(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="WEslides"></div>
+
<div id="MIslides"></div>
 
<script type="text/javascript">/*<![CDATA[*/
 
<script type="text/javascript">/*<![CDATA[*/
$(function () {
+
RLQ.push(['jquery', function () {
  function weSlideShow() {
+
        console.log('mw.loader and jQuery are available now', $);
    $.getScript(wgServer + '/extensions/SlidesTemplates/slides/slides.js');
 
    $('#WEslides').remove();
 
    $('.mw-editsection').remove();
 
    return false;
 
  }
 
  
  var weAPI = wgServer + '/api.php';
+
    function MIslideshow() {
  var narration;
+
        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) {
+
    $.each($('div.slides').attr('class').split(/\s+/), function(i, v) {
    if (v.indexOf('narration:') === 0) {
+
        if (v.indexOf('narration:') === 0) {
      narration = v.substr('narration:'.length).replace(',', '|');
+
        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>';
 
        $('#WEslides').before(audiotag);
 
      }
 
 
     });
 
     });
  }
+
    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) { weSlideShow(); } else {
+
    if (window.location.search.indexOf('present') >= 0) { MIslideshow(); } else {
    $('#WEslides').html('<input type="submit" value="Mostrar presentación" href="#" /><br />');
+
        $('#MIslides').html('<input type="submit" value="Ver presentación" href="#" /><br />');
    $('#WEslides > input').click(weSlideShow);
+
        $('#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