* Inline JS compressor * @private * @param {String} html HTML. * @param {Number} index Last index. * @return {String}
(html, index, filename, nomarkup)
| 2588 | * @return {String} |
| 2589 | */ |
| 2590 | function compressJS(html, index, filename, nomarkup) { |
| 2591 | |
| 2592 | if (!CONF.allow_compile_script) |
| 2593 | return html; |
| 2594 | |
| 2595 | var strFrom = '<script type="text/javascript">'; |
| 2596 | var strTo = '</script>'; |
| 2597 | |
| 2598 | var indexBeg = html.indexOf(strFrom, index || 0); |
| 2599 | if (indexBeg === -1) { |
| 2600 | strFrom = '<script>'; |
| 2601 | indexBeg = html.indexOf(strFrom, index || 0); |
| 2602 | if (indexBeg === -1) |
| 2603 | return html; |
| 2604 | } |
| 2605 | |
| 2606 | var indexEnd = html.indexOf(strTo, indexBeg + strFrom.length); |
| 2607 | if (indexEnd === -1) |
| 2608 | return html; |
| 2609 | |
| 2610 | var js = html.substring(indexBeg, indexEnd + strTo.length).trim(); |
| 2611 | var beg = html.indexOf(js); |
| 2612 | if (beg === -1) |
| 2613 | return html; |
| 2614 | |
| 2615 | var val = js.substring(strFrom.length, js.length - strTo.length).trim(); |
| 2616 | var compiled = exports.compile_javascript(val, filename, nomarkup); |
| 2617 | html = html.replacer(js, strFrom + compiled.trim() + strTo.trim()); |
| 2618 | return compressJS(html, indexBeg + compiled.length + 9, filename, nomarkup); |
| 2619 | } |
| 2620 | |
| 2621 | function compressCSS(html, index, filename, nomarkup) { |
| 2622 |
no outgoing calls
no test coverage detected