<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Indsæt BB-Kode [
http://www.eksperten.dk/spm/872172]</title></head>
<body>
<script type="text/javascript">
function insBBTags(oTxt, sTag) {
var sVal = oTxt.value;
oTxt.focus();
if (document.selection && document.selection.createRange) {
var oSel = document.selection.createRange();
if (oSel.parentElement()==oTxt) {
if (sTag=="a") {
var oDialog = window.showModalDialog("dialog.html?u="+new Date().getTime(), ["link", oSel.text], "dialogHeight:150px;dialogWidth:400px;edge:Raised;center:Yes;resizable:No;status:No");
if (oDialog) oSel.text = "[a href='"+oDialog[0]+"']" + oDialog[1] + "[/a]";
}
else if (sTag=="g") {
var oDialog = window.showModalDialog("dialog.html?u="+new Date().getTime(), ["pic", ""], "dialogHeight:105px;dialogWidth:400px;edge:Raised;center:Yes;resizable:No;status:No");
if (oDialog) oSel.text += "[img src='"+oDialog[0]+"']";
}
else oSel.text = "["+sTag+"]" + oSel.text + "[/"+sTag+"]";
if (sTag!="g")oSel.moveStart("character", -4);
oSel.collapse();
oSel.select();
oTxt.focus();
}
}
else if (typeof oTxt.selectionStart=="number") {
var nLen = oTxt.textLength;
var nSelStart = oTxt.selectionStart;
var nSelEnd = oTxt.selectionEnd;
if (sTag=="a") {
var sHref = prompt("Angiv en URL:");
var sLnk = "<a href='"+sHref+"'>" + sVal.substring(nSelStart, nSelEnd) + "</a>";
oTxt.focus();
oTxt.value = sVal.substring(0, nSelStart) + sLnk + sVal.substring(nSelEnd, nLen);
oTxt.selectionStart = oTxt.selectionEnd = nSelStart+sLnk.length-4;
}
else if (sTag=="g") {
var sSrc = prompt("Angiv en URL:");
var sImg = sVal.substring(nSelStart, nSelEnd) + "[img src='"+sSrc+"']";
oTxt.focus();
oTxt.value = sVal.substring(0, nSelStart) + sImg + sVal.substring(nSelEnd, nLen);
oTxt.selectionStart = oTxt.selectionEnd = nSelStart+sImg.length;
} else {
oTxt.value = sVal.substring(0, nSelStart) + "["+sTag+"]" + sVal.substring(nSelStart, nSelEnd) + "[/"+sTag+"]" + sVal.substring(nSelEnd, nLen);
if (nLen>0) oTxt.selectionStart = oTxt.selectionEnd = nSelEnd+3;
else oTxt.selectionStart = oTxt.selectionEnd = nSelStart+3;
}
} else {
oTxt.value += "["+sTag+"][/"+sTag+"]";
oTxt.focus();
}
}
function insTagHere(oTxt, e) {
if (!e.ctrlKey) return true;
var bKillEvnt = true;
switch (e.keyCode) {
case 66:
insBBTags(oTxt, "b");
break;
case 73:
insBBTags(oTxt, "i");
break;
case 76:
insBBTags(oTxt, "a");
break;
case 71:
insBBTags(oTxt, "g");
break;
case 85:
insBBTags(oTxt, "u");
break;
default:
bKillEvnt = false;
}
if (!bKillEvnt) return true;
if (e.stopPropagation) e.stopPropagation();
if (e.preventDefault) e.preventDefault();
e.cancelBubble = true;
e.returnValue = false;
}
</script>
<p><textarea id="message" cols="50" rows="10" onkeydown="insTagHere(this, event)"></textarea></p>
<p><button title="Bold" onclick="insBBTags(document.getElementById('message'),'b')"><b>B</b></button>
<button title="Italic" onclick="insBBTags(document.getElementById('message'),'i')"><i>I</i></button>
<button title="Underline" onclick="insBBTags(document.getElementById('message'),'u')"><u>U</u></button>
<button title="Link" onclick="insBBTags(document.getElementById('message'),'a')">L</button>
<button title="Picture" onclick="insBBTags(document.getElementById('message'),'g')">G</button></p>
<!-- dialog.html - Start
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Titel</title>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
padding: 0;
font: 11px tahoma, sans-serif;
background: buttonface;
overflow: hidden;
}
body {
padding: 8px 20px 0 20px;
}
p {
padding: 6px 0 6px 0;
margin: 0;
}
input {
width: 355px;
font: 11px tahoma, sans-serif;
}
p.btns {
padding-top: 8px;
margin-top: 6px;
border-top: 2px groove buttonhighlight;
text-align: center;
}
p.btns button {
width: 80px;
margin: 0 3px;
}
</style>
<script type="text/javascript">
function gE(id){return document.getElementById(id)};
function setReturn() {
window.returnValue = [gE("url").value, gE("txt").value];
}
window.returnValue = false;
var aArgs = null;
window.onload = function() {
aArgs = window.dialogArguments;
if (aArgs[0]=="link") {
document.title = "Indsæt Link";
gE("txt").value = aArgs[1];
gE("lblUrl").firstChild.nodeValue = "Angiv en URL:";
gE("lblTxt").firstChild.nodeValue = "Linktekst:";
}
else if (aArgs[0]=="pic") {
document.title = "Indsæt Billede";
gE("lblUrl").firstChild.nodeValue = "Angiv en URL:";
gE("txtCont").style.display = "none";
}
var oUrl = gE("url");
var oRng = oUrl.createTextRange();
oRng.moveStart("character", oUrl.value.length);
oRng.collapse();
oRng.select();
}
</script>
</head>
<body>
<p><label id="lblUrl" for="url"> </label><br><input id="url" type="text" value="
http://"></p><p id="txtCont"><label id="lblTxt" for="txt"> </label>:<br><input id="txt" type="text"></p>
<p class="btns"><button onclick="setReturn();window.close()">OK</button><button onclick="window.close()">Fortryd</button></p>
</body>
</html>
dialog.html - End -->
</body>
</html>