Skip to content

Commit d026637

Browse files
committed
jslint
1 parent 41170a4 commit d026637

14 files changed

+11827
-160
lines changed

static/script.js

+98-98
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/script/08-olelo.i18n.js

+32-29
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
// Very simple i18n plugin
22
// Written by Daniel Mendler
33
(function($) {
4-
var locale = null, translations = {};
5-
$.translations = function(t) {
6-
for (var lang in t) {
7-
if (!translations[lang]) {
8-
translations[lang] = t[lang];
9-
} else {
10-
for (var name in t[lang])
11-
translations[lang][name] = t[lang][name];
12-
}
13-
}
14-
};
15-
function lookup(locale, name) {
16-
var t = translations[locale];
17-
return t && t[name];
18-
}
19-
$.t = function(name, args) {
20-
if (!locale) {
21-
var html = $('html');
22-
locale = html.attr('lang') || html.attr('xml:lang') || 'en';
23-
}
24-
var i, s = lookup(locale, name);
25-
if (!s && (i = locale.indexOf('-')))
26-
s = lookup(locale.substr(0, i), name);
27-
if (s) {
28-
for (var key in args)
29-
s = s.replace(new RegExp('#{' + key + '}', 'g'), args[key]);
30-
return s;
4+
var locale = null, translations = {};
5+
$.translations = function(t) {
6+
for (var lang in t) {
7+
if (!translations[lang]) {
8+
translations[lang] = t[lang];
9+
} else {
10+
for (var name in t[lang]) {
11+
translations[lang][name] = t[lang][name];
3112
}
32-
return '#' + name;
33-
};
13+
}
14+
}
15+
};
16+
function lookup(locale, name) {
17+
var t = translations[locale];
18+
return t && t[name];
19+
}
20+
$.t = function(name, args) {
21+
if (!locale) {
22+
var html = $('html');
23+
locale = html.attr('lang') || html.attr('xml:lang') || 'en';
24+
}
25+
var i, s = lookup(locale, name);
26+
if (!s && (i = locale.indexOf('-'))) {
27+
s = lookup(locale.substr(0, i), name);
28+
}
29+
if (s) {
30+
for (var key in args) {
31+
s = s.replace(new RegExp('#{' + key + '}', 'g'), args[key]);
32+
}
33+
return s;
34+
}
35+
return '#' + name;
36+
};
3437
})(jQuery);

static/script/09-olelo.unsaved.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
break;
2828
case 'select-one':
2929
case 'select-multiple':
30-
for (var i = 0; i < this.options.length && !unsaved; ++i)
30+
for (var i = 0; i < this.options.length && !unsaved; ++i) {
3131
unsaved = this.options[i].selected != this.options[i].defaultSelected;
32+
}
3233
break;
3334
}
3435
$('label[for=' + this.id + ']').toggleClass('unsaved', unsaved);
@@ -39,7 +40,7 @@
3940
$('input.observe, textarea.observe, select.observe').each(function() {
4041
updateUnsaved.call(this);
4142
});
42-
return $('.unsaved', element).size() != 0;
43+
return $('.unsaved', element).size() !== 0;
4344
}
4445

4546
$.fn.confirmUnsaved = function() {
@@ -56,7 +57,8 @@
5657
});
5758

5859
$(window).bind('beforeunload', function() {
59-
if (!submitForm && hasUnsavedChanges(document))
60+
if (!submitForm && hasUnsavedChanges(document)) {
6061
return $.t('pageUnsaved');
62+
}
6163
});
6264
})(jQuery);

