|
|
(24 mellemliggende versioner af 2 andre brugere ikke vist) |
Linje 3: |
Linje 3: |
| // Adds a default template to new pages | | // Adds a default template to new pages |
| $(function() { | | $(function() { |
| if (mw.config.get('wgAction') !== 'edit' || mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgArticleId') !== 0) {
| | if (mw.config.get('wgAction') !== 'edit' || mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgArticleId') !== 0) { |
| return;
| | return; |
| }
| | } |
| var template = "\n\n== Litteratur og kilder ==\n* \n\n[[Kategori:]]";
| | |
| var content = $('#wpTextbox1').val();
| | var template = "\n== {{BASEPAGENAME}} på AarhusArkivet ==\n\n{{Aarhusarkivet|text=[https://www.aarhusarkivet.dk/INDSÆTKORREKTLINK " + mw.config.get('wgPageName') + "]}}\n\n== Litteratur og kilder ==\n* \n\n[[Kategori:]]"; |
| if (!content) {
| | |
| $('#wpTextbox1').val(template);
| | var content = $('#wpTextbox1').val(); |
| } else if (content.indexOf('== Litteratur og kilder ==') === -1) {
| | if (!content) { |
| $('#wpTextbox1').val(content + '\n\n' + template);
| | $('#wpTextbox1').val(template); |
| }
| | } else if (content.indexOf('== Litteratur og kilder ==') === -1) { |
| }); | | $('#wpTextbox1').val(template + '\n\n' + content); |
| | | } |
| $(document).ready(function() {
| |
| $('head').append('<script defer data-domain="aarhuswiki.dk" src="https://plausible.io/js/plausible.js"></script>');
| |
| | |
| // Shorten text to keep background
| |
| $('#p-banner').text('Aarhuswiki');
| |
| | |
| $('#searchInput').on('focus', function() {
| |
| $('body .suggestions').prependTo('#container');
| |
| }); | | }); |
| | | |
| /* | | |
| if (window.location.href.indexOf("Louise_Lindskrog_(1992-)") > 0) {
| | |
| document.getElementById("ca-history").style.display = "none";
| | |
| }
| | $(document).ready(function() { |
| */
| | $('head').append('<script defer data-domain="aarhuswiki.dk" src="https://plausible.io/js/plausible.js"></script>'); |
| | | |
| /* Erstat link til Mediawiki, med link til vores hjemmeside */
| | // Shorten text to keep background |
| $('#f-poweredbyico a').attr('href', 'http://www.aarhusstadsarkiv.dk');
| | $('#p-banner').text('Aarhuswiki'); |
| | | |
| $("#mw-site-navigation").prepend( | | $('#searchInput').on('focus', function() { |
| '<div id="site-themes" class="sidebar-chunk"><div role="navigation" class="mw-portlet" id="p-tbt" aria-labelledby="p-tbt-label"><div class="mw-portlet-body"><img style="width:100%;" alt="Aarhus Stadsarkiv" src="/mediawiki/images/2/29/As_logo.png"/></div></div></div>'
| | $('body .suggestions').prependTo('#container'); |
| );
| | }); |
| | | |
| $("#mw-site-navigation").append(
| | /* |
| '<div id="site-themes" class="sidebar-chunk"><div role="navigation" class="mw-portlet" id="p-tbt" aria-labelledby="p-tbt-label"><h3 id="p-tbt-label" dir="ltr" lang="da" style="padding-bottom:0;margin-bottom:0;">Særlige temaer</h3><br><div class="mw-portlet-body"><a class="image" href="https://aarhuswiki.dk/wiki/Kongelunden"><img style="width:100%;margin-bottom:.7em;" alt="Kongelunden" src="/mediawiki/images/7/73/Kongelunden_logo_groen_01_150px.jpg"/></a><br><hr><p><div class="mw-portlet-body"><a class="image" href="https://aarhuswiki.dk/wiki/Teatre_i_Aarhus"><img style="width:100%;margin-bottom:.7em;" alt="Teatre i Aarhus" src="/mediawiki/images/0/0d/Teatre_i_Aarhus.png"/></a></div></div></div></div>'
| | if (window.location.href.indexOf("Louise_Lindskrog_(1992-)") > 0) { |
| | document.getElementById("ca-history").style.display = "none"; |
| | } |
| | */ |
| | |
| | /* Erstat link til Mediawiki, med link til vores hjemmeside */ |
| | $('#f-poweredbyico a').attr('href', 'http://www.aarhusstadsarkiv.dk'); |
| | |
| | $("#mw-site-navigation").prepend( |
| | '<div id="site-themes" class="sidebar-chunk"><div role="navigation" class="mw-portlet" id="p-tbt" aria-labelledby="p-tbt-label"><div class="mw-portlet-body"><img style="width:100%;" alt="Aarhus Stadsarkiv" src="/mediawiki/images/2/29/As_logo.png"/></div></div></div>' |
| ); | | ); |
| | | |
| /* Add link to accessability-declaration in footer */ | | $("#mw-site-navigation").append( |
| $("#f-list").append( '<li id="accessability-declaration"><a class="noprint stopMobileRedirectToggle" href="https://www.was.digst.dk/aarhuswiki-dk">Webtilgængelighedserklæring</a></li>' );
| | '<div id="site-themes" class="sidebar-chunk"><div role="navigation" class="mw-portlet" id="p-tbt" aria-labelledby="p-tbt-label"><h3 id="p-tbt-label" dir="ltr" lang="da" style="padding-bottom:0;margin-bottom:0;">Særlige temaer</h3><br><div class="mw-portlet-body"><a class="image" href="https://aarhuswiki.dk/wiki/Kongelunden"><img style="width:100%;margin-bottom:.7em;" alt="Kongelunden" src="/mediawiki/images/7/73/Kongelunden_logo_groen_01_150px.jpg"/></a><br><hr><p><div class="mw-portlet-body"><a class="image" href="https://aarhuswiki.dk/wiki/Boligforeninger_i_Aarhus_Kommune"><img style="width:100%;margin-bottom:.7em;" alt="Boligforeninger i Aarhus" src="/mediawiki/images/b/b0/Boligforeninger_i_Aarhus_wikigrafik.jpg"/></a></div></div></div></div>' |
| });
| | ); |
| | | |
| // Function to generate a random integer between 0 and max
| | /* Add link to accessability-declaration in footer */ |
| function getRandomInt(max) {
| | $("#f-list").append( '<li id="accessability-declaration"><a class="noprint stopMobileRedirectToggle" href="https://www.was.digst.dk/aarhuswiki-dk">Webtilgængelighedserklæring</a></li>' ); |
| return Math.floor(Math.random() * Math.floor(max));
| |
| }
| |
| | |
| // Function to retrieve the page ID of a random page
| |
| function getRandomPageId() {
| |
| var apiUrl = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php';
| |
| var params = {
| |
| action: 'query',
| |
| generator: 'random',
| |
| format: 'json',
| |
| prop: 'info',
| |
| inprop: 'url',
| |
| formatversion: 2,
| |
| indexpageids: true,
| |
| redirects: true
| |
| };
| |
| return new Promise(function(resolve, reject) {
| |
| $.get(apiUrl, params).done(function(data) {
| |
| var pageIds = data.query.pageids;
| |
| if (pageIds.length > 0) {
| |
| var randomIndex = getRandomInt(pageIds.length);
| |
| var pageId = pageIds[randomIndex];
| |
| resolve(pageId);
| |
| } else {
| |
| reject('No pages found.');
| |
| }
| |
| }).fail(function() {
| |
| reject('Failed to retrieve random page ID.');
| |
| });
| |
| }); | | }); |
| }
| | |
| | | $(function() { |
| // Function to add a "Random Article" link to the navigation panel
| | var navPanel = $('#p-navigation ul'); |
| function addRandomArticleLink() { | | if (navPanel.length > 0) { |
| var navPanel = $('#p-navigation ul');
| | var linkUrl = 'https://aarhuswiki.dk/wiki/Speciel:Tilf%C3%A6ldig_side'; |
| if (navPanel.length > 0) {
| |
| getRandomPageId().then(function(pageId) {
| |
| var linkUrl = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit§ion=0&random=' + pageId; | |
| var linkText = 'Tilfældig side'; | | var linkText = 'Tilfældig side'; |
| navPanel.append('<li><a href="' + linkUrl + '">' + linkText + '</a></li>'); | | navPanel.append('<li><a href="' + linkUrl + '">' + linkText + '</a></li>'); |
| }).catch(function(errorMessage) { | | } |
| console.error('Error adding "Random Article" link: ' + errorMessage);
| | }); |
| });
| |
| }
| |
| }
| |
| | |
| // Add the "Random Article" link to the navigation panel when the document is ready
| |
| $(function() {
| |
| addRandomArticleLink();
| |
| });
| |
| | |
| // Add "Lykke" link to the navigation menu
| |
| $(function() {
| |
| if ( mw.config.get('wgPageName') === 'AarhusWiki' ) {
| |
| var $nav = $('#p-navigation ul');
| |
| var $link = $('<a>', {
| |
| href: mw.util.wikiGetlink('Special:RandomInCategory/Lykke'),
| |
| text: 'Lykke'
| |
| });
| |
| var $li = $('<li>').append($link);
| |
| $nav.append($li);
| |
| } | |
| }); | |