User:Frode Fenis/common.js

document.write(' ');

document.write(' ');

document.write(' ');

document.write(' ');

document.write(' ');

popupAdminLinks=true;

popupStructure='fancy';

popupMaxPreviewSentences=8;

/* *********************** Pop-up billeder ******************************** */

/*

$(document).ready(function {

$('body').append('  ');

$('a.image').click(function(e) {

e.preventDefault;

if ($(this).find('img').attr('src').match('/thumb/')) {

var src = $(this).find('img').attr('src').replace('/thumb',).replace(/\/[\-_.%\w]*$/, );

} else {

var src = $(this).find('img').attr('src');

}

$('#lightbox')

.html('')

.css('line-height', $(window).height+'px')

.fadeIn('fast')

.live('click', function {

$(this).fadeOut('fast');

});

});

});

* /

/* ********************'Eksterne links i nye vinduer********************** */

externalLinks = function {

if (!document.getElementsByTagName) {

return;

}

var anchors = document.getElementsByTagName("a");

for (var i = 0; i < anchors.length; i++) {

var anchor = anchors[i];

if (anchor.getAttribute("href") &&

anchor.getAttribute("rel") != null &&

(anchor.getAttribute("rel").indexOf("external") >= 0 ||

anchor.getAttribute("rel").indexOf("nofollow") >= 0)

) {

anchor.target = "_blank";

}

}

}

if (window.addEventListener) {

window.addEventListener("load", externalLinks, false);

}

else if (window.attachEvent) {

window.attachEvent("onload", externalLinks);

}

/* *******Rigtige knapper i redigeringsvinduet****************************************** */

function ajaxPreviewInit{

if ((wgNamespaceNumber % 2 == 0) && /\.(js|css)$/.test(wgTitle)) return

if (typeof ajaxPreviewKey != 'string') ajaxPreviewKey = 'p'

if (typeof ajaxDiffKey != 'string') ajaxDiffKey  = 'v'

ajaxPreviewPos = window.ajaxPreviewPos || 'right'

if (ajaxPreviewPos != 'bottom'){

var tOld = document.getElementById('toolbar') || document.getElementById('wpTextbox1')

tOld.style.clear = 'none'

var d = document.createElement('div'); d.style.cssText = 'width:100%; clear:both'

tOld.parentNode.insertBefore(d, tOld)

var tNew = document.createElement('div'); tNew.style.cssText = 'float:'+ ajaxPreviewPos

tOld.parentNode.insertBefore(tNew, tOld)

}

addBtn(window.ajaxPreviewButton, 'wpPreview', ajaxPreviewKey)

addBtn(window.ajaxDiffButton, 'wpDiff', ajaxDiffKey)

function addBtn(name, id, akey){

var btnOld = document.getElementById(id)

if (!btnOld) return

//var

btn = document.createElement('input'); btn.type = 'button'

btn.onclick = ajaxPreviewClick;  btn.id = id + 'Live'

if (!name){ //extract last word from standard buttons

name = btnOld.value.split(' '); name = name[name.length-1]

name = name.substring(0,1).toUpperCase + name.substring(1)

}

btn.value = name;  btn.title = btnOld.value + ' (Ajax)'

if (ajaxPreviewPos == 'bottom'){

btnOld.parentNode.insertBefore(btn, btnOld)

btn.value = btnOld.value

btnOld.value = '>'

}else{

btn.style.cssText = 'height:22px; padding:0 1px'

tNew.appendChild(btn)

}

if (akey){ //reassign acces key

if (btnOld.accessKey == akey){

btnOld.accessKey = ''

//btnOld.setAttribute( 'accesskey', '' )

btnOld.title = btnOld.title.replace(tooltipAccessKeyRegexp, '')

}

//btn.setAttribute('accesskey', akey)

btn.accessKey = akey

btn.title += ' ['+tooltipAccessKeyPrefix+akey+']'

}

btn.value2 = btn.value

}

}

function ajaxPreviewClick{ajaxPreviewRun(this)}

function ajaxPreviewRun(btn){

var wkPreview = document.getElementById('wikiPreview'), form = document.editform

var aj = sajax_init_object

if (!wkPreview || !form || !aj) return

var oldHeight = wkPreview.offsetHeight

var el, htm, isDiff = (btn.id=='wpDiffLive')

wkPreview.style.opacity = '0.3'; wkPreview.style.color = 'gray'; document.body.style.cursor = 'wait'

if (el=document.getElementById('wikiDiff')) el.style.display = 'none'

if (el=document.getElementById('newarticletext')) el.style.display = 'none'

btn.style.width = Math.max(btn.scrollWidth, btn.offsetWidth) + 'px';  btn.value = '...'

//prepare

var txt = form.wpTextbox1.value, action = form.action

var boundary = '123xyz', data = ''

if (isDiff){

addData('wpDiff', ''); addData('wpStarttime'); addData('wpEdittime')

if (!window.ajaxPreview_CSS) ajaxPreview_CSS = importStylesheetURI('/skins-1.5/common/diff.css')

}else{

action += '&live'

if (form.wpSection && form.wpSection.value) txt += '\n ', p1)

htm = (p1!=-1 && p2!=-1) ? htm.substring(p1, p2+8) : 'Error'

}else{

htm = aj.responseText.replace(/&amp;gt;/g,'>').replace(/&amp;lt;/g,'<').replace(/&amp;quot;/g,'"').replace(/&amp;amp;/g,'&').replace(/&amp;apos;/g,"'")

}

wkPreview.innerHTML = htm

btn.value = btn.value2

btn.blur

if (el = wkPreview.getElementsByTagName('h2')[0]){

if (el.style.textAlign != 'right') el.innerHML +=  ' (Ajax)'

el.style.textAlign = 'right'

}

if (window.ajaxPreviewScrollTop && wkPreview.scrollIntoView) wkPreview.scrollIntoView

else document.documentElement.scrollTop +=  wkPreview.offsetHeight - oldHeight

wkPreview.style.opacity = ; wkPreview.style.color = ; document.body.style.cursor = ''

if (!isDiff) ajaxPreviewFinish(wkPreview)

}

function addData(name, value){

if (!value) value = form[name] ? form[name].value : ''

data += '--' + boundary + '\nContent-Disposition: form-data; name="'+name+'"\n\n' + value + '\n'

}

}

function ajaxPreviewFinish(el){

sortables_init

if (window.createCollapseButtons){//en.wp

createCollapseButtons

createNavigationBarToggleButton

}

if (window.ajaxPreviewExec) ajaxPreviewExec(el)

}

if (wgAction=='edit' || wgAction=='submit') addOnloadHook(ajaxPreviewInit)

//*************************** Quiz om Nationen************************************************

var quizName = "Nationen";

var quizLang = "da";

var resultsTextArray = [

"Du har den laveste score af os alle velkommen til Nationen!",

"Din score var ikke tilpas lav til at blive taget i betragtning som medlem af Nationen!",

"Du havde den højeste score. Hold dig til dit gode faste atbejde...og Nationen!.....DROP DET!!!!!"

];

var questions = [

["Du graver et hul som er 2 meter langt, 3 meter bredt og en meter dybt. Hvor meget jord er der i hullet?",

"Det er umuligt at svare på",

"Ingen af svarmulighederne1",

"6 kubikmeter",

"9.5 kubikmeter"],

["Der er 10 æbler. Du tager de 3. Hvor mange æbler har du nu?",

"3",

"7",

"10",

"Ved ikke"]

];

importArticles({

type: 'script',

articles: [

'u:dev:Quiz/code.js'

]

});