(doc,loadFileTextFn)
| 51 | |
| 52 | // Helper to inject overrides into TiddlyWiki Classic |
| 53 | function injectClassicOverrides(doc,loadFileTextFn) { |
| 54 | // Read classic-inject.js |
| 55 | var fs = require("fs"), |
| 56 | path = require("path"), |
| 57 | text = fs.readFileSync(path.resolve(path.dirname(module.filename),"classic-inject.js")); |
| 58 | // Add the source text of the file so that the injected loadFile function can access it |
| 59 | text += "\n\nwindow.tiddlywikiSourceText=\"" + stringify(loadFileTextFn()) + "\";" |
| 60 | // Inject it in a script tag |
| 61 | var script = doc.createElement("script"); |
| 62 | script.appendChild(doc.createTextNode(text)); |
| 63 | doc.getElementsByTagName("head")[0].appendChild(script); |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | Pad a string to a given length with "0"s. Length defaults to 2 |
no test coverage detected