MCPcopy
hub / github.com/TiddlyWiki/TiddlyDesktop / injectClassicOverrides

Function injectClassicOverrides

source/js/utils/saving.js:53–64  ·  view source on GitHub ↗
(doc,loadFileTextFn)

Source from the content-addressed store, hash-verified

51
52// Helper to inject overrides into TiddlyWiki Classic
53function 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/*
67Pad a string to a given length with "0"s. Length defaults to 2

Callers 1

saving.jsFile · 0.85

Calls 2

stringifyFunction · 0.85
loadFileTextFnFunction · 0.85

Tested by

no test coverage detected