gitdocs 0.5.0.pre6 → 0.5.0.pre7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.haml-lint.yml +3 -0
- data/.jslint.yml +84 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG +11 -0
- data/README.md +6 -2
- data/Rakefile +22 -3
- data/gitdocs.gemspec +36 -29
- data/lib/gitdocs.rb +5 -2
- data/lib/gitdocs/cli.rb +31 -8
- data/lib/gitdocs/configuration.rb +95 -49
- data/lib/gitdocs/manager.rb +36 -28
- data/lib/gitdocs/migration/001_create_shares.rb +2 -0
- data/lib/gitdocs/migration/002_add_remote_branch.rb +2 -0
- data/lib/gitdocs/migration/003_create_configs.rb +2 -0
- data/lib/gitdocs/migration/004_add_index_for_path.rb +4 -0
- data/lib/gitdocs/migration/005_add_start_web_frontend.rb +2 -0
- data/lib/gitdocs/migration/006_add_web_port_to_config.rb +2 -0
- data/lib/gitdocs/migration/007_add_sync_type.rb +11 -0
- data/lib/gitdocs/notifier.rb +89 -6
- data/lib/gitdocs/public/img/file.png +0 -0
- data/lib/gitdocs/public/img/folder.png +0 -0
- data/lib/gitdocs/public/js/app.js +26 -11
- data/lib/gitdocs/public/js/edit.js +3 -3
- data/lib/gitdocs/public/js/settings.js +8 -5
- data/lib/gitdocs/public/js/util.js +21 -20
- data/lib/gitdocs/rendering.rb +14 -9
- data/lib/gitdocs/repository.rb +180 -216
- data/lib/gitdocs/repository/path.rb +166 -0
- data/lib/gitdocs/runner.rb +22 -65
- data/lib/gitdocs/search.rb +35 -0
- data/lib/gitdocs/server.rb +123 -86
- data/lib/gitdocs/version.rb +1 -1
- data/lib/gitdocs/views/_header.haml +6 -6
- data/lib/gitdocs/views/app.haml +17 -17
- data/lib/gitdocs/views/dir.haml +10 -10
- data/lib/gitdocs/views/edit.haml +8 -9
- data/lib/gitdocs/views/file.haml +1 -1
- data/lib/gitdocs/views/home.haml +4 -4
- data/lib/gitdocs/views/revisions.haml +6 -6
- data/lib/gitdocs/views/search.haml +6 -6
- data/lib/gitdocs/views/settings.haml +23 -16
- data/test/.rubocop.yml +13 -0
- data/test/integration/browse_test.rb +149 -0
- data/test/integration/full_sync_test.rb +3 -11
- data/test/integration/share_management_test.rb +59 -10
- data/test/integration/status_test.rb +2 -0
- data/test/integration/test_helper.rb +40 -7
- data/test/unit/configuration_test.rb +82 -0
- data/test/unit/notifier_test.rb +165 -0
- data/test/unit/repository_path_test.rb +368 -0
- data/test/{repository_test.rb → unit/repository_test.rb} +426 -245
- data/test/unit/runner_test.rb +122 -0
- data/test/unit/search_test.rb +52 -0
- data/test/{test_helper.rb → unit/test_helper.rb} +5 -0
- metadata +138 -41
- data/lib/gitdocs/docfile.rb +0 -23
- data/test/configuration_test.rb +0 -41
- data/test/notifier_test.rb +0 -68
- data/test/runner_test.rb +0 -123
data/lib/gitdocs/manager.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
1
3
|
module Gitdocs
|
2
4
|
Restart = Class.new(RuntimeError)
|
3
5
|
|
@@ -14,44 +16,27 @@ module Gitdocs
|
|
14
16
|
def start(web_port = nil)
|
15
17
|
log("Starting Gitdocs v#{VERSION}...")
|
16
18
|
log("Using configuration root: '#{config.config_root}'")
|
17
|
-
log("Shares: (#{
|
19
|
+
log("Shares: (#{shares.length}) #{shares.map(&:inspect).join(', ')}")
|
18
20
|
|
19
|
-
restarting = false
|
20
21
|
begin
|
21
22
|
EM.run do
|
22
23
|
log('Starting EM loop...')
|
23
24
|
|
24
|
-
@runners = Runner.start_all(
|
25
|
-
|
26
|
-
|
27
|
-
if config.global.start_web_frontend
|
28
|
-
web_port ||= config.global.web_frontend_port
|
29
|
-
repositories = config.shares.map { |x| Repository.new(x) }
|
30
|
-
web_server = Server.new(self, web_port, repositories)
|
31
|
-
web_server.start
|
32
|
-
web_server.wait_for_start_and_open(restarting)
|
33
|
-
end
|
25
|
+
@runners = Runner.start_all(shares)
|
26
|
+
repositories = shares.map { |x| Repository.new(x) }
|
27
|
+
Server.start_and_wait(self, web_port, repositories)
|
34
28
|
end
|
35
29
|
rescue Restart
|
36
|
-
restarting = true
|
37
30
|
retry
|
38
31
|
end
|
39
|
-
rescue Exception => e #
|
40
|
-
|
32
|
+
rescue Exception => e # rubocop:disable RescueException
|
33
|
+
# Report all errors in log
|
34
|
+
log("#{e.class.inspect} - #{e.inspect} - #{e.message.inspect}", :error)
|
41
35
|
log(e.backtrace.join("\n"), :error)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
msg = 'Something went wrong. Please see the log for details.'
|
47
|
-
|
48
|
-
Guard::Notifier.notify(msg, title: title, image: :failure)
|
49
|
-
Kernel.warn("#{title}: #{msg}")
|
50
|
-
rescue
|
51
|
-
# do nothing, This contain any exceptions which might be thrown by
|
52
|
-
# the notification.
|
53
|
-
end
|
54
|
-
|
36
|
+
Gitdocs::Notifier.error(
|
37
|
+
'Unexpected exit',
|
38
|
+
'Something went wrong. Please see the log for details.'
|
39
|
+
)
|
55
40
|
raise
|
56
41
|
ensure
|
57
42
|
log("Gitdocs is terminating...goodbye\n\n")
|
@@ -74,5 +59,28 @@ module Gitdocs
|
|
74
59
|
def log(msg, level = :info)
|
75
60
|
@debug ? puts(msg) : @logger.send(level, msg)
|
76
61
|
end
|
62
|
+
|
63
|
+
def start_web_frontend
|
64
|
+
config.start_web_frontend
|
65
|
+
end
|
66
|
+
|
67
|
+
def web_frontend_port
|
68
|
+
config.web_frontend_port
|
69
|
+
end
|
70
|
+
|
71
|
+
def shares
|
72
|
+
config.shares
|
73
|
+
end
|
74
|
+
|
75
|
+
# @see Gitdocs::Configuration#update_all
|
76
|
+
def update_all(new_config)
|
77
|
+
config.update_all(new_config)
|
78
|
+
EM.add_timer(0.1) { restart }
|
79
|
+
end
|
80
|
+
|
81
|
+
# @see Gitdocs::Configuration#remove_by_id
|
82
|
+
def remove_by_id(id)
|
83
|
+
config.remove_by_id(id)
|
84
|
+
end
|
77
85
|
end
|
78
86
|
end
|
data/lib/gitdocs/notifier.rb
CHANGED
@@ -4,35 +4,118 @@
|
|
4
4
|
class Gitdocs::Notifier
|
5
5
|
INFO_ICON = File.expand_path('../../img/icon.png', __FILE__)
|
6
6
|
|
7
|
+
# Wrapper around #error for a single call to the notifier.
|
8
|
+
# @param (see #error)
|
9
|
+
def self.error(title, message)
|
10
|
+
Gitdocs::Notifier.new(true).error(title, message)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [Boolean] show_notifications
|
7
14
|
def initialize(show_notifications)
|
8
15
|
@show_notifications = show_notifications
|
9
16
|
Guard::Notifier.turn_on if @show_notifications
|
10
17
|
end
|
11
18
|
|
19
|
+
# @param [String] title
|
20
|
+
# @param [String] message
|
12
21
|
def info(title, message)
|
13
22
|
if @show_notifications
|
14
23
|
Guard::Notifier.notify(message, title: title, image: INFO_ICON)
|
15
24
|
else
|
16
25
|
puts("#{title}: #{message}")
|
17
26
|
end
|
18
|
-
rescue #
|
27
|
+
rescue # rubocop:disable Lint/HandleExceptions
|
28
|
+
# Prevent StandardErrors from stopping the daemon.
|
19
29
|
end
|
20
30
|
|
21
|
-
|
31
|
+
# @param [String] title
|
32
|
+
# @param [String] message
|
33
|
+
def warn(title, message)
|
22
34
|
if @show_notifications
|
23
|
-
Guard::Notifier.notify(
|
35
|
+
Guard::Notifier.notify(message, title: title)
|
24
36
|
else
|
25
|
-
Kernel.warn("#{title}: #{
|
37
|
+
Kernel.warn("#{title}: #{message}")
|
26
38
|
end
|
27
|
-
rescue #
|
39
|
+
rescue # rubocop:disable Lint/HandleExceptions
|
40
|
+
# Prevent StandardErrors from stopping the daemon.
|
28
41
|
end
|
29
42
|
|
43
|
+
# @param [String] title
|
44
|
+
# @param [String] message
|
30
45
|
def error(title, message)
|
31
46
|
if @show_notifications
|
32
47
|
Guard::Notifier.notify(message, title: title, image: :failure)
|
33
48
|
else
|
34
49
|
Kernel.warn("#{title}: #{message}")
|
35
50
|
end
|
36
|
-
rescue #
|
51
|
+
rescue # rubocop:disable Lint/HandleExceptions
|
52
|
+
# Prevent StandardErrors from stopping the daemon.
|
53
|
+
end
|
54
|
+
|
55
|
+
# @param [nil, Symbol, Array<String>, Hash<String => Integer>, #to_s] result
|
56
|
+
# @param [String] root
|
57
|
+
def merge_notification(result, root)
|
58
|
+
return if result.nil?
|
59
|
+
return if result == :no_remote
|
60
|
+
return if result == :ok
|
61
|
+
return if result == {}
|
62
|
+
|
63
|
+
if result.is_a?(Array)
|
64
|
+
warn(
|
65
|
+
'There were some conflicts',
|
66
|
+
result.map { |f| "* #{f}" }.join("\n")
|
67
|
+
)
|
68
|
+
elsif result.is_a?(Hash)
|
69
|
+
info(
|
70
|
+
"Updated with #{change_to_s(result)}",
|
71
|
+
"In #{root}:\n#{author_list(result)}"
|
72
|
+
)
|
73
|
+
else
|
74
|
+
error(
|
75
|
+
'There was a problem synchronizing this gitdoc',
|
76
|
+
"A problem occurred in #{root}:\n#{result}"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# @param [nil, Symbol, Hash<String => Integer>, #to_s] result push operation
|
82
|
+
# @param [String] root
|
83
|
+
def push_notification(result, root)
|
84
|
+
return if result.nil?
|
85
|
+
return if result == :no_remote
|
86
|
+
return if result == :nothing
|
87
|
+
|
88
|
+
if result == :conflict
|
89
|
+
warn("There was a conflict in #{root}, retrying", '')
|
90
|
+
elsif result.is_a?(Hash)
|
91
|
+
info("Pushed #{change_to_s(result)}", "#{root} has been pushed")
|
92
|
+
else
|
93
|
+
error("BAD Could not push changes in #{root}", result.to_s)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
##############################################################################
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
# @param [Hash<String => Integer>] changes
|
102
|
+
# @return [String]
|
103
|
+
def author_list(changes)
|
104
|
+
changes
|
105
|
+
.map { |author, count| "* #{author} (#{change_to_s(count)})" }
|
106
|
+
.join("\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
# @param [Integer, Hash<String => Integer>] count_or_hash
|
110
|
+
# @return [String]
|
111
|
+
def change_to_s(count_or_hash)
|
112
|
+
count =
|
113
|
+
if count_or_hash.respond_to?(:values)
|
114
|
+
count_or_hash.values.reduce(:+)
|
115
|
+
else
|
116
|
+
count_or_hash
|
117
|
+
end
|
118
|
+
|
119
|
+
"#{count} change#{count == 1 ? '' : 's'}"
|
37
120
|
end
|
38
121
|
end
|
Binary file
|
Binary file
|
@@ -2,9 +2,9 @@ GitDocs = {
|
|
2
2
|
// Links all breadcrumb options in the explored path
|
3
3
|
linkBreadcrumbs : function() {
|
4
4
|
var fullPath = $('span.path').text().replace(/\/+/g, '/').replace(/\/$/, '');
|
5
|
-
if (fullPath.length
|
5
|
+
if (fullPath.length === 0) { return; }
|
6
6
|
var docIdx = window.location.pathname.match(/\/(\d+)/);
|
7
|
-
if (!docIdx) return false;
|
7
|
+
if (!docIdx) { return false; }
|
8
8
|
var paths = fullPath.split("/");
|
9
9
|
$(paths).each(function(idx, subpath) {
|
10
10
|
var relPath = paths.slice(0, idx+1).join("/");
|
@@ -17,7 +17,7 @@ GitDocs = {
|
|
17
17
|
fillDirMeta : function(){
|
18
18
|
$('table#fileListing tbody tr').each(function(i, e) {
|
19
19
|
var file = $(e).find('a').attr('href');
|
20
|
-
var fileListingBody = $('table#fileListing tbody')
|
20
|
+
var fileListingBody = $('table#fileListing tbody');
|
21
21
|
$.getJSON(file + "?mode=meta", function(data) {
|
22
22
|
$(e).addClass('loaded').find('td.author').html(data.author);
|
23
23
|
$(e).find('td.modified').html(RelativeDate.time_ago_in_words(data.modified));
|
@@ -31,22 +31,26 @@ GitDocs = {
|
|
31
31
|
// Fire when the page is finished loading
|
32
32
|
pageLoaded : function() {
|
33
33
|
// Enable table sorter
|
34
|
-
var extractor = function(e) { return $(e).data('val') || $(e).text() }
|
34
|
+
var extractor = function(e) { return $(e).data('val') || $(e).text(); };
|
35
35
|
$("table#fileListing").tablesorter({ textExtraction : extractor, sortList: [[0,0]] });
|
36
36
|
},
|
37
37
|
// Displays a closeable alert within the content pane
|
38
38
|
// Gitdocs.showAlert('This is the message', 'success')
|
39
39
|
showAlert : function(body, result) {
|
40
|
-
if (result
|
40
|
+
if (result === null) { result = 'info'; }
|
41
41
|
$('.content div.alert-message').remove();
|
42
|
-
var el = $('.content').prepend(
|
43
|
-
'
|
42
|
+
var el = $('.content').prepend(
|
43
|
+
'<div class="alert-message ' + result + '">'
|
44
|
+
+ '<a class="close" href="#">×</a>'
|
45
|
+
+ body
|
46
|
+
+ '</div>'
|
47
|
+
);
|
44
48
|
$('div.alert-message').alert();
|
45
49
|
},
|
46
50
|
// converts iso8601 dates tagged with .reldate to relative
|
47
51
|
convertRelativeTimes : function() {
|
48
52
|
$('.reldate').each(function(ind, el) {
|
49
|
-
if ($(el).data("iso")) return;
|
53
|
+
if ($(el).data("iso")) { return; }
|
50
54
|
var iso = $(el).text();
|
51
55
|
$(el).data("iso", iso);
|
52
56
|
$(el).text(RelativeDate.time_ago_in_words(iso));
|
@@ -54,7 +58,8 @@ GitDocs = {
|
|
54
58
|
},
|
55
59
|
activateTabs : function() {
|
56
60
|
$('ul.tabs li a').each(function() {
|
57
|
-
|
61
|
+
var href = $(this).attr('href');
|
62
|
+
if ((href === location.pathname && location.search === '') || href === location.search) {
|
58
63
|
$(this).parent().addClass('active');
|
59
64
|
}
|
60
65
|
});
|
@@ -76,7 +81,7 @@ $('form.add').live('submit', function(e){
|
|
76
81
|
|
77
82
|
$('form.add input.file').live('click', function(e) {
|
78
83
|
var docIdx = window.location.pathname.match(/\/(\d+)/);
|
79
|
-
if (!docIdx) return false;
|
84
|
+
if (!docIdx) { return false; }
|
80
85
|
var fullPath = $('span.path').text();
|
81
86
|
var newPath = "/" + docIdx[1] + (fullPath == "/" ? "/" : fullPath + "/") + $(this).parents('form').find('input.edit').val();
|
82
87
|
window.location = newPath;
|
@@ -85,7 +90,7 @@ $('form.add input.file').live('click', function(e) {
|
|
85
90
|
|
86
91
|
$('form.add input.directory').live('click', function(e) {
|
87
92
|
var docIdx = window.location.pathname.match(/\/(\d+)/);
|
88
|
-
if (!docIdx) return false;
|
93
|
+
if (!docIdx) { return false; }
|
89
94
|
var fullPath = $('span.path').text();
|
90
95
|
var newPath = "/" + docIdx[1] + (fullPath == "/" ? "/" : fullPath + "/") + $(this).parents('form').find('input.edit').val() + '?dir=true';
|
91
96
|
window.location = newPath;
|
@@ -105,3 +110,13 @@ $('a[data-method]').live('click', function(e) {
|
|
105
110
|
form.hide().append(metadata_input).appendTo('body');
|
106
111
|
form.submit();
|
107
112
|
});
|
113
|
+
|
114
|
+
// Deletion tab
|
115
|
+
$('ul.tabs a.delete').live('click', function(e) {
|
116
|
+
return confirm('Are you sure?')
|
117
|
+
});
|
118
|
+
|
119
|
+
// Revert a revision from the revision table
|
120
|
+
$('#revisions td.revert a').live('click', function(e) {
|
121
|
+
return confirm('Are you sure?')
|
122
|
+
});
|
@@ -21,10 +21,10 @@ $(document).ready(function() {
|
|
21
21
|
|
22
22
|
// Apply code highlighting mode based on map
|
23
23
|
$.each(langMap, function(ext, name) {
|
24
|
-
if (filename.match(ext)) { editor.getSession().setMode(new langMode[name]); }
|
24
|
+
if (filename.match(ext)) { editor.getSession().setMode(new langMode[name]()); }
|
25
25
|
});
|
26
26
|
|
27
27
|
// Display ace editor
|
28
28
|
$('form.edit').show().find('#editor').show();
|
29
|
-
editor.focus()
|
30
|
-
});
|
29
|
+
editor.focus();
|
30
|
+
});
|
@@ -6,13 +6,16 @@ GitDocs.settings = {
|
|
6
6
|
$.ajax({
|
7
7
|
type: 'POST', url: this.action, data: $(this).serialize(),
|
8
8
|
success: function() {
|
9
|
-
GitDocs.showAlert(
|
9
|
+
GitDocs.showAlert(
|
10
|
+
'<p><strong>Settings saved!</strong> Gitdocs has been restarted with your new settings.</p>',
|
11
|
+
'success'
|
12
|
+
);
|
10
13
|
}
|
11
14
|
});
|
12
15
|
return false;
|
13
16
|
});
|
14
17
|
}
|
15
|
-
}
|
18
|
+
};
|
16
19
|
|
17
20
|
$(document).ready(function() {
|
18
21
|
GitDocs.settings.observeSettingsForm();
|
@@ -20,6 +23,6 @@ $(document).ready(function() {
|
|
20
23
|
|
21
24
|
// Handle delete for settings form
|
22
25
|
$('input.remove_share').live('click', function(e){
|
23
|
-
$(this).siblings("input[type=hidden]").val("true")
|
24
|
-
$(this).parents("form").submit()
|
25
|
-
});
|
26
|
+
$(this).siblings("input[type=hidden]").val("true");
|
27
|
+
$(this).parents("form").submit();
|
28
|
+
});
|
@@ -16,7 +16,7 @@ Utils = {
|
|
16
16
|
},
|
17
17
|
// humanizeBytes(1234)
|
18
18
|
humanizeBytes : function(filesize) {
|
19
|
-
if (filesize
|
19
|
+
if (filesize === null || filesize <= 0 || filesize === "") { return "—"; }
|
20
20
|
if (filesize >= 1073741824) {
|
21
21
|
filesize = Utils.number_format(filesize / 1073741824, 2, '.', '') + ' Gb';
|
22
22
|
} else {
|
@@ -27,16 +27,16 @@ Utils = {
|
|
27
27
|
filesize = Utils.number_format(filesize / 1024, 0) + ' Kb';
|
28
28
|
} else {
|
29
29
|
filesize = Utils.number_format(filesize, 0) + ' bytes';
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
33
|
return filesize;
|
34
34
|
},
|
35
35
|
number_format : function( number, decimals, dec_point, thousands_sep ) {
|
36
36
|
var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
|
37
|
-
var d = dec_point
|
38
|
-
var t = thousands_sep
|
39
|
-
var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
|
37
|
+
var d = dec_point === undefined ? "," : dec_point;
|
38
|
+
var t = thousands_sep === undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
|
39
|
+
var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + "", j = (j = i.length) > 3 ? j % 3 : 0;
|
40
40
|
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
|
41
41
|
}
|
42
42
|
};
|
@@ -62,7 +62,7 @@ StringFormatter = {
|
|
62
62
|
// RelativeDate.time_ago_in_words(date)
|
63
63
|
var RelativeDate = {
|
64
64
|
time_ago_in_words: function(from) {
|
65
|
-
return RelativeDate.distance_of_time_in_words(new Date, RelativeDate.parseISO8601(from));
|
65
|
+
return RelativeDate.distance_of_time_in_words(new Date(), RelativeDate.parseISO8601(from));
|
66
66
|
|
67
67
|
},
|
68
68
|
distance_of_time_in_words: function(to, from) {
|
@@ -91,7 +91,7 @@ var RelativeDate = {
|
|
91
91
|
timeSubParts = timeParts[0].split(':'),
|
92
92
|
timeSecParts = timeSubParts[2].split('.'),
|
93
93
|
timeHours = Number(timeSubParts[0]),
|
94
|
-
_date = new Date;
|
94
|
+
_date = new Date();
|
95
95
|
|
96
96
|
_date.setUTCFullYear(Number(dateParts[0]));
|
97
97
|
_date.setUTCMonth(Number(dateParts[1])-1);
|
@@ -99,41 +99,42 @@ var RelativeDate = {
|
|
99
99
|
_date.setUTCHours(Number(timeHours));
|
100
100
|
_date.setUTCMinutes(Number(timeSubParts[1]));
|
101
101
|
_date.setUTCSeconds(Number(timeSecParts[0]));
|
102
|
-
if (timeSecParts[1]) _date.setUTCMilliseconds(Number(timeSecParts[1]));
|
102
|
+
if (timeSecParts[1]) { _date.setUTCMilliseconds(Number(timeSecParts[1])); }
|
103
103
|
|
104
104
|
// by using setUTC methods the date has already been converted to local time(?)
|
105
105
|
return _date;
|
106
106
|
},
|
107
107
|
humanize : function(str, shortened) {
|
108
|
-
var parts = str.split('T')[0].split('-')
|
109
|
-
var humDate = new Date;
|
108
|
+
var parts = str.split('T')[0].split('-');
|
109
|
+
var humDate = new Date();
|
110
110
|
|
111
111
|
humDate.setFullYear(Number(parts[0]));
|
112
112
|
humDate.setMonth(Number(parts[1])-1);
|
113
113
|
humDate.setDate(Number(parts[2]));
|
114
114
|
|
115
|
+
var day = "";
|
115
116
|
switch(humDate.getDay())
|
116
117
|
{
|
117
118
|
case 0:
|
118
|
-
|
119
|
+
day = "Sunday";
|
119
120
|
break;
|
120
121
|
case 1:
|
121
|
-
|
122
|
+
day = "Monday";
|
122
123
|
break;
|
123
124
|
case 2:
|
124
|
-
|
125
|
+
day = "Tuesday";
|
125
126
|
break;
|
126
127
|
case 3:
|
127
|
-
|
128
|
+
day = "Wednesday";
|
128
129
|
break;
|
129
130
|
case 4:
|
130
|
-
|
131
|
+
day = "Thursday";
|
131
132
|
break;
|
132
133
|
case 5:
|
133
|
-
|
134
|
+
day = "Friday";
|
134
135
|
break;
|
135
136
|
case 6:
|
136
|
-
|
137
|
+
day = "Saturday";
|
137
138
|
break;
|
138
139
|
}
|
139
140
|
if(shortened) {
|
@@ -142,4 +143,4 @@ var RelativeDate = {
|
|
142
143
|
return day + ', ' + humDate.toLocaleDateString();
|
143
144
|
}
|
144
145
|
}
|
145
|
-
};
|
146
|
+
};
|