/* Copyright 2006 por Connecty Networks. Todos os direitos reservados */
domWebnote = [ { tag: "div", id: "text_show", style: {width: "100%", minHeight: "16px"}}, { tag: "textarea", id: "text_edit", display: false, style: {width: "100%", minHeight: "16px", border: "1px solid #FF9900"}, events: {onclick: "applyText()", onblur: "showText()"}}
]
function Webnote() { this.init(); this.cfg = { hasRefreshBtn: false, title: "Post-it", module: "Webnote"
}
this.defaultProfile["title"] = this.cfg.title; this.defaultProfile["text"] = "Bem-vindo ao portal Origo! Para editar este texto clique aqui e escreva o que quiser, o texto ficar&aacute; gravado at&eacute; o eliminar ou editar."; this.onBuildInterface = function() { this.buildDomModel(this.elements.content, domWebnote); var text_show = this.elements.text_show; var text_edit = this.elements.text_edit; var widget = this; this.elements.text_show["onclick"] = function() { widget.editText(widget, text_show, text_edit);}; this.elements.text_show.innerHTML = text2html(unescape(this.profile.text)).parseUrl(); this.elements.text_edit.innerHTML = unescape(this.profile.text); this.setTitle(this.profile.title);}
this.editText = function(widget, text_show, text_edit) { var h = text_show.offsetHeight; hideEl(text_show); showEl(text_edit); text_edit.style.height = (h+16)+"px"; text_edit.focus(); text_edit.onkeyup = function() { text_show.innerHTML = text2html(this.value); showEl(text_show); this.style.height = (text_show.offsetHeight+16) + "px"; hideEl(text_show);}
text_edit.onblur = function() { text = this.value.replace(/\\/g, ""); this.onblur = null; hideEl(this); htmlText = text2html(text); text_show.innerHTML = htmlText.parseUrl(); text_show.style.display = "block"; text_show.onclick = function() { widget.editText(widget, text_show, text_edit);}; widget.profile.text = escape(text); widget.save();}
}
this.showText = function() {}
this.applyText = function() {}
}
Webnote.prototype = new Widget(); String.prototype.parseUrl = function(){ var lines = this.split("<br>"); for(var z=0; z<lines.length; z++){ var tmp = lines[z].split(" "); for(var i=0; i<tmp.length; i++){ if(tmp[i].indexOf("www.")!=-1 && tmp[i].indexOf("http://")==-1){ tmp[i] = "<a href='http://"+tmp[i]+"' target='_blank'>"+tmp[i]+"</a>";} else if(tmp[i].indexOf("http://")!=-1 || tmp[i].indexOf("ftp://")!=-1 || tmp[i].indexOf("https://")!=-1){ tmp[i] = "<a href='"+tmp[i]+"' target='_blank'>"+tmp[i]+"</a>";} else if (tmp[i].indexOf("@") != -1 && tmp[i].charAt(0) != "@" && tmp[i].charAt(tmp[i].length-1) != "@") { tmp[i] = "<a href='mailto:"+tmp[i]+"'>"+tmp[i]+"</a>";}
}
lines[z] = tmp.join(" ");}
return lines.join("<br>");}