solid-ui 2.4.14-842f7f26 → 2.4.14-alpha
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.
- package/LICENSE.md +0 -0
- package/README.md +0 -0
- package/lib/acl/access-controller.d.ts +0 -0
- package/lib/acl/access-controller.d.ts.map +0 -0
- package/lib/acl/access-controller.js +334 -441
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.d.ts +0 -0
- package/lib/acl/access-groups.d.ts.map +0 -0
- package/lib/acl/access-groups.js +347 -492
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.d.ts +0 -0
- package/lib/acl/acl-control.d.ts.map +0 -0
- package/lib/acl/acl-control.js +168 -198
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.d.ts +0 -0
- package/lib/acl/acl.d.ts.map +0 -0
- package/lib/acl/acl.js +444 -459
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.d.ts +0 -0
- package/lib/acl/add-agent-buttons.d.ts.map +0 -0
- package/lib/acl/add-agent-buttons.js +318 -515
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/index.d.ts +0 -0
- package/lib/acl/index.d.ts.map +0 -0
- package/lib/acl/index.js +27 -35
- package/lib/acl/index.js.map +1 -1
- package/lib/acl/styles.d.ts +0 -0
- package/lib/acl/styles.d.ts.map +0 -0
- package/lib/acl/styles.js +84 -90
- package/lib/acl/styles.js.map +1 -1
- package/lib/acl/types.d.ts +0 -0
- package/lib/acl/types.d.ts.map +0 -0
- package/lib/acl/types.js +5 -4
- package/lib/acl/types.js.map +1 -1
- package/lib/authn/authSession.d.ts +0 -0
- package/lib/authn/authSession.d.ts.map +0 -0
- package/lib/authn/authSession.js +14 -21
- package/lib/authn/authSession.js.map +1 -1
- package/lib/authn/authn.d.ts +0 -0
- package/lib/authn/authn.d.ts.map +0 -0
- package/lib/authn/authn.js +1391 -1935
- package/lib/authn/authn.js.map +1 -1
- package/lib/authn/config-default.js +0 -0
- package/lib/authn/config-default.js.map +0 -0
- package/lib/authn/index.d.ts +0 -0
- package/lib/authn/index.d.ts.map +0 -0
- package/lib/authn/index.js +26 -37
- package/lib/authn/index.js.map +1 -1
- package/lib/authn/signup.js +0 -0
- package/lib/authn/signup.js.map +0 -0
- package/lib/authn/types.d.ts +0 -0
- package/lib/authn/types.d.ts.map +0 -0
- package/lib/authn/types.js +1 -4
- package/lib/authn/types.js.map +1 -1
- package/lib/chat/bookmarks.js +0 -0
- package/lib/chat/bookmarks.js.map +0 -0
- package/lib/chat/dateFolder.js +0 -0
- package/lib/chat/dateFolder.js.map +0 -0
- package/lib/chat/infinite.js +0 -0
- package/lib/chat/infinite.js.map +0 -0
- package/lib/chat/message.js +0 -0
- package/lib/chat/message.js.map +0 -0
- package/lib/chat/messageTools.js +0 -0
- package/lib/chat/messageTools.js.map +0 -0
- package/lib/chat/thread.js +0 -0
- package/lib/chat/thread.js.map +0 -0
- package/lib/create/create.d.ts +0 -0
- package/lib/create/create.d.ts.map +0 -0
- package/lib/create/create.js +209 -214
- package/lib/create/create.js.map +1 -1
- package/lib/create/index.d.ts +0 -0
- package/lib/create/index.d.ts.map +0 -0
- package/lib/create/index.js +4 -10
- package/lib/create/index.js.map +1 -1
- package/lib/create/types.d.ts +0 -0
- package/lib/create/types.d.ts.map +0 -0
- package/lib/create/types.js +1 -4
- package/lib/create/types.js.map +1 -1
- package/lib/debug.d.ts +0 -0
- package/lib/debug.d.ts.map +0 -0
- package/lib/debug.js +30 -28
- package/lib/debug.js.map +1 -1
- package/lib/folders.js +0 -0
- package/lib/folders.js.map +0 -0
- package/lib/footer/index.d.ts +20 -0
- package/lib/footer/index.d.ts.map +1 -0
- package/lib/footer/index.js +130 -0
- package/lib/footer/index.js.map +1 -0
- package/lib/footer/styleMap.d.ts +8 -0
- package/lib/footer/styleMap.d.ts.map +1 -0
- package/lib/footer/styleMap.js +11 -0
- package/lib/footer/styleMap.js.map +1 -0
- package/lib/header/empty-profile.d.ts +0 -0
- package/lib/header/empty-profile.d.ts.map +0 -0
- package/lib/header/empty-profile.js +2 -6
- package/lib/header/empty-profile.js.map +1 -1
- package/lib/header/index.d.ts +11 -8
- package/lib/header/index.d.ts.map +1 -1
- package/lib/header/index.js +291 -355
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.d.ts +0 -2
- package/lib/header/styleMap.d.ts.map +1 -1
- package/lib/header/styleMap.js +116 -136
- package/lib/header/styleMap.js.map +1 -1
- package/lib/iconBase.d.ts +0 -0
- package/lib/iconBase.d.ts.map +0 -0
- package/lib/iconBase.js +23 -30
- package/lib/iconBase.js.map +1 -1
- package/lib/icons/solid_logo.d.ts +0 -0
- package/lib/icons/solid_logo.d.ts.map +0 -0
- package/lib/icons/solid_logo.js +0 -0
- package/lib/icons/solid_logo.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +103 -198
- package/lib/index.js.map +1 -1
- package/lib/jss/index.d.ts +0 -0
- package/lib/jss/index.d.ts.map +0 -0
- package/lib/jss/index.js +21 -30
- package/lib/jss/index.js.map +1 -1
- package/lib/log.d.ts +0 -0
- package/lib/log.d.ts.map +0 -0
- package/lib/log.js +83 -131
- package/lib/log.js.map +1 -1
- package/lib/logic.d.ts +0 -0
- package/lib/logic.d.ts.map +0 -0
- package/lib/logic.js +82 -69
- package/lib/logic.js.map +1 -1
- package/lib/matrix/index.d.ts +0 -0
- package/lib/matrix/index.d.ts.map +0 -0
- package/lib/matrix/index.js +4 -10
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/matrix.d.ts +0 -0
- package/lib/matrix/matrix.d.ts.map +0 -0
- package/lib/matrix/matrix.js +210 -237
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/matrix/types.d.ts +0 -0
- package/lib/matrix/types.d.ts.map +0 -0
- package/lib/matrix/types.js +1 -4
- package/lib/matrix/types.js.map +1 -1
- package/lib/media/index.d.ts +0 -0
- package/lib/media/index.d.ts.map +0 -0
- package/lib/media/index.js +5 -11
- package/lib/media/index.js.map +1 -1
- package/lib/media/media-capture.d.ts +0 -0
- package/lib/media/media-capture.d.ts.map +0 -0
- package/lib/media/media-capture.js +187 -181
- package/lib/media/media-capture.js.map +1 -1
- package/lib/messageArea.js +0 -0
- package/lib/messageArea.js.map +0 -0
- package/lib/noun_Camera_1618446_000000.js +0 -0
- package/lib/noun_Camera_1618446_000000.js.map +0 -0
- package/lib/ns.js +0 -0
- package/lib/ns.js.map +0 -0
- package/lib/pad.d.ts +0 -0
- package/lib/pad.d.ts.map +0 -0
- package/lib/pad.js +794 -954
- package/lib/pad.js.map +1 -1
- package/lib/participation.d.ts +0 -0
- package/lib/participation.d.ts.map +0 -0
- package/lib/participation.js +170 -199
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +0 -0
- package/lib/preferences.js.map +0 -0
- package/lib/stories/decorators.js +0 -0
- package/lib/stories/decorators.js.map +0 -0
- package/lib/style.js +0 -0
- package/lib/style.js.map +0 -0
- package/lib/table.js +0 -0
- package/lib/table.js.map +0 -0
- package/lib/tabs.d.ts +0 -0
- package/lib/tabs.d.ts.map +0 -0
- package/lib/tabs.js +235 -342
- package/lib/tabs.js.map +1 -1
- package/lib/typings.d.js +0 -0
- package/lib/typings.d.js.map +0 -0
- package/lib/{header/headerHelpers.d.ts → utils/headerFooterHelpers.d.ts} +11 -3
- package/lib/utils/headerFooterHelpers.d.ts.map +1 -0
- package/lib/utils/headerFooterHelpers.js +164 -0
- package/lib/utils/headerFooterHelpers.js.map +1 -0
- package/lib/utils/index.js +0 -0
- package/lib/utils/index.js.map +0 -0
- package/lib/utils/label.d.ts +0 -0
- package/lib/utils/label.d.ts.map +0 -0
- package/lib/utils/label.js +121 -113
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.d.ts +0 -0
- package/lib/versionInfo.d.ts.map +0 -0
- package/lib/versionInfo.js +23 -28
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +454 -160
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.d.ts +0 -0
- package/lib/widgets/buttons/iconLinks.d.ts.map +0 -0
- package/lib/widgets/buttons/iconLinks.js +19 -30
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- package/lib/widgets/buttons.d.ts +0 -0
- package/lib/widgets/buttons.d.ts.map +0 -0
- package/lib/widgets/buttons.js +935 -1113
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +0 -0
- package/lib/widgets/dragAndDrop.js.map +0 -0
- package/lib/widgets/error.d.ts +0 -0
- package/lib/widgets/error.d.ts.map +0 -0
- package/lib/widgets/error.js +18 -24
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteBar.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +234 -325
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteField.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/autocompleteField.js +246 -276
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +317 -497
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/language.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/language.js +159 -212
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.d.ts +0 -0
- package/lib/widgets/forms/autocomplete/publicData.d.ts.map +0 -0
- package/lib/widgets/forms/autocomplete/publicData.js +485 -718
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.d.ts +0 -0
- package/lib/widgets/forms/basic.d.ts.map +0 -0
- package/lib/widgets/forms/basic.js +208 -239
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.d.ts +0 -0
- package/lib/widgets/forms/comment.d.ts.map +0 -0
- package/lib/widgets/forms/comment.js +48 -48
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.d.ts +0 -0
- package/lib/widgets/forms/fieldFunction.d.ts.map +0 -0
- package/lib/widgets/forms/fieldFunction.js +31 -50
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/fieldParams.d.ts +0 -0
- package/lib/widgets/forms/fieldParams.d.ts.map +0 -0
- package/lib/widgets/forms/fieldParams.js +102 -81
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms/formStyle.d.ts +0 -0
- package/lib/widgets/forms/formStyle.d.ts.map +0 -0
- package/lib/widgets/forms/formStyle.js +52 -50
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +0 -0
- package/lib/widgets/forms.js.map +0 -0
- package/lib/widgets/index.js +0 -0
- package/lib/widgets/index.js.map +0 -0
- package/lib/widgets/peoplePicker.js +0 -0
- package/lib/widgets/peoplePicker.js.map +0 -0
- package/lib/widgets/widgetHelpers.d.ts +0 -0
- package/lib/widgets/widgetHelpers.d.ts.map +0 -0
- package/lib/widgets/widgetHelpers.js +18 -30
- package/lib/widgets/widgetHelpers.js.map +1 -1
- package/package.json +5 -4
- package/lib/header/headerHelpers.d.ts.map +0 -1
- package/lib/header/headerHelpers.js +0 -96
- package/lib/header/headerHelpers.js.map +0 -1
package/lib/widgets/buttons.js
CHANGED
|
@@ -1,248 +1,203 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
7
13
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
exports.continueButton =
|
|
17
|
-
exports.createLinkDiv = createLinkDiv;
|
|
18
|
-
exports.createNameDiv = createNameDiv;
|
|
19
|
-
exports.defaultAnnotationStore = defaultAnnotationStore;
|
|
20
|
-
exports.deleteButtonWithCheck = deleteButtonWithCheck;
|
|
21
|
-
exports.extractLogURI = extractLogURI;
|
|
22
|
-
exports.faviconOrDefault = faviconOrDefault;
|
|
23
|
-
exports.fileUploadButtonDiv = fileUploadButtonDiv;
|
|
24
|
-
exports.findImage = findImage;
|
|
25
|
-
exports.findImageFromURI = findImageFromURI;
|
|
26
|
-
exports.formatDateTime = formatDateTime;
|
|
27
|
-
exports.iconForClass = void 0;
|
|
28
|
-
exports.imagesOf = imagesOf;
|
|
29
|
-
exports.index = void 0;
|
|
30
|
-
exports.isAudio = isAudio;
|
|
31
|
-
exports.isImage = isImage;
|
|
32
|
-
exports.isVideo = isVideo;
|
|
33
|
-
exports.linkButton = linkButton;
|
|
34
|
-
exports.openHrefInOutlineMode = openHrefInOutlineMode;
|
|
35
|
-
exports.personTR = void 0;
|
|
36
|
-
exports.propertyTriage = propertyTriage;
|
|
37
|
-
exports.refreshTree = refreshTree;
|
|
38
|
-
exports.removeButton = removeButton;
|
|
39
|
-
exports.renderAsDiv = renderAsDiv;
|
|
40
|
-
exports.renderAsRow = renderAsRow;
|
|
41
|
-
exports.selectorPanel = selectorPanel;
|
|
42
|
-
exports.selectorPanelRefresh = selectorPanelRefresh;
|
|
43
|
-
exports.setImage = setImage;
|
|
44
|
-
exports.setName = setName;
|
|
45
|
-
exports.shortDate = shortDate;
|
|
46
|
-
exports.shortTime = shortTime;
|
|
47
|
-
exports.timestamp = timestamp;
|
|
48
|
-
|
|
49
|
-
var _rdflib = require("rdflib");
|
|
50
|
-
|
|
51
|
-
var _iconBase = require("../iconBase");
|
|
52
|
-
|
|
53
|
-
var ns = _interopRequireWildcard(require("../ns"));
|
|
54
|
-
|
|
55
|
-
var style = _interopRequireWildcard(require("../style"));
|
|
56
|
-
|
|
57
|
-
var debug = _interopRequireWildcard(require("../debug"));
|
|
58
|
-
|
|
59
|
-
var _log = require("../log");
|
|
60
|
-
|
|
61
|
-
var _jss = require("../jss");
|
|
62
|
-
|
|
63
|
-
var _dragAndDrop = require("./dragAndDrop");
|
|
64
|
-
|
|
65
|
-
var _logic = require("../logic");
|
|
66
|
-
|
|
67
|
-
var utils = _interopRequireWildcard(require("../utils"));
|
|
68
|
-
|
|
69
|
-
var _error = require("./error");
|
|
70
|
-
|
|
71
|
-
var _widgetHelpers = require("./widgetHelpers");
|
|
72
|
-
|
|
73
|
-
var _iconLinks = require("./buttons/iconLinks");
|
|
74
|
-
|
|
75
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
76
|
-
|
|
77
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
78
|
-
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.fileUploadButtonDiv = exports.isImage = exports.isVideo = exports.isAudio = exports.addStyleSheet = exports.index = exports.selectorPanelRefresh = exports.selectorPanel = exports.removeButton = exports.linkButton = exports.propertyTriage = exports.allClassURIs = exports.defaultAnnotationStore = exports.openHrefInOutlineMode = exports.attachmentList = exports.refreshTree = exports.renderAsDiv = exports.createLinkDiv = exports.createNameDiv = exports.renderAsRow = exports.personTR = exports.askName = exports.continueButton = exports.cancelButton = exports.button = exports.deleteButtonWithCheck = exports.faviconOrDefault = exports.setImage = exports.findImage = exports.findImageFromURI = exports.iconForClass = exports.imagesOf = exports.setName = exports.shortTime = exports.timestamp = exports.formatDateTime = exports.shortDate = exports.extractLogURI = exports.clearElement = exports.complain = void 0;
|
|
79
23
|
/* Buttons
|
|
80
24
|
*/
|
|
81
|
-
|
|
25
|
+
var rdflib_1 = require("rdflib");
|
|
26
|
+
var iconBase_1 = require("../iconBase");
|
|
27
|
+
var ns = __importStar(require("../ns"));
|
|
28
|
+
var style = __importStar(require("../style"));
|
|
29
|
+
var debug = __importStar(require("../debug"));
|
|
30
|
+
var log_1 = require("../log");
|
|
31
|
+
var jss_1 = require("../jss");
|
|
32
|
+
var dragAndDrop_1 = require("./dragAndDrop");
|
|
33
|
+
var logic_1 = require("../logic");
|
|
34
|
+
var utils = __importStar(require("../utils"));
|
|
35
|
+
var error_1 = require("./error");
|
|
36
|
+
var widgetHelpers_1 = require("./widgetHelpers");
|
|
37
|
+
var iconLinks_1 = require("./buttons/iconLinks");
|
|
82
38
|
/**
|
|
83
39
|
* UI Widgets such as buttons
|
|
84
40
|
* @packageDocumentation
|
|
85
41
|
*/
|
|
86
|
-
|
|
87
42
|
/* global alert */
|
|
88
|
-
var iconBase =
|
|
43
|
+
var iconBase = iconBase_1.icons.iconBase;
|
|
89
44
|
var cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
|
|
90
|
-
|
|
91
45
|
var checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
|
|
92
|
-
|
|
93
46
|
function getStatusArea(context) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (dom) {
|
|
103
|
-
var body = dom.getElementsByTagName('body')[0];
|
|
104
|
-
box = dom.createElement('div');
|
|
105
|
-
body.insertBefore(box, body.firstElementChild);
|
|
106
|
-
|
|
107
|
-
if (context) {
|
|
108
|
-
context.statusArea = box;
|
|
47
|
+
var box = (context && context.statusArea) || (context && context.div) || null;
|
|
48
|
+
if (box)
|
|
49
|
+
return box;
|
|
50
|
+
var dom = context && context.dom;
|
|
51
|
+
if (!dom && typeof document !== 'undefined') {
|
|
52
|
+
dom = document;
|
|
109
53
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
54
|
+
if (dom) {
|
|
55
|
+
var body = dom.getElementsByTagName('body')[0];
|
|
56
|
+
box = dom.createElement('div');
|
|
57
|
+
body.insertBefore(box, body.firstElementChild);
|
|
58
|
+
if (context) {
|
|
59
|
+
context.statusArea = box;
|
|
60
|
+
}
|
|
61
|
+
return box;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
115
64
|
}
|
|
116
65
|
/**
|
|
117
66
|
* Display an error message block
|
|
118
67
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
68
|
function complain(context, err) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
69
|
+
if (!err)
|
|
70
|
+
return; // only if error
|
|
71
|
+
var ele = getStatusArea(context);
|
|
72
|
+
debug.log('Complaint: ' + err);
|
|
73
|
+
if (ele)
|
|
74
|
+
ele.appendChild((0, error_1.errorMessageBlock)((context && context.dom) || document, err));
|
|
75
|
+
else
|
|
76
|
+
alert(err);
|
|
127
77
|
}
|
|
78
|
+
exports.complain = complain;
|
|
128
79
|
/**
|
|
129
80
|
* Remove all the children of an HTML element
|
|
130
81
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
82
|
function clearElement(ele) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return ele;
|
|
83
|
+
while (ele.firstChild) {
|
|
84
|
+
ele.removeChild(ele.firstChild);
|
|
85
|
+
}
|
|
86
|
+
return ele;
|
|
139
87
|
}
|
|
88
|
+
exports.clearElement = clearElement;
|
|
140
89
|
/**
|
|
141
90
|
* To figure out the log URI from the full URI used to invoke the reasoner
|
|
142
91
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
92
|
function extractLogURI(fullURI) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
93
|
+
var logPos = fullURI.search(/logFile=/);
|
|
94
|
+
var rulPos = fullURI.search(/&rulesFile=/);
|
|
95
|
+
return fullURI.substring(logPos + 8, rulPos);
|
|
149
96
|
}
|
|
97
|
+
exports.extractLogURI = extractLogURI;
|
|
150
98
|
/**
|
|
151
99
|
* By default, converts e.g. '2020-02-19T19:35:28.557Z' to '19:35'
|
|
152
100
|
* if today is 19 Feb 2020, and to 'Feb 19' if not.
|
|
153
101
|
* @@@ TODO This needs to be changed to local time
|
|
154
102
|
* @param noTime Return a string like 'Feb 19' even if it's today.
|
|
155
103
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
104
|
function shortDate(str, noTime) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
105
|
+
if (!str)
|
|
106
|
+
return '???';
|
|
107
|
+
var month = [
|
|
108
|
+
'Jan',
|
|
109
|
+
'Feb',
|
|
110
|
+
'Mar',
|
|
111
|
+
'Apr',
|
|
112
|
+
'May',
|
|
113
|
+
'Jun',
|
|
114
|
+
'Jul',
|
|
115
|
+
'Aug',
|
|
116
|
+
'Sep',
|
|
117
|
+
'Oct',
|
|
118
|
+
'Nov',
|
|
119
|
+
'Dec'
|
|
120
|
+
];
|
|
121
|
+
try {
|
|
122
|
+
var nowZ = new Date().toISOString();
|
|
123
|
+
// var nowZ = $rdf.term(now).value
|
|
124
|
+
// var n = now.getTimezoneOffset() // Minutes
|
|
125
|
+
if (str.slice(0, 10) === nowZ.slice(0, 10) && !noTime) {
|
|
126
|
+
return str.slice(11, 16);
|
|
127
|
+
}
|
|
128
|
+
if (str.slice(0, 4) === nowZ.slice(0, 4)) {
|
|
129
|
+
return (month[parseInt(str.slice(5, 7), 10) - 1] +
|
|
130
|
+
' ' +
|
|
131
|
+
parseInt(str.slice(8, 10), 10));
|
|
132
|
+
}
|
|
133
|
+
return str.slice(0, 10);
|
|
168
134
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return month[parseInt(str.slice(5, 7), 10) - 1] + ' ' + parseInt(str.slice(8, 10), 10);
|
|
135
|
+
catch (e) {
|
|
136
|
+
return 'shortdate:' + e;
|
|
172
137
|
}
|
|
173
|
-
|
|
174
|
-
return str.slice(0, 10);
|
|
175
|
-
} catch (e) {
|
|
176
|
-
return 'shortdate:' + e;
|
|
177
|
-
}
|
|
178
138
|
}
|
|
139
|
+
exports.shortDate = shortDate;
|
|
179
140
|
/**
|
|
180
141
|
* Format a date and time
|
|
181
142
|
* @param date for instance `new Date()`
|
|
182
143
|
* @param format for instance '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}'
|
|
183
144
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
184
145
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
146
|
function formatDateTime(date, format) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
147
|
+
return format
|
|
148
|
+
.split('{')
|
|
149
|
+
.map(function (s) {
|
|
150
|
+
var k = s.split('}')[0];
|
|
151
|
+
var width = { Milliseconds: 3, FullYear: 4 };
|
|
152
|
+
var d = { Month: 1 };
|
|
153
|
+
return s
|
|
154
|
+
? ('000' + (date['get' + k]() + (d[k] || 0))).slice(-(width[k] || 2)) + s.split('}')[1]
|
|
155
|
+
: '';
|
|
156
|
+
})
|
|
157
|
+
.join('');
|
|
199
158
|
}
|
|
159
|
+
exports.formatDateTime = formatDateTime;
|
|
200
160
|
/**
|
|
201
161
|
* Get a string representation of the current time
|
|
202
162
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
203
163
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
164
|
function timestamp() {
|
|
207
|
-
|
|
165
|
+
return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
208
166
|
}
|
|
167
|
+
exports.timestamp = timestamp;
|
|
209
168
|
/**
|
|
210
169
|
* Get a short string representation of the current time
|
|
211
170
|
* @returns for instance '23:14:23.002'
|
|
212
171
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
172
|
function shortTime() {
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
173
|
+
return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
174
|
+
}
|
|
175
|
+
exports.shortTime = shortTime;
|
|
176
|
+
// ///////////////////// Handy UX widgets
|
|
219
177
|
/**
|
|
220
178
|
* Sets the best name we have and looks up a better one
|
|
221
179
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
180
|
function setName(element, x) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
244
|
-
}
|
|
181
|
+
var kb = logic_1.store;
|
|
182
|
+
var findName = function (x) {
|
|
183
|
+
var name = kb.any(x, ns.vcard('fn')) ||
|
|
184
|
+
kb.any(x, ns.foaf('name')) ||
|
|
185
|
+
kb.any(x, ns.vcard('organization-name'));
|
|
186
|
+
return name ? name.value : null;
|
|
187
|
+
};
|
|
188
|
+
var name = x.sameTerm(ns.foaf('Agent')) ? 'Everyone' : findName(x);
|
|
189
|
+
element.textContent = name || utils.label(x);
|
|
190
|
+
if (!name && x.uri) {
|
|
191
|
+
if (!kb.fetcher) {
|
|
192
|
+
throw new Error('kb has no fetcher');
|
|
193
|
+
}
|
|
194
|
+
// Note this is only a fetch, not a lookUP of all sameAs etc
|
|
195
|
+
kb.fetcher.nowOrWhenFetched(x.doc(), undefined, function (_ok) {
|
|
196
|
+
element.textContent = findName(x) || utils.label(x); // had: (ok ? '' : '? ') +
|
|
197
|
+
});
|
|
198
|
+
}
|
|
245
199
|
}
|
|
200
|
+
exports.setName = setName;
|
|
246
201
|
/**
|
|
247
202
|
* Set of suitable images
|
|
248
203
|
* See also [[findImage]]
|
|
@@ -260,104 +215,97 @@ function setName(element, x) {
|
|
|
260
215
|
* * ns.foaf('depiction')
|
|
261
216
|
|
|
262
217
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
218
|
function imagesOf(x, kb) {
|
|
266
|
-
|
|
219
|
+
return kb
|
|
220
|
+
.each(x, ns.sioc('avatar'))
|
|
221
|
+
.concat(kb.each(x, ns.foaf('img')))
|
|
222
|
+
.concat(kb.each(x, ns.vcard('logo')))
|
|
223
|
+
.concat(kb.each(x, ns.vcard('hasPhoto')))
|
|
224
|
+
.concat(kb.each(x, ns.vcard('photo')))
|
|
225
|
+
.concat(kb.each(x, ns.foaf('depiction')));
|
|
267
226
|
}
|
|
227
|
+
exports.imagesOf = imagesOf;
|
|
268
228
|
/**
|
|
269
229
|
* Best logo or avatar or photo etc to represent someone or some group etc
|
|
270
230
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
'rdf:Property': 'property-diamond.svg',
|
|
299
|
-
'owl:Ontology': 'noun_classification_1479198.svg',
|
|
300
|
-
'wf:Tracker': 'noun_122196.svg',
|
|
301
|
-
'wf:Task': 'noun_17020_gray-tick.svg',
|
|
302
|
-
'wf:Open': 'noun_17020_sans-tick.svg',
|
|
303
|
-
'wf:Closed': 'noun_17020.svg'
|
|
231
|
+
exports.iconForClass = {
|
|
232
|
+
// Potentially extendable by other apps, panes, etc
|
|
233
|
+
// Relative URIs to the iconBase
|
|
234
|
+
'solid:AppProviderClass': 'noun_144.svg',
|
|
235
|
+
'solid:AppProvider': 'noun_15177.svg',
|
|
236
|
+
'solid:Pod': 'noun_Cabinet_1434380.svg',
|
|
237
|
+
'vcard:Group': 'noun_339237.svg',
|
|
238
|
+
'vcard:Organization': 'noun_143899.svg',
|
|
239
|
+
'vcard:Individual': 'noun_15059.svg',
|
|
240
|
+
'schema:Person': 'noun_15059.svg',
|
|
241
|
+
'foaf:Person': 'noun_15059.svg',
|
|
242
|
+
'foaf:Agent': 'noun_98053.svg',
|
|
243
|
+
'acl:AuthenticatedAgent': 'noun_99101.svg',
|
|
244
|
+
'prov:SoftwareAgent': 'noun_Robot_849764.svg',
|
|
245
|
+
'vcard:AddressBook': 'noun_15695.svg',
|
|
246
|
+
'trip:Trip': 'noun_581629.svg',
|
|
247
|
+
'meeting:LongChat': 'noun_1689339.svg',
|
|
248
|
+
'meeting:Meeting': 'noun_66617.svg',
|
|
249
|
+
'meeting:Project': 'noun_1036577.svg',
|
|
250
|
+
'ui:Form': 'noun_122196.svg',
|
|
251
|
+
'rdfs:Class': 'class-rectangle.svg',
|
|
252
|
+
'rdf:Property': 'property-diamond.svg',
|
|
253
|
+
'owl:Ontology': 'noun_classification_1479198.svg',
|
|
254
|
+
'wf:Tracker': 'noun_122196.svg',
|
|
255
|
+
'wf:Task': 'noun_17020_gray-tick.svg',
|
|
256
|
+
'wf:Open': 'noun_17020_sans-tick.svg',
|
|
257
|
+
'wf:Closed': 'noun_17020.svg'
|
|
304
258
|
};
|
|
305
259
|
/**
|
|
306
260
|
* Returns the origin of the URI of a NamedNode
|
|
307
261
|
*/
|
|
308
|
-
|
|
309
|
-
exports.iconForClass = iconForClass;
|
|
310
|
-
|
|
311
262
|
function tempSite(x) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
263
|
+
// use only while one in rdflib fails with origins 2019
|
|
264
|
+
var str = x.uri.split('#')[0];
|
|
265
|
+
var p = str.indexOf('//');
|
|
266
|
+
if (p < 0)
|
|
267
|
+
throw new Error('This URI does not have a web site part (origin)');
|
|
268
|
+
var q = str.indexOf('/', p + 2);
|
|
269
|
+
if (q < 0) {
|
|
270
|
+
// no third slash?
|
|
271
|
+
return str.slice(0) + '/'; // Add slash to a bare origin
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return str.slice(0, q + 1);
|
|
275
|
+
}
|
|
324
276
|
}
|
|
325
277
|
/**
|
|
326
278
|
* Find an image for this thing as a class
|
|
327
279
|
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
280
|
function findImageFromURI(x) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
281
|
+
var iconDir = iconBase;
|
|
282
|
+
// Special cases from URI scheme:
|
|
283
|
+
if (typeof x !== 'string' && x.uri) {
|
|
284
|
+
if (x.uri.split('/').length === 4 &&
|
|
285
|
+
!x.uri.split('/')[1] &&
|
|
286
|
+
!x.uri.split('/')[3]) {
|
|
287
|
+
return iconDir + 'noun_15177.svg'; // App -- this is an origin
|
|
288
|
+
}
|
|
289
|
+
// Non-HTTP URI types imply types
|
|
290
|
+
if (x.uri.startsWith('message:') || x.uri.startsWith('mid:')) {
|
|
291
|
+
// message: is apple bug-- should be mid:
|
|
292
|
+
return iconDir + 'noun_480183.svg'; // envelope noun_567486
|
|
293
|
+
}
|
|
294
|
+
if (x.uri.startsWith('mailto:')) {
|
|
295
|
+
return iconDir + 'noun_567486.svg'; // mailbox - an email desitination
|
|
296
|
+
}
|
|
297
|
+
// For HTTP(s) documents, we could look at the MIME type if we know it.
|
|
298
|
+
if (x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
|
|
299
|
+
return tempSite(x) + 'favicon.ico'; // was x.site().uri + ...
|
|
300
|
+
// Todo: make the document icon a fallback for if the favicon does not exist
|
|
301
|
+
// todo: pick up a possible favicon for the web page itself from a link
|
|
302
|
+
// was: return iconDir + 'noun_681601.svg' // document - under solid assumptions
|
|
303
|
+
}
|
|
304
|
+
return null;
|
|
354
305
|
}
|
|
355
|
-
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
|
|
306
|
+
return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
|
|
360
307
|
}
|
|
308
|
+
exports.findImageFromURI = findImageFromURI;
|
|
361
309
|
/**
|
|
362
310
|
* Find something we have as explicit image data for the thing
|
|
363
311
|
* See also [[imagesOf]]
|
|
@@ -375,260 +323,224 @@ function findImageFromURI(x) {
|
|
|
375
323
|
* * ns.vcard('photo')
|
|
376
324
|
* * ns.foaf('depiction')
|
|
377
325
|
*/
|
|
378
|
-
|
|
379
|
-
|
|
380
326
|
function findImage(thing) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
327
|
+
var kb = logic_1.store;
|
|
328
|
+
var iconDir = iconBase;
|
|
329
|
+
if (thing.sameTerm(ns.foaf('Agent')) || thing.sameTerm(ns.rdf('Resource'))) {
|
|
330
|
+
return iconDir + 'noun_98053.svg'; // Globe
|
|
331
|
+
}
|
|
332
|
+
var image = kb.any(thing, ns.sioc('avatar')) ||
|
|
333
|
+
kb.any(thing, ns.foaf('img')) ||
|
|
334
|
+
kb.any(thing, ns.vcard('logo')) ||
|
|
335
|
+
kb.any(thing, ns.vcard('hasPhoto')) ||
|
|
336
|
+
kb.any(thing, ns.vcard('photo')) ||
|
|
337
|
+
kb.any(thing, ns.foaf('depiction'));
|
|
338
|
+
return image ? image.uri : null;
|
|
390
339
|
}
|
|
340
|
+
exports.findImage = findImage;
|
|
391
341
|
/**
|
|
392
342
|
* Do the best you can with the data available
|
|
393
343
|
*
|
|
394
344
|
* @return {Boolean} Are we happy with this icon?
|
|
395
345
|
* Sets src AND STYLE of the image.
|
|
396
346
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
347
|
function trySetImage(element, thing, iconForClassMap) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return true;
|
|
406
|
-
} // This is one of the classes we know about - the class itself?
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var typeIcon = iconForClassMap[thing.uri];
|
|
410
|
-
|
|
411
|
-
if (typeIcon) {
|
|
412
|
-
element.setAttribute('src', typeIcon);
|
|
413
|
-
element.style = style.classIconStyle; // element.style.border = '0.1em solid green;'
|
|
414
|
-
// element.style.backgroundColor = '#eeffee' // pale green
|
|
415
|
-
|
|
416
|
-
return true;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
var schemeIcon = findImageFromURI(thing);
|
|
420
|
-
|
|
421
|
-
if (schemeIcon) {
|
|
422
|
-
element.setAttribute('src', schemeIcon);
|
|
423
|
-
return true; // happy with this -- don't look it up
|
|
424
|
-
} // Do we have a generic icon for something in any class its in?
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
var types = kb.findTypeURIs(thing);
|
|
428
|
-
|
|
429
|
-
for (var typeURI in types) {
|
|
430
|
-
if (iconForClassMap[typeURI]) {
|
|
431
|
-
element.setAttribute('src', iconForClassMap[typeURI]);
|
|
432
|
-
return false; // maybe we can do better
|
|
348
|
+
var kb = logic_1.store;
|
|
349
|
+
var explitImage = findImage(thing);
|
|
350
|
+
if (explitImage) {
|
|
351
|
+
element.setAttribute('src', explitImage);
|
|
352
|
+
return true;
|
|
433
353
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
354
|
+
// This is one of the classes we know about - the class itself?
|
|
355
|
+
var typeIcon = iconForClassMap[thing.uri];
|
|
356
|
+
if (typeIcon) {
|
|
357
|
+
element.setAttribute('src', typeIcon);
|
|
358
|
+
element.style = style.classIconStyle;
|
|
359
|
+
// element.style.border = '0.1em solid green;'
|
|
360
|
+
// element.style.backgroundColor = '#eeffee' // pale green
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
var schemeIcon = findImageFromURI(thing);
|
|
364
|
+
if (schemeIcon) {
|
|
365
|
+
element.setAttribute('src', schemeIcon);
|
|
366
|
+
return true; // happy with this -- don't look it up
|
|
367
|
+
}
|
|
368
|
+
// Do we have a generic icon for something in any class its in?
|
|
369
|
+
var types = kb.findTypeURIs(thing);
|
|
370
|
+
for (var typeURI in types) {
|
|
371
|
+
if (iconForClassMap[typeURI]) {
|
|
372
|
+
element.setAttribute('src', iconForClassMap[typeURI]);
|
|
373
|
+
return false; // maybe we can do better
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
element.setAttribute('src', iconBase + 'noun_10636_grey.svg'); // Grey Circle - some thing
|
|
377
|
+
return false; // we can do better
|
|
439
378
|
}
|
|
440
379
|
/**
|
|
441
380
|
* ToDo: Also add icons for *properties* like home, work, email, range, domain, comment,
|
|
442
381
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
382
|
function setImage(element, thing) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
var theClass = ns[pref](id);
|
|
454
|
-
iconForClassMap[theClass.uri] = _rdflib.uri.join(iconForClass[k], iconBase);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
var happy = trySetImage(element, thing, iconForClassMap);
|
|
458
|
-
|
|
459
|
-
if (!happy && thing.uri) {
|
|
460
|
-
if (!kb.fetcher) {
|
|
461
|
-
throw new Error('kb has no fetcher');
|
|
383
|
+
var kb = logic_1.store;
|
|
384
|
+
var iconForClassMap = {};
|
|
385
|
+
for (var k in exports.iconForClass) {
|
|
386
|
+
var pref = k.split(':')[0];
|
|
387
|
+
var id = k.split(':')[1];
|
|
388
|
+
var theClass = ns[pref](id);
|
|
389
|
+
iconForClassMap[theClass.uri] = rdflib_1.uri.join(exports.iconForClass[k], iconBase);
|
|
462
390
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
391
|
+
var happy = trySetImage(element, thing, iconForClassMap);
|
|
392
|
+
if (!happy && thing.uri) {
|
|
393
|
+
if (!kb.fetcher) {
|
|
394
|
+
throw new Error('kb has no fetcher');
|
|
395
|
+
}
|
|
396
|
+
kb.fetcher.nowOrWhenFetched(thing.doc(), undefined, function (ok) {
|
|
397
|
+
if (ok) {
|
|
398
|
+
trySetImage(element, thing, iconForClassMap);
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
exports.setImage = setImage;
|
|
404
|
+
// If a web page, then a favicon, with a fallback to ???
|
|
471
405
|
// See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
|
|
472
|
-
|
|
473
|
-
|
|
474
406
|
function faviconOrDefault(dom, x) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
setImage(image, x);
|
|
497
|
-
return image;
|
|
498
|
-
}
|
|
407
|
+
var image = dom.createElement('img');
|
|
408
|
+
image.style = style.iconStyle;
|
|
409
|
+
var isOrigin = function (x) {
|
|
410
|
+
if (!x.uri)
|
|
411
|
+
return false;
|
|
412
|
+
var parts = x.uri.split('/');
|
|
413
|
+
return parts.length === 3 || (parts.length === 4 && parts[3] === '');
|
|
414
|
+
};
|
|
415
|
+
image.setAttribute('src', iconBase + (isOrigin(x) ? 'noun_15177.svg' : 'noun_681601.svg') // App symbol vs document
|
|
416
|
+
);
|
|
417
|
+
if (x.uri && x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
|
|
418
|
+
var res = dom.createElement('object'); // favico with a fallback of a default image if no favicon
|
|
419
|
+
res.setAttribute('data', tempSite(x) + 'favicon.ico');
|
|
420
|
+
res.setAttribute('type', 'image/x-icon');
|
|
421
|
+
res.appendChild(image); // fallback
|
|
422
|
+
return res;
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
setImage(image, x);
|
|
426
|
+
return image;
|
|
427
|
+
}
|
|
499
428
|
}
|
|
429
|
+
exports.faviconOrDefault = faviconOrDefault;
|
|
500
430
|
/* Two-option dialog pop-up
|
|
501
431
|
*/
|
|
502
|
-
|
|
503
|
-
|
|
504
432
|
function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction) {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
popup.appendChild(sureButtonElt);
|
|
549
|
-
affirmIcon.addEventListener('click', removePopupAndDoDeletion);
|
|
550
|
-
sureButtonElt.addEventListener('click', removePopupAndDoDeletion); // xButton.addEventListener('click', removePopup)
|
|
551
|
-
|
|
552
|
-
cancelPrompt.addEventListener('click', removePopup);
|
|
553
|
-
return popup;
|
|
433
|
+
function removePopup() {
|
|
434
|
+
refererenceElement.parentElement.removeChild(refererenceElement);
|
|
435
|
+
}
|
|
436
|
+
function removePopupAndDoDeletion() {
|
|
437
|
+
removePopup();
|
|
438
|
+
deleteFunction();
|
|
439
|
+
}
|
|
440
|
+
var popup = dom.createElement('div');
|
|
441
|
+
popup.style = style.confirmPopupStyle;
|
|
442
|
+
popup.style.position = 'absolute';
|
|
443
|
+
popup.style.top = '-1em'; // try leaving original button clear
|
|
444
|
+
popup.style.display = 'grid';
|
|
445
|
+
popup.style.gridTemplateColumns = 'auto auto';
|
|
446
|
+
var affirm = dom.createElement('div');
|
|
447
|
+
affirm.style.gridColumn = '1/2';
|
|
448
|
+
affirm.style.gridRow = '1'; // @@ sigh; TS. could pass number in fact
|
|
449
|
+
var cancel = dom.createElement('div');
|
|
450
|
+
cancel.style.gridColumn = '1/2';
|
|
451
|
+
cancel.style.gridRow = '2';
|
|
452
|
+
var xButton = cancelButton(dom, removePopup);
|
|
453
|
+
popup.appendChild(xButton);
|
|
454
|
+
xButton.style.gridColumn = '1';
|
|
455
|
+
xButton.style.gridRow = '2';
|
|
456
|
+
var cancelPrompt = popup.appendChild(dom.createElement('button'));
|
|
457
|
+
cancelPrompt.style = style.buttonStyle;
|
|
458
|
+
cancelPrompt.style.gridRow = '2';
|
|
459
|
+
cancelPrompt.style.gridColumn = '2';
|
|
460
|
+
cancelPrompt.textContent = 'Cancel'; // @@ I18n
|
|
461
|
+
var affirmIcon = button(dom, iconBase_1.icons.iconBase + 'noun_925021.svg', 'Delete it'); // trashcan
|
|
462
|
+
popup.appendChild(affirmIcon);
|
|
463
|
+
affirmIcon.style.gridRow = '1';
|
|
464
|
+
affirmIcon.style.gridColumn = '1';
|
|
465
|
+
var sureButtonElt = popup.appendChild(dom.createElement('button'));
|
|
466
|
+
sureButtonElt.style = style.buttonStyle;
|
|
467
|
+
sureButtonElt.style.gridRow = '1';
|
|
468
|
+
sureButtonElt.style.gridColumn = '2';
|
|
469
|
+
sureButtonElt.textContent = prompt;
|
|
470
|
+
popup.appendChild(sureButtonElt);
|
|
471
|
+
affirmIcon.addEventListener('click', removePopupAndDoDeletion);
|
|
472
|
+
sureButtonElt.addEventListener('click', removePopupAndDoDeletion);
|
|
473
|
+
// xButton.addEventListener('click', removePopup)
|
|
474
|
+
cancelPrompt.addEventListener('click', removePopup);
|
|
475
|
+
return popup;
|
|
554
476
|
}
|
|
555
477
|
/**
|
|
556
478
|
* Delete button with a check you really mean it
|
|
557
479
|
* @@ Supress check if command key held down?
|
|
558
480
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
481
|
function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
deleteButton.addEventListener('click', createPopup);
|
|
583
|
-
container.classList.add('hoverControl');
|
|
584
|
-
container.appendChild(deleteButton);
|
|
585
|
-
deleteButton.setAttribute('data-testid', 'deleteButtonWithCheck');
|
|
586
|
-
return deleteButton; // or button div? caller may change size of image
|
|
482
|
+
function createPopup() {
|
|
483
|
+
var refererenceElement = dom.createElement('div');
|
|
484
|
+
container.insertBefore(refererenceElement, deleteButton);
|
|
485
|
+
refererenceElement.style.position = 'relative'; // Needed as reference for popup
|
|
486
|
+
refererenceElement.appendChild(renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction));
|
|
487
|
+
}
|
|
488
|
+
var minusIconURI = iconBase + 'noun_2188_red.svg'; // white minus in red #cc0000 circle
|
|
489
|
+
var deleteButton = dom.createElement('img');
|
|
490
|
+
deleteButton.setAttribute('src', minusIconURI);
|
|
491
|
+
deleteButton.setAttribute('style', style.smallButtonStyle); // @@tsc - would set deleteButton.style
|
|
492
|
+
deleteButton.style.float = 'right'; // Historically this has alwaus floated right
|
|
493
|
+
var prompt = 'Remove this ' + noun;
|
|
494
|
+
deleteButton.title = prompt;
|
|
495
|
+
// @@ In an ideal world, make use of hover an accessibility option
|
|
496
|
+
deleteButton.classList.add('hoverControlHide');
|
|
497
|
+
deleteButton.addEventListener('click', createPopup);
|
|
498
|
+
container.classList.add('hoverControl');
|
|
499
|
+
container.appendChild(deleteButton);
|
|
500
|
+
deleteButton.setAttribute('data-testid', 'deleteButtonWithCheck');
|
|
501
|
+
return deleteButton; // or button div? caller may change size of image
|
|
587
502
|
}
|
|
503
|
+
exports.deleteButtonWithCheck = deleteButtonWithCheck;
|
|
588
504
|
/**
|
|
589
505
|
* Get the button style, based on options.
|
|
590
506
|
* See https://design.inrupt.com/atomic-core/?cat=Atoms#Buttons
|
|
591
507
|
*/
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
borderColor = color;
|
|
609
|
-
hoverBackgroundColor = color;
|
|
610
|
-
hoverFontColor = backgroundColor;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return {
|
|
614
|
-
'background-color': "".concat(backgroundColor),
|
|
615
|
-
color: "".concat(fontColor),
|
|
616
|
-
'font-family': 'Raleway, Roboto, sans-serif',
|
|
617
|
-
'border-radius': '0.25em',
|
|
618
|
-
'border-color': "".concat(borderColor),
|
|
619
|
-
border: '1px solid',
|
|
620
|
-
cursor: 'pointer',
|
|
621
|
-
'font-size': '.8em',
|
|
622
|
-
'text-decoration': 'none',
|
|
623
|
-
padding: '0.5em 4em',
|
|
624
|
-
transition: '0.25s all ease-in-out',
|
|
625
|
-
outline: 'none',
|
|
626
|
-
'&:hover': {
|
|
627
|
-
'background-color': "".concat(hoverBackgroundColor),
|
|
628
|
-
color: "".concat(hoverFontColor),
|
|
629
|
-
transition: '0.25s all ease-in-out'
|
|
508
|
+
function getButtonStyle(options) {
|
|
509
|
+
if (options === void 0) { options = {}; }
|
|
510
|
+
// default to primary color
|
|
511
|
+
var color = (options.buttonColor === 'Secondary') ? '#01c9ea' : '#7c4dff';
|
|
512
|
+
var backgroundColor = color;
|
|
513
|
+
var fontColor = '#ffffff';
|
|
514
|
+
var borderColor = color;
|
|
515
|
+
// default to primary color
|
|
516
|
+
var hoverBackgroundColor = (options.buttonColor === 'Secondary') ? '#37cde6' : '#9f7dff';
|
|
517
|
+
var hoverFontColor = fontColor;
|
|
518
|
+
if (options.needsBorder) {
|
|
519
|
+
backgroundColor = '#ffffff';
|
|
520
|
+
fontColor = color;
|
|
521
|
+
borderColor = color;
|
|
522
|
+
hoverBackgroundColor = color;
|
|
523
|
+
hoverFontColor = backgroundColor;
|
|
630
524
|
}
|
|
631
|
-
|
|
525
|
+
return {
|
|
526
|
+
'background-color': "".concat(backgroundColor),
|
|
527
|
+
color: "".concat(fontColor),
|
|
528
|
+
'font-family': 'Raleway, Roboto, sans-serif',
|
|
529
|
+
'border-radius': '0.25em',
|
|
530
|
+
'border-color': "".concat(borderColor),
|
|
531
|
+
border: '1px solid',
|
|
532
|
+
cursor: 'pointer',
|
|
533
|
+
'font-size': '.8em',
|
|
534
|
+
'text-decoration': 'none',
|
|
535
|
+
padding: '0.5em 4em',
|
|
536
|
+
transition: '0.25s all ease-in-out',
|
|
537
|
+
outline: 'none',
|
|
538
|
+
'&:hover': {
|
|
539
|
+
'background-color': "".concat(hoverBackgroundColor),
|
|
540
|
+
color: "".concat(hoverFontColor),
|
|
541
|
+
transition: '0.25s all ease-in-out'
|
|
542
|
+
}
|
|
543
|
+
};
|
|
632
544
|
}
|
|
633
545
|
/* Make a button
|
|
634
546
|
*
|
|
@@ -639,42 +551,32 @@ function getButtonStyle() {
|
|
|
639
551
|
*
|
|
640
552
|
* @returns <dDomElement> - the button
|
|
641
553
|
*/
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}),
|
|
667
|
-
classes = _getClasses.classes;
|
|
668
|
-
|
|
669
|
-
button.classList.add(classes.textButton);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
if (handler) {
|
|
673
|
-
button.addEventListener('click', handler, false);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
return button;
|
|
554
|
+
function button(dom, iconURI, text, handler, options) {
|
|
555
|
+
if (options === void 0) { options = { buttonColor: 'Primary', needsBorder: false }; }
|
|
556
|
+
var button = dom.createElement('button');
|
|
557
|
+
button.setAttribute('type', 'button');
|
|
558
|
+
// button.innerHTML = text // later, user preferences may make text preferred for some
|
|
559
|
+
if (iconURI) {
|
|
560
|
+
var img = button.appendChild(dom.createElement('img'));
|
|
561
|
+
img.setAttribute('src', iconURI);
|
|
562
|
+
img.setAttribute('style', 'width: 2em; height: 2em;'); // trial and error. 2em disappears
|
|
563
|
+
img.title = text;
|
|
564
|
+
button.setAttribute('style', style.buttonStyle);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
button.textContent = text.toLocaleUpperCase();
|
|
568
|
+
var style_1 = getButtonStyle(options);
|
|
569
|
+
var classes = (0, jss_1.getClasses)(dom.head, {
|
|
570
|
+
textButton: style_1
|
|
571
|
+
}).classes;
|
|
572
|
+
button.classList.add(classes.textButton);
|
|
573
|
+
}
|
|
574
|
+
if (handler) {
|
|
575
|
+
button.addEventListener('click', handler, false);
|
|
576
|
+
}
|
|
577
|
+
return button;
|
|
677
578
|
}
|
|
579
|
+
exports.button = button;
|
|
678
580
|
/* Make a cancel button
|
|
679
581
|
*
|
|
680
582
|
* @param dom - the DOM document object
|
|
@@ -682,11 +584,10 @@ function button(dom, iconURI, text, handler) {
|
|
|
682
584
|
*
|
|
683
585
|
* @returns <dDomElement> - the button
|
|
684
586
|
*/
|
|
685
|
-
|
|
686
|
-
|
|
687
587
|
function cancelButton(dom, handler) {
|
|
688
|
-
|
|
588
|
+
return button(dom, cancelIconURI, 'Cancel', handler);
|
|
689
589
|
}
|
|
590
|
+
exports.cancelButton = cancelButton;
|
|
690
591
|
/* Make a continue button
|
|
691
592
|
*
|
|
692
593
|
* @param dom - the DOM document object
|
|
@@ -694,415 +595,374 @@ function cancelButton(dom, handler) {
|
|
|
694
595
|
*
|
|
695
596
|
* @returns <dDomElement> - the button
|
|
696
597
|
*/
|
|
697
|
-
|
|
698
|
-
|
|
699
598
|
function continueButton(dom, handler) {
|
|
700
|
-
|
|
599
|
+
return button(dom, checkIconURI, 'Continue', handler);
|
|
701
600
|
}
|
|
601
|
+
exports.continueButton = continueButton;
|
|
702
602
|
/* Grab a name for a new thing
|
|
703
603
|
*
|
|
704
604
|
* Form to get the name of a new thing before we create it
|
|
705
605
|
* @params theClass Misspelt to avoid clashing with the JavaScript keyword
|
|
706
606
|
* @returns: a promise of (a name or null if cancelled)
|
|
707
607
|
*/
|
|
708
|
-
|
|
709
|
-
|
|
710
608
|
function askName(dom, kb, container, predicate, theClass, noun) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}));
|
|
748
|
-
form.appendChild(continueButton(dom, function (_event) {
|
|
749
|
-
gotName();
|
|
750
|
-
}));
|
|
751
|
-
namefield.focus();
|
|
752
|
-
}); // Promise
|
|
609
|
+
// eslint-disable-next-line promise/param-names
|
|
610
|
+
return new Promise(function (resolve, _reject) {
|
|
611
|
+
var form = dom.createElement('div'); // form is broken as HTML behaviour can resurface on js error
|
|
612
|
+
// classLabel = utils.label(ns.vcard('Individual'))
|
|
613
|
+
predicate = predicate || ns.foaf('name'); // eg 'name' in user's language
|
|
614
|
+
noun = noun || (theClass ? utils.label(theClass) : ' '); // eg 'folder' in users's language
|
|
615
|
+
var prompt = noun + ' ' + utils.label(predicate) + ': ';
|
|
616
|
+
form.appendChild(dom.createElement('p')).textContent = prompt;
|
|
617
|
+
var namefield = dom.createElement('input');
|
|
618
|
+
namefield.setAttribute('type', 'text');
|
|
619
|
+
namefield.setAttribute('size', '100');
|
|
620
|
+
namefield.setAttribute('maxLength', '2048'); // No arbitrary limits
|
|
621
|
+
namefield.setAttribute('style', style.textInputStyle);
|
|
622
|
+
namefield.select(); // focus next user input
|
|
623
|
+
form.appendChild(namefield);
|
|
624
|
+
container.appendChild(form);
|
|
625
|
+
// namefield.focus()
|
|
626
|
+
function gotName() {
|
|
627
|
+
form.parentNode.removeChild(form);
|
|
628
|
+
resolve(namefield.value.trim());
|
|
629
|
+
}
|
|
630
|
+
namefield.addEventListener('keyup', function (e) {
|
|
631
|
+
if (e.keyCode === 13) {
|
|
632
|
+
gotName();
|
|
633
|
+
}
|
|
634
|
+
}, false);
|
|
635
|
+
form.appendChild(dom.createElement('br'));
|
|
636
|
+
form.appendChild(cancelButton(dom, function (_event) {
|
|
637
|
+
form.parentNode.removeChild(form);
|
|
638
|
+
resolve(null);
|
|
639
|
+
}));
|
|
640
|
+
form.appendChild(continueButton(dom, function (_event) {
|
|
641
|
+
gotName();
|
|
642
|
+
}));
|
|
643
|
+
namefield.focus();
|
|
644
|
+
}); // Promise
|
|
753
645
|
}
|
|
646
|
+
exports.askName = askName;
|
|
754
647
|
/**
|
|
755
648
|
* A TR to represent a draggable person, etc in a list
|
|
756
649
|
*
|
|
757
650
|
* pred is unused param at the moment
|
|
758
651
|
*/
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
var personTR = renderAsRow; // The legacy name is used in a lot of places
|
|
762
|
-
|
|
763
|
-
exports.personTR = personTR;
|
|
764
|
-
|
|
652
|
+
exports.personTR = renderAsRow; // The legacy name is used in a lot of places
|
|
765
653
|
function renderAsRow(dom, pred, obj, options) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
td2.textContent = options.title;
|
|
781
|
-
} else {
|
|
782
|
-
setName(td2, obj); // This is async
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
if (options.deleteFunction) {
|
|
786
|
-
deleteButtonWithCheck(dom, td3, options.noun || 'one', options.deleteFunction);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
if (obj.uri) {
|
|
790
|
-
// blank nodes need not apply
|
|
791
|
-
if (options.link !== false) {
|
|
792
|
-
var anchor = td3.appendChild((0, _iconLinks.linkIcon)(dom, obj));
|
|
793
|
-
anchor.classList.add('HoverControlHide');
|
|
794
|
-
td3.appendChild(dom.createElement('br'));
|
|
654
|
+
var tr = dom.createElement('tr');
|
|
655
|
+
options = options || {};
|
|
656
|
+
// tr.predObj = [pred.uri, obj.uri] moved to acl-control
|
|
657
|
+
var td1 = tr.appendChild(dom.createElement('td'));
|
|
658
|
+
var td2 = tr.appendChild(dom.createElement('td'));
|
|
659
|
+
var td3 = tr.appendChild(dom.createElement('td'));
|
|
660
|
+
// const image = td1.appendChild(dom.createElement('img'))
|
|
661
|
+
var image = options.image || faviconOrDefault(dom, obj);
|
|
662
|
+
td1.setAttribute('style', 'vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;');
|
|
663
|
+
td2.setAttribute('style', 'vertical-align: middle; text-align:left;');
|
|
664
|
+
td3.setAttribute('style', 'vertical-align: middle; width:2em; padding:0.5em; height: 4em;');
|
|
665
|
+
td1.appendChild(image);
|
|
666
|
+
if (options.title) {
|
|
667
|
+
td2.textContent = options.title;
|
|
795
668
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
// default is on
|
|
799
|
-
image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
|
|
800
|
-
|
|
801
|
-
(0, _dragAndDrop.makeDraggable)(tr, obj);
|
|
669
|
+
else {
|
|
670
|
+
setName(td2, obj); // This is async
|
|
802
671
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
672
|
+
if (options.deleteFunction) {
|
|
673
|
+
deleteButtonWithCheck(dom, td3, options.noun || 'one', options.deleteFunction);
|
|
674
|
+
}
|
|
675
|
+
if (obj.uri) {
|
|
676
|
+
// blank nodes need not apply
|
|
677
|
+
if (options.link !== false) {
|
|
678
|
+
var anchor = td3.appendChild((0, iconLinks_1.linkIcon)(dom, obj));
|
|
679
|
+
anchor.classList.add('HoverControlHide');
|
|
680
|
+
td3.appendChild(dom.createElement('br'));
|
|
681
|
+
}
|
|
682
|
+
if (options.draggable !== false) {
|
|
683
|
+
// default is on
|
|
684
|
+
image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
|
|
685
|
+
(0, dragAndDrop_1.makeDraggable)(tr, obj);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
;
|
|
689
|
+
tr.subject = obj;
|
|
690
|
+
return tr;
|
|
808
691
|
}
|
|
692
|
+
exports.renderAsRow = renderAsRow;
|
|
809
693
|
/* A helper function for renderAsDiv
|
|
810
694
|
* creates the NameDiv for the person
|
|
811
695
|
* Note: could not move it to the helper file because they call exported functions
|
|
812
696
|
* from buttons
|
|
813
697
|
* @internal exporting this only for unit tests
|
|
814
698
|
*/
|
|
815
|
-
|
|
816
|
-
|
|
817
699
|
function createNameDiv(dom, div, title, obj) {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
700
|
+
var nameDiv = div.appendChild(dom.createElement('div'));
|
|
701
|
+
if (title) {
|
|
702
|
+
nameDiv.textContent = title;
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
setName(nameDiv, obj); // This is async
|
|
706
|
+
}
|
|
825
707
|
}
|
|
708
|
+
exports.createNameDiv = createNameDiv;
|
|
826
709
|
/* A helper function for renderAsDiv
|
|
827
710
|
* creates the linkDiv for the person
|
|
828
711
|
* Note: could not move it to the helper file because they call exported functions
|
|
829
712
|
* from buttons
|
|
830
713
|
* @internal exporting this only for unit tests
|
|
831
714
|
*/
|
|
832
|
-
|
|
833
|
-
|
|
834
715
|
function createLinkDiv(dom, div, obj, options) {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
716
|
+
var linkDiv = div.appendChild(dom.createElement('div'));
|
|
717
|
+
linkDiv.setAttribute('style', style.linkDivStyle);
|
|
718
|
+
if (options.deleteFunction) {
|
|
719
|
+
deleteButtonWithCheck(dom, linkDiv, options.noun || 'one', options.deleteFunction);
|
|
720
|
+
}
|
|
721
|
+
if (obj.uri) {
|
|
722
|
+
// blank nodes need not apply
|
|
723
|
+
if (options.link !== false) {
|
|
724
|
+
(0, iconLinks_1.createLinkForURI)(dom, linkDiv, obj);
|
|
725
|
+
}
|
|
726
|
+
(0, dragAndDrop_1.makeDraggable)(div, obj);
|
|
846
727
|
}
|
|
847
|
-
|
|
848
|
-
(0, _dragAndDrop.makeDraggable)(div, obj);
|
|
849
|
-
}
|
|
850
728
|
}
|
|
729
|
+
exports.createLinkDiv = createLinkDiv;
|
|
851
730
|
/**
|
|
852
731
|
* A Div to represent a draggable person, etc in a list
|
|
853
732
|
* configurable to add an onClick listener
|
|
854
733
|
*/
|
|
855
|
-
|
|
856
|
-
|
|
857
734
|
function renderAsDiv(dom, obj, options) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
return
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
return div;
|
|
735
|
+
var div = dom.createElement('div');
|
|
736
|
+
div.setAttribute('style', style.renderAsDivStyle);
|
|
737
|
+
options = options || {};
|
|
738
|
+
var image = options.image || faviconOrDefault(dom, obj);
|
|
739
|
+
(0, widgetHelpers_1.createImageDiv)(dom, div, image);
|
|
740
|
+
createNameDiv(dom, div, options.title, obj);
|
|
741
|
+
createLinkDiv(dom, div, obj, options);
|
|
742
|
+
if (options.clickable && options.onClickFunction) {
|
|
743
|
+
(0, widgetHelpers_1.addClickListenerToElement)(div, options.onClickFunction);
|
|
744
|
+
}
|
|
745
|
+
// to be compatible with the SolidOS table layout
|
|
746
|
+
if (options.wrapInATR) {
|
|
747
|
+
var tr = (0, widgetHelpers_1.wrapDivInATR)(dom, div, obj);
|
|
748
|
+
return tr;
|
|
749
|
+
}
|
|
750
|
+
return div;
|
|
877
751
|
}
|
|
752
|
+
exports.renderAsDiv = renderAsDiv;
|
|
878
753
|
/**
|
|
879
754
|
* Refresh a DOM tree recursively
|
|
880
755
|
*/
|
|
881
|
-
|
|
882
|
-
|
|
883
756
|
function refreshTree(root) {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
757
|
+
if (root.refresh) {
|
|
758
|
+
root.refresh();
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
for (var i = 0; i < root.children.length; i++) {
|
|
762
|
+
refreshTree(root.children[i]);
|
|
763
|
+
}
|
|
892
764
|
}
|
|
893
|
-
|
|
894
|
-
* Options argument for [[attachmentList]] function
|
|
895
|
-
*/
|
|
896
|
-
|
|
897
|
-
|
|
765
|
+
exports.refreshTree = refreshTree;
|
|
898
766
|
/**
|
|
899
767
|
* Component that displays a list of resources, for instance
|
|
900
768
|
* the attachments of a message, or the various documents related
|
|
901
769
|
* to a meeting.
|
|
902
770
|
* Accepts dropping URLs onto it to add attachments to it.
|
|
903
771
|
*/
|
|
904
|
-
function attachmentList(dom, subject, div) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
772
|
+
function attachmentList(dom, subject, div, options) {
|
|
773
|
+
// options = options || {}
|
|
774
|
+
if (options === void 0) { options = {}; }
|
|
775
|
+
var deleteAttachment = function (target) {
|
|
776
|
+
if (!kb.updater) {
|
|
777
|
+
throw new Error('kb has no updater');
|
|
778
|
+
}
|
|
779
|
+
kb.updater.update((0, rdflib_1.st)(subject, predicate, target, doc), [], function (uri, ok, errorBody, _xhr) {
|
|
780
|
+
if (ok) {
|
|
781
|
+
refresh();
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
complain(undefined, 'Error deleting one: ' + errorBody);
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
};
|
|
788
|
+
function createNewRow(target) {
|
|
789
|
+
var theTarget = target;
|
|
790
|
+
var opt = { noun: noun };
|
|
791
|
+
if (modify) {
|
|
792
|
+
opt.deleteFunction = function () {
|
|
793
|
+
deleteAttachment(theTarget);
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
return (0, exports.personTR)(dom, predicate, target, opt);
|
|
911
797
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
} else {
|
|
917
|
-
complain(undefined, 'Error deleting one: ' + errorBody);
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
function createNewRow(target) {
|
|
923
|
-
var theTarget = target;
|
|
924
|
-
var opt = {
|
|
925
|
-
noun: noun
|
|
798
|
+
var refresh = function () {
|
|
799
|
+
var things = kb.each(subject, predicate);
|
|
800
|
+
things.sort();
|
|
801
|
+
utils.syncTableToArray(attachmentTable, things, createNewRow);
|
|
926
802
|
};
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
803
|
+
function droppedURIHandler(uris) {
|
|
804
|
+
var ins = [];
|
|
805
|
+
uris.forEach(function (u) {
|
|
806
|
+
var target = (0, rdflib_1.sym)(u); // Attachment needs text label to disinguish I think not icon.
|
|
807
|
+
debug.log('Dropped on attachemnt ' + u); // icon was: iconBase + 'noun_25830.svg'
|
|
808
|
+
ins.push((0, rdflib_1.st)(subject, predicate, target, doc));
|
|
809
|
+
});
|
|
810
|
+
if (!kb.updater) {
|
|
811
|
+
throw new Error('kb has no updater');
|
|
812
|
+
}
|
|
813
|
+
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
814
|
+
if (ok) {
|
|
815
|
+
refresh();
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
complain(undefined, 'Error adding one: ' + errorBody);
|
|
819
|
+
}
|
|
820
|
+
});
|
|
932
821
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
});
|
|
952
|
-
|
|
953
|
-
if (!kb.updater) {
|
|
954
|
-
throw new Error('kb has no updater');
|
|
822
|
+
function droppedFileHandler(files) {
|
|
823
|
+
var _a, _b;
|
|
824
|
+
(0, dragAndDrop_1.uploadFiles)(kb.fetcher, files, (_a = options.uploadFolder) === null || _a === void 0 ? void 0 : _a.uri, // Files
|
|
825
|
+
(_b = options.uploadFolder) === null || _b === void 0 ? void 0 : _b.uri, // Pictures
|
|
826
|
+
function (theFile, destURI) {
|
|
827
|
+
var ins = [(0, rdflib_1.st)(subject, predicate, kb.sym(destURI), doc)];
|
|
828
|
+
if (!kb.updater) {
|
|
829
|
+
throw new Error('kb has no updater');
|
|
830
|
+
}
|
|
831
|
+
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
832
|
+
if (ok) {
|
|
833
|
+
refresh();
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
complain(undefined, 'Error adding link to uploaded file: ' + errorBody);
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
});
|
|
955
840
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
var
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
841
|
+
var doc = options.doc || subject.doc();
|
|
842
|
+
if (options.modify === undefined)
|
|
843
|
+
options.modify = true;
|
|
844
|
+
var modify = options.modify;
|
|
845
|
+
var promptIcon = options.promptIcon || iconBase + 'noun_748003.svg'; // target
|
|
846
|
+
// const promptIcon = options.promptIcon || (iconBase + 'noun_25830.svg') // paperclip
|
|
847
|
+
var predicate = options.predicate || ns.wf('attachment');
|
|
848
|
+
var noun = options.noun || 'attachment';
|
|
849
|
+
var kb = logic_1.store;
|
|
850
|
+
var attachmentOuter = div.appendChild(dom.createElement('table'));
|
|
851
|
+
attachmentOuter.setAttribute('style', 'margin-top: 1em; margin-bottom: 1em;');
|
|
852
|
+
var attachmentOne = attachmentOuter.appendChild(dom.createElement('tr'));
|
|
853
|
+
var attachmentLeft = attachmentOne.appendChild(dom.createElement('td'));
|
|
854
|
+
var attachmentRight = attachmentOne.appendChild(dom.createElement('td'));
|
|
855
|
+
var attachmentTable = attachmentRight.appendChild(dom.createElement('table'));
|
|
856
|
+
attachmentTable.appendChild(dom.createElement('tr')) // attachmentTableTop
|
|
857
|
+
;
|
|
858
|
+
attachmentOuter.refresh = refresh; // Participate in downstream changes
|
|
859
|
+
// ;(attachmentTable as any).refresh = refresh <- outer should be best?
|
|
860
|
+
refresh();
|
|
861
|
+
if (modify) {
|
|
862
|
+
// const buttonStyle = 'width; 2em; height: 2em; margin: 0.5em; padding: 0.1em;'
|
|
863
|
+
var paperclip = button(dom, promptIcon, 'Drop attachments here');
|
|
864
|
+
// paperclip.style = buttonStyle // @@ needed? default has white background
|
|
865
|
+
attachmentLeft.appendChild(paperclip);
|
|
866
|
+
var fhandler = options.uploadFolder ? droppedFileHandler : null;
|
|
867
|
+
(0, dragAndDrop_1.makeDropTarget)(paperclip, droppedURIHandler, fhandler); // beware missing the wire of the paparclip!
|
|
868
|
+
(0, dragAndDrop_1.makeDropTarget)(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
|
|
869
|
+
if (options.uploadFolder) { // Addd an explicit file upload button as well
|
|
870
|
+
var buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
|
|
871
|
+
attachmentLeft.appendChild(buttonDiv);
|
|
872
|
+
// buttonDiv.children[1].style = buttonStyle
|
|
983
873
|
}
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
var doc = options.doc || subject.doc();
|
|
989
|
-
if (options.modify === undefined) options.modify = true;
|
|
990
|
-
var modify = options.modify;
|
|
991
|
-
var promptIcon = options.promptIcon || iconBase + 'noun_748003.svg'; // target
|
|
992
|
-
// const promptIcon = options.promptIcon || (iconBase + 'noun_25830.svg') // paperclip
|
|
993
|
-
|
|
994
|
-
var predicate = options.predicate || ns.wf('attachment');
|
|
995
|
-
var noun = options.noun || 'attachment';
|
|
996
|
-
var kb = _logic.store;
|
|
997
|
-
var attachmentOuter = div.appendChild(dom.createElement('table'));
|
|
998
|
-
attachmentOuter.setAttribute('style', 'margin-top: 1em; margin-bottom: 1em;');
|
|
999
|
-
var attachmentOne = attachmentOuter.appendChild(dom.createElement('tr'));
|
|
1000
|
-
var attachmentLeft = attachmentOne.appendChild(dom.createElement('td'));
|
|
1001
|
-
var attachmentRight = attachmentOne.appendChild(dom.createElement('td'));
|
|
1002
|
-
var attachmentTable = attachmentRight.appendChild(dom.createElement('table'));
|
|
1003
|
-
attachmentTable.appendChild(dom.createElement('tr')) // attachmentTableTop
|
|
1004
|
-
;
|
|
1005
|
-
attachmentOuter.refresh = refresh; // Participate in downstream changes
|
|
1006
|
-
// ;(attachmentTable as any).refresh = refresh <- outer should be best?
|
|
1007
|
-
|
|
1008
|
-
refresh();
|
|
1009
|
-
|
|
1010
|
-
if (modify) {
|
|
1011
|
-
// const buttonStyle = 'width; 2em; height: 2em; margin: 0.5em; padding: 0.1em;'
|
|
1012
|
-
var paperclip = button(dom, promptIcon, 'Drop attachments here'); // paperclip.style = buttonStyle // @@ needed? default has white background
|
|
1013
|
-
|
|
1014
|
-
attachmentLeft.appendChild(paperclip);
|
|
1015
|
-
var fhandler = options.uploadFolder ? droppedFileHandler : null;
|
|
1016
|
-
(0, _dragAndDrop.makeDropTarget)(paperclip, droppedURIHandler, fhandler); // beware missing the wire of the paparclip!
|
|
1017
|
-
|
|
1018
|
-
(0, _dragAndDrop.makeDropTarget)(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
|
|
1019
|
-
|
|
1020
|
-
if (options.uploadFolder) {
|
|
1021
|
-
// Addd an explicit file upload button as well
|
|
1022
|
-
var buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
|
|
1023
|
-
attachmentLeft.appendChild(buttonDiv); // buttonDiv.children[1].style = buttonStyle
|
|
1024
874
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
875
|
+
return attachmentOuter;
|
|
876
|
+
}
|
|
877
|
+
exports.attachmentList = attachmentList;
|
|
878
|
+
// /////////////////////////////////////////////////////////////////////////////
|
|
1030
879
|
/**
|
|
1031
880
|
* Event Handler for links within solid apps.
|
|
1032
881
|
*
|
|
1033
882
|
* Note that native links have constraints in Firefox, they
|
|
1034
883
|
* don't work with local files for instance (2011)
|
|
1035
884
|
*/
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
885
|
function openHrefInOutlineMode(e) {
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
886
|
+
e.preventDefault();
|
|
887
|
+
e.stopPropagation();
|
|
888
|
+
var target = utils.getTarget(e);
|
|
889
|
+
var uri = target.getAttribute('href');
|
|
890
|
+
if (!uri)
|
|
891
|
+
return debug.log('openHrefInOutlineMode: No href found!\n');
|
|
892
|
+
var dom = window.document;
|
|
893
|
+
if (dom.outlineManager) {
|
|
894
|
+
// @@ TODO Remove the use of document as a global object
|
|
895
|
+
;
|
|
896
|
+
dom.outlineManager.GotoSubject(logic_1.store.sym(uri), true, undefined, true, undefined);
|
|
897
|
+
}
|
|
898
|
+
else if (window && window.panes && window.panes.getOutliner) {
|
|
899
|
+
// @@ TODO Remove the use of window as a global object
|
|
900
|
+
;
|
|
901
|
+
window.panes
|
|
902
|
+
.getOutliner()
|
|
903
|
+
.GotoSubject(logic_1.store.sym(uri), true, undefined, true, undefined);
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
debug.log('ERROR: Can\'t access outline manager in this config');
|
|
907
|
+
}
|
|
908
|
+
// dom.outlineManager.GotoSubject(store.sym(uri), true, undefined, true, undefined)
|
|
1058
909
|
}
|
|
910
|
+
exports.openHrefInOutlineMode = openHrefInOutlineMode;
|
|
1059
911
|
/**
|
|
1060
912
|
* Make a URI in the Tabulator.org annotation store out of the URI of the thing to be annotated.
|
|
1061
913
|
*
|
|
1062
914
|
* @@ Todo: make it a personal preference.
|
|
1063
915
|
*/
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
916
|
function defaultAnnotationStore(subject) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
917
|
+
if (subject.uri === undefined)
|
|
918
|
+
return undefined;
|
|
919
|
+
var s = subject.uri;
|
|
920
|
+
if (s.slice(0, 7) !== 'http://')
|
|
921
|
+
return undefined;
|
|
922
|
+
s = s.slice(7); // Remove
|
|
923
|
+
var hash = s.indexOf('#');
|
|
924
|
+
if (hash >= 0)
|
|
925
|
+
s = s.slice(0, hash);
|
|
926
|
+
// Strip trailing
|
|
927
|
+
else {
|
|
928
|
+
var slash = s.lastIndexOf('/');
|
|
929
|
+
if (slash < 0)
|
|
930
|
+
return undefined;
|
|
931
|
+
s = s.slice(0, slash);
|
|
932
|
+
}
|
|
933
|
+
return logic_1.store.sym('http://tabulator.org/wiki/annnotation/' + s);
|
|
1080
934
|
}
|
|
935
|
+
exports.defaultAnnotationStore = defaultAnnotationStore;
|
|
1081
936
|
/**
|
|
1082
937
|
* Retrieve all RDF class URIs from solid-ui's RDF store
|
|
1083
938
|
* @returns an object `ret` such that `Object.keys(ret)` is
|
|
1084
939
|
* the list of all class URIs.
|
|
1085
940
|
*/
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
941
|
function allClassURIs() {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
942
|
+
var set = {};
|
|
943
|
+
logic_1.store
|
|
944
|
+
.statementsMatching(undefined, ns.rdf('type'), undefined)
|
|
945
|
+
.forEach(function (st) {
|
|
946
|
+
if (st.object.value)
|
|
947
|
+
set[st.object.value] = true;
|
|
948
|
+
});
|
|
949
|
+
logic_1.store
|
|
950
|
+
.statementsMatching(undefined, ns.rdfs('subClassOf'), undefined)
|
|
951
|
+
.forEach(function (st) {
|
|
952
|
+
if (st.object.value)
|
|
953
|
+
set[st.object.value] = true;
|
|
954
|
+
if (st.subject.value)
|
|
955
|
+
set[st.subject.value] = true;
|
|
956
|
+
});
|
|
957
|
+
logic_1.store
|
|
958
|
+
.each(undefined, ns.rdf('type'), ns.rdfs('Class'))
|
|
959
|
+
.forEach(function (c) {
|
|
960
|
+
if (c.value)
|
|
961
|
+
set[c.value] = true;
|
|
962
|
+
});
|
|
963
|
+
return set;
|
|
1105
964
|
}
|
|
965
|
+
exports.allClassURIs = allClassURIs;
|
|
1106
966
|
/**
|
|
1107
967
|
* Figuring which properties we know about
|
|
1108
968
|
*
|
|
@@ -1114,85 +974,75 @@ function allClassURIs() {
|
|
|
1114
974
|
* TODO: move to diff module? Not really a button.
|
|
1115
975
|
* @param {Store} kb The quadstore to be searched.
|
|
1116
976
|
*/
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
977
|
function propertyTriage(kb) {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
if (!op[_p] && !dp[_p]) {
|
|
1149
|
-
dp[_p] = true;
|
|
1150
|
-
op[_p] = true;
|
|
1151
|
-
nu++;
|
|
978
|
+
var possibleProperties = {};
|
|
979
|
+
// if (possibleProperties === undefined) possibleProperties = {}
|
|
980
|
+
// const kb = store
|
|
981
|
+
var dp = {};
|
|
982
|
+
var op = {};
|
|
983
|
+
var no = 0;
|
|
984
|
+
var nd = 0;
|
|
985
|
+
var nu = 0;
|
|
986
|
+
var pi = kb.predicateIndex; // One entry for each pred
|
|
987
|
+
for (var p in pi) {
|
|
988
|
+
var object = pi[p][0].object;
|
|
989
|
+
if (object.termType === 'Literal') {
|
|
990
|
+
dp[p] = true;
|
|
991
|
+
nd++;
|
|
992
|
+
}
|
|
993
|
+
else {
|
|
994
|
+
op[p] = true;
|
|
995
|
+
no++;
|
|
996
|
+
}
|
|
997
|
+
} // If nothing discovered, then could be either:
|
|
998
|
+
var ps = kb.each(undefined, ns.rdf('type'), ns.rdf('Property'));
|
|
999
|
+
for (var i = 0; i < ps.length; i++) {
|
|
1000
|
+
var p = ps[i].toNT();
|
|
1001
|
+
if (!op[p] && !dp[p]) {
|
|
1002
|
+
dp[p] = true;
|
|
1003
|
+
op[p] = true;
|
|
1004
|
+
nu++;
|
|
1005
|
+
}
|
|
1152
1006
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
(0, _log.info)("propertyTriage: ".concat(no, " non-lit, ").concat(nd, " literal. ").concat(nu, " unknown."));
|
|
1158
|
-
return possibleProperties;
|
|
1007
|
+
possibleProperties.op = op;
|
|
1008
|
+
possibleProperties.dp = dp;
|
|
1009
|
+
(0, log_1.info)("propertyTriage: ".concat(no, " non-lit, ").concat(nd, " literal. ").concat(nu, " unknown."));
|
|
1010
|
+
return possibleProperties;
|
|
1159
1011
|
}
|
|
1012
|
+
exports.propertyTriage = propertyTriage;
|
|
1160
1013
|
/**
|
|
1161
1014
|
* General purpose widgets
|
|
1162
1015
|
*/
|
|
1163
|
-
|
|
1164
1016
|
/**
|
|
1165
1017
|
* A button for jumping
|
|
1166
1018
|
*/
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
1019
|
function linkButton(dom, object) {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1020
|
+
var b = dom.createElement('button');
|
|
1021
|
+
b.setAttribute('type', 'button');
|
|
1022
|
+
b.textContent = 'Goto ' + utils.label(object);
|
|
1023
|
+
b.addEventListener('click', function (_event) {
|
|
1024
|
+
// b.parentNode.removeChild(b)
|
|
1025
|
+
;
|
|
1026
|
+
dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
|
|
1027
|
+
}, true);
|
|
1028
|
+
return b;
|
|
1179
1029
|
}
|
|
1030
|
+
exports.linkButton = linkButton;
|
|
1180
1031
|
/**
|
|
1181
1032
|
* A button to remove some other element from the page
|
|
1182
1033
|
*/
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
1034
|
function removeButton(dom, element) {
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1035
|
+
var b = dom.createElement('button');
|
|
1036
|
+
b.setAttribute('type', 'button');
|
|
1037
|
+
b.textContent = '✕'; // MULTIPLICATION X
|
|
1038
|
+
b.addEventListener('click', function (_event) {
|
|
1039
|
+
;
|
|
1040
|
+
element.parentNode.removeChild(element);
|
|
1041
|
+
}, true);
|
|
1042
|
+
return b;
|
|
1043
|
+
}
|
|
1044
|
+
exports.removeButton = removeButton;
|
|
1045
|
+
// Description text area
|
|
1196
1046
|
//
|
|
1197
1047
|
// Make a box to demand a description or display existing one
|
|
1198
1048
|
//
|
|
@@ -1207,7 +1057,6 @@ function removeButton(dom, element) {
|
|
|
1207
1057
|
//
|
|
1208
1058
|
// These are for selecting different modes, sources,styles, etc.
|
|
1209
1059
|
//
|
|
1210
|
-
|
|
1211
1060
|
/*
|
|
1212
1061
|
buttons.headerButtons = function (dom, kb, name, words) {
|
|
1213
1062
|
const box = dom.createElement('table')
|
|
@@ -1228,115 +1077,105 @@ buttons.headerButtons = function (dom, kb, name, words) {
|
|
|
1228
1077
|
//
|
|
1229
1078
|
// @param inverse means this is the object rather than the subject
|
|
1230
1079
|
//
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
1080
|
function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1234
|
-
|
|
1081
|
+
return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
|
|
1235
1082
|
}
|
|
1236
|
-
|
|
1083
|
+
exports.selectorPanel = selectorPanel;
|
|
1237
1084
|
function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
item = f(dom, x);
|
|
1259
|
-
item.setAttribute('style', style0);
|
|
1260
|
-
var nav = dom.createElement('div');
|
|
1261
|
-
nav.setAttribute('class', 'hideTillHover'); // See tabbedtab.css
|
|
1262
|
-
|
|
1263
|
-
nav.setAttribute('style', 'float:right; width:10%');
|
|
1264
|
-
var a = dom.createElement('a');
|
|
1265
|
-
a.setAttribute('href', x.uri);
|
|
1266
|
-
a.setAttribute('style', 'float:right');
|
|
1267
|
-
nav.appendChild(a).textContent = '>';
|
|
1268
|
-
box.appendChild(nav);
|
|
1269
|
-
var iconDiv = dom.createElement('div');
|
|
1270
|
-
iconDiv.setAttribute('style', (inverse ? 'float:left;' : 'float:right;') + ' width:30px;');
|
|
1271
|
-
image = dom.createElement('img');
|
|
1272
|
-
setStyle();
|
|
1273
|
-
iconDiv.appendChild(image);
|
|
1274
|
-
box.appendChild(iconDiv);
|
|
1275
|
-
item.addEventListener('click', function (event) {
|
|
1276
|
-
if (selected === item) {
|
|
1277
|
-
// deselect
|
|
1085
|
+
var style0 = 'border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;';
|
|
1086
|
+
var selected = null;
|
|
1087
|
+
list.innerHTML = '';
|
|
1088
|
+
var refreshItem = function (box, x) {
|
|
1089
|
+
// Scope to hold item and x
|
|
1090
|
+
var item;
|
|
1091
|
+
// eslint-disable-next-line prefer-const
|
|
1092
|
+
var image;
|
|
1093
|
+
var setStyle = function () {
|
|
1094
|
+
var already = inverse
|
|
1095
|
+
? kb.each(undefined, predicate, x)
|
|
1096
|
+
: kb.each(x, predicate);
|
|
1097
|
+
iconDiv.setAttribute('class', already.length === 0 ? 'hideTillHover' : ''); // See tabbedtab.css
|
|
1098
|
+
image.setAttribute('src', options.connectIcon || iconBase + 'noun_25830.svg');
|
|
1099
|
+
image.setAttribute('title', already.length ? already.length : 'attach');
|
|
1100
|
+
};
|
|
1101
|
+
var f = exports.index.twoLine.widgetForClass(type);
|
|
1102
|
+
// eslint-disable-next-line prefer-const
|
|
1103
|
+
item = f(dom, x);
|
|
1278
1104
|
item.setAttribute('style', style0);
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1105
|
+
var nav = dom.createElement('div');
|
|
1106
|
+
nav.setAttribute('class', 'hideTillHover'); // See tabbedtab.css
|
|
1107
|
+
nav.setAttribute('style', 'float:right; width:10%');
|
|
1108
|
+
var a = dom.createElement('a');
|
|
1109
|
+
a.setAttribute('href', x.uri);
|
|
1110
|
+
a.setAttribute('style', 'float:right');
|
|
1111
|
+
nav.appendChild(a).textContent = '>';
|
|
1112
|
+
box.appendChild(nav);
|
|
1113
|
+
var iconDiv = dom.createElement('div');
|
|
1114
|
+
iconDiv.setAttribute('style', (inverse ? 'float:left;' : 'float:right;') + ' width:30px;');
|
|
1115
|
+
image = dom.createElement('img');
|
|
1116
|
+
setStyle();
|
|
1117
|
+
iconDiv.appendChild(image);
|
|
1118
|
+
box.appendChild(iconDiv);
|
|
1119
|
+
item.addEventListener('click', function (event) {
|
|
1120
|
+
if (selected === item) {
|
|
1121
|
+
// deselect
|
|
1122
|
+
item.setAttribute('style', style0);
|
|
1123
|
+
selected = null;
|
|
1124
|
+
}
|
|
1125
|
+
else {
|
|
1126
|
+
if (selected)
|
|
1127
|
+
selected.setAttribute('style', style0);
|
|
1128
|
+
item.setAttribute('style', style0 + 'background-color: #ccc; color:black;');
|
|
1129
|
+
selected = item;
|
|
1130
|
+
}
|
|
1131
|
+
callbackFunction(x, event, selected === item);
|
|
1132
|
+
setStyle();
|
|
1133
|
+
}, false);
|
|
1134
|
+
image.addEventListener('click', function (event) {
|
|
1135
|
+
linkCallback(x, event, inverse, setStyle);
|
|
1136
|
+
}, false);
|
|
1137
|
+
box.appendChild(item);
|
|
1138
|
+
return box;
|
|
1139
|
+
};
|
|
1140
|
+
for (var i = 0; i < possible.length; i++) {
|
|
1141
|
+
var box = dom.createElement('div');
|
|
1142
|
+
list.appendChild(box);
|
|
1143
|
+
refreshItem(box, possible[i]);
|
|
1144
|
+
}
|
|
1145
|
+
return list;
|
|
1146
|
+
}
|
|
1147
|
+
exports.selectorPanelRefresh = selectorPanelRefresh;
|
|
1148
|
+
// ###########################################################################
|
|
1304
1149
|
//
|
|
1305
1150
|
// Small compact views of things
|
|
1306
1151
|
//
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
var index = {}; // ///////////////////////////////////////////////////////////////////////////
|
|
1152
|
+
exports.index = {};
|
|
1153
|
+
// ///////////////////////////////////////////////////////////////////////////
|
|
1310
1154
|
// We need these for anything which is a subject of an attachment.
|
|
1311
1155
|
//
|
|
1312
1156
|
// These should be moved to type-dependeent UI code. Related panes maybe
|
|
1313
|
-
|
|
1314
|
-
exports.index = index;
|
|
1315
|
-
|
|
1316
1157
|
function twoLineDefault(dom, x) {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1158
|
+
// Default
|
|
1159
|
+
var box = dom.createElement('div');
|
|
1160
|
+
box.textContent = utils.label(x);
|
|
1161
|
+
return box;
|
|
1321
1162
|
}
|
|
1322
1163
|
/**
|
|
1323
1164
|
* Find a function that can create a widget for a given class
|
|
1324
1165
|
* @param c The RDF class for which we want a widget generator function
|
|
1325
1166
|
*/
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
1167
|
function twoLineWidgetForClass(c) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1168
|
+
var widget = exports.index.twoLine[c.uri];
|
|
1169
|
+
var kb = logic_1.store;
|
|
1170
|
+
if (widget)
|
|
1171
|
+
return widget;
|
|
1172
|
+
var sup = kb.findSuperClassesNT(c);
|
|
1173
|
+
for (var cl in sup) {
|
|
1174
|
+
widget = exports.index.twoLine[kb.fromNT(cl).uri];
|
|
1175
|
+
if (widget)
|
|
1176
|
+
return widget;
|
|
1177
|
+
}
|
|
1178
|
+
return exports.index.twoLine[''];
|
|
1340
1179
|
}
|
|
1341
1180
|
/**
|
|
1342
1181
|
* Display a transaction
|
|
@@ -1345,26 +1184,20 @@ function twoLineWidgetForClass(c) {
|
|
|
1345
1184
|
* * ns.qu('date) -> a literal
|
|
1346
1185
|
* * ns.qu('amount') -> a literal
|
|
1347
1186
|
*/
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
1187
|
function twoLineTransaction(dom, x) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
box.innerHTML = "\n <tr>\n <td><a href=\"".concat(utils.escapeForXML(x.uri), "\">").concat(utils.escapeForXML(failed), "</a></td>\n </tr>");
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
return box;
|
|
1188
|
+
var failed = '';
|
|
1189
|
+
var enc = function (p) {
|
|
1190
|
+
var y = logic_1.store.any(x, ns.qu(p));
|
|
1191
|
+
if (!y)
|
|
1192
|
+
failed += '@@ No value for ' + p + '! ';
|
|
1193
|
+
return y ? utils.escapeForXML(y.value) : '?'; // @@@@
|
|
1194
|
+
};
|
|
1195
|
+
var box = dom.createElement('table');
|
|
1196
|
+
box.innerHTML = "\n <tr>\n <td colspan=\"2\"> ".concat(enc('payee'), "</td>\n < /tr>\n < tr >\n <td>").concat(enc('date').slice(0, 10), "</td>\n <td style = \"text-align: right;\">").concat(enc('amount'), "</td>\n </tr>");
|
|
1197
|
+
if (failed) {
|
|
1198
|
+
box.innerHTML = "\n <tr>\n <td><a href=\"".concat(utils.escapeForXML(x.uri), "\">").concat(utils.escapeForXML(failed), "</a></td>\n </tr>");
|
|
1199
|
+
}
|
|
1200
|
+
return box;
|
|
1368
1201
|
}
|
|
1369
1202
|
/**
|
|
1370
1203
|
* Display a trip
|
|
@@ -1373,76 +1206,68 @@ function twoLineTransaction(dom, x) {
|
|
|
1373
1206
|
* * ns.cal('dtstart') -> a literal
|
|
1374
1207
|
* * ns.cal('dtend') -> a literal
|
|
1375
1208
|
*/
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
1209
|
function twoLineTrip(dom, x) {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
box.innerHTML = "\n <tr>\n <td colspan=\"2\">".concat(enc(ns.dc('title')), "</td>\n </tr>\n <tr style=\"color: #777\">\n <td>").concat(enc(ns.cal('dtstart')), "</td>\n <td>").concat(enc(ns.cal('dtend')), "</td>\n </tr>");
|
|
1387
|
-
return box;
|
|
1210
|
+
var enc = function (p) {
|
|
1211
|
+
var y = logic_1.store.any(x, p);
|
|
1212
|
+
return y ? utils.escapeForXML(y.value) : '?';
|
|
1213
|
+
};
|
|
1214
|
+
var box = dom.createElement('table');
|
|
1215
|
+
box.innerHTML = "\n <tr>\n <td colspan=\"2\">".concat(enc(ns.dc('title')), "</td>\n </tr>\n <tr style=\"color: #777\">\n <td>").concat(enc(ns.cal('dtstart')), "</td>\n <td>").concat(enc(ns.cal('dtend')), "</td>\n </tr>");
|
|
1216
|
+
return box;
|
|
1388
1217
|
}
|
|
1389
1218
|
/**
|
|
1390
1219
|
* Stick a stylesheet link the document if not already there
|
|
1391
1220
|
*/
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
1221
|
function addStyleSheet(dom, href) {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1222
|
+
var links = dom.querySelectorAll('link');
|
|
1223
|
+
for (var i = 0; i < links.length; i++) {
|
|
1224
|
+
if ((links[i].getAttribute('rel') || '') === 'stylesheet' &&
|
|
1225
|
+
(links[i].getAttribute('href') || '') === href) {
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1400
1228
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1229
|
+
var link = dom.createElement('link');
|
|
1230
|
+
link.setAttribute('rel', 'stylesheet');
|
|
1231
|
+
link.setAttribute('type', 'text/css');
|
|
1232
|
+
link.setAttribute('href', href);
|
|
1233
|
+
dom.getElementsByTagName('head')[0].appendChild(link);
|
|
1234
|
+
}
|
|
1235
|
+
exports.addStyleSheet = addStyleSheet;
|
|
1236
|
+
// Figure (or guess) whether this is an image, etc
|
|
1409
1237
|
//
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
1238
|
function isAudio(file) {
|
|
1413
|
-
|
|
1239
|
+
return isImage(file, 'audio');
|
|
1414
1240
|
}
|
|
1415
|
-
|
|
1241
|
+
exports.isAudio = isAudio;
|
|
1416
1242
|
function isVideo(file) {
|
|
1417
|
-
|
|
1243
|
+
return isImage(file, 'video');
|
|
1418
1244
|
}
|
|
1245
|
+
exports.isVideo = isVideo;
|
|
1419
1246
|
/**
|
|
1420
1247
|
*
|
|
1421
1248
|
*/
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
1249
|
function isImage(file, kind) {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
return false;
|
|
1250
|
+
var dcCLasses = {
|
|
1251
|
+
audio: 'http://purl.org/dc/dcmitype/Sound',
|
|
1252
|
+
image: 'http://purl.org/dc/dcmitype/Image',
|
|
1253
|
+
video: 'http://purl.org/dc/dcmitype/MovingImage'
|
|
1254
|
+
};
|
|
1255
|
+
var what = kind || 'image';
|
|
1256
|
+
// See https://github.com/linkeddata/rdflib.js/blob/e367d5088c/src/formula.ts#L554
|
|
1257
|
+
//
|
|
1258
|
+
var typeURIs = logic_1.store.findTypeURIs(file);
|
|
1259
|
+
// See https://github.com/linkeddata/rdflib.js/blob/d5000f/src/utils-js.js#L14
|
|
1260
|
+
// e.g.'http://www.w3.org/ns/iana/media-types/audio'
|
|
1261
|
+
var prefix = rdflib_1.Util.mediaTypeClass(what + '/*').uri.split('*')[0];
|
|
1262
|
+
for (var t in typeURIs) {
|
|
1263
|
+
if (t.startsWith(prefix))
|
|
1264
|
+
return true;
|
|
1265
|
+
}
|
|
1266
|
+
if (dcCLasses[what] in typeURIs)
|
|
1267
|
+
return true;
|
|
1268
|
+
return false;
|
|
1445
1269
|
}
|
|
1270
|
+
exports.isImage = isImage;
|
|
1446
1271
|
/**
|
|
1447
1272
|
* File upload button
|
|
1448
1273
|
* @param dom The DOM aka document
|
|
@@ -1451,42 +1276,39 @@ function isImage(file, kind) {
|
|
|
1451
1276
|
* The input is hidden, as it is uglky - the user clicks on the nice icons and fires the input.
|
|
1452
1277
|
*/
|
|
1453
1278
|
// See https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
1279
|
function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1280
|
+
var div = dom.createElement('div');
|
|
1281
|
+
var input = div.appendChild(dom.createElement('input'));
|
|
1282
|
+
input.setAttribute('type', 'file');
|
|
1283
|
+
input.setAttribute('multiple', 'true');
|
|
1284
|
+
input.addEventListener('change', function (event) {
|
|
1285
|
+
debug.log('File drop event: ', event);
|
|
1286
|
+
if (event.files) {
|
|
1287
|
+
droppedFileHandler(event.files);
|
|
1288
|
+
}
|
|
1289
|
+
else if (event.target && event.target.files) {
|
|
1290
|
+
droppedFileHandler(event.target.files);
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
alert('Sorry no files .. internal error?');
|
|
1294
|
+
}
|
|
1295
|
+
}, false);
|
|
1296
|
+
input.style = 'display:none';
|
|
1297
|
+
var buttonElt = div.appendChild(button(dom, iconBase + 'noun_Upload_76574_000000.svg', 'Upload files', function (_event) {
|
|
1298
|
+
input.click();
|
|
1299
|
+
}));
|
|
1300
|
+
(0, dragAndDrop_1.makeDropTarget)(buttonElt, null, droppedFileHandler); // Can also just drop on button
|
|
1301
|
+
return div;
|
|
1479
1302
|
}
|
|
1480
|
-
|
|
1481
|
-
exports.index =
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
}
|
|
1303
|
+
exports.fileUploadButtonDiv = fileUploadButtonDiv;
|
|
1304
|
+
exports.index = {
|
|
1305
|
+
line: { // Approx 80em
|
|
1306
|
+
},
|
|
1307
|
+
twoLine: {
|
|
1308
|
+
'': twoLineDefault,
|
|
1309
|
+
'http://www.w3.org/2000/10/swap/pim/qif#Transaction': twoLineTransaction,
|
|
1310
|
+
'http://www.w3.org/ns/pim/trip#Trip': twoLineTrip,
|
|
1311
|
+
widgetForClass: twoLineWidgetForClass
|
|
1312
|
+
}
|
|
1491
1313
|
};
|
|
1492
1314
|
//# sourceMappingURL=buttons.js.map
|