×
Einen neuen Artikel erstellen
Schreibe den Seitennamen hierhin:
Wir haben derzeit 9.351 Artikel auf VAULTPEDIA. Gib deinen Artikelnamen oberhalb von oder klicke auf einen der unten stehenden Titel und beginne zu schreiben! ein



    VAULTPEDIA
    9.351Artikel

    Benutzer:Eckserah/cosmos.js: Unterschied zwischen den Versionen

    VAULTPEDIA.DE ist seit dem 02.02.2026 öffentlich zugänglich.

    Da es sich um ein frisch migriertes Wiki handelt, können vereinzelt noch Datenbank-, Seiten- oder Designfehler auftreten.

    Tritt unserem Discord bei, um Fehler zu melden oder direkt mit dem Team in Kontakt zu treten.

    Keine Bearbeitungszusammenfassung
    Keine Bearbeitungszusammenfassung
    Zeile 2: Zeile 2:
    mw.loader.using("oojs-ui").done(function() {
    mw.loader.using("oojs-ui").done(function() {
    var _create_class = {
    var _create_class = {
    _class_call_check: function(e, r) {
                if (!(e instanceof r))
                    throw new TypeError("Cannot call a class as a function")
            },
    _defineProperties: function(e, r) {
    _defineProperties: function(e, r) {
        for (var a = 0; a < r.length; a++) {
        for (var a = 0; a < r.length; a++) {
    Zeile 311: Zeile 315:
        $(".mw-indicators").prependTo("#wikiPreview .mw-parser-output"),
        $(".mw-indicators").prependTo("#wikiPreview .mw-parser-output"),
        $(".page-footer__categories").appendTo("#wikiPreview .mw-parser-output"),
        $(".page-footer__categories").appendTo("#wikiPreview .mw-parser-output"),
        setTimeout(wikiEditorTracking),
        mw.hook("ext.CodeMirror.initialize").add((function(e) {
        mw.hook("ext.CodeMirror.initialize").add((function(e) {
            "submit" === mw.config.get("wgAction") && window.scrollTo({
            "submit" === mw.config.get("wgAction") && window.scrollTo({

    Version vom 5. Februar 2026, 09:29 Uhr

    $(document).ready(function() {
    	mw.loader.using("oojs-ui").done(function() {
    		var _create_class = {
    			_class_call_check: function(e, r) {
    	            if (!(e instanceof r))
    	                throw new TypeError("Cannot call a class as a function")
    	        },
    			_defineProperties: function(e, r) {
    			    for (var a = 0; a < r.length; a++) {
    			        var c = r[a];
    			        c.enumerable = c.enumerable || !1,
    			        c.configurable = !0,
    			        "value"in c && (c.writable = !0),
    			        Object.defineProperty(e, c.key, c)
    			    }
    			},
    			 _create_class: function(e, r, a) {
    			    return r && this._defineProperties(e.prototype, r),
    			    a && this._defineProperties(e, a),
    			    e
    			}
    		};
    		var SET_LINK_SUGGESTIONS = "SET_LINK_SUGGESTIONS"
    		  , CLOSE_LINK_SUGGESTIONS = "CLOSE_LINK_SUGGESTIONS"
    		  , HIGHLIGHTED_SUGGESTION_CHANGED = "HIGHLIGHTED_SUGGESTION_CHANGED";
    		function LinkSuggestModel(e) {
    		    OO.EventEmitter.call(this),
    		    this.isCodeMirrorActive = e,
    		    this.linkSuggestions = [],
    		    this.query = {},
    		    this.highlightedSuggestionIndex = -1
    		}
    		OO.initClass(LinkSuggestModel),
    		OO.mixinClass(LinkSuggestModel, OO.EventEmitter),
    		LinkSuggestModel.prototype.setCodeMirrorActive = function(e) {
    		    this.isCodeMirrorActive = e
    		}
    		,
    		LinkSuggestModel.prototype.setLinkSuggestQuery = function(e, t) {
    		    this.query = e,
    		    this.linkSuggestions = t,
    		    this.highlightedSuggestionIndex = -1,
    		    this.emit(SET_LINK_SUGGESTIONS)
    		}
    		,
    		LinkSuggestModel.prototype.highlightNextSuggestion = function() {
    		    this.highlightedSuggestionIndex === this.linkSuggestions.length - 1 ? this.highlightedSuggestionIndex = -1 : this.highlightedSuggestionIndex++,
    		    this.emit(HIGHLIGHTED_SUGGESTION_CHANGED)
    		}
    		,
    		LinkSuggestModel.prototype.highlightPreviousSuggestion = function() {
    		    -1 === this.highlightedSuggestionIndex ? this.highlightedSuggestionIndex = this.linkSuggestions.length - 1 : this.highlightedSuggestionIndex--,
    		    this.emit(HIGHLIGHTED_SUGGESTION_CHANGED)
    		}
    		,
    		LinkSuggestModel.prototype.closeLinkSuggestions = function() {
    		    this.highlightedSuggestionIndex = -1,
    		    this.linkSuggestions = [],
    		    this.emit(CLOSE_LINK_SUGGESTIONS)
    		}
    		;
    		var LinkSuggestController = function() {
    		    function e(t, i, o, n) {
    		        var r = this;
    		        _create_class._class_call_check(this, e),
    		        _define_property._define_property(this, "debouncedPerformLinkSuggestQuery", OO.ui.debounce(this.performLinkSuggestQuery.bind(this), 300)),
    		        _define_property._define_property(this, "handleKeydown", (function(e) {
    		            var t = e.key
    		              , i = r.model
    		              , o = i.linkSuggestions
    		              , n = i.highlightedSuggestionIndex
    		              , s = i.query.originalContent;
    		            if (!!o.length) {
    		                if ("ArrowDown" === t)
    		                    return e.preventDefault(),
    		                    r.model.highlightNextSuggestion(),
    		                    !0;
    		                if ("ArrowUp" === t)
    		                    return e.preventDefault(),
    		                    r.model.highlightPreviousSuggestion(),
    		                    !0;
    		                if ("Enter" === t && -1 !== n) {
    		                    e.preventDefault();
    		                    var a = o[n]
    		                      , d = index$1.getContentForSuggestions({
    		                        suggestion: a,
    		                        originalContent: s
    		                    }).textToInsert;
    		                    return r.applyLinkSuggest(d),
    		                    !0
    		                }
    		                if ("Esc" === t || "Escape" === t)
    		                    return e.preventDefault(),
    		                    r.model.closeLinkSuggestions(),
    		                    !0
    		            }
    		            r.debouncedPerformLinkSuggestQuery()
    		        }
    		        )),
    		        this.model = t,
    		        this.$textbox = i,
    		        this.api = o,
    		        this.pageLanguageHasWordBreaks = n
    		    }
    		    return _create_class._create_class(e, [{
    		        key: "applyLinkSuggest",
    		        value: function(e) {
    		            var t = this.model.query
    		              , i = t.startOffset
    		              , o = t.wasTemplateTransclusion
    		              , n = this.$textbox.textSelection("getCaretPosition")
    		              , r = o ? "}}" : "]]"
    		              , s = 1 + i + e.length + r.length;
    		            this.$textbox.textSelection("setSelection", {
    		                start: 1 + i,
    		                end: n
    		            }).textSelection("replaceSelection", e + r).textSelection("setSelection", {
    		                start: s,
    		                end: s
    		            }),
    		            this.model.closeLinkSuggestions()
    		        }
    		    }, {
    		        key: "performLinkSuggestQuery",
    		        value: function() {
    		            var e = this
    		              , t = this.$textbox.textSelection("getContents")
    		              , i = this.$textbox.textSelection("getCaretPosition")
    		              , o = this.pageLanguageHasWordBreaks ? 4 : 1
    		              , n = index$1.getLinkSuggestQueryFromText(t, i, o);
    		            if (!n || n.content.length < o || n.content.includes("|"))
    		                this.model.closeLinkSuggestions();
    		            else {
    		                var r = n.content.includes("|");
    		                this.api.get({
    		                    action: "linksuggest",
    		                    get: "suggestions",
    		                    query: n.content
    		                }).then((function(t) {
    		                    var i = t.linksuggest.result.suggestions;
    		                    i.length && !r ? e.model.setLinkSuggestQuery(n, i) : e.model.closeLinkSuggestions()
    		                }
    		                ))
    		            }
    		        }
    		    }, {
    		        key: "setLinkSuggestEventHandlers",
    		        value: function() {
    		            var e = this
    		              , t = this.model.isCodeMirrorActive;
    		            this.model.closeLinkSuggestions(),
    		            t ? mw.loader.using(["ext.CodeMirror.v6", "ext.CodeMirror.v6.mode.mediawiki"], (function(t) {
    		                var i = t("ext.CodeMirror.v6.lib")
    		                  , o = i.EditorView
    		                  , n = i.StateEffect
    		                  , r = i.Prec;
    		                e.$textbox.off("keydown.linksuggest");
    		                var s = o.domEventHandlers({
    		                    keydown: function(t, i) {
    		                        return e.handleKeydown(t)
    		                    }
    		                });
    		                mw.hook("ext.CodeMirror.ready").add((function(e, t) {
    		                    t.view.dispatch({
    		                        effects: n.appendConfig.of(r.high(s))
    		                    })
    		                }
    		                ))
    		            }
    		            )) : this.addLinkSuggestWithoutSyntaxHighlighting()
    		        }
    		    }, {
    		        key: "addLinkSuggestWithoutSyntaxHighlighting",
    		        value: function() {
    		            this.$textbox.on("keydown.linksuggest", this.handleKeydown)
    		        }
    		    }, {
    		        key: "updateCodeMirrorState",
    		        value: function(e) {
    		            var t = this;
    		            this.model.setCodeMirrorActive(e),
    		            setTimeout((function() {
    		                return t.setLinkSuggestEventHandlers()
    		            }
    		            ))
    		        }
    		    }]),
    		    e
    		}();
    		function LinkSuggestPopupWidget(e, t, i, o) {
    		    var n;
    		    this.model = e,
    		    this.controller = t,
    		    this.$textbox = i,
    		    this.codeMirrorInstance = null,
    		    this.$caretCoordinateCalculator = o,
    		    this.textboxLineHeight = i.css("line-height"),
    		    this.debouncedUpdatePosition = OO.ui.debounce(this.updatePosition.bind(this), 300),
    		    this.model.connect(this, (n = {},
    		    _define_property._define_property(n, SET_LINK_SUGGESTIONS, "onLinkSuggestionsSet"),
    		    _define_property._define_property(n, CLOSE_LINK_SUGGESTIONS, "onCloseLinkSuggestions"),
    		    _define_property._define_property(n, HIGHLIGHTED_SUGGESTION_CHANGED, "onHighlightedSuggestionChanged"),
    		    n)),
    		    this.selectWidget = new OO.ui.SelectWidget,
    		    this.selectWidget.connect(this, {
    		        choose: "onSuggestionSelected"
    		    }),
    		    LinkSuggestPopupWidget.super.call(this, {
    		        $content: this.selectWidget.$element,
    		        padded: !1,
    		        autoFlip: !1,
    		        hideWhenOutOfView: !1
    		    }),
    		    this.$element.addClass("wikiEditor-ui-linkSuggest"),
    		    this.$popup.addClass("wikiEditor-ui-linkSuggest-popup"),
    		    this.toggle(!1),
    		    this.$textbox.on("scroll", this.debouncedUpdatePosition),
    		    jquery.$(document).on("scroll", this.debouncedUpdatePosition)
    		}
    		function WikiEditorModeSwitchPopupButtonWidget(e) {
    		    var t = new OO.ui.ButtonWidget({
    		        framed: !1,
    		        label: mw.msg("visualeditor-mweditmodeve-tool-current"),
    		        icon: "eye"
    		    });
    		    t.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-visualSwitch"),
    		    t.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-member"),
    		    t.on("click", e),
    		    t.connect(this, {
    		        click: "hidePopup"
    		    }),
    		    WikiEditorModeSwitchPopupButtonWidget.super.call(this, {
    		        framed: !1,
    		        indicator: "down",
    		        popup: {
    		            containerPadding: 0,
    		            $content: t.$element,
    		            width: null
    		        },
    		        icon: "wikiText",
    		        label: mw.msg("visual-editor-fandom-switch-dropdown-mode-source-label")
    		    }),
    		    this.$element.addClass("ve-ui-modeSwitchPopupButtonWidget ve-ui-modeSwitchPopupButtonWidget-fd ve-header-action-item"),
    		    this.$button.attr("id", "ve-ui-modeSwitchPopupButtonWidget-button"),
    		    this.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-button"),
    		    this.popup.$popup.addClass("ve-ui-modeSwitchPopupButtonWidget-popup")
    		}
    		function CodeEditorModeSwitchPopupButtonWidget(e) {
    		    var t = new OO.ui.ButtonWidget({
    		        framed: !1,
    		        label: mw.msg("visualeditor-mweditmodeve-tool-current"),
    		        icon: "eye",
    		        href: e.href
    		    });
    		    t.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-visualSwitch"),
    		    t.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-member");
    		    var i = new OO.ui.ButtonWidget({
    		        framed: !1,
    		        label: mw.msg("visualeditor-mweditmodesource-tool-current"),
    		        icon: "wikiText"
    		    });
    		    i.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-sourceSwitch"),
    		    i.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-member"),
    		    i.setDisabled(!0);
    		    var o = t.$element.add(i.$element);
    		    CodeEditorModeSwitchPopupButtonWidget.super.call(this, {
    		        framed: !1,
    		        indicator: "down",
    		        popup: {
    		            containerPadding: 0,
    		            $content: o,
    		            width: null
    		        },
    		        icon: "wikiText",
    		        label: mw.msg("visual-editor-fandom-switch-dropdown-mode-source-label")
    		    }),
    		    this.$element.addClass("ve-ui-modeSwitchPopupButtonWidget ve-ui-modeSwitchPopupButtonWidget-fd ve-header-action-item"),
    		    this.$button.attr("id", "ve-ui-modeSwitchPopupButtonWidget-button"),
    		    this.$button.addClass("ve-ui-modeSwitchPopupButtonWidget-button"),
    		    this.popup.$popup.addClass("ve-ui-modeSwitchPopupButtonWidget-popup")
    		}
    		function initLinkSuggest(e) {
    		    var t = !mw.user.options.get("disablelinksuggest")
    		      , i = "wikitext" === mw.config.get("wgPageContentModel");
    		    if (t && i) {
    		        var o = mw.user.options.get("usecodemirror") > 0
    		          , n = mw.config.get("wgPageLanguageHasWordBreaks")
    		          , r = new mw.Api
    		          , s = new LinkSuggestModel(o)
    		          , a = new LinkSuggestController(s,e,r,n)
    		          , d = $("<div />").css({
    		            position: "absolute",
    		            top: "-2000px",
    		            left: "-2000px",
    		            visibility: "hidden",
    		            "white-space": "pre-wrap",
    		            "font-family": e.css("font-family"),
    		            "font-size": e.css("font-size"),
    		            "line-height": e.css("line-height")
    		        }).appendTo(document.body)
    		          , u = new LinkSuggestPopupWidget(s,a,e,d);
    		        $(".wikiEditor-ui-text").prepend(u.$element),
    		        mw.hook("ext.CodeMirror.switch").add((function(e) {
    		            a.updateCodeMirrorState(e),
    		            u.setCodeMirrorInstance(e)
    		        }
    		        )),
    		        setTimeout((function() {
    		            return a.addLinkSuggestWithoutSyntaxHighlighting()
    		        }
    		        ))
    		    }
    		}
    		function postSetupInit() {
    		    $(".mw-indicators").prependTo("#wikiPreview .mw-parser-output"),
    		    $(".page-footer__categories").appendTo("#wikiPreview .mw-parser-output"),
    		    mw.hook("ext.CodeMirror.initialize").add((function(e) {
    		        "submit" === mw.config.get("wgAction") && window.scrollTo({
    		            top: 0
    		        })
    		    }
    		    ))
    		}
    		OO.inheritClass(LinkSuggestPopupWidget, OO.ui.PopupWidget),
    		LinkSuggestPopupWidget.prototype.onLinkSuggestionsSet = function() {
    		    var e = this.model
    		      , t = e.linkSuggestions
    		      , i = e.query.originalContent;
    		    if (t.length) {
    		        this.selectWidget.clearItems();
    		        var o = t.map((function(e) {
    		            var t = index$1.getContentForSuggestions({
    		                suggestion: e,
    		                originalContent: i
    		            })
    		              , o = t.textToInsert
    		              , n = t.textToDisplay
    		              , r = new OO.ui.OptionWidget({
    		                data: o,
    		                label: n
    		            });
    		            return r.$element.addClass("wikiEditor-ui-linkSuggest-suggestion"),
    		            r
    		        }
    		        ));
    		        this.selectWidget.addItems(o),
    		        this.toggle(!0),
    		        this.updatePosition(),
    		        this.model.isCodeMirrorActive && (this.toggle(!1),
    		        this.toggleClipping(!1),
    		        this.position(),
    		        this.toggleClipping(!0),
    		        this.toggle(!0)),
    		        this.updatePositionIfOutsideOfViewport()
    		    } else
    		        this.toggle(!1)
    		}
    		,
    		LinkSuggestPopupWidget.prototype.onCloseLinkSuggestions = function() {
    		    this.toggle(!1),
    		    this.$element.addClass("oo-ui-element-hidden"),
    		    this.selectWidget.clearItems()
    		}
    		,
    		LinkSuggestPopupWidget.prototype.computePosition = function() {
    		    var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null;
    		    LinkSuggestPopupWidget.super.prototype.computePosition.call(this),
    		    this.$anchor.css({
    		        left: 12
    		    });
    		    var t = null != e ? e : this.getCaretPosition()
    		      , i = t.top
    		      , o = t.left;
    		    return {
    		        position: "fixed",
    		        top: "".concat(i, "px"),
    		        left: "".concat(o, "px"),
    		        "margin-top": this.textboxLineHeight
    		    }
    		}
    		,
    		LinkSuggestPopupWidget.prototype.getCaretPosition = function() {
    		    var e = this.model
    		      , t = e.isCodeMirrorActive
    		      , i = e.query.startOffset;
    		    if (t) {
    		        var o = this.codeMirrorInstance.view.state.selection.main.head;
    		        return this.codeMirrorInstance.view.coordsAtPos(o)
    		    }
    		    var n = this.$textbox.textSelection("getContents")
    		      , r = this.$textbox.textSelection("getCaretPosition")
    		      , s = jquery.$("<span />").text(n.substring(i, r));
    		    this.$caretCoordinateCalculator.width(this.$textbox[0].scrollWidth).text(n.substring(0, i)).append(s);
    		    var a = this.$textbox.offset()
    		      , d = a.top
    		      , u = a.left
    		      , c = s.position()
    		      , l = c.top
    		      , g = c.left
    		      , p = s.width()
    		      , h = this.$textbox.scrollTop()
    		      , m = this.$textbox.scrollLeft();
    		    return {
    		        top: d + l - h - window.scrollY,
    		        left: u + g + p - m - window.scrollX
    		    }
    		}
    		,
    		LinkSuggestPopupWidget.prototype.updatePosition = function() {
    		    var e = this.getCaretPosition();
    		    if (this.toggleClipping(!1),
    		    this.position(),
    		    this.toggleClipping(!0),
    		    this.selectWidget.items.length) {
    		        var t, i;
    		        this.$element.css(this.computePosition(e));
    		        var o = null !== (i = null === (t = this.codeMirrorInstance) || void 0 === t ? void 0 : t.view.dom.getBoundingClientRect()) && void 0 !== i ? i : this.$textbox[0].getBoundingClientRect()
    		          , n = e.top >= o.top && e.top <= o.bottom;
    		        this.toggle(n)
    		    }
    		}
    		,
    		LinkSuggestPopupWidget.prototype.setCodeMirrorInstance = function(e) {
    		    var t = this;
    		    e ? mw.loader.using(["ext.CodeMirror.v6", "ext.CodeMirror.v6.mode.mediawiki"], (function(e) {
    		        var i = e("ext.CodeMirror.v6.lib")
    		          , o = i.EditorView
    		          , n = i.StateEffect;
    		        t.$textbox.off("keydown.linksuggest");
    		        var r = o.domEventHandlers({
    		            scroll: function(e, i) {
    		                return t.debouncedUpdatePosition()
    		            }
    		        });
    		        mw.hook("ext.CodeMirror.ready").add((function(e, i) {
    		            t.codeMirrorInstance = i,
    		            t.codeMirrorInstance.view.dispatch({
    		                effects: n.appendConfig.of(r)
    		            })
    		        }
    		        ))
    		    }
    		    )) : this.codeMirrorInstance = null
    		}
    		,
    		LinkSuggestPopupWidget.prototype.onHighlightedSuggestionChanged = function() {
    		    var e = this.model.highlightedSuggestionIndex;
    		    if (-1 === e)
    		        this.selectWidget.highlightItem();
    		    else {
    		        var t = this.selectWidget.items[e];
    		        this.selectWidget.highlightItem(t)
    		    }
    		}
    		,
    		LinkSuggestPopupWidget.prototype.onSuggestionSelected = function(e) {
    		    var t = e.getData();
    		    this.controller.applyLinkSuggest(t)
    		}
    		,
    		LinkSuggestPopupWidget.prototype.updatePositionIfOutsideOfViewport = function() {
    		    var e = this.$element.get(0).getBoundingClientRect()
    		      , t = e.left
    		      , i = e.right
    		      , o = e.width;
    		    window.innerWidth < i && (this.$anchor.css({
    		        left: "auto",
    		        right: 12
    		    }),
    		    this.$element.css({
    		        left: t - o
    		    }))
    		}
    		,
    		OO.inheritClass(WikiEditorModeSwitchPopupButtonWidget, OO.ui.PopupButtonWidget),
    		WikiEditorModeSwitchPopupButtonWidget.prototype.hidePopup = function() {
    		    this.getPopup().toggle(!1)
    		}
    		,
    		OO.inheritClass(CodeEditorModeSwitchPopupButtonWidget, OO.ui.PopupButtonWidget),
    		mw.hook("wikiEditor.toolbarReady").add(initLinkSuggest).add(postSetupInit);
    	});
    });