mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
autolink 스크립트를 외부 파일로 옮기고 RFC3986에 의거하여 url 규칙을 엄격하게 지키도록 함
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4469 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d316c3f98b
commit
7743da3915
2 changed files with 48 additions and 10 deletions
|
|
@ -7,15 +7,6 @@
|
|||
* @brief 자동 링크 애드온
|
||||
**/
|
||||
if($called_position == 'after_module_proc' && Context::getResponseMethod()!="XMLRPC") {
|
||||
$script_code = <<<EndOfScript
|
||||
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
var url_regx = new RegExp("(http|https|ftp|news)://([^ \\r\\n\"\'\>\<]*)","i"); function replaceHrefLink(target_obj) { var obj_list = new Array(); var obj = target_obj; while(obj) { obj_list[obj_list.length] = obj; obj = obj.nextSibling; } for(var i=0;i<obj_list.length;i++) { var obj = obj_list[i]; var pObj = obj.parentNode; if(!pObj) continue; var pN = pObj.nodeName.toLowerCase(); if(pN == 'a' || pN == 'pre' || pN == 'xml' || pN == 'textarea' || pN == 'input') continue; if(obj.nodeType == 3 && obj.data && url_regx.test(obj.data) ) { var html = obj.nodeValue.split('<'); for(var i=0;i<html.length;i++) { var html2 = html[i].split('>'); for(var j=0;j<html2.length;j++) { html2[j] = html2[j].replace(url_regx,"<a href=\"$1://$2\" onclick=\"window.open(this.href); return false;\">$1://$2</a>"); } html[i] = html2.join('>'); } var output = html.join('<'); var dummy = xCreateElement('span'); xInnerHtml(dummy, output); pObj.insertBefore(dummy, obj); pObj.removeChild(obj); } else if(obj.nodeType == 1 && obj.firstChild) { replaceHrefLink(obj.firstChild); } } } function addUrlLink() { var objs = xGetElementsByClassName('xe_content'); if(objs.length<1) return; for(var i=0;i<objs.length;i++) { if(url_regx.test(xInnerHtml(objs[i]))) replaceHrefLink(objs[i].firstChild); } } xAddEventListener(window,'load', addUrlLink);
|
||||
// ]]>
|
||||
</script>
|
||||
|
||||
EndOfScript;
|
||||
Context::addHtmlHeader($script_code);
|
||||
Context::addJsFile('./addons/autolink/autolink.js');
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue