|
|
(117 mellemliggende versioner af 5 andre brugere ikke vist) |
Linje 1: |
Linje 1: |
| /*<pre>*/
| |
| /* Javascript inkluderet her vil være aktivt for alle brugere. */ | | /* Javascript inkluderet her vil være aktivt for alle brugere. */ |
|
| |
|
| /** WikiMiniAtlas *******************************************************
| | function siteNoticeScroll(obj,interval) { |
| *
| | $(obj).animate({ |
| * Description: WikiMiniAtlas is a popup click and drag world map.
| | height: 'show', |
| * This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
| | paddingTop: 'show', |
| * The script itself is located on meta because it is used by many projects.
| | marginTop: 'show', |
| * See [[Meta:WikiMiniAtlas]] for more information.
| | paddingBottom: 'show', |
| * Created by: [[User:Dschwen]]
| | marginBottom: 'show', |
| */
| | }); |
|
| | setInterval(function() { |
| document.write('<script type="text/javascript" src="'
| | $(obj).find('ul:first').animate({ |
| + 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js'
| | marginTop: '-25px' |
| + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
| | }, |
| // This is a 3 set parts script
| | 300, |
| // This script is from Wikipedia. For author attribution, please see
| | function() { |
| // http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js
| | $(this).css({ |
| | | marginTop: '0px', |
| // 1st part will look for the class name
| | }).find('li:first').appendTo(this); |
| /* Test if an element has a certain class **************************************
| | }); |
| *
| | }, |
| * Description: Uses regular expressions and caching for better performance.
| | interval); |
| * Maintainers: [[Wikipedia:User:Mike Dillon]], [[Wikipedia:User:R. Koot]], [[Wikipedia:User:SG]]
| |
| */
| |
|
| |
| var hasClass = (function () {
| |
| var reCache = {};
| |
| return function (element, className) {
| |
| return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
| |
| };
| |
| })();
| |
| | |
| // 2nd part is the Scrip for Wikitables
| |
| /* <pre style="height: 45em"><nowiki> */
| |
| /** Collapsible tables *********************************************************
| |
| *
| |
| * Description: Allows tables to be collapsed, showing only the header. See
| |
| * [[Wikipedia:Wikipedia:NavFrame]].
| |
| * Maintainers: [[Wikipedia:User:R. Koot]]
| |
| */
| |
|
| |
| var autoCollapse = 2;
| |
| var collapseCaption = "skjul";
| |
| var expandCaption = "vis";
| |
|
| |
| function collapseTable( tableIndex )
| |
| {
| |
| var Button = document.getElementById( "collapseButton" + tableIndex );
| |
| var Table = document.getElementById( "collapsibleTable" + tableIndex );
| |
|
| |
| if ( !Table || !Button ) {
| |
| return false;
| |
| }
| |
|
| |
| var Rows = Table.rows;
| |
|
| |
| if ( Button.firstChild.data == collapseCaption ) {
| |
| for ( var i = 1; i < Rows.length; i++ ) {
| |
| Rows[i].style.display = "none";
| |
| }
| |
| Button.firstChild.data = expandCaption;
| |
| } else {
| |
| for ( var i = 1; i < Rows.length; i++ ) {
| |
| Rows[i].style.display = Rows[0].style.display;
| |
| }
| |
| Button.firstChild.data = collapseCaption;
| |
| }
| |
| }
| |
|
| |
| function createCollapseButtons()
| |
| {
| |
| var tableIndex = 0;
| |
| var NavigationBoxes = new Object();
| |
| var Tables = document.getElementsByTagName( "table" );
| |
|
| |
| for ( var i = 0; i < Tables.length; i++ ) {
| |
| if ( hasClass( Tables[i], "collapsible" ) ) {
| |
|
| |
| /* only add button and increment count if there is a header row to work with */
| |
| var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
| |
| if (!HeaderRow) continue;
| |
| var Header = HeaderRow.getElementsByTagName( "th" )[0];
| |
| if (!Header) continue;
| |
|
| |
| NavigationBoxes[ tableIndex ] = Tables[i];
| |
| Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
| |
|
| |
| var Button = document.createElement( "span" );
| |
| var ButtonLink = document.createElement( "a" );
| |
| var ButtonText = document.createTextNode( collapseCaption );
| |
|
| |
| Button.style.styleFloat = "right";
| |
| Button.style.cssFloat = "right";
| |
| Button.style.fontWeight = "normal";
| |
| Button.style.textAlign = "right";
| |
| Button.style.width = "6em";
| |
|
| |
| ButtonLink.style.color = Header.style.color;
| |
| ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
| |
| ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
| |
| ButtonLink.appendChild( ButtonText );
| |
|
| |
| Button.appendChild( document.createTextNode( "[" ) );
| |
| Button.appendChild( ButtonLink );
| |
| Button.appendChild( document.createTextNode( "]" ) );
| |
|
| |
| Header.insertBefore( Button, Header.childNodes[0] );
| |
| tableIndex++;
| |
| }
| |
| }
| |
|
| |
| for ( var i = 0; i < tableIndex; i++ ) {
| |
| if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
| |
| collapseTable( i );
| |
| }
| |
| }
| |
| }
| |
|
| |
| addOnloadHook( createCollapseButtons );
| |
| /* </nowiki></pre> */
| |
| | |
| // 3er part is the Scrip for NavFram
| |
| /* <pre style="height: 45em"><nowiki> */
| |
| /** Dynamic Navigation Bars (experimental) *************************************
| |
| *
| |
| * Description: See [[Wikipedia:Wikipedia:NavFrame]].
| |
| * Maintainers: UNMAINTAINED
| |
| */
| |
|
| |
| // set up the words in your language
| |
| var NavigationBarHide = '[' + collapseCaption + ']';
| |
| var NavigationBarShow = '[' + expandCaption + ']'; | |
|
| |
| // shows and hides content and picture (if available) of navigation bars | |
| // Parameters:
| |
| // indexNavigationBar: the index of navigation bar to be toggled
| |
| function toggleNavigationBar(indexNavigationBar)
| |
| {
| |
| var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
| |
| var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
| |
|
| |
| if (!NavFrame || !NavToggle) {
| |
| return false;
| |
| }
| |
|
| |
| // if shown now
| |
| if (NavToggle.firstChild.data == NavigationBarHide) {
| |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if ( hasClass( NavChild, 'NavPic' ) ) {
| |
| NavChild.style.display = 'none';
| |
| }
| |
| if ( hasClass( NavChild, 'NavContent') ) {
| |
| NavChild.style.display = 'none';
| |
| }
| |
| }
| |
| NavToggle.firstChild.data = NavigationBarShow;
| |
|
| |
| // if hidden now
| |
| } else if (NavToggle.firstChild.data == NavigationBarShow) {
| |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if (hasClass(NavChild, 'NavPic')) {
| |
| NavChild.style.display = 'block';
| |
| }
| |
| if (hasClass(NavChild, 'NavContent')) {
| |
| NavChild.style.display = 'block';
| |
| }
| |
| }
| |
| NavToggle.firstChild.data = NavigationBarHide;
| |
| }
| |
| }
| |
|
| |
| // adds show/hide-button to navigation bars
| |
| function createNavigationBarToggleButton()
| |
| {
| |
| var indexNavigationBar = 0;
| |
| // iterate over all < div >-elements
| |
| var divs = document.getElementsByTagName("div");
| |
| for(
| |
| var i=0;
| |
| NavFrame = divs[i];
| |
| i++
| |
| ) {
| |
| // if found a navigation bar
| |
| if (hasClass(NavFrame, "NavFrame")) {
| |
|
| |
| indexNavigationBar++;
| |
| var NavToggle = document.createElement("a");
| |
| NavToggle.className = 'NavToggle';
| |
| NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
| |
| NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
| |
|
| |
| var NavToggleText = document.createTextNode(NavigationBarHide);
| |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
| |
| if (NavChild.style.display == 'none') {
| |
| NavToggleText = document.createTextNode(NavigationBarShow);
| |
| break;
| |
| }
| |
| }
| |
| }
| |
|
| |
| NavToggle.appendChild(NavToggleText);
| |
| // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
| |
| for(
| |
| var j=0;
| |
| j < NavFrame.childNodes.length;
| |
| j++
| |
| ) {
| |
| if (hasClass(NavFrame.childNodes[j], "NavHead")) {
| |
| NavFrame.childNodes[j].appendChild(NavToggle);
| |
| }
| |
| }
| |
| NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
| |
| }
| |
| }
| |
| } | |
|
| |
| addOnloadHook( createNavigationBarToggleButton ); | |
| | |
| //Hjemmelavede knapper specielt til Spademanns
| |
| | |
| if (mwCustomEditButtons) {
| |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images.wikia.com/da.uncyclopedia/images/1/11/Button_category.png",
| |
| "speedTip": "Kategori",
| |
| "tagOpen": "[[Kategori:",
| |
| "tagClose": "]]",
| |
| "sampleText": "Indsæt en kategori"};
| |
| | |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images.wikia.com/da.uncyclopedia/images/1/13/Button_enter.png",
| |
| "speedTip": "Linieskift",
| |
| "tagOpen": "<br />",
| |
| "tagClose": "",
| |
| "sampleText": ""};
| |
| | |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images.wikia.com/da.uncyclopedia/images/e/ea/Button_easy_cite.png",
| |
| "speedTip": "Citat",
| |
| "tagOpen": "\{\{citat|",
| |
| "tagClose": "|En eller anden|et eller andet\}\}",
| |
| "sampleText": "Indsæt din citattekst her"};
| |
| | |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images.wikia.com/da.uncyclopedia/images/c/c4/Button_ref.png",
| |
| "speedTip": "Fodnote",
| |
| "tagOpen": "<ref>",
| |
| "tagClose": "</ref>",
| |
| "sampleText": "Indsæt fodnote her"};
| |
| | |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images.wikia.com/da.uncyclopedia/images/b/bf/WP-icon.png",
| |
| "speedTip": "Wikipedia",
| |
| "tagOpen": "\{\{wikipedia|",
| |
| "tagClose": "\}\}",
| |
| "sampleText": "Navnet på linkartikel"};
| |
| | |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images.wikia.com/da.uncyclopedia/images/8/8e/Button_stub.png",
| |
| "speedTip": "Under konstruktion",
| |
| "tagOpen": "\{\{Under konstruktion\}\}",
| |
| "tagClose": "",
| |
| "sampleText": ""};
| |
| | |
| mwCustomEditButtons[mwCustomEditButtons.length] = {
| |
| "imageFile": "http://images1.wikia.nocookie.net/da.uncyclopedia/images/4/49/Button_talk.png",
| |
| "speedTip": "Egen signatur",
| |
| "tagOpen": "~~~",
| |
| "tagClose": "",
| |
| "sampleText": ""};
| |
| } | | } |
| | | siteNoticeScroll('.siteNoticeScroll',5000); |
| /* *****************************Tidstempel i lokalt tidsangivelse****************
| | if (mw.config.get('wgPageName') == 'Guides') { |
| Documentation: [[Wikipedia:Comments in Local Time]]
| | $('.CategoryTreeToggle').click(); |
| */
| |
|
| |
| addOnloadHook(function()
| |
| {
| |
| /*
| |
| Settings
| |
| */
| |
| if (typeof(LocalComments) == 'undefined')
| |
| LocalComments = {};
| |
|
| |
| if (typeof(LocalComments.dateFormat) == 'undefined')
| |
| {
| |
| // Deprecated: LocalizeConfig
| |
| if (typeof(LocalizeConfig) != 'undefined' && typeof(LocalizeConfig.dateFormat) != 'undefined' && LocalizeConfig.dateFormat != '')
| |
| LocalComments.dateFormat = LocalizeConfig.dateFormat;
| |
| else
| |
| LocalComments.dateFormat = 'dmy';
| |
| }
| |
|
| |
| if (typeof(LocalComments.timeFirst) == 'undefined')
| |
| LocalComments.timeFirst = true;
| |
| /*
| |
| End Settings
| |
| */
| |
|
| |
| if (wgCanonicalNamespace == '' || wgCanonicalNamespace == 'MediaWiki' || wgCanonicalNamespace == 'Special')
| |
| return;
| |
|
| |
| var disabled_urls = new Array('action=history'), unique_url = false, wikiPreview = new Array('action=edit', 'action=submit');
| |
| for (var i = 0; i < disabled_urls.length; i++)
| |
| {
| |
| if (document.location.href.indexOf(disabled_urls[i]) != -1)
| |
| return;
| |
| }
| |
|
| |
| for (var i = 0; i < wikiPreview.length; i++)
| |
| {
| |
| if (document.location.href.indexOf(wikiPreview[i]) != -1)
| |
| unique_url = 'wikiPreview';
| |
| }
| |
|
| |
| var element_id = unique_url ? unique_url : 'bodyContent';
| |
| replace_text(document.getElementById(element_id), /(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjust_time);
| |
| });
| |
| | |
| function add_leading_zero(number)
| |
| {
| |
| if (number < 10)
| |
| number = '0' + number;
| |
| return number;
| |
| } | | } |
|
| |
|
| function adjust_time(original_timestamp, old_hour, old_minute, old_day, old_month, old_year, offset)
| | /*$( '#discord-widget' ).html( '<iframe src="https://discord.com/widget?id=993729088458068039&theme=dark" width="380" height="580" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>' );*/ |
| {
| |
| var today = new Date(), yesterday = new Date(), tomorrow = new Date();
| |
| yesterday.setDate(yesterday.getDate() - 1);
| |
| tomorrow.setDate(tomorrow.getDate() + 1);
| |
|
| |
| // set the date entered
| |
| var time = new Date();
| |
| time.setUTCHours(old_hour);
| |
| time.setUTCMinutes(old_minute);
| |
| time.setUTCMonth(convert_month_to_number(old_month));
| |
| time.setUTCDate(old_day);
| |
| time.setUTCFullYear(old_year);
| |
|
| |
| // determine the time offset
| |
| var utc_offset = -1 * time.getTimezoneOffset() / 60;
| |
| if (utc_offset >= 0)
| |
| utc_offset = '+' + utc_offset;
| |
| else
| |
| utc_offset = '−' + Math.abs(utc_offset);
| |
|
| |
| // set the date bits to output
| |
| var year = time.getFullYear(), month = add_leading_zero(time.getMonth() + 1);
| |
| var day = time.getDate();
| |
| var hour = parseInt(time.getHours()), minute = add_leading_zero(time.getMinutes());
| |
|
| |
|
| // output am or pm depending on the date
| | /* debug */ |
| var ampm = 'am';
| | console.info('Common.js has been successfully loaded.'); |
| if (hour > 11) ampm = 'pm';
| |
| if (hour > 12) hour -= 12;
| |
| if (hour == '00') hour = 12;
| |
|
| |
| // return 'today' or 'yesterday' if that is the case
| |
| if (year == today.getFullYear() && month == add_leading_zero(today.getMonth() + 1) && day == today.getDate())
| |
| var date = 'Today';
| |
| else if (year == yesterday.getFullYear() && month == add_leading_zero(yesterday.getMonth() + 1) && day == yesterday.getDate())
| |
| var date = 'Yesterday';
| |
| else if (year == tomorrow.getFullYear() && month == add_leading_zero(tomorrow.getMonth() + 1) && day == tomorrow.getDate())
| |
| var date = 'Tomorrow';
| |
| else
| |
| {
| |
| // calculate day of week
| |
| var day_names = new Array('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'), day_of_the_week = day_names[time.getDay()];
| |
| | |
| // the distance in days from today and last Monday?
| |
| today = new Date(today.getYear(), today.getMonth(), today.getDate());
| |
| time = new Date(time.getYear(), time.getMonth(), time.getDate());
| |
|
| |
| // calculate time difference
| |
| var milliseconds_ago = today.getTime() - time.getTime(), days_ago = Math.round(milliseconds_ago / 1000 / 60 / 60 / 24);
| |
| | |
| // the difference between today and the timestamp
| |
| var difference, difference_word = '', last = '';
| |
| if (today.valueOf() >= time.valueOf())
| |
| {
| |
| difference = new Date(today.valueOf() - time.valueOf());
| |
| difference_word = 'ago';
| |
| if (days_ago <= 7)
| |
| last = 'last ';
| |
| }
| |
| else
| |
| {
| |
| difference = new Date(time.valueOf() - today.valueOf());
| |
| difference_word = 'from now';
| |
| if (days_ago >= -7)
| |
| last = 'this ';
| |
| }
| |
| var descriptive_difference = [];
| |
| | |
| if (difference.getYear() - 70 > 0)
| |
| {
| |
| var years_ago = (difference.getYear() - 70) + ' ' + pluralize('year', difference.getYear() - 70, 'years');
| |
| descriptive_difference.push(years_ago);
| |
| }
| |
| if (difference.getMonth() > 0)
| |
| {
| |
| var months_ago = difference.getMonth() + ' ' + pluralize('month', difference.getMonth(), 'months');
| |
| descriptive_difference.push(months_ago);
| |
| }
| |
| if (difference.getDate() > 0)
| |
| {
| |
| var new_days_ago = difference.getDate() + ' ' + pluralize('day', difference.getDate(), 'days');
| |
| descriptive_difference.push(new_days_ago);
| |
| }
| |
|
| |
| // format the date according to user preferences
| |
| var formatted_date = '', month_name = convert_number_to_month(time.getMonth());
| |
|
| |
| switch (LocalComments.dateFormat.toLowerCase())
| |
| {
| |
| case 'dmy':
| |
| formatted_date = day + ' ' + month_name + ' ' + year;
| |
| break;
| |
| case 'mdy':
| |
| formatted_date = month_name + ' ' + day + ', ' + year;
| |
| break;
| |
| default:
| |
| formatted_date = year + '-' + month + '-' + add_leading_zero(day);
| |
| }
| |
|
| |
| var date = formatted_date + ', ' + last + day_of_the_week + ' (' + descriptive_difference.join(', ') + ' ' + difference_word + ')';
| |
| }
| |
|
| |
| var time = hour + ':' + minute + ' ' + ampm;
| |
|
| |
| if (LocalComments.timeFirst)
| |
| var return_date = time + ', ' + date + ' (UTC' + utc_offset + ')';
| |
| else
| |
| var return_date = date + ', ' + time + ' (UTC' + utc_offset + ')';
| |
| | |
| return return_date;
| |
| }
| |
| | |
| function convert_month_to_number(month)
| |
| {
| |
| var output = new Date(month + ' 1, 2001');
| |
| return output.getMonth();
| |
| }
| |
| | |
| function convert_number_to_month(number)
| |
| {
| |
| var month = new Array('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December');
| |
| return month[number];
| |
| }
| |
| | |
| function pluralize(term, count, plural)
| |
| {
| |
| if (plural == null)
| |
| plural = term + 's';
| |
| | |
| return (count == 1 ? term : plural)
| |
| }
| |
| | |
| function replace_text(node, search, replace)
| |
| {
| |
| if (node.nodeType == 3)
| |
| {
| |
| var value = node.nodeValue;
| |
| var position = value.search(search);
| |
| var match = value.match(search);
| |
|
| |
| if (position != -1)
| |
| {
| |
| var length = match.toString().length;
| |
|
| |
| var before_match = value.substring(0, position);
| |
| var after_match = value.substring(position + length);
| |
|
| |
| var first_span = document.createElement('span');
| |
| first_span.setAttribute('style', 'font-size: 95%; white-space: nowrap;');
| |
|
| |
| var second_span = document.createElement('span');
| |
| second_span.setAttribute('class', 'localcomments');
| |
| second_span.setAttribute('title', match);
| |
| second_span.appendChild(document.createTextNode(match.toString().replace(search, replace)));
| |
|
| |
| first_span.appendChild(second_span);
| |
|
| |
| var parent_node = document.createDocumentFragment();
| |
| parent_node.appendChild(document.createTextNode(before_match));
| |
| parent_node.appendChild(first_span);
| |
| parent_node.appendChild(document.createTextNode(after_match));
| |
|
| |
| node.parentNode.replaceChild(parent_node, node);
| |
| }
| |
| }
| |
| else
| |
| {
| |
| var children = [], child = node.firstChild;
| |
| while (child)
| |
| {
| |
| children[children.length] = child;
| |
| child = child.nextSibling;
| |
| }
| |
|
| |
| for (var child = 0; child < children.length; child++)
| |
| replace_text(children[child], search, replace);
| |
| }
| |
| }
| |
| /*</pre>*/
| |