Skip to content

Commit

Permalink
Clean code.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrsjng committed Apr 13, 2015
1 parent 6137120 commit cdca37e
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 47 deletions.
31 changes: 31 additions & 0 deletions .jshintrc
@@ -0,0 +1,31 @@
{
"bitwise": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"futurehostile": true,
"latedef": true,
"maxdepth": 3,
"noarg": true,
"nocomma": true,
"nonbsp": true,
"nonew": true,
"plusplus": true,
"strict": false,
"supernew": true,
"trailing": true,
"undef": true,
"unused": true,

"browser": true,

"globals": {
"jQuery": false,
"marked": false,
"Modernizr": false,
"modulejs": false,
"Prism": false,
"_": false
}
}
23 changes: 3 additions & 20 deletions mkrfile.js
Expand Up @@ -70,28 +70,11 @@ module.exports = function (suite) {

suite.target('lint', [], 'lint all JavaScript files with JSHint').task(function () {

var jshint = {
// Enforcing Options
bitwise: true,
curly: true,
eqeqeq: true,
forin: true,
latedef: true,
newcap: true,
noempty: true,
plusplus: true,
trailing: true,
undef: true,

// Environments
browser: true
};
var globals = {
modulejs: true
};
var fs = require('fs');
var jshint = JSON.parse(fs.readFileSync('.jshintrc', 'utf8'));

$(src + '/_h5ai/client/js: **/*.js, ! lib/**')
.jshint(jshint, globals);
.jshint(jshint, jshint.globals);
});


Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/core/event.js
Expand Up @@ -23,7 +23,7 @@ modulejs.define('core/event', ['_'], function (_) {
}
}

function pub(topic, data) {
function pub(topic) {

var args = slice.call(arguments, 1);

Expand Down
6 changes: 3 additions & 3 deletions src/_h5ai/client/js/inc/ext/contextmenu.js
Expand Up @@ -81,9 +81,9 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/settings', 'core/resource'],
var overlayWidth = $overlay.outerWidth(true);
var overlayHeight = $overlay.outerHeight(true);

var panelOffset = $panel.offset();
var panelLeft = panelOffset.left;
var panelTop = panelOffset.top;
// var panelOffset = $panel.offset();
// var panelLeft = panelOffset.left;
// var panelTop = panelOffset.top;
var panelWidth = $panel.outerWidth(true);
var panelHeight = $panel.outerHeight(true);

Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/ext/custom.js
@@ -1,4 +1,4 @@
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server', 'core/event', 'core/resource'], function (_, $, marked, allsettings, server, event, resource) {
modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server', 'core/event'], function (_, $, marked, allsettings, server, event) {

var settings = _.extend({
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/ext/download.js
Expand Up @@ -25,7 +25,7 @@ modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'co
}
}

function onClick(event) {
function onClick() {

var type = settings.type;
var name = settings.packageName;
Expand Down
3 changes: 1 addition & 2 deletions src/_h5ai/client/js/inc/ext/info.js
Expand Up @@ -27,7 +27,6 @@ modulejs.define('ext/info', ['_', '$', 'modernizr', 'core/settings', 'core/resou
'<img src="' + resource.image('info-toggle') + '" alt="view-info"/>' +
'</div>' +
'</div>';
var sepTemplate = '<span class="sep"/>';
var storekey = 'ext/info';
var $img;
var $label;
Expand Down Expand Up @@ -108,7 +107,7 @@ modulejs.define('ext/info', ['_', '$', 'modernizr', 'core/settings', 'core/resou
update(item);
}

function onMouseleave(item) {
function onMouseleave() {

update(currentFolder);
}
Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/ext/preview-aud.js
Expand Up @@ -103,7 +103,7 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/settings', 'core/event', '
_.each(item.content, initItem);
}

function onLocationRefreshed(item, added, removed) {
function onLocationRefreshed(item, added) {

_.each(added, initItem);
}
Expand Down
3 changes: 1 addition & 2 deletions src/_h5ai/client/js/inc/ext/preview-img.js
Expand Up @@ -5,7 +5,6 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
size: null,
types: []
}, allsettings['preview-img']);
var templateLoading = '<img id="pv-img-image" class="loading"/>';
var spinnerThreshold = 200;
var spinnerTimeoutId;
var currentItems;
Expand Down Expand Up @@ -139,7 +138,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
_.each(item.content, initItem);
}

function onLocationRefreshed(item, added, removed) {
function onLocationRefreshed(item, added) {

_.each(added, initItem);
}
Expand Down
4 changes: 2 additions & 2 deletions src/_h5ai/client/js/inc/ext/preview-txt.js
Expand Up @@ -19,7 +19,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
callback(content);
// setTimeout(function () { callback(content); }, 1000); // for testing
})
.fail(function (jqXHR, textStatus, errorThrown) {
.fail(function (jqXHR, textStatus) {

callback('[ajax error] ' + textStatus);
});
Expand Down Expand Up @@ -119,7 +119,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
_.each(item.content, initItem);
}

function onLocationRefreshed(item, added, removed) {
function onLocationRefreshed(item, added) {

_.each(added, initItem);
}
Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/ext/preview-vid.js
Expand Up @@ -104,7 +104,7 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
_.each(item.content, initItem);
}

function onLocationRefreshed(item, added, removed) {
function onLocationRefreshed(item, added) {

_.each(added, initItem);
}
Expand Down
2 changes: 0 additions & 2 deletions src/_h5ai/client/js/inc/ext/preview.js
Expand Up @@ -22,8 +22,6 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
'</div>' +
'</div>';
var storekey = 'ext/preview';
var currentEntries = [];
var currentIdx = 0;
var isFullscreen = store.get(storekey) || false;
var userAliveTimeoutId = null;
var onIndexChange = null;
Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/ext/select.js
Expand Up @@ -207,7 +207,7 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
ev.stopImmediatePropagation();
ev.preventDefault();
})
.on('click', function (ev) {
.on('click', function () {

$('#items .item').removeClass('selected');
publish();
Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/ext/sort.js
Expand Up @@ -110,7 +110,7 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
}
}

function onContentChanged(item) {
function onContentChanged() {

var order = store.get(storekey);
var column = order && order.column || settings.column;
Expand Down
4 changes: 2 additions & 2 deletions src/_h5ai/client/js/inc/ext/thumbnails.js
@@ -1,4 +1,4 @@
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/server', 'core/resource'], function (_, allsettings, event, server, resource) {
modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/server'], function (_, allsettings, event, server) {

var settings = _.extend({
enabled: false,
Expand Down Expand Up @@ -71,7 +71,7 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
}, settings.delay);
}

function onLocationRefreshed(item, added, removed) {
function onLocationRefreshed(item, added) {

_.each(added, checkItem);
}
Expand Down
2 changes: 0 additions & 2 deletions src/_h5ai/client/js/inc/ext/tree.js
Expand Up @@ -109,8 +109,6 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/s

function createOnIndicatorClick() {

var $tree = $('#tree');

function slide(item, $indicator, $content, down) {

item.isContentVisible = down;
Expand Down
2 changes: 1 addition & 1 deletion src/_h5ai/client/js/inc/view/ensure.js
@@ -1,4 +1,4 @@
modulejs.define('view/ensure', ['$', 'config', 'core/event'], function ($, config, event) {
modulejs.define('view/ensure', ['$', 'config'], function ($, config) {

var templateTopbar =
'<div id="topbar">' +
Expand Down
3 changes: 1 addition & 2 deletions src/_h5ai/client/js/inc/view/items.js
Expand Up @@ -16,7 +16,6 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
'<span class="size"/>' +
'</a>' +
'</li>';
var hintTemplate = '<span class="hint"/>';
var contentTemplate =
'<div id="content">' +
'<div id="view">' +
Expand Down Expand Up @@ -149,7 +148,7 @@ modulejs.define('view/items', ['_', '$', 'core/settings', 'core/resource', 'core
var $content = $(contentTemplate);
var $view = $content.find('#view');
var $items = $view.find('#items');
var $emtpy = $view.find('.empty').hide();
$view.find('.empty').hide();

format.setDefaultMetric(settings.binaryPrefix);

Expand Down
3 changes: 1 addition & 2 deletions src/_h5ai/client/js/scripts.js
Expand Up @@ -9,12 +9,11 @@
(function () {
'use strict';

/*global jQuery, marked, Modernizr, Prism, _ */
modulejs.define('$', function () { return jQuery; });
modulejs.define('_', function () { return _; });
modulejs.define('marked', function () { return marked; });
modulejs.define('modernizr', function () { return Modernizr; });
modulejs.define('prism', function () { return Prism; });
modulejs.define('_', function () { return _; });

// @include "inc/**/*.js"

Expand Down

0 comments on commit cdca37e

Please sign in to comment.