mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Several fixes
1. Made crypto module optional 2. Moved hasOwnProperty into boot kernel 3. Fixed handling of modules in the browser
This commit is contained in:
parent
35d8ff871a
commit
bf75735db9
53
core/boot.js
53
core/boot.js
@ -47,7 +47,7 @@ $tw.crypto = new function() {
|
|||||||
getPassword();
|
getPassword();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
outputText = method(password,inputText);
|
outputText = $tw.crypto.sjcl[method](password,inputText);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
console.log("Crypto error:" + ex)
|
console.log("Crypto error:" + ex)
|
||||||
outputText = null;
|
outputText = null;
|
||||||
@ -64,14 +64,14 @@ $tw.crypto = new function() {
|
|||||||
password = newPassword;
|
password = newPassword;
|
||||||
}
|
}
|
||||||
this.encrypt = function(text) {
|
this.encrypt = function(text) {
|
||||||
return callSjcl($tw.crypto.sjcl.encrypt,text);
|
return callSjcl("encrypt",text);
|
||||||
};
|
};
|
||||||
this.decrypt = function(text) {
|
this.decrypt = function(text) {
|
||||||
return callSjcl($tw.crypto.sjcl.decrypt,text);
|
return callSjcl("decrypt",text);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$tw.crypto.sjcl = $tw.browser ? sjcl : require("./sjcl.js");
|
$tw.crypto.sjcl = $tw.browser ? window.sjcl : require("./sjcl.js");
|
||||||
|
|
||||||
// Boot information
|
// Boot information
|
||||||
$tw.boot = {};
|
$tw.boot = {};
|
||||||
@ -134,6 +134,15 @@ $tw.config.contentTypeInfo = {
|
|||||||
|
|
||||||
$tw.utils = $tw.utils || {};
|
$tw.utils = $tw.utils || {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check if an object has a property
|
||||||
|
*/
|
||||||
|
$tw.utils.hop = function(object,property) {
|
||||||
|
return Object.prototype.hasOwnProperty.call(object,property);
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Determine if a value is an array
|
Determine if a value is an array
|
||||||
*/
|
*/
|
||||||
@ -141,7 +150,9 @@ $tw.utils.isArray = function(value) {
|
|||||||
return Object.prototype.toString.call(value) == "[object Array]";
|
return Object.prototype.toString.call(value) == "[object Array]";
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert "&" to &, "<" to <, ">" to > and """ to "
|
/*
|
||||||
|
Convert "&" to &, "<" to <, ">" to > and """ to "
|
||||||
|
*/
|
||||||
$tw.utils.htmlDecode = function(s) {
|
$tw.utils.htmlDecode = function(s) {
|
||||||
return s.toString().replace(/</mg,"<").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
return s.toString().replace(/</mg,"<").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
||||||
};
|
};
|
||||||
@ -473,10 +484,16 @@ $tw.Wiki.prototype.registerModuleTiddlers = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Register and execute any modules in ordinary tiddlers
|
// Register and execute any modules in ordinary tiddlers
|
||||||
for(title in $tw.wiki.tiddlers) {
|
if($tw.browser) {
|
||||||
tiddler = $tw.wiki.getTiddler(title);
|
for(title in $tw.modules.titles) {
|
||||||
if(tiddler.fields.type === "application/javascript" && tiddler.fields["module-type"] !== undefined) {
|
$tw.modules.registerModuleExports(title,$tw.modules.titles[title].moduleType,$tw.modules.execute(title));
|
||||||
$tw.modules.registerModuleExports(title,tiddler.fields["module-type"],$tw.modules.execute(title));
|
}
|
||||||
|
} else {
|
||||||
|
for(title in $tw.wiki.tiddlers) {
|
||||||
|
tiddler = $tw.wiki.getTiddler(title);
|
||||||
|
if(tiddler.fields.type === "application/javascript" && tiddler.fields["module-type"] !== undefined) {
|
||||||
|
$tw.modules.registerModuleExports(title,tiddler.fields["module-type"],$tw.modules.execute(title));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -664,14 +681,16 @@ $tw.modules.registerModuleExports("$:/boot/tiddlerdeserializer/dom","tiddlerdese
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
t,result = [];
|
t,result = [];
|
||||||
for(t = 0; t < node.childNodes.length; t++) {
|
if(node) {
|
||||||
var tiddlers = extractTextTiddlers(node.childNodes[t]),
|
for(t = 0; t < node.childNodes.length; t++) {
|
||||||
childNode = node.childNodes[t];
|
var tiddlers = extractTextTiddlers(node.childNodes[t]),
|
||||||
tiddlers = tiddlers || extractModuleTiddlers(childNode);
|
childNode = node.childNodes[t];
|
||||||
tiddlers = tiddlers || extractEncryptedTiddlers(childNode);
|
tiddlers = tiddlers || extractModuleTiddlers(childNode);
|
||||||
if(tiddlers) {
|
tiddlers = tiddlers || extractEncryptedTiddlers(childNode);
|
||||||
result.push.apply(result,tiddlers);
|
if(tiddlers) {
|
||||||
}
|
result.push.apply(result,tiddlers);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,6 @@ Various static utility functions.
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Check if an object has a property
|
|
||||||
exports.hop = function(object,property) {
|
|
||||||
return Object.prototype.hasOwnProperty.call(object,property);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Push entries onto an array, removing them first if they already exist in the array
|
Push entries onto an array, removing them first if they already exist in the array
|
||||||
array: array to modify
|
array: array to modify
|
||||||
|
Loading…
Reference in New Issue
Block a user