diff --git a/dist/UI/base_selector.js b/dist/UI/base_selector.js index b4f43030..f9efa16b 100644 --- a/dist/UI/base_selector.js +++ b/dist/UI/base_selector.js @@ -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; @@ -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; @@ -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) { diff --git a/dist/file_handling/file_getters.js b/dist/file_handling/file_getters.js index 7c6439f7..59043e77 100644 --- a/dist/file_handling/file_getters.js +++ b/dist/file_handling/file_getters.js @@ -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); diff --git a/ts/UI/base_selector.ts b/ts/UI/base_selector.ts index d3f6b0e7..909295f2 100644 --- a/ts/UI/base_selector.ts +++ b/ts/UI/base_selector.ts @@ -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; @@ -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 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); } } diff --git a/ts/file_handling/file_getters.ts b/ts/file_handling/file_getters.ts index b3479db5..fac1bc24 100644 --- a/ts/file_handling/file_getters.ts +++ b/ts/file_handling/file_getters.ts @@ -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) }