Skip to content

Commit

Permalink
fixed url parameter loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPoppleton committed Jun 13, 2024
1 parent 23e553d commit afff99e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 49 deletions.
25 changes: 15 additions & 10 deletions dist/UI/base_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,11 @@ function fancySelectIntermediate(e) {
});
}
function selectIntermediate(n, selecting) {
let last = selecting ? selectedBases.last : selectedBases.last;
//how to cooly set select/deselect? Do I just need to have ifs?
function selectIdRange() {
function selectIdRange(selecting) {
let n = elements.getNextId();
let iMin = 0;
let iMax = n;
// Find the edges of selectedBases
while (iMin <= n) {
if (elements.has(iMin) && selectedBases.has(elements.get(iMin))) {
break;
Expand All @@ -287,20 +286,17 @@ function selectIntermediate(n, selecting) {
}
iMax--;
}
console.log(iMin, iMax);
// And select everything in between (this isn't necessarily what we want, but it's how it's been for a long time.)
for (let i = iMin; i < iMax; i++) {
if (elements.has(i) && !selectedBases.has(elements.get(i))) {
selecting ? elements.get(i).select() : elements.get(i).deselect();
}
}
}
if (last == undefined) {
notify("Last selected base undefined! Select something new to use range select.", 'alert');
return;
}
if (last.strand == n.strand && !n.isPatchyParticle()) {
function selectStrandRange(n, selecting) {
let s5 = n.strand.end5;
let s3 = n.strand.end3;
//find the substrand affected
while (s5 != s3) {
if (s5 == last || s5 == n) {
break;
Expand All @@ -313,13 +309,22 @@ function selectIntermediate(n, selecting) {
}
s3 = s3.n5;
}
//Select or deselect it
let substr = n.strand.getSubstrand(s5, s3);
substr.forEach(n => selecting ? n.select() : n.deselect());
}
let last = selecting ? selectedBases.last : selectedBases.last;
if (last == undefined) {
notify("Last selected base undefined! Select something new to use range select.", 'alert');
return;
}
if (last.strand == n.strand && !n.isPatchyParticle()) {
selectStrandRange(n, selecting);
}
else {
notify("Selections not on same strand! Selecting id range instead", "warning");
n.toggle();
selectIdRange();
selectIdRange(selecting);
}
}
function makeTextArea(bases, id) {
Expand Down
16 changes: 2 additions & 14 deletions dist/file_handling/file_getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,9 @@ function readFilesFromURLPath(paths) {
// And from the URL of oxView itself (can be used to read local files if you host oxView yourself)
function readFilesFromURLParams() {
let paths = [];
// I don't think we need this anymore???
const types = ['file', 'pdb', 'topology', 'configuration', 'overlay', 'force', 'par', 'oxview', 'hb', 'mgl', 'idx', 'json', 'select'];
const url = new URL(window.location.href);
types.forEach(t => {
if (url.searchParams.get(t)) {
if (t == 'pdb') {
paths.push(...url.searchParams.getAll(t).map(pdbID => `https://files.rcsb.org/download/${pdbID}.pdb`));
}
//else if (t == 'nanobase') { //NEEDS TESTING
// paths.push(...url.searchParams.getAll(t).map(nanobaseID=>`https://nanobase.org/oxdna/${nanobaseID}`));
//}
else {
paths.push(...url.searchParams.getAll(t));
}
}
url.searchParams.forEach((k, v) => {
paths.push(k);
});
if (paths.length > 0) {
readFilesFromURLPath(paths);
Expand Down
34 changes: 23 additions & 11 deletions ts/UI/base_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,12 @@ function fancySelectIntermediate(e: BasicElement) {

function selectIntermediate(n:BasicElement, selecting:Boolean) {

let last = selecting ? selectedBases.last : selectedBases.last;
//how to cooly set select/deselect? Do I just need to have ifs?

function selectIdRange(){
function selectIdRange(selecting){
let n = elements.getNextId();
let iMin = 0;
let iMax = n;

// Find the edges of selectedBases
while(iMin <= n) {
if(elements.has(iMin) && selectedBases.has(elements.get(iMin))) {
break;
Expand All @@ -311,20 +310,20 @@ function selectIntermediate(n:BasicElement, selecting:Boolean) {
}
iMax--;
}
console.log(iMin, iMax)

// And select everything in between (this isn't necessarily what we want, but it's how it's been for a long time.)
for(let i=iMin; i<iMax; i++) {
if (elements.has(i) && !selectedBases.has(elements.get(i))) {
selecting ? elements.get(i).select() : elements.get(i).deselect();
}
}
}
if (last == undefined) {
notify("Last selected base undefined! Select something new to use range select.", 'alert');
return
}
if (last.strand == n.strand && !n.isPatchyParticle()) {

function selectStrandRange(n, selecting) {
let s5 = n.strand.end5;
let s3 = n.strand.end3;

//find the substrand affected
while (s5 != s3) {
if (s5 == last || s5 == n) {
break
Expand All @@ -337,13 +336,26 @@ function selectIntermediate(n:BasicElement, selecting:Boolean) {
}
s3 = s3.n5;
}

//Select or deselect it
let substr = n.strand.getSubstrand(s5, s3)
substr.forEach(n => selecting ? n.select() : n.deselect())
}

let last = selecting ? selectedBases.last : selectedBases.last;

if (last == undefined) {
notify("Last selected base undefined! Select something new to use range select.", 'alert');
return
}

if (last.strand == n.strand && !n.isPatchyParticle()) {
selectStrandRange(n, selecting);
}
else {
notify("Selections not on same strand! Selecting id range instead", "warning")
n.toggle();
selectIdRange();
selectIdRange(selecting);
}

}
Expand Down
18 changes: 4 additions & 14 deletions ts/file_handling/file_getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,12 @@ function readFilesFromURLPath(paths: string[]) {
// And from the URL of oxView itself (can be used to read local files if you host oxView yourself)
function readFilesFromURLParams() {
let paths = []
// I don't think we need this anymore???
const types = ['file', 'pdb', 'topology', 'configuration', 'overlay', 'force', 'par', 'oxview', 'hb', 'mgl', 'idx', 'json', 'select']
const url = new URL(window.location.href);
types.forEach(t =>{
if (url.searchParams.get(t)) {
if (t == 'pdb') {
paths.push(...url.searchParams.getAll(t).map(pdbID=>`https://files.rcsb.org/download/${pdbID}.pdb`));
}
//else if (t == 'nanobase') { //NEEDS TESTING
// paths.push(...url.searchParams.getAll(t).map(nanobaseID=>`https://nanobase.org/oxdna/${nanobaseID}`));
//}
else {
paths.push(...url.searchParams.getAll(t))
}
}

url.searchParams.forEach((k, v) => {
paths.push(k)
})

if (paths.length > 0) {
readFilesFromURLPath(paths)
}
Expand Down

0 comments on commit afff99e

Please sign in to comment.