|
@@ -48,40 +48,101 @@ function date_to_unix(value) {
|
|
|
}
|
|
|
|
|
|
class ArchiveView {
|
|
|
- constructor(mindate, selecttype, dateselector, range_from, range_to, rangespan, commitsSelect, content, token, url, project_id, branch, page_path, index) {
|
|
|
+ constructor(mindate, maindiv, token, url, project_id, branch, page_path, index) {
|
|
|
+
|
|
|
this.token = token
|
|
|
this.url = url
|
|
|
this.project_id = project_id
|
|
|
this.branch = branch
|
|
|
|
|
|
+ this.maindiv = maindiv
|
|
|
+
|
|
|
+ var outer_span = document.createElement("span")
|
|
|
+ this.maindiv.appendChild(outer_span)
|
|
|
+
|
|
|
+ // ---
|
|
|
+
|
|
|
+ this.selecttype = document.createElement("select")
|
|
|
+ outer_span.appendChild(this.selecttype)
|
|
|
+
|
|
|
+ var option_date = document.createElement("option")
|
|
|
+ option_date.value = "date"
|
|
|
+ option_date.innerHTML = "Date"
|
|
|
+ this.selecttype.appendChild(option_date)
|
|
|
+
|
|
|
+ var option_range = document.createElement("option")
|
|
|
+ option_range.value = "range"
|
|
|
+ option_range.innerHTML = "Range"
|
|
|
+ this.selecttype.appendChild(option_range)
|
|
|
+
|
|
|
+ this.selecttype.addEventListener("input",(() => this.on_selecttype_selected()))
|
|
|
+
|
|
|
+ // ---
|
|
|
+
|
|
|
+ outer_span.append(" (" + mindate + " to today): ")
|
|
|
+
|
|
|
+ this.dateselector = document.createElement("input")
|
|
|
+ this.dateselector.type = "date"
|
|
|
+
|
|
|
// Alternative, doesn't allow selecting today in first two hours of day:
|
|
|
// var maxdate = new Date().toISOString().split("T")[0]
|
|
|
var maxdate = new Date().toLocaleDateString('en-ca')
|
|
|
- this.dateselector = dateselector
|
|
|
this.dateselector.value = ""
|
|
|
this.dateselector.max = maxdate
|
|
|
this.dateselector.addEventListener("input",((event) => this.on_date_selected(event)))
|
|
|
|
|
|
- this.range_from = range_from
|
|
|
+ outer_span.appendChild(this.dateselector)
|
|
|
+
|
|
|
+ // ---
|
|
|
+
|
|
|
+ this.rangespan = document.createElement("span")
|
|
|
+ outer_span.appendChild(this.rangespan)
|
|
|
+
|
|
|
+
|
|
|
+ this.range_from = document.createElement("input")
|
|
|
+ this.range_from.type = "datetime-local"
|
|
|
+
|
|
|
this.range_from.value = ""
|
|
|
this.range_from.min = mindate + "T00:00"
|
|
|
this.range_from.max = maxdate + "T23:59"
|
|
|
this.range_from.addEventListener("input",(() => this.on_range_from_selected()))
|
|
|
|
|
|
- this.range_to = range_to
|
|
|
+ this.rangespan.appendChild(this.range_from)
|
|
|
+
|
|
|
+
|
|
|
+ this.rangespan.insertAdjacentHTML('beforeend', " – ")
|
|
|
+
|
|
|
+
|
|
|
+ this.range_to = document.createElement("input")
|
|
|
+ this.range_to.type = "datetime-local"
|
|
|
+ this.range_to.disabled = true
|
|
|
+
|
|
|
this.range_to.value = ""
|
|
|
this.range_to.max = maxdate + "T23:59"
|
|
|
this.range_to.addEventListener("input",(() => this.on_range_to_selected()))
|
|
|
+
|
|
|
+ this.rangespan.appendChild(this.range_to)
|
|
|
|
|
|
- this.rangespan = rangespan
|
|
|
+ // ---
|
|
|
|
|
|
- this.selecttype = selecttype
|
|
|
- this.selecttype.addEventListener("input",(() => this.on_selecttype_selected()))
|
|
|
+ outer_span.append(" | Version: ")
|
|
|
|
|
|
- this.commitsSelect = commitsSelect
|
|
|
+ this.commitsSelect = document.createElement("select")
|
|
|
+ this.commitsSelect.className = "archive commits"
|
|
|
+
|
|
|
this.commitsSelect.addEventListener("input",(() => this.on_commit_selected()))
|
|
|
+
|
|
|
+ outer_span.appendChild(this.commitsSelect)
|
|
|
+
|
|
|
+ outer_span.insertAdjacentHTML('beforeend', "<br/><i>Note: Large time ranges can slow the version selection down.</i>")
|
|
|
+
|
|
|
+ // ---
|
|
|
+
|
|
|
+ this.content = document.createElement("iframe")
|
|
|
+ this.content.className = "archive content"
|
|
|
+ this.content.height = "100%"
|
|
|
|
|
|
- this.content = content
|
|
|
+ this.maindiv.appendChild(this.content)
|
|
|
|
|
|
this.page_path = page_path
|
|
|
|