forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicenseOptions.js
More file actions
92 lines (77 loc) · 2.95 KB
/
licenseOptions.js
File metadata and controls
92 lines (77 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This was a student project to
// allow the user to chose favoite CC licence terms and have them highlighted
// tabulator.options becaome UI.licenseOptions
// Possible future alternative directoons: Store licence preferences in a solid preferences file
const licenseURI = ['http://creativecommons.org/licenses/by-nc-nd/3.0/',
'http://creativecommons.org/licenses/by-nc-sa/3.0/',
'http://creativecommons.org/licenses/by-nc/3.0/',
'http://creativecommons.org/licenses/by-nd/3.0/',
'http://creativecommons.org/licenses/by-sa/3.0/',
'http://creativecommons.org/licenses/by/3.0/'
]
const names = ['BY-NC-ND', 'BY-NC-SA', 'BY-NC', 'BY-ND', 'BY-SA', 'BY']
const UI = require('solid-ui')
var kb = UI.store
module.exports = function licenseOptions () {
this.options = {}
this.references = []
this.checkedLicenses = []
this.openCheckBoxWindow = function () {
this.this.display = window.open(' ', 'NewWin',
'menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=200,width=200')
}
var message = "<font face='arial' size='2'><form name ='checkboxes'>"
var lics = this.checkedLicenses
for (var kk = 0; kk < lics.length; kk++) {
message += "<input type='checkbox' name = 'n" + kk +
"' onClick = 'tabulator.options.submit()'" + // @@ FIXME
(lics[kk] ? 'CHECKED' : '') + ' />CC: ' + names[kk] + '<br />'
}
message += "<br /> <a onclick='tabulator.options.selectAll()'>[Select All] </a>" // @@ FIXME
message += "<a onclick='tabulator.options.deselectAll()'> [Deselect All]</a>" // @@ FIXME
message += '</form></font>'
this.display.document.write(message)
this.display.document.close()
var i
for (i = 0; i < 6; i++) {
this.references[i] = this.this.display.document.checkboxes.elements[i]
}
this.selectAll = function () {
var i
for (i = 0; i < 6; i++) {
this.display.document.checkboxes.elements[i].checked = true
this.references[i].checked = true
this.checkedLicenses[i] = true
}
}
this.deselectAll = function () {
var i
for (i = 0; i < 6; i++) {
this.display.document.checkboxes.elements[i].checked = false
this.references[i].checked = false
this.checkedLicenses[i] = false
}
}
this.submit = function () {
// alert('this.submit: checked=' + this.references[0].checked)
for (let i = 0; i < 6; i++) {
this.checkedLicenses[i] = !!this.references[i].checked
}
}
this.checkLicence = function checkLicense (statement) {
var licenses = kb.each(statement.why, kb.sym('http://creativecommons.org/ns#license'))
UI.log.info('licenses:' + statement.why + ': ' + licenses)
for (let i = 0; i < licenses.length; i++) {
for (let j = 0; j < this.checkedLicenses.length; j++) {
if (this.checkedLicenses[j] && (licenses[i].uri === licenseURI[j])) {
return true
// theClass += ' licOkay' // icon_expand
// break
}
}
}
return false
}
return this
}
// ends