Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/perspective-viewer/src/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function column_visibility_clicked(ev) {
}
} else {
// check if we're manipulating computed column input
if (ev.path[1].classList.contains("psp-cc-computation__input-column")) {
if (ev.path && ev.path[1].classList.contains("psp-cc-computation__input-column")) {
// this._computed_column._register_inputs();
this._computed_column.deselect_column(ev.currentTarget.getAttribute("name"));
this._update_column_view();
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-viewer/src/less/default.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

.dropping .psp-text-field__input,
.psp-text-field__input:not(:empty) {
display: initial;
display: block;
}

.dropping .psp-text-field__input::after {
Expand Down
1 change: 1 addition & 0 deletions packages/perspective-viewer/src/less/material.less
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ perspective-viewer #app {
position: absolute;
margin-top: 1px;
margin-left: -8px;
left: 24px;
}

span.is_visible {
Expand Down
4 changes: 4 additions & 0 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ function read_promise(filePath) {

function create_http_server(assets, host_psp) {
return async function(request, response) {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Request-Method", "*");
response.setHeader("Access-Control-Allow-Methods", "OPTIONS,GET");
response.setHeader("Access-Control-Allow-Headers", "*");
let url = request.url;
if (url === "/") {
url = "/index.html";
Expand Down
27 changes: 2 additions & 25 deletions packages/perspective/src/js/perspective.parallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

import {detectIE, ScriptPath} from "./utils.js";
import {ScriptPath} from "./utils.js";

import {TYPE_AGGREGATES, AGGREGATE_DEFAULTS, TYPE_FILTERS, FILTER_DEFAULTS, SORT_ORDERS} from "./defaults.js";

Expand All @@ -21,18 +21,6 @@ import {worker} from "./api.js";

var __SCRIPT_PATH__ = new ScriptPath();

// IE bug
if (detectIE() && window.location.href.indexOf(__SCRIPT_PATH__.host()) === -1) {
console.warn("Perspective does not support parallel mode in IE when loading cross-origin. Falling back to single-process mode ...");
(function(d, script) {
script = d.createElement("script");
script.type = "text/javascript";
script.async = true;
script.src = __SCRIPT_PATH__.path() + "perspective.worker.asm.js";
d.getElementsByTagName("head")[0].appendChild(script);
})(document);
}

// https://github.com/kripken/emscripten/issues/6042
function detect_iphone() {
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
Expand Down Expand Up @@ -61,7 +49,7 @@ class WebWorker extends worker {
super();
if (window.__PSP_WORKER__) {
this._start_embedded();
} else if (window.location.href.indexOf(__SCRIPT_PATH__.host()) > -1) {
} else if (window.location.host === __SCRIPT_PATH__.host().trim(window.location.host.length)) {
this._start_same_origin();
} else {
this._start_cross_origin();
Expand Down Expand Up @@ -189,17 +177,6 @@ class WebSocketWorker extends worker {

export default {
worker: function(url) {
if (window.location.href.indexOf(__SCRIPT_PATH__.host()) === -1 && detectIE()) {
/* This is a nasty edge case, specifically regarding when IE tries to load perspective as a WebWorker,
but as a cross-origin request. This is not supported by IE AFAIK, so we instead
download the inline version of the asmjs build of perspective, by inlining the script tag into <head>
via Javascript.

This binds the perspective symbol globally, and a reference to this symbol is returned here when an
attempt to instantiate a worker is made.
*/
return window.perspective;
}
if (url) {
return new WebSocketWorker(url);
} else {
Expand Down
65 changes: 65 additions & 0 deletions packages/perspective/src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,68 @@ export function ScriptPath() {
return pathParts ? pathParts[3] : "";
};
}

if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
if (typeof start !== "number") {
start = 0;
}

if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}

// from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
if (!Array.prototype.includes) {
Object.defineProperty(Array.prototype, "includes", {
value: function(searchElement, fromIndex) {
if (this == null) {
throw new TypeError('"this" is null or not defined');
}

// 1. Let O be ? ToObject(this value).
var o = Object(this);

// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;

// 3. If len is 0, return false.
if (len === 0) {
return false;
}

// 4. Let n be ? ToInteger(fromIndex).
// (If fromIndex is undefined, this step produces the value 0.)
var n = fromIndex | 0;

// 5. If n ≥ 0, then
// a. Let k be n.
// 6. Else n < 0,
// a. Let k be len + n.
// b. If k < 0, let k be 0.
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);

function sameValueZero(x, y) {
return x === y || (typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y));
}

// 7. Repeat, while k < len
while (k < len) {
// a. Let elementK be the result of ? Get(O, ! ToString(k)).
// b. If SameValueZero(searchElement, elementK) is true, return true.
if (sameValueZero(o[k], searchElement)) {
return true;
}
// c. Increase k by 1.
k++;
}

// 8. Return false
return false;
}
});
}