1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +00:00

More utilities

This commit is contained in:
Jeremy Ruston 2012-12-13 21:31:57 +00:00
parent ce273a22f1
commit 916ca8eecf

View File

@ -69,6 +69,19 @@ exports.removeArrayEntries = function(array,value) {
}
};
/*
Check whether any members of a hashmap are present in another hashmap
*/
exports.checkDependencies = function(dependencies,changes) {
var hit = false;
$tw.utils.each(changes,function(change,title) {
if($tw.utils.hop(dependencies,title)) {
hit = true;
}
});
return hit;
};
exports.deepCopy = function(object) {
var result,t;
if($tw.utils.isArray(object)) {
@ -302,6 +315,33 @@ exports.hyphenateCss = function(propName) {
});
};
/*
Parse a text reference in the format "title!!field" into its constituent parts
*/
exports.parseTextReference = function(textRef) {
// Look for a metadata field separator
var pos = textRef.indexOf("!!");
if(pos !== -1) {
if(pos === 0) {
// Just a field
return {
field: textRef.substring(2)
};
} else {
// Field and title
return {
title: textRef.substring(0,pos),
field: textRef.substring(pos + 2)
};
}
} else {
// Otherwise, we've just got a title
return {
title: textRef
};
}
};
/*
Extract the version number from the meta tag or from the boot file
*/