Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
10344905
Commit
10344905
authored
Aug 06, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abstracted functionality to get datetime into separate JS function
parent
eefed18b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
cms/static/js/base.js
+27
-14
No files found.
cms/static/js/base.js
View file @
10344905
...
...
@@ -253,6 +253,22 @@ function syncReleaseDate(e) {
$
(
"#start_time"
).
val
(
""
);
}
function
getDatetime
(
datepickerInput
,
timepickerInput
)
{
// given a pair of inputs (datepicker and timepicker), return a JS Date
// object that corresponds to the datetime that they represent. Assume
// UTC timezone, NOT the timezone of the user's browser.
var
date
=
$
(
datepickerInput
).
datepicker
(
"getDate"
);
var
time
=
$
(
timepickerInput
).
timepicker
(
"getTime"
);
if
(
date
&&
time
)
{
return
new
Date
(
Date
.
UTC
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
time
.
getHours
(),
time
.
getMinutes
()
));
}
else
{
return
null
;
}
}
function
autosaveInput
(
e
)
{
var
self
=
this
;
if
(
this
.
saveTimer
)
{
...
...
@@ -292,14 +308,13 @@ function saveSubsection() {
// get datetimes for start and due, stick into metadata
_
([
"start"
,
"due"
]).
each
(
function
(
name
)
{
var
date
,
time
;
date
=
$
(
"#"
+
name
+
"_date"
).
datepicker
(
"getDate"
);
time
=
$
(
"#"
+
name
+
"_time"
).
timepicker
(
"getTime"
);
if
(
date
&&
time
)
{
metadata
[
name
]
=
new
Date
(
Date
.
UTC
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
time
.
getHours
(),
time
.
getMinutes
()
));
var
datetime
=
getDatetime
(
document
.
getElementById
(
name
+
"_date"
),
document
.
getElementById
(
name
+
"_time"
)
);
if
(
datetime
)
{
metadata
[
name
]
=
datetime
;
}
});
...
...
@@ -764,12 +779,10 @@ function cancelSetSectionScheduleDate(e) {
function
saveSetSectionScheduleDate
(
e
)
{
e
.
preventDefault
();
var
date
=
$
(
'.edit-subsection-publish-settings .start-date'
).
datepicker
(
"getDate"
);
var
time
=
$
(
'.edit-subsection-publish-settings .start-time'
).
timepicker
(
"getTime"
);
var
datetime
=
new
Date
(
Date
.
UTC
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
time
.
getHours
(),
time
.
getMinutes
()
));
var
datetime
=
getDatetime
(
$
(
'.edit-subsection-publish-settings .start-date'
),
$
(
'.edit-subsection-publish-settings .start-time'
)
);
var
id
=
$modal
.
attr
(
'data-id'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment