index.html 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  6. <link rel="icon" href="./favicon.ico" type="image/x-icon">
  7. <title>Mol* Viewer</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. html, body {
  15. width: 100%;
  16. height: 100%;
  17. overflow: hidden;
  18. }
  19. hr {
  20. margin: 10px;
  21. }
  22. h1, h2, h3, h4, h5 {
  23. margin-top: 5px;
  24. margin-bottom: 3px;
  25. }
  26. button {
  27. padding: 2px;
  28. }
  29. #app {
  30. position: absolute;
  31. left: 100px;
  32. top: 100px;
  33. width: 800px;
  34. height: 600px;
  35. }
  36. </style>
  37. <link rel="stylesheet" type="text/css" href="molstar.css" />
  38. </head>
  39. <body>
  40. <div id="app"></div>
  41. <script type="text/javascript" src="./molstar.js"></script>
  42. <script type="text/javascript">
  43. function getParam(name, regex) {
  44. var r = new RegExp(name + '=' + '(' + regex + ')[&]?', 'i');
  45. return decodeURIComponent(((window.location.search || '').match(r) || [])[1] || '');
  46. }
  47. var debugMode = getParam('debug-mode', '[^&]+').trim() === '1';
  48. if (debugMode) molstar.setDebugMode(debugMode, debugMode);
  49. var disableAntialiasing = getParam('disable-antialiasing', '[^&]+').trim() === '1';
  50. var pixelScale = parseFloat(getParam('pixel-scale', '[^&]+').trim() || '1');
  51. var disableWboit = getParam('disable-wboit', '[^&]+').trim() === '1';
  52. var hideControls = getParam('hide-controls', '[^&]+').trim() === '1';
  53. var pdbProvider = getParam('pdb-provider', '[^&]+').trim().toLowerCase();
  54. var emdbProvider = getParam('emdb-provider', '[^&]+').trim().toLowerCase();
  55. var viewer = new molstar.Viewer('app', {
  56. disableAntialiasing: disableAntialiasing,
  57. pixelScale: pixelScale,
  58. enableWboit: !disableWboit,
  59. layoutShowControls: !hideControls,
  60. viewportShowExpand: false,
  61. pdbProvider: pdbProvider || 'pdbe',
  62. emdbProvider: emdbProvider || 'pdbe',
  63. });
  64. var snapshotId = getParam('snapshot-id', '[^&]+').trim();
  65. if (snapshotId) viewer.setRemoteSnapshot(snapshotId);
  66. var snapshotUrl = getParam('snapshot-url', '[^&]+').trim();
  67. var snapshotUrlType = getParam('snapshot-url-type', '[^&]+').toLowerCase().trim() || 'molj';
  68. if (snapshotUrl && snapshotUrlType) viewer.loadSnapshotFromUrl(snapshotUrl, snapshotUrlType);
  69. var structureUrl = getParam('structure-url', '[^&]+').trim();
  70. var structureUrlFormat = getParam('structure-url-format', '[a-z]+').toLowerCase().trim();
  71. var structureUrlIsBinary = getParam('structure-url-is-binary', '[^&]+').trim() === '1';
  72. if (structureUrl) viewer.loadStructureFromUrl(structureUrl, structureUrlFormat, structureUrlIsBinary);
  73. var pdb = getParam('pdb', '[^&]+').trim();
  74. if (pdb) viewer.loadPdb(pdb);
  75. var pdbDev = getParam('pdb-dev', '[^&]+').trim();
  76. if (pdbDev) viewer.loadPdbDev(pdbDev);
  77. var emdb = getParam('emdb', '[^&]+').trim();
  78. if (emdb) viewer.loadEmdb(emdb);
  79. </script>
  80. </body>
  81. </html>