Diferencia entre revisiones de «Widget:Slides»

De Vitalinux
Saltar a: navegación, buscar
 
(No se muestra una edición intermedia del mismo usuario)
Línea 2: Línea 2:
 
<div id="MIslides"></div>
 
<div id="MIslides"></div>
 
<script type="text/javascript">/*<![CDATA[*/
 
<script type="text/javascript">/*<![CDATA[*/
RLQ.push(['jquery', function () {
+
Element.prototype.remove = function() {
         console.log('mw.loader and jQuery are available now', $);
+
    this.parentElement.removeChild(this);
 +
}
 +
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
 +
    for(var i = this.length - 1; i >= 0; i--) {
 +
         if(this[i] && this[i].parentElement) {
 +
            this[i].parentElement.removeChild(this[i]);
 +
        }
 +
    }
 +
}
  
    function MIslideshow() {
+
function MIslideshow() {
         mw.loader.load(wgServer + '/w/extensions/WE/Slides/slides.js');
+
         mw.loader.load(wgServer + '/extensions/WE/Slides/slides.js');
         $('#MIslides').remove();
+
         document.getElementById("MIslides").remove();
         $('.mw-editsection').remove();
+
         document.getElementsByClassName('mw-editsection').remove();
 
         return false;
 
         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);
 
        }
 
        });
 
    }
 
  
 +
function creaSlides() {
 
     if (window.location.search.indexOf('present') >= 0) { MIslideshow(); } else {
 
     if (window.location.search.indexOf('present') >= 0) { MIslideshow(); } else {
        $('#MIslides').html('<input type="submit" value="Ver presentación" href="#" /><br />');
+
          var boton = document.createElement("input");
        $('#MIslides > input').click(MIslideshow);
+
          boton.setAttribute('type', 'submit');
 +
          boton.setAttribute('value', 'Ver presentación');
 +
          boton.setAttribute('href', '#');
 +
          boton.onclick = MIslideshow;
 +
          document.getElementById("MIslides").appendChild(boton)
 
     };
 
     };
}]);
+
}
 +
RLQ.push(function () {
 +
    creaSlides();
 +
});
 
/*]]>*/</script></includeonly>
 
/*]]>*/</script></includeonly>

Revisión actual del 19:24 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