MCPcopy
hub / github.com/Tampermonkey/tampermonkey / createScriptEditorTab

Function createScriptEditorTab

src/options.js:1248–1483  ·  view source on GitHub ↗
(i, tabd, close_cb)

Source from the content-addressed store, hash-verified

1246};
1247
1248var createScriptEditorTab = function(i, tabd, close_cb) {
1249
1250 var saveEm = null;
1251
1252 var tabh = cr('div', i.name, i.id, 'script_editor_h');
1253 var old = tabh.inserted;
1254
1255 tabh.textContent = I18N.getMessage('Editor');
1256 var tabc = cr('td', i.name, i.id, 'script_editor_c');
1257
1258 var container = crc('tr', 'editor_container p100100', i.name, i.id, 'container');
1259 var container_menu = crc('tr', 'editormenubar', i.name, i.id, 'container_menu');
1260 var container_o = crc('table', 'editor_container_o p100100 noborder', i.name, i.id, 'container_o');
1261
1262 container_o.appendChild(container_menu);
1263 container_o.appendChild(container);
1264 tabc.appendChild(container_o);
1265
1266 var saveEditor = function(cm, force) {
1267 if (saveEm) {
1268 if (saveEm(force)) {
1269 savedScript[i.id] = true;
1270 if (container.editor && gOptions.editor_enabled) container.editor.mirror.clearHistory();
1271 }
1272 }
1273 };
1274
1275 var closeEditor = function(cm, force) {
1276 if (close_cb) close_cb(force);
1277 };
1278
1279 var fullReset = function() {
1280 var cb = null;
1281 cb = function(r) {
1282 if (r.cleaned) {
1283 closeEditor();
1284 }
1285 }
1286 var ou = i_uu.input ? i_uu.input.oldvalue : "";
1287 var nu = i_uu.input ? i_uu.input.value : "";
1288
1289 var options = { old_url: ou,
1290 new_url: nu,
1291 clean: true,
1292 reload: true };
1293 saveScript(i.name, null, options, cb);
1294 };
1295
1296 var resetScript = function() {
1297 var c = confirm(I18N.getMessage("Really_reset_all_changes_"));
1298 if (c) {
1299 if (container.editor && gOptions.editor_enabled) {
1300 // set value clears history too
1301 container.editor.mirror.setValue(i.code);
1302 } else {
1303 input.textContent = i.code;
1304 }
1305 }

Callers 1

Calls 5

crFunction · 0.85
crcFunction · 0.85
closeEditorFunction · 0.85
saveScriptFunction · 0.85
doItFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…