Commit 6975a53a authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Whitespace and comment fixes.

- Add missing semicolons.
- Add comments to classes without one.
- Remove empty lines at the beginning of functions.
- Remove one accidental global variable.
parent c6713078
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
/**
 * Authentication controller.
 */
Ext.define('Docs.controller.Auth', {
    extend: 'Ext.app.Controller',

@@ -11,7 +14,6 @@ Ext.define('Docs.controller.Auth', {
    ],

    init: function() {

        this.sid = Ext.util.Cookies.get('sid');

        this.addEvents(
@@ -65,7 +67,6 @@ Ext.define('Docs.controller.Auth', {
     * Checks if a user is logged in server side and sets up a local session if they are.
     */
    getSession: function() {

        if (!Docs.enableComments) {
            return;
        }
@@ -98,7 +99,6 @@ Ext.define('Docs.controller.Auth', {
     * @param {Ext.Element} submitEl
     */
    login: function(username, password, remember, submitEl) {

        Ext.Ajax.request({
            url: Docs.baseUrl + '/login',
            method: 'POST',
@@ -162,7 +162,7 @@ Ext.define('Docs.controller.Auth', {
     */
    loggedOut: function(user) {
        this.currentUser = {};
        this.setSid(null)
        this.setSid(null);
        this.getAuth().showLoggedOut();
        this.fireEvent('loggedOut');
    },
@@ -189,7 +189,7 @@ Ext.define('Docs.controller.Auth', {
            username = form.down('input[name=username]').getValue(),
            password = form.down('input[name=password]').getValue(),
            rememberEl = form.down('input[name=remember]'),
            submitEl = form.down('input[type=submit]')
            submitEl = form.down('input[type=submit]');

        var remember = rememberEl ? Boolean(rememberEl.getAttribute('checked')) : false;

+4 −1
Original line number Diff line number Diff line
/**
 * A mixin for Comments controller to help with authentication.
 */
Ext.define('Docs.controller.AuthHelpers', {

    addSid: function(url) {
+6 −19
Original line number Diff line number Diff line
@@ -26,16 +26,17 @@ Ext.define('Docs.controller.Comments', {
    ],

    init: function() {

        this.addEvents(
            /**
             * @event add  Fired after a comment is added
             * @event add
             * Fired after a comment is added
             * @param {String} key  Key of the comment
             */
            'add',

            /**
             * @event remove  Fired after a comment is removed
             * @event remove
             * Fired after a comment is removed
             * @param {String} key  Key of the comment
             */
            'remove'
@@ -121,7 +122,6 @@ Ext.define('Docs.controller.Comments', {
    },

    fetchComments: function(id, callback, opts) {

        var startkey = Ext.JSON.encode(this.commentId(id)),
            endkey = Ext.JSON.encode(this.commentId(id).concat([{}])),
            currentUser = this.getController('Auth').currentUser,
@@ -144,7 +144,6 @@ Ext.define('Docs.controller.Comments', {
    },

    postComment: function(cmp, el) {

        if (!this.loggedIn()) {
            return false;
        }
@@ -214,7 +213,6 @@ Ext.define('Docs.controller.Comments', {
     * Fetches the most recent comments
     */
    fetchRecentComments: function(id) {

        var url = Docs.baseUrl + '/' + Docs.commentsDb + '/_design/Comments/_list/with_vote/by_date';

        Ext.data.JsonP.request({
@@ -236,7 +234,6 @@ Ext.define('Docs.controller.Comments', {
     * if the user confirms.
     */
    promptDeleteComment: function(cmp, el) {

        if (!this.loggedIn()) {
            return false;
        }
@@ -259,7 +256,6 @@ Ext.define('Docs.controller.Comments', {
     * Sends a delete comment request to the server.
     */
    deleteComment: function(cmp, el) {

        var id = Ext.get(el).up('.comment').getAttribute('id'),
            commentsEl = Ext.get(el).up('.comments'),
            cls = commentsEl && commentsEl.getAttribute('id');
@@ -295,7 +291,6 @@ Ext.define('Docs.controller.Comments', {
            callback: function(options, success, response) {
                var data = Ext.JSON.decode(response.responseText);
                if (data.success) {

                    contentEl.dom.origContent = contentEl.dom.innerHTML;

                    var commentData = Ext.merge(Ext.clone(currentUser), {
@@ -314,7 +309,6 @@ Ext.define('Docs.controller.Comments', {
    },

    updateComment: function(cmp, el) {

        if (!this.loggedIn()) {
            return false;
        }
@@ -370,7 +364,6 @@ Ext.define('Docs.controller.Comments', {
     * @private
     */
    vote: function(direction, el) {

        if (!this.loggedIn()) {
            this.showError('Please login to vote on this comment', el);
            return false;
@@ -410,7 +403,6 @@ Ext.define('Docs.controller.Comments', {
    },

    toggleComments: function(cmp, el) {

        var commentsDiv = Ext.get(el).up('.comments');

        if (commentsDiv.hasCls('open')) {
@@ -421,7 +413,6 @@ Ext.define('Docs.controller.Comments', {
    },

    openComments: function(commentsDiv) {

        if (commentsDiv.hasCls('open')) return;

        var commentNum =  commentsDiv.down('.name'),
@@ -439,7 +430,6 @@ Ext.define('Docs.controller.Comments', {
    },

    closeComments: function(commentsDiv) {

        if (!commentsDiv.hasCls('open')) return;

        var commentNum =  commentsDiv.down('.name'),
@@ -467,7 +457,6 @@ Ext.define('Docs.controller.Comments', {
    },

    renderComments: function(rows, id, opts) {

        opts = opts || {};

        var comments = Ext.get(id),
@@ -487,7 +476,6 @@ Ext.define('Docs.controller.Comments', {
        if (opts.hideCommentForm) {
            comments.addCls('hideCommentForm');
        } else if (!comments.hasCls('hideCommentForm')) {

            var commentWrap = comments.down('.new-comment-wrap');
            if (this.loggedIn()) {
                var wrap = Docs.view.Comments.loggedInCommentTpl.overwrite(commentWrap, this.getController('Auth').currentUser, true);
@@ -527,7 +515,7 @@ Ext.define('Docs.controller.Comments', {
                    data = row.value;
                    data.id = opts.id;
                }
            })
            });
        } else {
            data = rows[rows.length - 1].value;
            data.id = rows[rows.length - 1].id;
@@ -556,7 +544,6 @@ Ext.define('Docs.controller.Comments', {
    },

    showError: function(msg, el) {

        if (this.errorTip) {
            this.errorTip.update(msg);
            this.errorTip.setTarget(el);
+5 −11
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ Ext.define('Docs.controller.CommentsMeta', {
    ],

    init: function() {

        Docs.commentMeta = {
            idMap: {},
            'class': {}
@@ -83,7 +82,6 @@ Ext.define('Docs.controller.CommentsMeta', {
                group_level: 3
            },
            success: function(response) {

                Ext.Array.each(response.rows, function(r) {
                    this.updateMeta(r.key, r.value.num);
                }, this);
@@ -97,7 +95,6 @@ Ext.define('Docs.controller.CommentsMeta', {
    },

    // updateVoteMeta: function() {
    //
    //     var id = Docs.App.getController('Classes').currentCls.name,
    //         startkey = Ext.JSON.encode(['class',id]),
    //         endkey = Ext.JSON.encode(['class',id,{}]),
@@ -123,7 +120,6 @@ Ext.define('Docs.controller.CommentsMeta', {
    // },

    fetchCommentLeaders: function() {

        Ext.data.JsonP.request({
            url: Docs.baseUrl + '/' + Docs.commentsDb + '/_design/Comments/_view/by_author',
            method: 'GET',
@@ -134,7 +130,6 @@ Ext.define('Docs.controller.CommentsMeta', {
                limit: 10
            },
            success: function(response) {

                var tpl = Ext.create('Ext.XTemplate',
                    '<h1>Comment reputation</h1>',
                    '<table>',
@@ -177,15 +172,14 @@ Ext.define('Docs.controller.CommentsMeta', {
     * Creates a mapping between comment element IDs and DB view keys.
     */
    createCommentIdMap: function(cls) {
        var key, commentId, member
        Docs.commentMeta.idMap[('comments-class-' + cls.name).replace(/\./g, '-')] = ['class', cls.name, ''];

        if (cls.members) {
            for(member in cls.members) {
            for (var member in cls.members) {
                Ext.Array.each(cls.members[member], function(memberItem) {
                    origKey = ['class', cls.name, memberItem.id];
                    key = ['class', memberItem.owner, memberItem.id];
                    commentId = 'comments-' + origKey.join('-').replace(/\./g, '-');
                    var origKey = ['class', cls.name, memberItem.id];
                    var key = ['class', memberItem.owner, memberItem.id];
                    var commentId = 'comments-' + origKey.join('-').replace(/\./g, '-');
                    Docs.commentMeta.idMap[commentId] = key;
                }, this);
            }
+7 −14
Original line number Diff line number Diff line
/**
 * View for rendering comments.
 */
Ext.define('Docs.view.Comments', {

    singleton: true,
    requires: ['Docs.view.auth.Login'],

    constructor: function() {

        var numComments = [
            '<tpl if="num &gt; 0">',
                'View {[values.num == 1 ? "1 comment" : values.num + " comments"]}',
@@ -268,7 +269,6 @@ Ext.define('Docs.view.Comments', {
     * Renders the comment containers for the currently active class
     */
    renderClassCommentContainers: function(cls) {

        // Add comment button to class toolbar
        Ext.ComponentQuery.query('classoverview toolbar')[0].insert(-2, {
            xtype: 'container',
@@ -299,7 +299,6 @@ Ext.define('Docs.view.Comments', {
     * Updates the comment meta information (i.e. number of comments) on a class page
     */
    updateClassCommentMeta: function(cls) {

        var clsMeta = Docs.commentMeta['class'][cls];

        if (clsMeta && clsMeta['']) {
@@ -323,7 +322,6 @@ Ext.define('Docs.view.Comments', {

        // Update class member comments meta
        Ext.Array.each(Ext.query('.member'), function(memberDom) {

            var memberEl = Ext.get(memberDom),
                memberId = memberEl.getAttribute('id'),
                memberCls = memberEl.down('.meta .docClass').getAttribute('rel'),
@@ -350,14 +348,12 @@ Ext.define('Docs.view.Comments', {

        this.updateClassIndex();
        Ext.Array.each(Ext.ComponentQuery.query('hovermenu'), function(m) {
            m.fireEvent('refresh', this)
            m.fireEvent('refresh', this);
        });
    },

    renderHoverMenuMeta: function(cmp) {

        Ext.Array.each(cmp.query('a.docClass'), function(a) {

            var rel = "comments-class-" + a.getAttribute('rel').replace(/[^A-Za-z\-]/g, '-'),
                relEl = Ext.get(a),
                memberComments = relEl.down('.toggleMemberComments'),
@@ -368,7 +364,7 @@ Ext.define('Docs.view.Comments', {

                if (memberComments) {
                    if (!meta) {
                        memberComments.remove()
                        memberComments.remove();
                    } else {
                        memberComments.update(String(meta));
                    }
@@ -397,16 +393,14 @@ Ext.define('Docs.view.Comments', {
    },

    renderNewCommentForms: function() {

        var currentUser = Docs.App.getController('Auth').currentUser;

        Ext.Array.each(Ext.query('.new-comment-wrap'), function(newComment) {

            var hideCommentForm = Ext.get(newComment).up('.comment-list').parent().hasCls('hideCommentForm');

            if (hideCommentForm) {
                // Do nothing
            } else if (Docs.App.getController('Auth').isLoggedIn()) {

                var wrap = this.loggedInCommentTpl.overwrite(newComment, currentUser, true),
                    textarea = wrap.down('textarea').dom;

@@ -445,7 +439,6 @@ Ext.define('Docs.view.Comments', {
    },

    showMember: function(cls, member) {

        var memberEl = Ext.get(member).down('.long'),
            id = ('class-' + cls + '-' + member).replace(/\./g, '-');

Loading