var edButtons = new Array(); var edLinks = new Array(); var edOpenTags = new Array(); function edButton(id, display, tagStart, tagEnd, access, open) { this.id = id; // used to name the toolbar button this.display = display; // label on button this.tagStart = tagStart; // open tag this.tagEnd = tagEnd; // close tag this.access = access; // access key this.open = open; // set to -1 if tag does not need to be closed } function zeroise(number, threshold) { // FIXME: or we could use an implementation of printf in js here var str = number.toString(); if (number < 0) { str = str.substr(1, str.length) } while (str.length < threshold) { str = "0" + str } if (number < 0) { str = '-' + str } return str; } var now = new Date(); var datetime = now.getFullYear() + '-' + zeroise(now.getMonth() + 1, 2) + '-' + zeroise(now.getDate(), 2) + 'T' + zeroise(now.getHours(), 2) + ':' + zeroise(now.getMinutes(), 2) + ':' + zeroise(now.getSeconds() ,2) + // FIXME: we could try handling timezones like +05:30 and the like zeroise((now.getTimezoneOffset()/60), 2) + ':' + '00'; edButtons[edButtons.length] = new edButton('ed_strong' ,'str' ,'' ,'' ,'b' ); edButtons[edButtons.length] = new edButton('ed_em' ,'em' ,'' ,'' ,'i' ); edButtons[edButtons.length] = new edButton('ed_block' ,'b-quote' ,'
' ,'' ,'q' ); edButtons[edButtons.length] = new edButton('ed_link' ,'link' ,'' ,'' ,'a' ); // special case function edLink() { this.display = ''; this.URL = ''; this.newWin = 0; } edButtons[edButtons.length] = new edButton('ed_pre' ,'code (inline)' ,'
'
,''
,'c'
);
edButtons[edButtons.length] =
new edButton('ed_new'
,'code block'
,''
,''
,'y'
);
function edShowButton(button, i) {
if (button.id == 'ed_img') {
document.write('');
}
else if (button.id == 'ed_link') {
document.write('');
}
else {
document.write('');
}
}
function edAddTag(button) {
if (edButtons[button].tagEnd != '') {
edOpenTags[edOpenTags.length] = button;
document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value;
}
}
function edRemoveTag(button) {
for (i = 0; i < edOpenTags.length; i++) {
if (edOpenTags[i] == button) {
edOpenTags.splice(i, 1);
document.getElementById(edButtons[button].id).value = document.getElementById(edButtons[button].id).value.replace('/', '');
}
}
}
function edCheckOpenTags(button) {
var tag = 0;
for (i = 0; i < edOpenTags.length; i++) {
if (edOpenTags[i] == button) {
tag++;
}
}
if (tag > 0) {
return true; // tag found
}
else {
return false; // tag not found
}
}
function edCloseAllTags() {
var count = edOpenTags.length;
for (o = 0; o < count; o++) {
edInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]);
}
}
function edToolbar() {
document.write('