static/script/10-olelo.historytable.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ jQuery.fn.historyTable = function() {
77
rows.mousedown(function(event) {
88
var from = $(this),
99
offset = from.offset(),
10-
to = null;
10+
to = null,
1111
fromText = $('td:first-child a:first-child', from).text(),
1212
fromDate = $('td:nth-child(3)', from).text(),
1313
draggable = null;
1414

1515
// Stop dragging -> Remove draggable, unbind events
1616
function stop() {
17-
if (draggable)
17+
if (draggable) {
1818
draggable.remove();
19+
}
1920
$(document).unbind('mouseup.historyTable keypress.historyTable');
2021
rows.unbind('mouseover.historyTable mousemove.historyTable');
2122
}
@@ -26,8 +27,9 @@ jQuery.fn.historyTable = function() {
2627
if (to) {
2728
var toVersion = to.attr('id').substr(8),
2829
fromVersion = from.attr('id').substr(8);
29-
if (toVersion != fromVersion)
30+
if (toVersion != fromVersion) {
3031
location.href = location.pathname.replace('/history', '/compare/' + fromVersion + '...' + toVersion);
32+
}
3133
}
3234
return true;
3335
});

static/script/11-olelo.pagination.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Written by Daniel Mendler
55
(function($) {
66
$.fn.pagination = function(page) {
7-
var page = $(page);
7+
page = $(page);
88
this.live('click', function() {
99
$(this).addClass('loading');
1010
var href = this.href;

static/script/12-olelo.placeholder.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// Written by Daniel Mendler
33
jQuery.fn.placeholder = function() {
44
this.focus(function() {
5-
if (this.value == this.defaultValue)
5+
if (this.value == this.defaultValue) {
66
this.value = '';
7+
}
78
}).blur(function() {
8-
if (this.value == '')
9+
if (this.value === '') {
910
this.value = this.defaultValue;
11+
}
1012
});
1113
};

static/script/13-olelo.tabwidget.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,40 @@
77

88
// Handle tab clicks
99
$("> a[href^='#']", this).click(function() {
10-
if (selected.data('tab') == $(this).data('tab'))
10+
if (selected.data('tab') == $(this).data('tab')) {
1111
return false;
12-
if (!selected.data('tab').confirmUnsaved())
12+
}
13+
if (!selected.data('tab').confirmUnsaved()) {
1314
return false;
15+
}
1416
selected.data('tab').hide();
1517
selected.parent().removeClass('selected');
1618
selected = $(this);
1719
selected.data('tab').show();
1820
selected.parent().addClass('selected');
19-
if (store)
21+
if (store) {
2022
jStorage.set(store, selected.data('tab').attr('id'));
23+
}
2124
return false;
2225
});
2326

2427
// Get selected tab from store
2528
if (store) {
2629
var name = jStorage.get(store);
27-
if (name)
30+
if (name) {
2831
selected = $("> a[href='#" + name + "']", this);
32+
}
2933
}
3034

3135
// Get selected tab by class
32-
if (!selected || selected.size() == 0)
36+
if (!selected || selected.size() === 0) {
3337
selected = $(this).filter('.selected').find("> a[href^='#']");
38+
}
3439

3540
// Select first tab
36-
if (!selected || selected.size() == 0)
41+
if (!selected || selected.size() === 0) {
3742
selected = $(this).filter(':first').find("> a[href^='#']");
43+
}
3844

3945
// Find all tabs and hide them
4046
$("> a[href^='#']", this).each(function() {

static/script/14-olelo.timeago.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,27 @@
3131
});
3232

3333
function timeAgo(from) {
34-
var n = Math.floor((new Date().getTime() - new Date(from * 1000)) / 60000)
35-
if (n <= 0) return $.t('less_than_a_minute_ago');
36-
if (n == 1) return $.t('a_minute_ago');
37-
if (n < 45) return $.t('n_minutes_ago', {n: n});
38-
if (n < 90) return $.t('one_hour_ago');
39-
if (n < 1440) return $.t('n_hours_ago', {n: Math.round(n / 60)});
40-
if (n < 2880) return $.t('one_day_ago');
41-
if (n < 43200) return $.t('n_days_ago', {n: Math.round(n / 1440)});
42-
if (n < 86400) return $.t('one_month_ago');
43-
if (n < 525960) return $.t('n_months_ago', {n: Math.round(n / 43200)});
44-
if (n < 1051920) return $.t('one_year_ago');
34+
var n = Math.floor((new Date().getTime() - new Date(from * 1000)) / 60000);
35+
if (n <= 0) { return $.t('less_than_a_minute_ago'); }
36+
if (n == 1) { return $.t('a_minute_ago'); }
37+
if (n < 45) { return $.t('n_minutes_ago', {n: n}); }
38+
if (n < 90) { return $.t('one_hour_ago'); }
39+
if (n < 1440) { return $.t('n_hours_ago', {n: Math.round(n / 60)}); }
40+
if (n < 2880) { return $.t('one_day_ago'); }
41+
if (n < 43200) { return $.t('n_days_ago', {n: Math.round(n / 1440)}); }
42+
if (n < 86400) { return $.t('one_month_ago'); }
43+
if (n < 525960) { return $.t('n_months_ago', {n: Math.round(n / 43200)}); }
44+
if (n < 1051920) { return $.t('one_year_ago'); }
4545
return $.t('over_n_years_ago', {n: Math.round(n / 525960)});
4646
}
4747

4848
$.fn.timeAgo = function() {
4949
this.each(function() {
5050
var elem = $(this);
5151
var match = elem.attr('class').match(/epoch-(\d+)/);
52-
if (match)
52+
if (match) {
5353
elem.attr('title', elem.text()).html(timeAgo(match[1]));
54+
}
5455
});
5556
};
5657
})(jQuery);

static/script/15-olelo.underliner.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
underlineText: function(str) {
77
this.each(function() {
88
var elem = $(this), text, i;
9-
if (elem.children().size() == 0) {
9+
if (elem.children().size() === 0) {
1010
text = elem.text();
1111
i = text.toLowerCase().indexOf(str.toLowerCase());
12-
if (i >= 0)
12+
if (i >= 0) {
1313
elem.html(text.substr(0, i) + '<span style="text-decoration: underline">' +
1414
text.substr(i, str.length) + '</span>' + text.substr(i+str.length));
15+
}
1516
} else {
1617
elem.children().underlineText(str);
1718
}
@@ -21,8 +22,9 @@
2122
underlineAccessKey: function() {
2223
this.each(function() {
2324
var key = $(this).attr('accesskey');
24-
if (key)
25+
if (key) {
2526
$(this).underlineText(key);
27+
}
2628
});
2729
}
2830
});

static/script/16-olelo.ui.combobox.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
minLength: 0,
88
source: this.options.source
99
}).click(function() {
10-
if (input.autocomplete('widget').is(':visible'))
10+
if (input.autocomplete('widget').is(':visible')) {
1111
input.autocomplete('close');
12-
else
12+
} else {
1313
input.autocomplete('search', this.value);
14+
}
1415
});
1516
$('<button class="ui-combo-button"/>')
1617
.attr('tabIndex', -1)

static/script/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $(function() {
77
var elem = this;
88
var old = elem.value;
99
var base = elem.value;
10-
if (base.length == 0 || base.match(/\/$/)) {
10+
if (base.length === 0 || base.match(/\/$/)) {
1111
$('#upload-file').change(function() {
1212
if (elem.value == old) {
1313
elem.value = base + this.value;

0 commit comments

Comments
 (0)