Changeset 1707 in ExiteCMS
- Timestamp:
- 08/27/08 22:55:36 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PLi-Fusion/includes/jscripts/hoteditor-4.2/editor.js
r1694 r1707 1 1 /* 2 3 2 +-------------------------------------------------------------------------- 4 3 | … … 37 36 | conditions of the free version aren't exactly clear. 38 37 | 38 | NOTE //-------------------------- 39 | 40 | This version of editor.js has been modified by the ExiteCMS team: 41 | - new wrapSelection() function that can handle scrolling in textarea's 42 | - made sure all BBcode tags are in lower case 43 | - changed relative font sizes (1-7) to absolute size in pixels 44 | - make sure the script doesn't touch input in [code], [php] and [html] blocks 45 | - added test to see toolbars and text strings are already defined 46 | (allows override of default settings by the calling ExiteCMS template) 47 | - added option to define a keycode in the calling ExiteCMS template 48 | so that a CMS user can buy one and doesn't have to change this script 49 | - convert relative URL's pasted in the rich text editor to absolute 50 | url's when converting to BBcode (to avoid ../ kind of relative paths 51 | in [url] and [img] tags, which the ExiteCMS BBcode parser refuses) 52 | 39 53 +-------------------------------------------------------------------------- 40 54 */ … … 42 56 // HotEditor free-use notice 43 57 var Credit ="Rich Text Editor by www.eCardMax.com"; 44 var Keycode ="8059051C55C81839D1E2BAA6355AC0253063E38835";58 if (Keycode == null) var Keycode ="8059051C55C81839D1E2BAA6355AC0253063E38835"; 45 59 46 60 // ExiteCMS configuration … … 65 79 //---------------- FOR WYSIWYG EDITOR (BBCODE EDITOR) ---------------- 66 80 67 var TitleText = "Rich Text Editor";81 if (TitleText == null) var TitleText = "Rich Text Editor"; 68 82 var iframe_meta_tag = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n"; 69 83 var iframe_style = "BODY{font-family:Verdana,Arial,Sans-Serif,Tahoma;font-size:12px;color: black;}"; … … 75 89 var array_toolbar_user_custom=new Array(); 76 90 77 var toolbar1 ="SPACE,btFont_Name,btFont_Size,btFont_Color,btHighlight,btRemove_Format,SPACE,btBold,btItalic,btUnderline"; 78 var toolbar2 ="SPACE,btAlign_Left,btCenter,btAlign_Right,btJustify,SPACE,btCut,btCopy,btPaste,btUndo,SPACE,btStrikethrough,btSubscript,btSuperscript,btHorizontal,SPACE,btBullets,btNumbering,btIncrease_Indent"; 79 var toolbar3 ="SPACE,btHyperlink,btHyperlink_Email,btInsert_Image,btEmotions,btYouTube,SPACE,btQuote,btCode"; 80 81 var minibar ="SPACE,btFont_Name,btFont_Color,btHighlight,SPACE,btBold,btItalic,btUnderline,SPACE,btHyperlink,btEmotions,SPACE,btQuote,btCode"; 91 if (toolbar1 == null) { 92 var toolbar1 ="SPACE,btFont_Name,btFont_Size,btFont_Color,btHighlight,btRemove_Format,SPACE,btBold,btItalic,btUnderline"; 93 } 94 if (toolbar2 == null) { 95 var toolbar2 ="SPACE,btAlign_Left,btCenter,btAlign_Right,btJustify,SPACE,btCut,btCopy,btPaste,btUndo,SPACE,btStrikethrough,btSubscript,btSuperscript,btHorizontal,SPACE,btBullets,btNumbering,btIncrease_Indent"; 96 } 97 if (toolbar3 == null) { 98 var toolbar3 ="SPACE,btHyperlink,btHyperlink_Email,btInsert_Image,btEmotions,btYouTube,SPACE,btQuote,btCode"; 99 } 100 if (minibar == null) { 101 var minibar ="SPACE,btFont_Name,btFont_Color,btHighlight,SPACE,btBold,btItalic,btUnderline,SPACE,btHyperlink,btEmotions,SPACE,btQuote,btCode"; 102 } 82 103 83 104 // Setup Popup layer Width & Height & Title bar here (for WYSIWYG Editor) 84 var forecolor_frame_width =235; var forecolor_frame_height =185; var pop_Select_Forecolor ="Font Color";85 var hilitecolor_frame_width =165; var hilitecolor_frame_height =110; var pop_Select_Hilitecolor ="Text Highlight Color";86 var fontname_frame_width =205; var fontname_frame_height =300; var pop_Select_Font ="Font Face";87 var fontsize_frame_width =80; var fontsize_frame_height =249; var pop_Select_FontSize ="Font Size";88 var simley_frame_width =370; var simley_frame_height =340; var pop_Select_Smile ="Insert your emotions to document";89 var wordart_frame_width =370; var wordart_frame_height =340; var pop_Select_WordArt ="Insert WordArt to document";90 var clipart_frame_width =370; var clipart_frame_height =340; var pop_Select_ClipArt ="Insert ClipArt to document";91 var calendar_frame_width =330; var calendar_frame_height =350; var pop_Select_Calendar ="View Calendar / World Clock";92 var upload_frame_width =385; var upload_frame_height =250; var pop_Select_Upload ="Upload your image files";93 var vk_frame_width =520; var vk_frame_height =250; var pop_Insert_VK ="Virtual Keyboard";94 var moretags_frame_width =190; var moretags_frame_height =150; var pop_Insert_Moretags="Insert Forum Tags";95 var symbol_frame_width =382; var symbol_frame_height =300; var pop_Insert_Symbol ="Insert Symbol - Special characters";105 var forecolor_frame_width =235; var forecolor_frame_height =185; if (pop_Select_Forecolor == null) var pop_Select_Forecolor ="Font Color"; 106 var hilitecolor_frame_width =165; var hilitecolor_frame_height =110; if (pop_Select_Hilitecolor == null) var pop_Select_Hilitecolor ="Text Highlight Color"; 107 var fontname_frame_width =205; var fontname_frame_height =300; if (pop_Select_Font == null) var pop_Select_Font ="Font Face"; 108 var fontsize_frame_width =80; var fontsize_frame_height =249; if (pop_Select_FontSize == null) var pop_Select_FontSize ="Font Size"; 109 var simley_frame_width =370; var simley_frame_height =340; if (pop_Select_Smile == null) var pop_Select_Smile ="Insert your emotions to document"; 110 var wordart_frame_width =370; var wordart_frame_height =340; if (pop_Select_WordArt == null) var pop_Select_WordArt ="Insert WordArt to document"; 111 var clipart_frame_width =370; var clipart_frame_height =340; if (pop_Select_ClipArt == null) var pop_Select_ClipArt ="Insert ClipArt to document"; 112 var calendar_frame_width =330; var calendar_frame_height =350; if (pop_Select_Calendar == null) var pop_Select_Calendar ="View Calendar / World Clock"; 113 var upload_frame_width =385; var upload_frame_height =250; if (pop_Select_Upload == null) var pop_Select_Upload ="Upload your image files"; 114 var vk_frame_width =520; var vk_frame_height =250; if (pop_Insert_VK == null) var pop_Insert_VK ="Virtual Keyboard"; 115 var moretags_frame_width =190; var moretags_frame_height =150; if (pop_Insert_Moretags == null) var pop_Insert_Moretags="Insert Forum Tags"; 116 var symbol_frame_width =382; var symbol_frame_height =300; if (pop_Insert_Symbol == null) var pop_Insert_Symbol ="Insert Symbol - Special characters"; 96 117 97 118 //---------------- FOR BBCODE EDITOR ---------------- 98 119 99 var TitleText_Texarea ="BBCode Editor"; 100 101 var textarea_toolbar1 ="SPACE,btFont_Name,btFont_Size,btFont_Color,btHighlight,btRemove_Format,SPACE,btBold,btItalic,btUnderline"; 102 var textarea_toolbar2 ="SPACE,btAlign_Left,btCenter,btAlign_Right,btJustify,SPACE,btCut,btCopy,btPaste,SPACE,btStrikethrough,btSubscript,btSuperscript,btHorizontal,SPACE,btBullets,btNumbering,btIncrease_Indent"; 103 var textarea_toolbar3 ="SPACE,btHyperlink,btHyperlink_Email,btInsert_Image,btEmotions,btYouTube,SPACE,btQuote,btCode"; 104 105 var textarea_minibar ="SPACE,btFont_Name,btFont_Color,btHighlight,SPACE,btBold,btItalic,btUnderline,SPACE,btHyperlink,btEmotions,SPACE,btQuote,btCode"; 120 if (TitleText_Textarea == null) var TitleText_Textarea ="BBCode Editor"; 121 122 if (textarea_toolbar1 == null) { 123 var textarea_toolbar1 ="SPACE,btFont_Name,btFont_Size,btFont_Color,btHighlight,btRemove_Format,SPACE,btBold,btItalic,btUnderline"; 124 } 125 if (textarea_toolbar2 == null) { 126 var textarea_toolbar2 ="SPACE,btAlign_Left,btCenter,btAlign_Right,btJustify,SPACE,btCut,btCopy,btPaste,SPACE,btStrikethrough,btSubscript,btSuperscript,btHorizontal,SPACE,btBullets,btNumbering,btIncrease_Indent"; 127 } 128 if (textarea_toolbar3 == null) { 129 var textarea_toolbar3 ="SPACE,btHyperlink,btHyperlink_Email,btInsert_Image,btEmotions,btYouTube,SPACE,btQuote,btCode"; 130 } 131 if (textarea_minibar == null) { 132 var textarea_minibar ="SPACE,btFont_Name,btFont_Color,btHighlight,SPACE,btBold,btItalic,btUnderline,SPACE,btHyperlink,btEmotions,SPACE,btQuote,btCode"; 133 } 106 134 107 135 var array_fontname = new Array(); … … 138 166 array_fontcolor[60] ="#C00000";array_fontcolor[61] ="#FF0000";array_fontcolor[62] ="#FFC000";array_fontcolor[63] ="#FFFF00";array_fontcolor[64] ="#92D050";array_fontcolor[65] ="#00B050";array_fontcolor[66] ="#00B0F0";array_fontcolor[67] ="#0070C0";array_fontcolor[68] ="#002060";array_fontcolor[69] ="#7030A0"; 139 167 140 var safari_paste_command ="Please press key Command + V to paste text to editor."; 141 var safari_enter_text_link="Enter Text Link"; 142 var safari_bullets_numbering_prompt="Write your text here. Click Cancel button or press Escape when you're done"; 143 144 var flash_enter_url="Enter Flash URL"; 145 var flash_width_number_text="Enter Width number"; var flash_width_number_default=425; 146 var flash_height_number_text="Enter Height number"; var flash_height_number_default=350; 147 148 var enter_url_text="Enter a URL:"; 149 var enter_email_text="Enter Email Address:"; 150 var enter_image_url="Enter Image URL:"; 151 152 var capIESpell ="Spell check with IESpell"; 153 var alertNoIESpell ="IESpell Tool has not installed.\n\nWould you like to download and install it now?\n\nClick OK button to open IESpell download page in new window"; 154 var IESpellURL ="http://www.iespell.com/download.php"; 155 var IESpellError="Sorry! Your browser can't load IESpell"; 156 157 var capDesignModeTitle ="Switch On/Off WYSIWYG Mode"; 158 var capFont_Name ="Font Name"; 159 var capFont_Size ="Font Size"; 160 var capFont_Color ="Font Color"; 161 var capHighlight ="Highlight"; 162 var capRemove_Format ="Clear Formatting"; 163 var capBold ="Bold (Ctrl-B)"; 164 var capItalic ="Italic (Ctrl-I)"; 165 var capUnderline ="Underline (Ctrl-U)"; 166 var capAlign_Left ="Align Text Left"; 167 var capCenter ="Center"; 168 var capAlign_Right ="Align Text Right"; 169 var capJustify ="Justify"; 170 var capBreakLine ="Break (Shift Enter)"; 171 var capBullets ="Bullets"; 172 var capNumbering ="Numbering"; 173 var capDecrease_Indent ="Decrease Indent"; 174 var capIncrease_Indent ="Increase Indent"; 175 var capDecrease_Size ="Decrease Editor Size"; 176 var capIncrease_Size ="Increase Editor Size"; 177 var capQuote ="Wrap in [quote][/quote]"; 178 var capCode ="Wrap in [code][/code]"; 179 var capPHP ="Wrap in [php][/php]"; 180 var capHTML="Wrap in [html][/html]"; 181 var capMoreTags="View More Tags [xxx][/xxx]"; 182 183 var capFlash="Insert Flash"; 184 var capYouTube="Insert YouTube Video"; var promptYouTube="Enter YouTube video ID from the URL (v=XXXXXXXX)"; var URLDefaultYouTube="XXXXXXXX"; 185 var capGoogle="Insert Google Video"; var promptGoogle="Enter Google Video URL"; var URLDefaultGoogle="http://video.google.com/videoplay?docid=XXXXXXXXXXXXXX&hl=en"; 186 var capYahoo="Insert Yahoo Video"; var promptYahoo="Enter Yahoo Add to Site Code"; var URLDefaultYahoo="<embed src='http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player...........' type='application/x-shockwave-flash' width='425' height='350'></embed>"; 187 188 var capTable ="Insert Table"; 189 var capCut ="Cut (Ctrl-X)"; 190 var capCopy ="Copy (Ctrl-C)"; 191 var capPaste ="Paste (Ctrl-V)"; 192 var capUndo ="Undo (Ctrl-Z)"; 193 var capRedo ="Redo (Ctrl-Y)"; 194 var capHyperlink ="Insert Hyperlink (Ctrl-K)"; 195 var capHyperlink_Email ="Insert Email Link"; 196 var capRemovelink ="Remove Hyperlink"; 197 var capCalendar ="View Calendar / World Clock"; 198 var capInsert_Image ="Insert Image"; 199 var capClipart ="Insert Clipart"; 200 var capWordArt ="Insert WordArt"; 201 var capEmotions ="Insert your emotions"; 202 var capUpload ="Upload your own Photo"; 203 var capStrikethrough ="Strikethrough"; 204 var capSubscript ="Subscript"; 205 var capSuperscript ="Superscript"; 206 var capHorizontal ="Horizontal Line"; 207 var capSymbol ="Insert Symbol"; 208 var capVirtualKeyboard ="Open Virtual Keyboard"; 209 var capViewHTML ="View/Edit HTML source code"; 210 var capDelete_All ="Delete All"; 211 var capOnOff_RichText ="Switch On/Off WYSIWYG Mode"; 212 213 // Hoteditor code ----------------------------------------------------------- 168 var flash_width_number_default=425; 169 var flash_height_number_default=350; 170 171 // Hoteditor code - [ no more changes from here! ]--------------------------- 214 172 215 173 var bbNumbering = "list=1,*"; … … 448 406 document.getElementById("editor_switch" + a).src = styles_folder_path + "/" + "switch_richtext_off.gif"; 449 407 document.getElementById("switch_span" + a).className = "Hoteditor_DesignModeOff_TextColor"; 450 document.getElementById("change_title_editor" + a).innerHTML = TitleText_Tex area;408 document.getElementById("change_title_editor" + a).innerHTML = TitleText_Textarea; 451 409 var c = document.getElementById(a).contentWindow.document.body.innerHTML; 452 410 c = c.replace(/[\n\r]/gi, ""); … … 540 498 541 499 500 function autoresize(b, c) { 501 return; 502 while (document.getElementById(c).clientHeight < document.getElementById(c).scrollHeight) { 503 resize_editor('increase_size', b, c); 504 } 505 } 506 542 507 function writeRTE(a, b, c, d, e, f, g) { 543 508 if (Credit != "Rich Text Editor by www.eCardMax.com") { … … 556 521 document.write("<img align=absmiddle border=0 src=" + styles_folder_path + "/logo.gif> <span id=change_title_editor" + b + ">" + TitleText + "</span></td>\n"); 557 522 } else { 558 document.write("<img align=absmiddle border=0 src=" + styles_folder_path + "/logo.gif> <span id=change_title_editor" + b + ">" + TitleText_Tex area + "</span></td>\n");523 document.write("<img align=absmiddle border=0 src=" + styles_folder_path + "/logo.gif> <span id=change_title_editor" + b + ">" + TitleText_Textarea + "</span></td>\n"); 559 524 } 560 525 if (show_arrow_up_down == 1) { … … 690 655 j = j.replace(/\[\/table\]/gi, "\n[/table]"); 691 656 j = j.replace(/\[\/table\]$/gi, "[/table]\n"); 692 document.write("<center><textarea wrap=auto " + print_dir + " style='font-family:Verdana,Arial,Sans-Serif,Tahoma;font-size:12px;color: black;width:98%;height:" + e + "' class=Hoteditor_iTextarea id='textarea_" + b + "' name='textarea_" + b + "'>" + j + "</textarea></center>\n");657 document.write("<center><textarea wrap=auto " + print_dir + " style='font-family:Verdana,Arial,Sans-Serif,Tahoma;font-size:12px;color: black;width:98%;height:" + e + "' class=Hoteditor_iTextarea id='textarea_" + b + "' onkeyup='autoresize(\"" + b + "\",\"" + "textarea_" + b + "\");' name='textarea_" + b + "'>" + j + "</textarea></center>\n"); 693 658 if (isMacOS && isGecko) { 694 659 var h = ""; … … 949 914 write_button_textarea(capClipart, "insertclipart.gif", "", "insertclipart", b); 950 915 } else if (a == "btFont_Name") { 951 document.write("<select class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('font','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''> Fonts</option>");916 document.write("<select class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('font','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''>" + dropdownFonts + "</option>"); 952 917 for (i = 0; i < array_fontname.length; i++) { 953 918 document.write("<option value='" + array_fontname[i] + "'>" + array_fontname[i] + "</option>"); … … 957 922 var c = new Array; 958 923 var px = new Array(0, 6, 8,10,12,14,18,24,36); 959 document.write("<select style=\"width:52px\" class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('size','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''> Size</option>");924 document.write("<select style=\"width:52px\" class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('size','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''>" + dropdownSize + "</option>"); 960 925 for (i = 1; i < 9; i++) { 961 926 document.write("<option value='" + px[i] + "'>" + px[i] + "px</option>"); … … 963 928 document.write("</select><img src=" + styles_folder_path + "/button_space.gif>"); 964 929 } else if (a == "btFont_Color") { 965 document.write("<select style=\"width:60px\" class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('color','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''> Color</option>");930 document.write("<select style=\"width:60px\" class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('color','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''>" + dropdownColor + "</option>"); 966 931 for (i = 0; i < array_fontcolor.length; i++) { 967 932 document.write("<option style='background-color:" + array_fontcolor[i] + ";color:" + array_fontcolor[i] + "' value='" + array_fontcolor[i] + "'>" + array_fontcolor[i] + "</option>"); … … 969 934 document.write("</select><img src=" + styles_folder_path + "/button_space.gif>"); 970 935 } else if (a == "btHighlight") { 971 document.write("<select style=\"width:65px\" class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('highlight','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''> HiLight</option>");936 document.write("<select style=\"width:65px\" class=Hoteditor_iTextarea size=1 onchange=\"wrapSelection('highlight','=' + this.value,'" + b + "');this.selectedIndex='0';\"><option value=''>" + dropdownHighlight + "</option>"); 972 937 for (i = 0; i < array_fontcolor.length; i++) { 973 938 document.write("<option style='background-color:" + array_fontcolor[i] + ";color:" + array_fontcolor[i] + "' value='" + array_fontcolor[i] + "'>" + array_fontcolor[i] + "</option>"); … … 2070 2035 onerror = NoError; 2071 2036 2072 function mozWrap(a, b, c) { 2037 2038 // ExiteCMS: New wrapSelection function to deal with textarea's with scrollbars 2039 function wrapSelection(a, b, c) { 2073 2040 var d = document.getElementById(c); 2074 2041 var e = d.textLength; … … 2082 2049 var j = d.value.substring(g, e); 2083 2050 if (b == "HR" || b == "hr") { 2084 d.value = h + "[" + a + "]" + j; 2051 var startTag = "[" + a + "]"; 2052 var endTag = ""; 2085 2053 } else { 2086 2054 var k = ""; … … 2090 2058 } 2091 2059 } 2092 d.value = h + "[" + a + b + "]" + i + k + "[/" + a + "]" + j; 2093 } 2094 } 2095 2096 2097 function IEWrap(a, b, c) { 2098 strSelection = document.selection.createRange().text; 2099 document.getElementById(c).focus(); 2100 if (b == "HR" || b == "hr") { 2101 document.selection.createRange().text = "[" + a + "]"; 2102 } else { 2103 if (strSelection != "") { 2104 document.selection.createRange().text = "[" + a + b + "]" + strSelection + "[/" + a.replace(/=(.*?)$/g, "") + "]"; 2105 } else { 2106 if (a == "URL" || 2107 a == "url" || a == "MAIL" || a == "mail") { 2108 var d = b.replace("=", ""); 2109 document.selection.createRange().text = "[" + a + b + "]" + d + "[/" + a.replace(/=(.*?)$/g, "") + "]"; 2110 } else { 2111 document.selection.createRange().text = "[" + a + b + "]" + "[/" + a.replace(/=(.*?)$/g, "") + "]"; 2112 } 2113 } 2114 } 2115 } 2116 2117 2118 function wrapSelection(a, b, c) { 2119 if (isIE) { 2120 IEWrap(a, b, c); 2121 } else { 2122 mozWrap(a, b, c); 2123 } 2060 var startTag = "[" + a + b + "]" 2061 var endTag ="[/" + a + "]"; 2062 } 2063 var s=d.scrollTop; 2064 if(typeof d.selectionStart == 'number') { 2065 // Mozilla, Opera, and other browsers 2066 if (endTag != "") { 2067 d.value = h + startTag + i + k + endTag + j; 2068 } else { 2069 d.value = h + startTag + j; 2070 } 2071 d.focus(); 2072 d.selectionStart=f; 2073 d.selectionEnd=g+(d.value.length-e); 2074 } else if(document.selection) { 2075 // Internet Explorer 2076 d.focus(); 2077 var range = document.selection.createRange(); 2078 if(range.parentElement() != d) { 2079 return false; 2080 } 2081 if(typeof range.text == 'string') { 2082 document.selection.createRange().text = startTag + range.text + endTag; 2083 } 2084 d.focus(); 2085 } else { 2086 d.value += startTag + endTag; 2087 d.focus(); 2088 } 2089 d.scrollTop=s; 2124 2090 } 2125 2091 … … 2514 2480 o = o.replace(">" + n[1], ""); 2515 2481 var p = o.split(" "); 2516 o = p[0];2482 o = toAbsURL(p[0]); 2517 2483 if (k.style) { 2518 2484 if (n[1] == o) { … … 2631 2597 } else { 2632 2598 f.match(/<img(.*?)src="(.*?)"(.*?)>/gi); 2633 var s = RegExp.$2;2599 var s = toAbsURL(RegExp.$2); 2634 2600 s = s.replace("./", ""); 2635 2601 if (s.toLowerCase().substr(0, 7) != "http://" && s.toLowerCase().substr(0, 1) != "/") { … … 2645 2611 f = f.replace(/\<img(.*?)src="(.*?)"(.*?)>/gi, "[img]" + v + s + "[/img]"); 2646 2612 } else { 2647 f = f.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img] $2[/img]");2613 f = f.replace(/<img(.*?)src="(.*?)"(.*?)>/gi, "[img]" + s + "[/img]"); 2648 2614 } 2649 2615 } … … 2754 2720 return "#" + r + g + b; 2755 2721 } 2722 2723 function toAbsURL(s) { 2724 var l = location, h, p, f, i; 2725 if (/^\w+:/.test(s)) { 2726 return s; 2727 } 2728 h = l.protocol + '//' + l.host; 2729 if (s.indexOf('/') == 0) { 2730 return h + s; 2731 } 2732 p = l.pathname.replace(/\/[^\/]*$/, ''); 2733 f = s.match(/\.\.\//g); 2734 if (f) { 2735 s = s.substring(f.length * 3); 2736 for (i = f.length; i--;) { 2737 p = p.substring(0, p.lastIndexOf('/')); 2738 } 2739 } 2740 return h + p + '/' + s; 2741 }
Note: See TracChangeset
for help on using the changeset viewer.
