2012-09-25 09:20:49 +09:00
|
|
|
t=function(message){
|
|
|
|
var d=new Date();
|
|
|
|
console.log("### "+message+" rendered at "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds());
|
|
|
|
}
|
|
|
|
|
|
|
|
nl2br= function(str) {
|
|
|
|
var breakTag = '<br />';
|
|
|
|
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
|
|
|
}
|
|
|
|
|
|
|
|
getSetting = function(setting){
|
|
|
|
var settings=Settings.find().fetch()[0];
|
|
|
|
if(settings){
|
|
|
|
return settings[setting];
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2012-10-04 14:54:26 +09:00
|
|
|
trackEvent = function(event, properties){
|
2012-10-01 11:45:18 +09:00
|
|
|
console.log('trackevent: ', event, properties);
|
2012-09-25 09:20:49 +09:00
|
|
|
var properties= (typeof properties === 'undefined') ? {} : properties;
|
2012-09-27 21:55:46 +02:00
|
|
|
if(typeof mixpanel.track != 'undefined'){
|
2012-09-25 09:20:49 +09:00
|
|
|
mixpanel.track(event, properties);
|
|
|
|
}
|
2012-09-25 10:51:43 +09:00
|
|
|
}
|
|
|
|
|
2012-10-04 10:09:20 +09:00
|
|
|
|
2012-09-25 10:51:43 +09:00
|
|
|
sessionSetObject=function(name, value){
|
|
|
|
Session.set(name, JSON.stringify(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
sessionGetObject=function(name){
|
|
|
|
return JSON.parse(Session.get(name));
|
2012-09-26 06:51:38 +09:00
|
|
|
}
|
2012-10-02 10:54:04 +09:00
|
|
|
getAuthorName = function(item){
|
|
|
|
// keep both variables for transition period
|
|
|
|
var id=item.userId || item.user_id;
|
|
|
|
// if item is linked to a user, get that user's display name. Else, return the author field.
|
|
|
|
return (id && (user=Meteor.users.findOne(id))) ? getDisplayName(user) : this.author;
|
2012-10-02 13:49:38 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
scrollPageTo = function(selector){
|
|
|
|
$('body').scrollTop($(selector).offset().top);
|
|
|
|
}
|
|
|
|
|
2012-10-04 13:30:57 +09:00
|
|
|
// sortJsonArrayByProperty= function(objArray, prop, direction){
|
|
|
|
// // http://stackoverflow.com/questions/4222690/sorting-a-json-object-in-javascript
|
|
|
|
// var direct = arguments.length>2 ? arguments[2] : 1; //Default to ascending
|
|
|
|
// if (objArray && objArray.constructor===Array){
|
|
|
|
// var propPath = (prop.constructor===Array) ? prop : prop.split(".");
|
|
|
|
// objArray.sort(function(a,b){
|
|
|
|
// for (var p in propPath){
|
|
|
|
// if (a[propPath[p]] && b[propPath[p]]){
|
|
|
|
// a = a[propPath[p]];
|
|
|
|
// b = b[propPath[p]];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// // convert numeric strings to integers
|
|
|
|
// a = a.match(/^\d+$/) ? +a : a;
|
|
|
|
// b = b.match(/^\d+$/) ? +b : b;
|
|
|
|
// return ( (a < b) ? -1*direct : ((a > b) ? 1*direct : 0) );
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|