Diferencia entre revisiones de «MediaWiki:Gadget-Biblia.js»

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
(Se ha deshecho la revisión 626 de Juancc (disc.))
Etiquetas: Revertido Deshacer
Etiqueta: Revertido
Línea 27: Línea 27:
const rangejson = JSON.stringify(range, getCircularReplacer());
const rangejson = JSON.stringify(range, getCircularReplacer());
const docrangejson = JSON.stringify(docRange, getCircularReplacer());
const docrangejson = JSON.stringify(docRange, getCircularReplacer());
var keyboardEvent = document.createEvent('KeyboardEvent');
Podium = {};
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent';


keyboardEvent[initMethod](
Podium.keydown = function(k) {
  'keydown', // event type: keydown, keyup, keypress
    var oEvent = document.createEvent('KeyboardEvent');
  true, // bubbles
 
  true, // cancelable
    // Chromium Hack
  window, // view: should be window
    Object.defineProperty(oEvent, 'keyCode', {
  false, // ctrlKey
                get : function() {
  false, // altKey
                    return this.keyCodeVal;
  false, // shiftKey
                }
  false, // metaKey
    });   
  8, // keyCode: unsigned long - the virtual key code, else 0
    Object.defineProperty(oEvent, 'which', {
  0 // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
                get : function() {
);
                    return this.keyCodeVal;
document.dispatchEvent(keyboardEvent);
                }
//alert((range.from+1)+" a "+(range.to+1));
    });   
//alert(range.from+' a '+range.to);
 
    if (oEvent.initKeyboardEvent) {
        oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, k, k, "", "", false, "");
    } else {
        oEvent.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, k, 0);
    }
 
    oEvent.keyCodeVal = k;
 
    if (oEvent.keyCode !== k) {
        alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
    }
 
    document.body.dispatchEvent(oEvent);
}
 
Podium.keydown(40); // for arrow-down, arrow-up is 38
};
};



Revisión del 14:30 3 ene 2023

ve.ui.BibliaCommand = function VeUiBibliaCommand() {
	ve.ui.BibliaCommand.super.call(	this, 'Biblia' );
};
OO.inheritClass( ve.ui.BibliaCommand, ve.ui.Command );

ve.ui.BibliaCommand.prototype.execute = function ( surface ) {
	var model = surface.getModel(),
		doc = model.getDocument(),
		range = model.getSelection().getRange(),
		docRange = doc.shallowCloneFromRange( range );

	ve.init.target.getWikitextFragment( docRange, false ).done( function ( wikitext ) {
		model.getFragment().insertHtml('<bible>'+wikitext+'</bible>');
	} );
	const getCircularReplacer = function () {
		const seen = new WeakSet();
		return function (key, value) {
		if (typeof value === 'object' && value !== null) {
    		if (seen.has(value)) {
        return;
      }
      seen.add(value);
    }
    return value;
	};
	};
	const rangejson = JSON.stringify(range, getCircularReplacer());
	const docrangejson = JSON.stringify(docRange, getCircularReplacer());
Podium = {};

Podium.keydown = function(k) {
    var oEvent = document.createEvent('KeyboardEvent');

    // Chromium Hack
    Object.defineProperty(oEvent, 'keyCode', {
                get : function() {
                    return this.keyCodeVal;
                }
    });     
    Object.defineProperty(oEvent, 'which', {
                get : function() {
                    return this.keyCodeVal;
                }
    });     

    if (oEvent.initKeyboardEvent) {
        oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, k, k, "", "", false, "");
    } else {
        oEvent.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, k, 0);
    }

    oEvent.keyCodeVal = k;

    if (oEvent.keyCode !== k) {
        alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
    }

    document.body.dispatchEvent(oEvent);
}

Podium.keydown(40); // for arrow-down, arrow-up is 38
};

ve.ui.commandRegistry.register( new ve.ui.BibliaCommand() );

ve.ui.BibliaTool = function VeUiBibliaTool() {
	ve.ui.BibliaTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.BibliaTool, ve.ui.Tool );
ve.ui.BibliaTool.static.name = 'Biblia';
ve.ui.BibliaTool.static.group = 'cite';
ve.ui.BibliaTool.static.icon = 'book';
ve.ui.BibliaTool.static.title = 'Biblia';
ve.ui.BibliaTool.static.commandName = 'Biblia';
ve.ui.toolFactory.register( ve.ui.BibliaTool );