Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samussiah committed Dec 3, 2019
1 parent 67dc6a8 commit 823f3a9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 29 deletions.
23 changes: 12 additions & 11 deletions build/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@
function layout() {
var cat = this;
/* Layout primary sections */
console.log(cat.config);
cat.controls.wrap = cat.wrap
.append('div')
.classed('cat-controls section', true)
Expand Down Expand Up @@ -484,7 +483,6 @@
//Parameters can be specified by number (for renderer and data file), base64 encoded text or raw text (in that order of precedence).

var queries = parseQuery(window.location.search.substring(1));
console.log(queries);

//draw the chart?
if (queries.hasOwnProperty('draw')) {
Expand Down Expand Up @@ -525,7 +523,7 @@
var numericOptions = ['rn', 'dn'];
numericOptions.forEach(function(v) {
if (queries[v]) {
if (isNAN(+queries[v])) {
if (isNaN(+queries[v])) {
console.warn("The '" + v + "' parameter isn't numeric. Ignoring");
queries[v] = null;
}
Expand All @@ -539,7 +537,7 @@
if (queries.rn) {
fromURL.renderer = this.config.renderers.find(function(d, i) {
return i == queries.rn;
})[name];
}).name;
} else if (queries.re) {
fromURL.renderer = atob(queries.re);
} else {
Expand All @@ -564,7 +562,7 @@
if (queries.dn) {
fromURL.data = this.config.dataFiles.find(function(d, i) {
return i == queries.dn;
})[label];
}).label;
} else if (queries.de) {
fromURL.data = atob(queries.de);
} else {
Expand Down Expand Up @@ -1778,8 +1776,13 @@
cat.controls.settingsInput.node().value = JSON5.stringify(cat.current.config, null, 4);

if (cat.current.hasValidSchema) {
console.log('... and it is valid. Making a nice form.');
makeForm(cat);
makeForm(
cat,
cat.config.fromURL.renderer !== null &&
JSON.stringify(cat.config.settings) !== '{}'
? cat.current.config
: undefined
);
}
});
}
Expand Down Expand Up @@ -1852,9 +1855,7 @@
}

function createChartURL() {
console.log(this.current);
// const root_url = 'https://rhoinc.github.io/CAT/';
var root_url = 'http://localhost:8000/';
var root_url = '' + window.location.origin + window.location.pathname;
var se = btoa(JSON.stringify(this.current.config, null, ' '));
var re = btoa(this.current.name);
var de = btoa(this.current.data);
Expand All @@ -1875,7 +1876,7 @@
.append('div')
.attr('class', 'initSuccess')
.html(
"All Done. Your chart should be below. You can also visit this <a href='" +
"All Done. Your chart should be below. You can also visit this <a target = '_blank' href='" +
createChartURL.call(cat) +
"'>permanent link</a>. <span class='showLog'>Show full log</span>"
)
Expand Down
20 changes: 13 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/cat/export/createChartURL.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export default function createChartURL() {
console.log(this.current);
// const root_url = 'https://rhoinc.github.io/CAT/';
const root_url = 'http://localhost:8000/';
const root_url = `${window.location.origin}${window.location.pathname}`;
const se = btoa(JSON.stringify(this.current.config, null, ' '));
const re = btoa(this.current.name);
const de = btoa(this.current.data);
Expand Down
1 change: 0 additions & 1 deletion src/cat/layout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default function layout() {
var cat = this;
/* Layout primary sections */
console.log(cat.config);
cat.controls.wrap = cat.wrap
.append('div')
.classed('cat-controls section', true)
Expand Down
7 changes: 3 additions & 4 deletions src/cat/parseURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default function parseURL() {
//Parameters can be specified by number (for renderer and data file), base64 encoded text or raw text (in that order of precedence).

var queries = parseQuery(window.location.search.substring(1));
console.log(queries);

//draw the chart?
if (queries.hasOwnProperty('draw')) {
Expand Down Expand Up @@ -48,7 +47,7 @@ export default function parseURL() {
const numericOptions = ['rn', 'dn'];
numericOptions.forEach(function(v) {
if (queries[v]) {
if (isNAN(+queries[v])) {
if (isNaN(+queries[v])) {
console.warn("The '" + v + "' parameter isn't numeric. Ignoring");
queries[v] = null;
}
Expand All @@ -60,7 +59,7 @@ export default function parseURL() {

//get renderer name
if (queries.rn) {
fromURL.renderer = this.config.renderers.find((d, i) => i == queries.rn)[name];
fromURL.renderer = this.config.renderers.find((d, i) => i == queries.rn).name;
} else if (queries.re) {
fromURL.renderer = atob(queries.re);
} else {
Expand All @@ -83,7 +82,7 @@ export default function parseURL() {

//get data file name
if (queries.dn) {
fromURL.data = this.config.dataFiles.find((d, i) => i == queries.dn)[label];
fromURL.data = this.config.dataFiles.find((d, i) => i == queries.dn).label;
} else if (queries.de) {
fromURL.data = atob(queries.de);
} else {
Expand Down
8 changes: 6 additions & 2 deletions src/cat/settings/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export function set(cat) {
cat.controls.settingsInput.node().value = JSON5.stringify(cat.current.config, null, 4);

if (cat.current.hasValidSchema) {
console.log('... and it is valid. Making a nice form.');
makeForm(cat);
makeForm(
cat,
cat.config.fromURL.renderer !== null && JSON.stringify(cat.config.settings) !== '{}'
? cat.current.config
: undefined
);
}
});
}
2 changes: 1 addition & 1 deletion src/cat/status/chartInitStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function chartInitStatus(statusDiv, success, err, htmlExport) {
.append('div')
.attr('class', 'initSuccess')
.html(
"All Done. Your chart should be below. You can also visit this <a href='" +
"All Done. Your chart should be below. You can also visit this <a target = '_blank' href='" +
createChartURL.call(cat) +
"'>permanent link</a>. <span class='showLog'>Show full log</span>"
)
Expand Down

0 comments on commit 823f3a9

Please sign in to comment.