diff --git a/client/helpers/handlebars.js b/client/helpers/handlebars.js index 442a8f99f..c54814d87 100644 --- a/client/helpers/handlebars.js +++ b/client/helpers/handlebars.js @@ -3,7 +3,7 @@ Handlebars.registerHelper('eachWithRank', function(items, options) { // not used, forces multiple renders // note: cannot use this because it would delete and recreate all nodes - items.rewind() + items.rewind(); var out = ''; items.forEach(function(item, i){ var key = 'Branch-' + i; diff --git a/client/js/Markdown.Editor.js b/client/js/Markdown.Editor.js index 1aa0312ca..2f0fbe6c6 100644 --- a/client/js/Markdown.Editor.js +++ b/client/js/Markdown.Editor.js @@ -61,7 +61,7 @@ * image url (or null if the user cancelled). If this hook returns false, the default dialog will be used. */ - this.getConverter = function () { return markdownConverter; } + this.getConverter = function () { return markdownConverter; }; var that = this, panels; @@ -85,7 +85,7 @@ undoManager.setCommandMode(); f(); that.refreshPreview(); - } + }; } uiManager = new UIManager(idPostfix, panels, undoManager, previewManager, commandManager, help); @@ -96,7 +96,7 @@ forceRefresh(); }; - } + }; // before: contains all the text in the input box BEFORE the selection. // after: contains all the text in the input box AFTER the selection. @@ -157,8 +157,8 @@ if (remove) { beforeReplacer = afterReplacer = ""; } else { - beforeReplacer = function (s) { that.before += s; return ""; } - afterReplacer = function (s) { that.after = s + that.after; return ""; } + beforeReplacer = function (s) { that.before += s; return ""; }; + afterReplacer = function (s) { that.after = s + that.after; return ""; }; } this.selection = this.selection.replace(/^(\s*)/, beforeReplacer).replace(/(\s*)$/, afterReplacer); @@ -250,7 +250,7 @@ this.buttonBar = doc.getElementById("wmd-button-bar" + postfix); this.preview = doc.getElementById("wmd-preview" + postfix); this.input = doc.getElementById("wmd-input" + postfix); - }; + } // Returns true if the DOM element is visible, false if it's hidden. // Checks if display is anything other than none. @@ -262,7 +262,7 @@ } else if (elem.currentStyle) { // IE - return elem.currentStyle["display"] !== "none"; + return elem.currentStyle.display !== "none"; } }; @@ -332,7 +332,7 @@ pattern = pre + pattern + post; return new re(pattern, flags); - } + }; // UNFINISHED // The assignment in the while loop makes jslint cranky. @@ -650,7 +650,7 @@ this.text = inputArea.value; } - } + }; // Sets the selected text in the input box after we've performed an // operation. @@ -767,7 +767,7 @@ this.scrollTop = chunk.scrollTop; }; this.init(); - }; + } function PreviewManager(converter, panels, previewRefreshCallback) { @@ -902,11 +902,11 @@ parent.appendChild(preview); else parent.insertBefore(preview, sibling); - } + }; var nonSuckyBrowserPreviewSet = function (text) { panels.preview.innerHTML = text; - } + }; var previewSetter; @@ -962,7 +962,7 @@ }; init(); - }; + } // Creates the background behind the hyperlink text entry box. // And download dialog @@ -1321,7 +1321,7 @@ if (button.execute) { button.execute(undoManager); } - }; + } function setupButton(button, isEnabled) { @@ -1359,7 +1359,7 @@ } doClick(this); return false; - } + }; } } else { @@ -1371,7 +1371,7 @@ function bindCommand(method) { if (typeof method === "string") method = commandManager[method]; - return function () { method.apply(commandManager, arguments); } + return function () { method.apply(commandManager, arguments); }; } function makeSpritedButtonRow() { @@ -1409,7 +1409,7 @@ spacer.id = "wmd-spacer" + num + postfix; buttonRow.appendChild(spacer); xPosition += 25; - } + }; buttons.bold = makeButton("wmd-bold-button", "Strong Ctrl+B", "0px", bindCommand("doBold")); buttons.italic = makeButton("wmd-italic-button", "Emphasis Ctrl+I", "-20px", bindCommand("doItalic")); @@ -1467,7 +1467,7 @@ setupButton(buttons.undo, undoManager.canUndo()); setupButton(buttons.redo, undoManager.canRedo()); } - }; + } this.setUndoRedoButtonStates = setUndoRedoButtonStates; @@ -2154,7 +2154,7 @@ chunk.startTag = "----------\n"; chunk.selection = ""; chunk.skipLines(2, 1, true); - } + }; })(); \ No newline at end of file diff --git a/client/js/Markdown.Sanitizer.js b/client/js/Markdown.Sanitizer.js index cc5826fa8..4f4e7553b 100644 --- a/client/js/Markdown.Sanitizer.js +++ b/client/js/Markdown.Sanitizer.js @@ -13,7 +13,7 @@ converter.hooks.chain("postConversion", sanitizeHtml); converter.hooks.chain("postConversion", balanceTags); return converter; - } + }; function sanitizeHtml(html) { return html.replace(/<[^>]*>?/gi, sanitizeTag); diff --git a/client/js/autolink.js b/client/js/autolink.js index 221a779e1..0694c6881 100644 --- a/client/js/autolink.js +++ b/client/js/autolink.js @@ -1,2 +1,2 @@ //https://github.com/bryanwoods/autolink-js -(function(){var a,b=[].slice;a=function(){var j,i,d,f,e,c,g,h;c=1<=arguments.length?b.call(arguments,0):[];g=/(^|\s)(\b(https?):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|]\b)/ig;if(c.length>0){e=c[0];i=e.callback;if((i!=null)&&typeof i==="function"){j=i;delete e.callback}f="";for(d in e){h=e[d];f+=" "+d+"='"+h+"'"}return this.replace(g,function(l,o,k){var n,m;m=j&&j(k);n=m||(""+k+"");return""+o+n})}else{return this.replace(g,"$1$2")}};String.prototype.autoLink=a}).call(this); +(function(){var a,b=[].slice;a=function(){var j,i,d,f,e,c,g,h;c=1<=arguments.length?b.call(arguments,0):[];g=/(^|\s)(\b(https?):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|]\b)/ig;if(c.length>0){e=c[0];i=e.callback;if((i!=null)&&typeof i==="function"){j=i;delete e.callback;}f="";for(d in e){h=e[d];f+=" "+d+"='"+h+"'";}return this.replace(g,function(l,o,k){var n,m;m=j&&j(k);n=m||(""+k+"");return""+o+n;});}else{return this.replace(g,"$1$2");}};String.prototype.autoLink=a;}).call(this); diff --git a/client/js/bootstrap-datepicker.js b/client/js/bootstrap-datepicker.js index 8875ec124..9e109aee9 100644 --- a/client/js/bootstrap-datepicker.js +++ b/client/js/bootstrap-datepicker.js @@ -171,7 +171,7 @@ fillMonths: function(){ var html = ''; - var i = 0 + var i = 0; while (i < 12) { html += ''+DPGlobal.dates.monthsShort[i++]+''; } @@ -362,10 +362,10 @@ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }, isLeapYear: function (year) { - return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) + return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)); }, getDaysInMonth: function (year, month) { - return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] + return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }, parseFormat: function(format){ var separator = format.match(/[.\/\-\s].*?/), @@ -451,4 +451,4 @@ ''+ ''; -}( window.jQuery ) \ No newline at end of file +}( window.jQuery ); \ No newline at end of file diff --git a/collections/categories.js b/collections/categories.js index 01e50e3bf..def1359f9 100644 --- a/collections/categories.js +++ b/collections/categories.js @@ -9,7 +9,7 @@ Categories.allow({ Meteor.methods({ category: function(category){ if (!Meteor.user() || !isAdmin(Meteor.user())) - throw new Meteor.Error(i18n.t('You need to login and be an admin to add a new category.')) + throw new Meteor.Error(i18n.t('You need to login and be an admin to add a new category.')); var categoryId=Categories.insert(category); return category.name; } diff --git a/collections/errors.js b/collections/errors.js index 1cb21b900..f69782d95 100644 --- a/collections/errors.js +++ b/collections/errors.js @@ -6,4 +6,4 @@ throwError = function(message, type){ type = (typeof type === 'undefined') ? 'error': type; // Store errors in the 'Errors' local collection Errors.insert({message:message, type:type, seen: false, show:true}); -} +}; diff --git a/collections/notifications.js b/collections/notifications.js index a4722c8f8..15524b948 100644 --- a/collections/notifications.js +++ b/collections/notifications.js @@ -23,7 +23,7 @@ getNotificationContents = function(notification, context){ subject: 'Someone replied to your comment on "'+p.postHeadline+'"', text: p.commentAuthorName+' has replied to your comment on "'+p.postHeadline+'": '+getPostCommentUrl(p.postId, p.commentId), html: '

'+p.commentAuthorName+' has replied to your comment on "'+p.postHeadline+'"

' - } + }; if(context == 'email') n.html += '

'+p.commentExcerpt+'

Read more'; break; @@ -33,7 +33,7 @@ getNotificationContents = function(notification, context){ subject: 'A new comment on your post "'+p.postHeadline+'"', text: 'You have a new comment by '+p.commentAuthorName+' on your post "'+p.postHeadline+'": '+getPostCommentUrl(p.postId, p.commentId), html: '

'+p.commentAuthorName+' left a new comment on your post "'+p.postHeadline+'"

' - } + }; if(context == 'email') n.html += '

'+p.commentExcerpt+'

Read more'; break; @@ -43,7 +43,7 @@ getNotificationContents = function(notification, context){ subject: p.postAuthorName+' has created a new post: "'+p.postHeadline+'"', text: p.postAuthorName+' has created a new post: "'+p.postHeadline+'" '+getPostUrl(p.postId), html: ''+p.postAuthorName+' has created a new post: "'+p.postHeadline+'".' - } + }; break; case 'accountApproved': @@ -51,7 +51,7 @@ getNotificationContents = function(notification, context){ subject: 'Your account has been approved.', text: 'Welcome to '+getSetting('title')+'! Your account has just been approved.', html: 'Welcome to '+getSetting('title')+'!
Your account has just been approved. Start posting.' - } + }; break; case 'newUser': @@ -59,7 +59,7 @@ getNotificationContents = function(notification, context){ subject: 'New user: '+p.username, text: 'A new user account has been created: '+p.profileUrl, html: 'A new user account has been created: '+p.username+'' - } + }; break; default: @@ -74,7 +74,7 @@ getNotificationContents = function(notification, context){ } return n; -} +}; Meteor.methods({ markAllNotificationsAsRead: function() { diff --git a/collections/posts.js b/collections/posts.js index 379f3c8e5..aa2815142 100644 --- a/collections/posts.js +++ b/collections/posts.js @@ -39,7 +39,7 @@ Meteor.methods({ // only let admins post as another user if(isAdmin(Meteor.user())) - userId = post.userId || user._id + userId = post.userId || user._id; // check that user can post if (!user || !canPost(user)) @@ -105,7 +105,7 @@ Meteor.methods({ postHeadline : headline, postId : postId } - } + }; // call a server method because we do not have access to users' info on the client Meteor.call('newPostNotify', notification, function(error, result){ //run asynchronously diff --git a/lib/Markdown.Converter.js b/lib/Markdown.Converter.js index deef866f2..9804cdd86 100644 --- a/lib/Markdown.Converter.js +++ b/lib/Markdown.Converter.js @@ -67,7 +67,7 @@ else if (original === identity) this[hookname] = func; else - this[hookname] = function (x) { return func(original(x)); } + this[hookname] = function (x) { return func(original(x)); }; }, set: function (hookname, func) { if (!this[hookname]) @@ -251,8 +251,8 @@ else // "paragraphs" that are wrapped in non-block-level tags, such as anchors, // phrase emphasis, and spans. The list of tags we're looking for is // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" + var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"; + var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"; // First, look for nested blocks, e.g.: //
@@ -1137,7 +1137,7 @@ else else if (/\S/.test(str)) { str = _RunSpanGamut(str); str = str.replace(/^([ \t]*)/g, "

"); - str += "

" + str += "

"; grafsOut.push(str); } @@ -1206,7 +1206,7 @@ else // autolink anything like - var replacer = function (wholematch, m1) { return "" + pluginHooks.plainLinkText(m1) + ""; } + var replacer = function (wholematch, m1) { return "" + pluginHooks.plainLinkText(m1) + ""; }; text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer); // Email addresses: @@ -1257,7 +1257,7 @@ else text = text.replace(/^(\t|[ ]{1,4})/gm, "~0"); // attacklab: g_tab_width // attacklab: clean up hack - text = text.replace(/~0/g, "") + text = text.replace(/~0/g, ""); return text; } @@ -1299,7 +1299,7 @@ else return "%24"; if (match == ":") { if (offset == len - 1 || /[0-9\/]/.test(url.charAt(offset + 1))) - return ":" + return ":"; } return "%" + match.charCodeAt(0).toString(16); }); diff --git a/lib/analytics.js b/lib/analytics.js index 02d395647..d034a42d7 100644 --- a/lib/analytics.js +++ b/lib/analytics.js @@ -17,17 +17,17 @@ analyticsInit = _.once(function() { var c = b.split("."); 2 == c.length && (a = a[c[0]], b = c[1]); a[b] = function () { - a.push([b].concat(Array.prototype.slice.call(arguments, 0))) - } + a.push([b].concat(Array.prototype.slice.call(arguments, 0))); + }; } var g = a; "undefined" !== typeof f ? g = a[f] = [] : f = "mixpanel"; g.people = g.people || []; h = "disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.identify people.set people.increment".split(" "); for (e = 0; e < h.length; e++) d(g, h[e]); - a._i.push([b, c, f]) + a._i.push([b, c, f]); }; - a.__SV = 1.1 + a.__SV = 1.1; })(document, window.mixpanel || []); mixpanel.init(mixpanelId); } @@ -36,7 +36,7 @@ analyticsInit = _.once(function() { if (goSquaredId = getSetting("goSquaredId")) { window.GoSquared = {}; GoSquared.acct = goSquaredId; - window._gstc_lt = +new Date; + window._gstc_lt = +new Date(); var d = document, g = d.createElement("script"); g.type = "text/javascript"; g.src = "//d1l6p2sc9645hc.cloudfront.net/tracker.js"; @@ -110,4 +110,4 @@ analyticsRequest = function() { clicky.log(encodeURIComponent(window.location.pathname), getCurrentTemplate(), "pageview"); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/deepExtend.js b/lib/deepExtend.js index b9984d73f..1cca463a8 100644 --- a/lib/deepExtend.js +++ b/lib/deepExtend.js @@ -22,35 +22,35 @@ deepExtend = function () { }, jQuery = { isFunction: function (obj) { - return jQuery.type(obj) === "function" + return jQuery.type(obj) === "function"; }, isArray: Array.isArray || function (obj) { - return jQuery.type(obj) === "array" + return jQuery.type(obj) === "array"; }, isWindow: function (obj) { - return obj != null && obj == obj.window + return obj != null && obj == obj.window; }, isNumeric: function (obj) { - return !isNaN(parseFloat(obj)) && isFinite(obj) + return !isNaN(parseFloat(obj)) && isFinite(obj); }, type: function (obj) { - return obj == null ? String(obj) : class2type[toString.call(obj)] || "object" + return obj == null ? String(obj) : class2type[toString.call(obj)] || "object"; }, isPlainObject: function (obj) { if (!obj || jQuery.type(obj) !== "object" || obj.nodeType) { - return false + return false; } try { if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { - return false + return false; } } catch (e) { - return false + return false; } var key; for (key in obj) {} - return key === undefined || hasOwn.call(obj, key) + return key === undefined || hasOwn.call(obj, key); } }; if (typeof target === "boolean") { @@ -59,7 +59,7 @@ deepExtend = function () { i = 2; } if (typeof target !== "object" && !jQuery.isFunction(target)) { - target = {} + target = {}; } if (length === i) { target = this; @@ -71,12 +71,12 @@ deepExtend = function () { src = target[name]; copy = options[name]; if (target === copy) { - continue + continue; } if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) { if (copyIsArray) { copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : [] + clone = src && jQuery.isArray(src) ? src : []; } else { clone = src && jQuery.isPlainObject(src) ? src : {}; } @@ -89,4 +89,4 @@ deepExtend = function () { } } return target; - } \ No newline at end of file + }; \ No newline at end of file diff --git a/lib/events.js b/lib/events.js index 751ee0c3d..ed6f000da 100644 --- a/lib/events.js +++ b/lib/events.js @@ -11,4 +11,4 @@ trackEvent = function(event, properties){ GoSquared.DefaultTracker.TrackEvent(event, JSON.stringify(properties)); } } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/gravatar.js b/lib/gravatar.js index d8fbf622e..149eb33d6 100644 --- a/lib/gravatar.js +++ b/lib/gravatar.js @@ -9,7 +9,7 @@ Gravatar = { var hash = user.email_hash; var url = protocol + '://www.gravatar.com/avatar/' + hash; - var params = _.map(options, function(val, key) { return key + "=" + val}).join('&'); + var params = _.map(options, function(val, key) { return key + "=" + val;}).join('&'); if (params !== '') url += '?' + params; @@ -21,4 +21,4 @@ Gravatar = { return 'http://graph.facebook.com/'+user.services.facebook.id+'/picture';//for the oauth-login avatar, diff for diff oauth, maybe it could be better } } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/helpers.js b/lib/helpers.js index 122351c48..9d9d1fb11 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -4,34 +4,34 @@ getSetting = function(setting, defaultValue){ return settings[setting]; } return typeof defaultValue === 'undefined' ? '' : defaultValue; -} +}; getCurrentTemplate = function() { return Router._currentController.template; -} +}; getCurrentRoute = function() { return Router._currentController.path; -} +}; clearSeenErrors = function(){ Errors.update({seen:true}, {$set: {show:false}}, {multi:true}); -} +}; t=function(message){ var d=new Date(); console.log("### "+message+" rendered at "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()); -} +}; nl2br= function(str) { var breakTag = '
'; return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); -} +}; getAuthorName = function(item){ // since we are not publishing the user collection except for admins, just display the normalized author field return item.author; -} +}; scrollPageTo = function(selector){ $('body').scrollTop($(selector).offset().top); -} +}; getDigestURL = function(moment){ - return '/digest/'+moment.year()+'/'+(moment.month()+1)+'/'+moment.date() -} + return '/digest/'+moment.year()+'/'+(moment.month()+1)+'/'+moment.date(); +}; getDateRange= function(pageNumber){ var now = moment(new Date()); var dayToDisplay=now.subtract('days', pageNumber-1); @@ -41,7 +41,7 @@ getDateRange= function(pageNumber){ // console.log("after: ", dayToDisplay.startOf('day').format("dddd, MMMM Do YYYY, h:mm:ss a")); // console.log("before: ", dayToDisplay.endOf('day').format("dddd, MMMM Do YYYY, h:mm:ss a")); return range; -} +}; // getPostCategories = function(post){ // var postCategories = _.map(post.categories, function(categoryId){ // return Categories.findOne(categoryId); @@ -53,23 +53,23 @@ getDateRange= function(pageNumber){ // ---------------------------------- URL Helper Functions ----------------------------------- // goTo = function(url){ Router.go(url); -} +}; getPostUrl = function(id){ return Meteor.absoluteUrl()+'posts/'+id; -} +}; getPostEditUrl = function(id){ return Meteor.absoluteUrl()+'posts/'+id+'/edit'; -} +}; getCommentUrl = function(id){ return Meteor.absoluteUrl()+'comments/'+id; -} +}; getPostCommentUrl = function(postId, commentId){ // get link to a comment on a post page return Meteor.absoluteUrl()+'posts/'+postId+'/comment/'+commentId; -} +}; getCategoryUrl = function(slug){ return Meteor.absoluteUrl()+'category/'+slug; -} +}; slugify = function(text) { if(text){ text = text.replace(/[^-a-zA-Z0-9,&\s]+/ig, ''); @@ -78,38 +78,38 @@ slugify = function(text) { text = text.toLowerCase(); } return text; -} +}; getShortUrl = function(post){ return post.shortUrl ? post.shortUrl : post.url; -} +}; getDomain = function(url){ urlObject = Npm.require('url'); return urlObject.parse(url).hostname; -} +}; invitesEnabled = function () { return getSetting("requireViewInvite") || getSetting("requirePostInvite"); -} +}; getOutgoingUrl = function(url){ return Meteor.absoluteUrl() + 'out?url=' + encodeURIComponent(url); -} +}; // ---------------------------------- String Helper Functions ----------------------------------- // cleanUp = function(s){ return stripHTML(s); -} +}; stripHTML = function(s){ return s.replace(/<(?:.|\n)*?>/gm, ''); -} +}; stripMarkdown = function(s){ var converter = new Markdown.Converter(); var html_body = converter.makeHtml(s); return stripHTML(html_body); -} +}; trimWords = function(s, numWords) { expString = s.split(/\s+/,numWords); if(expString.length >= numWords) return expString.join(" ")+"…"; return s; -} +}; // http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key checkNested = function(obj /*, level1, level2, ... levelN*/) { @@ -123,4 +123,4 @@ checkNested = function(obj /*, level1, level2, ... levelN*/) { obj = obj[args[i]]; } return true; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/locales/es.js b/lib/locales/es.js index 0db77804d..99575dca3 100644 --- a/lib/locales/es.js +++ b/lib/locales/es.js @@ -187,4 +187,4 @@ i18n.translations.es = { "Please log in first": "Por favor, inicia sesión", "Sign In/Sign Up with Twitter": "Inicia sesión/Inscribete con Twitter", "Load more": "Cargar más" -} +}; diff --git a/lib/parameters.js b/lib/parameters.js index a391c72ce..018280d33 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -15,7 +15,7 @@ getParameters = function (terms) { options: { limit: 10 } - } + }; switch (terms.view) { @@ -72,7 +72,7 @@ getParameters = function (terms) { } // sort by _id to break ties - deepExtend(true, parameters, {options: {sort: {_id: -1}}}) + deepExtend(true, parameters, {options: {sort: {_id: -1}}}); if(typeof terms.limit != 'undefined' && !!terms.limit) _.extend(parameters.options, {limit: parseInt(terms.limit)}); @@ -83,7 +83,7 @@ getParameters = function (terms) { // console.log(parameters) return parameters; -} +}; getUsersParameters = function(filterBy, sortBy, limit) { var find = {}, @@ -121,4 +121,4 @@ getUsersParameters = function(filterBy, sortBy, limit) { find: find, options: {sort: sort, limit: limit} }; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/permissions.js b/lib/permissions.js index 049e55a03..f49f2744d 100644 --- a/lib/permissions.js +++ b/lib/permissions.js @@ -24,7 +24,7 @@ canView = function(user){ } return true; -} +}; canViewById = function(userId, returnError){ // if an invite is required to view, run permission check, else return true if(getSetting('requireViewInvite', false)){ @@ -32,7 +32,7 @@ canViewById = function(userId, returnError){ return userId ? canView(Meteor.users.findOne(userId), returnError) : false; } return true; -} +}; canPost = function(user, returnError){ var user=(typeof user === 'undefined') ? Meteor.user() : user; @@ -51,32 +51,32 @@ canPost = function(user, returnError){ } else { return true; } -} +}; canPostById = function(userId, returnError){ var user = Meteor.users.findOne(userId); return canPost(user, returnError); -} +}; canComment = function(user, returnError){ return canPost(user, returnError); -} +}; canCommentById = function(userId, returnError){ var user = Meteor.users.findOne(userId); return canComment(user, returnError); -} +}; canUpvote = function(user, collection, returnError){ return canPost(user, returnError); -} +}; canUpvoteById = function(userId, returnError){ var user = Meteor.users.findOne(userId); return canUpvote(user, returnError); -} +}; canDownvote = function(user, collection, returnError){ return canPost(user, returnError); -} +}; canDownvoteById = function(userId, returnError){ var user = Meteor.users.findOne(userId); return canDownvote(user, returnError); -} +}; canEdit = function(user, item, returnError){ var user=(typeof user === 'undefined') ? Meteor.user() : user; @@ -89,14 +89,14 @@ canEdit = function(user, item, returnError){ }else { return true; } -} +}; canEditById = function(userId, item){ var user = Meteor.users.findOne(userId); return canEdit(user, item); -} +}; currentUserCanEdit = function(item) { return canEdit(Meteor.user(), item); -} +}; canInvite = function(user){ return isInvited(user) || isAdmin(user); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/router.js b/lib/router.js index db57f513d..591dc9cae 100644 --- a/lib/router.js +++ b/lib/router.js @@ -128,7 +128,7 @@ var filters = { isLoggedIn: function() { if (!(Meteor.loggingIn() || Meteor.user())) { - throwError(i18n.t('Please Sign In First.')) + throwError(i18n.t('Please Sign In First.')); this.render('signin'); this.stop(); } @@ -144,7 +144,7 @@ var filters = { isAdmin: function() { if(!this.ready()) return; if(!isAdmin()){ - throwError(i18n.t("Sorry, you have to be an admin to view this page.")) + throwError(i18n.t("Sorry, you have to be an admin to view this page.")); this.render('no_rights'); this.stop(); } @@ -153,7 +153,7 @@ var filters = { canView: function() { if(!this.ready()) return; if(!canView()){ - console.log('cannot view') + console.log('cannot view'); this.render('no_rights'); this.stop(); } @@ -162,7 +162,7 @@ var filters = { canPost: function () { if(!this.ready()) return; if(!canPost()){ - throwError(i18n.t("Sorry, you don't have permissions to add new items.")) + throwError(i18n.t("Sorry, you don't have permissions to add new items.")); this.render('no_rights'); this.stop(); } @@ -173,7 +173,7 @@ var filters = { // Already subscribed to this post by route({waitOn: ...}) var post = Posts.findOne(this.params._id); if(!currentUserCanEdit(post)){ - throwError(i18n.t("Sorry, you cannot edit this post.")) + throwError(i18n.t("Sorry, you cannot edit this post.")); this.render('no_rights'); this.stop(); } @@ -184,7 +184,7 @@ var filters = { // Already subscribed to this commit by CommentPageController var comment = Comments.findOne(this.params._id); if(!currentUserCanEdit(comment)){ - throwError(i18n.t("Sorry, you cannot edit this comment.")) + throwError(i18n.t("Sorry, you cannot edit this comment.")); this.render('no_rights'); this.stop(); } @@ -199,7 +199,7 @@ var filters = { } } -} +}; if(Meteor.isClient){ @@ -253,7 +253,7 @@ if(Meteor.isClient){ Router.after(filters.resetScroll, {except:['posts_top', 'posts_new', 'posts_best', 'posts_pending', 'posts_category', 'all-users']}); Router.after( function () { analyticsInit(); // will only run once thanks to _.once() - analyticsRequest() // log this request with mixpanel, etc + analyticsRequest(); // log this request with mixpanel, etc }); // Unload Hooks @@ -287,7 +287,7 @@ PostsListController = FastRender.RouteController.extend({ return [ Meteor.subscribe('postsList', this._terms), Meteor.subscribe('postsListUsers', this._terms) - ] + ]; }, data: function () { var parameters = getParameters(this._terms), @@ -299,7 +299,7 @@ PostsListController = FastRender.RouteController.extend({ return { postsList: posts, postsCount: postsCount - } + }; }, after: function() { var view = this.path == '/' ? 'top' : this.path.split('/')[1]; @@ -318,11 +318,11 @@ PostsDigestController = FastRender.RouteController.extend({ view: 'digest', after: moment(currentDate).startOf('day').valueOf(), before: moment(currentDate).endOf('day').valueOf() - } + }; return [ Meteor.subscribe('postsList', terms), Meteor.subscribe('postsListUsers', terms) - ] + ]; }, data: function() { var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today'), @@ -335,7 +335,7 @@ PostsDigestController = FastRender.RouteController.extend({ Session.set('currentDate', currentDate); return { posts: Posts.find(parameters.find, parameters.options) - } + }; } }); @@ -368,12 +368,12 @@ CommentPageController = FastRender.RouteController.extend({ Meteor.subscribe('singleComment', this.params._id), Meteor.subscribe('commentUser', this.params._id), Meteor.subscribe('commentPost', this.params._id) - ] + ]; }, data: function() { return { comment: Comments.findOne(this.params._id) - } + }; }, after: function () { window.queueComments = false; @@ -395,7 +395,7 @@ UserPageController = FastRender.RouteController.extend({ }else{ return { user: (typeof findById == "undefined") ? findBySlug : findById - } + }; } } }); @@ -560,7 +560,7 @@ Router.map(function() { data: function() { return { user: Meteor.user() - } + }; } }); @@ -587,7 +587,7 @@ Router.map(function() { users: Meteor.users.find(parameters.find, parameters.options), filterBy: filterBy, sortBy: sortBy - } + }; }, fastRender: true }); @@ -599,7 +599,7 @@ Router.map(function() { data: function() { return { hash: this.params.hash - } + }; } }); diff --git a/lib/users.js b/lib/users.js index 6df117af1..8e33813c5 100644 --- a/lib/users.js +++ b/lib/users.js @@ -1,37 +1,37 @@ isAdminById=function(userId){ var user = Meteor.users.findOne(userId); return !!(user && isAdmin(user)); -} +}; isAdmin=function(user){ user = (typeof user === 'undefined') ? Meteor.user() : user; return !!user && !!user.isAdmin; -} +}; isInvited=function(user){ if(!user || typeof user === 'undefined') return false; return isAdmin(user) || !!user.isInvited; -} +}; adminUsers = function(){ return Meteor.users.find({isAdmin : true}).fetch(); -} +}; getUserName = function(user){ return user.username; -} +}; getDisplayName = function(user){ return (user.profile && user.profile.name) ? user.profile.name : user.username; -} +}; getDisplayNameById = function(userId){ return getDisplayName(Meteor.users.findOne(userId)); -} +}; getProfileUrl = function(user) { return Meteor.absoluteUrl()+'users/' + slugify(getUserName(user)); -} +}; getProfileUrlById = function(id){ return Meteor.absoluteUrl()+'users/'+ id; -} +}; getProfileUrlBySlug = function(slug) { return Meteor.absoluteUrl()+'users/' + slug; -} +}; getTwitterName = function(user){ // return twitter name provided by user, or else the one used for twitter login if(checkNested(user, 'profile', 'twitter')){ @@ -40,7 +40,7 @@ getTwitterName = function(user){ return user.services.twitter.screenName; } return null; -} +}; getGitHubName = function(user){ // return twitter name provided by user, or else the one used for twitter login if(checkNested(user, 'profile', 'github')){ @@ -49,10 +49,10 @@ getGitHubName = function(user){ return user.services.github.screenName; } return null; -} +}; getTwitterNameById = function(userId){ return getTwitterName(Meteor.users.findOne(userId)); -} +}; getSignupMethod = function(user){ if(user.services && user.services.twitter){ return 'twitter'; @@ -61,14 +61,14 @@ getSignupMethod = function(user){ }else{ return 'regular'; } -} +}; getEmail = function(user){ if(user.profile && user.profile.email){ return user.profile.email; }else{ return ''; } -} +}; getAvatarUrl = function(user){ if(getSignupMethod(user)=='twitter'){ return 'http://twitter.com/api/users/profile_image/'+user.services.twitter.screenName; @@ -80,24 +80,24 @@ getAvatarUrl = function(user){ s: 80 }); } -} +}; getCurrentUserEmail = function(){ return Meteor.user() ? getEmail(Meteor.user()) : ''; -} +}; userProfileComplete = function(user) { return !!getEmail(user); -} +}; findLast = function(user, collection){ return collection.findOne({userId: user._id}, {sort: {createdAt: -1}}); -} +}; timeSinceLast = function(user, collection){ var now = new Date().getTime(); var last = findLast(user, collection); if(!last) return 999; // if this is the user's first post or comment ever, stop here return Math.abs(Math.floor((now-last.createdAt)/1000)); -} +}; numberOfItemsInPast24Hours = function(user, collection){ var mDate = moment(new Date()); var items=collection.find({ @@ -107,22 +107,22 @@ numberOfItemsInPast24Hours = function(user, collection){ } }); return items.count(); -} +}; getUserSetting = function(setting, defaultValue, user){ var user = (typeof user == 'undefined') ? Meteor.user() : user; var defaultValue = (typeof defaultValue == "undefined") ? null: defaultValue; var settingValue = getProperty(user.profile, setting); return (settingValue == null) ? defaultValue : settingValue; -} +}; getProperty = function(object, property){ // recursive function to get nested properties var array = property.split('.'); if(array.length > 1){ var parent = array.shift(); // if our property is not at this level, call function again one level deeper if we can go deeper, else return null - return (typeof object[parent] == "undefined") ? null : getProperty(object[parent], array.join('.')) + return (typeof object[parent] == "undefined") ? null : getProperty(object[parent], array.join('.')); }else{ // else return property return object[array[0]]; } -} +}; diff --git a/lib/vote.js b/lib/vote.js index 2d74bd07b..d52d17985 100644 --- a/lib/vote.js +++ b/lib/vote.js @@ -10,12 +10,12 @@ }; var hasUpvotedItem= function(item, user){ - return item.upvoters && item.upvoters.indexOf(user._id) != -1 - } + return item.upvoters && item.upvoters.indexOf(user._id) != -1; + }; var hasDownvotedItem= function(item, user){ - return item.downvoters && item.downvoters.indexOf(user._id) != -1 - } + return item.downvoters && item.downvoters.indexOf(user._id) != -1; + }; var upvoteItem = function(collection, item) { var user = Meteor.user(), @@ -27,7 +27,7 @@ // if user is upvoting a previously downvoted item, cancel downvote first if (hasDownvotedItem(item, user)) - cancelDownvote(collection, item, user) + cancelDownvote(collection, item, user); // Votes & Score var result = collection.update({_id: item && item._id},{ @@ -50,7 +50,7 @@ if(getSetting('redistributeKarma', false)){ _.each(item.upvoters, function(upvoterId){ // share the karma equally among all upvoters, but cap the value at 0.1 - var karmaIncrease = Math.min(0.1, votePower/item.upvoters.length) + var karmaIncrease = Math.min(0.1, votePower/item.upvoters.length); modifyKarma(upvoterId, 0.1); }); } @@ -68,7 +68,7 @@ // if user is downvoting a previously upvoted item, cancel upvote first if (hasUpvotedItem(item, user)) - cancelUpvote(collection, item, user) + cancelUpvote(collection, item, user); // Votes & Score collection.update({_id: item && item._id},{ @@ -146,7 +146,7 @@ // only let admins specify different users for voting // if no user is specified, use current user by default return (isAdmin(Meteor.user()) && typeof user !== 'undefined') ? user : Meteor.user(); - } + }; Meteor.methods({ upvotePost: function(post, user){ diff --git a/server/api.js b/server/api.js index 4a0620022..e995979a2 100644 --- a/server/api.js +++ b/server/api.js @@ -16,16 +16,16 @@ serveAPI = function(limitSegment){ }; if(post.body) - properties['body'] = post.body; + properties.body = post.body; if(post.url) - properties['domain'] = getDomain(url); + properties.domain = getDomain(url); if(twitterName = getTwitterNameById(post.userId)) - properties['twitterName'] = twitterName; + properties.twitterName = twitterName; posts.push(properties); }); return JSON.stringify(posts); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/server/email.js b/server/email.js index 4f41d2d3b..7ced7d94c 100644 --- a/server/email.js +++ b/server/email.js @@ -5,14 +5,14 @@ sendEmail = function(to, subject, text, html){ var from = getSetting('defaultEmail', 'noreply@example.com'); var siteName = getSetting('title'); - var subject = '['+siteName+'] '+subject + var subject = '['+siteName+'] '+subject; console.log('sending email…'); - console.log(from) - console.log(to) - console.log(subject) - console.log(text) - console.log(html) + console.log(from); + console.log(to); + console.log(subject); + console.log(text); + console.log(html); Email.send({ from: from, diff --git a/server/invites.js b/server/invites.js index 9efdcc9fe..904aa8684 100644 --- a/server/invites.js +++ b/server/invites.js @@ -22,7 +22,7 @@ Meteor.methods({ invitedBy: currentUser._id, invitedByName: getDisplayName(currentUser) }}); - console.log(a) + console.log(a); createNotification({ event: 'accountApproved', diff --git a/server/migrations.js b/server/migrations.js index b493c7794..2cc1ef569 100644 --- a/server/migrations.js +++ b/server/migrations.js @@ -7,23 +7,23 @@ Meteor.startup(function () { // migration updatePostStatus: make sure posts have a status if (!Migrations.findOne({name: "updatePostStatus"})) { - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Starting updatePostStatus Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Starting updatePostStatus Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); Posts.find({status: {$exists : false}}).forEach(function (post) { Posts.update(post._id, {$set: {status: 2}}); // START CONSOLE LOGS - console.log("---------------------") + console.log("---------------------"); console.log("Post: "+post.headline); console.log("Updating status to approved"); // END CONSOLE LOGS }); Migrations.insert({name: "updatePostStatus"}); - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Ending updatePostStatus Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Ending updatePostStatus Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); } @@ -31,25 +31,25 @@ Meteor.startup(function () { // migration updateCategories: make sure categories have slugs if (!Migrations.findOne({name: "updateCategories"})) { - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Starting updateCategories Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Starting updateCategories Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); Categories.find().forEach(function (category) { if(typeof category.slug === "undefined"){ var slug = slugify(category.name); Categories.update(category._id, {$set: {slug: slug}}); // START CONSOLE LOGS - console.log("---------------------") + console.log("---------------------"); console.log("Category: "+category.name); console.log("Updating category with new slug: "+slug); // END CONSOLE LOGS } }); Migrations.insert({name: "updateCategories"}); - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Ending updateCategories Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Ending updateCategories Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); } @@ -57,9 +57,9 @@ Meteor.startup(function () { // migration updateCategories: store full category object in post instead of just the name if (!Migrations.findOne({name: "updatePostCategories"})) { - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Starting updatePostCategories Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Starting updatePostCategories Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); Posts.find().forEach(function (post) { var oldCategories = post.categories; var newCategories = []; @@ -88,10 +88,10 @@ Meteor.startup(function () { } // START CONSOLE LOGS - console.log("---------------------") + console.log("---------------------"); console.log("Post: "+post.headline); if(updating){ - console.log(oldCategories.length+" categories: "+oldCategories) + console.log(oldCategories.length+" categories: "+oldCategories); console.log("Updating categories array to: "); console.log(newCategories); }else{ @@ -101,16 +101,16 @@ Meteor.startup(function () { }); Migrations.insert({name: "updatePostCategories"}); - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Ending updateCategories Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Ending updateCategories Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); } // migration updateUserProfiles: update user profiles with slugs and a few other properties if (!Migrations.findOne({name: "updateUserProfiles"})) { - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Starting updateUserProfiles Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Starting updateUserProfiles Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); var allUsers = Meteor.users.find(); console.log('> Found '+allUsers.count()+' users.\n'); @@ -136,9 +136,9 @@ Meteor.startup(function () { }); Migrations.insert({name: "updateUserProfiles"}); - console.log("//----------------------------------------------------------------------//") - console.log("//------------// Ending updateUserProfiles Migration //-----------//") - console.log("//----------------------------------------------------------------------//") + console.log("//----------------------------------------------------------------------//"); + console.log("//------------// Ending updateUserProfiles Migration //-----------//"); + console.log("//----------------------------------------------------------------------//"); } }); \ No newline at end of file diff --git a/server/notifications.js b/server/notifications.js index 52b64df41..f4b1c0012 100644 --- a/server/notifications.js +++ b/server/notifications.js @@ -19,7 +19,7 @@ createNotification = function(options) { event: event, properties: properties, read: false - } + }; var newNotificationId=Notifications.insert(notification); // send the notification if notifications are activated, @@ -29,7 +29,7 @@ createNotification = function(options) { var contents = getNotificationContents(notification, 'email'); sendNotification(contents); } -} +}; Meteor.methods({ unsubscribeUser : function(hash){ @@ -51,7 +51,7 @@ Meteor.methods({ }, newPostNotify : function(properties){ var currentUser = Meteor.users.findOne(this.userId); - console.log('newPostNotify') + console.log('newPostNotify'); // send a notification to every user according to their notifications settings Meteor.users.find().forEach(function(user) { // don't send users notifications for their own posts @@ -68,4 +68,4 @@ sendNotification = function (notification) { // console.log('send notification:') // console.log(notification) sendEmail(notification.to, notification.subject, notification.text, notification.html); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/server/publications.js b/server/publications.js index a7cf2899c..8d8978b47 100644 --- a/server/publications.js +++ b/server/publications.js @@ -27,7 +27,7 @@ Meteor.publish('singleUser', function(userIdOrSlug) { if(canViewById(this.userId)){ var options = isAdminById(this.userId) ? {limit: 1} : {limit: 1, fields: privacyOptions}; var findById = Meteor.users.find(userIdOrSlug, options); - var findBySlug = Meteor.users.find({slug: userIdOrSlug}, options) + var findBySlug = Meteor.users.find({slug: userIdOrSlug}, options); // if we find something when treating the argument as an ID, return that; else assume it's a slug return findById.count() ? findById : findBySlug; } diff --git a/server/rss.js b/server/rss.js index 1b9e7a294..14eeeb1a7 100644 --- a/server/rss.js +++ b/server/rss.js @@ -19,4 +19,4 @@ serveRSS = function() { }); return feed.xml(); -} +}; diff --git a/server/search.js b/server/search.js index 8b88ada00..a99cc1449 100644 --- a/server/search.js +++ b/server/search.js @@ -2,5 +2,5 @@ logSearch = function (keyword) { Searches.insert({ timestamp: new Date().getTime(), keyword: keyword - }) -} \ No newline at end of file + }); +}; \ No newline at end of file diff --git a/server/toolbox.js b/server/toolbox.js index 8491be175..53971188d 100644 --- a/server/toolbox.js +++ b/server/toolbox.js @@ -38,4 +38,4 @@ Meteor.methods({ ); } } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/server/users.js b/server/users.js index 1ce88564f..10bc9b657 100644 --- a/server/users.js +++ b/server/users.js @@ -7,7 +7,7 @@ Accounts.onCreateUser(function(options, user){ postCount: 0, commentCount: 0, invitedCount: 0 - } + }; user = _.extend(user, userProperties); if (options.email) @@ -25,7 +25,7 @@ Accounts.onCreateUser(function(options, user){ posts: false, comments: true, replies: true - } + }; // create slug from username user.slug = slugify(getUserName(user)); @@ -66,7 +66,7 @@ Accounts.onCreateUser(function(options, user){ getEmailHash = function(user){ // todo: add some kind of salt in here return CryptoJS.MD5(getEmail(user).trim().toLowerCase() + user.createdAt).toString(); -} +}; addToMailChimpList = function(user){ // add a user to a MailChimp list. @@ -87,7 +87,7 @@ addToMailChimpList = function(user){ double_optin: false }); } -} +}; Meteor.methods({ changeEmail: function(newEmail) {