Vulcan/packages/telescope-lib/lib/lib.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-07-18 09:18:52 +09:00
getSiteUrl = function () {
2015-03-28 18:30:26 +09:00
return Settings.get('siteUrl', Meteor.absoluteUrl());
2014-07-18 09:18:52 +09:00
};
2015-03-22 10:55:30 +09:00
removeSetting = function (setting) {
var settings = Settings.find().fetch()[0];
console.log(settings._id)
console.log(setting)
if(isAdmin(Meteor.user())) {
var unsetObject = {};
unsetObject[setting] = true;
var update = Settings.update(settings._id, {$unset: unsetObject});
}
};
getThemeSetting = function(setting, defaultValue){
if(typeof themeSettings[setting] !== 'undefined'){
return themeSettings[setting];
}else{
return typeof defaultValue === 'undefined' ? '' : defaultValue;
}
};
2014-07-18 09:18:52 +09:00
camelToDash = function (str) {
return str.replace(/\W+/g, '-').replace(/([a-z\d])([A-Z])/g, '$1-$2').toLowerCase();
2015-03-28 18:30:26 +09:00
};
2014-08-28 10:16:17 +09:00
camelCaseify = function(str) {
return dashToCamel(str.replace(' ', '-'));
2015-03-28 18:30:26 +09:00
};
2014-08-28 10:16:17 +09:00
dashToCamel = function (str) {
return str.replace(/(\-[a-z])/g, function($1){return $1.toUpperCase().replace('-','');});
2015-03-28 18:30:26 +09:00
};
2014-08-04 19:02:21 +09:00
trimWords = function(s, numWords) {
expString = s.split(/\s+/,numWords);
if(expString.length >= numWords)
return expString.join(" ")+"…";
return s;
};
capitalise = function (string) {
return string.charAt(0).toUpperCase() + string.slice(1);
2015-03-28 18:30:26 +09:00
};