mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 11:00:27 +00:00
More utilities
This commit is contained in:
parent
ce273a22f1
commit
916ca8eecf
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user