| 120 | | if (str.indexOf('%SEL%') >= 0 || str.indexOf('%HTMLSEL%') >= 0){ |
| 121 | | sel = win.getSelection().rangeCount()>0? win.getSelection().getRangeAt(0): ''; |
| 122 | | } |
| 123 | | if (str.indexOf('%HTMLSEL%') >= 0){ |
| 124 | | var serializer = new XMLSerializer(); |
| 125 | | htmlsel = serializer.serializeToString(sel.cloneContents()); |
| 126 | | } |
| 127 | | return str.replace(/%TITLE%/g,buffer.title) |
| 128 | | .replace(/%URL%/g,buffer.URL) |
| 129 | | .replace(/%SEL%/g,sel.toString()) |
| 130 | | .replace(/%HTMLSEL%/g,htmlsel); |
| | 120 | var selection = win.getSelection(); |
| | 121 | function replacer(value){ //{{{ |
| | 122 | switch(value){ |
| | 123 | case '%TITLE%': |
| | 124 | return buffer.title; |
| | 125 | case '%URL%': |
| | 126 | return buffer.URL; |
| | 127 | case '%SEL%': |
| | 128 | if (sel) |
| | 129 | return sel; |
| | 130 | else if (selection.rangeCount < 1) |
| | 131 | return ''; |
| | 132 | |
| | 133 | for (var i=0, c=selection.rangeCount; i<c; i++){ |
| | 134 | sel += selection.getRangeAt(i).toString(); |
| | 135 | } |
| | 136 | return sel; |
| | 137 | case '%HTMLSEL%': |
| | 138 | if (htmlsel) |
| | 139 | return sel; |
| | 140 | else if (selection.rangeCount < 1) |
| | 141 | return ''; |
| | 142 | |
| | 143 | var serializer = new XMLSerializer(); |
| | 144 | for (var i=0, c=selection.rangeCount; i<c; i++){ |
| | 145 | htmlsel += serializer.serializeToString(selection.getRangeAt(i).cloneContents()); |
| | 146 | } |
| | 147 | return htmlsel; |
| | 148 | } |
| | 149 | return ''; |
| | 150 | } //}}} |
| | 151 | return str.replace(/%(TITLE|URL|SEL|HTMLSEL)%/g, replacer); |