From 0e11291dc5d49e969482f1b57509eb927d2ffdc6 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 28 Jun 2018 08:43:58 -0700 Subject: [PATCH] Start adding query params --- js/components/MainWindow/Position.js | 3 + .../__snapshots__/index.test.js.snap | 1 + js/index.js | 15 ++++- js/screenshotInitialState.js | 67 +++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 js/screenshotInitialState.js diff --git a/js/components/MainWindow/Position.js b/js/components/MainWindow/Position.js index 35bfc6ef..6daa353c 100644 --- a/js/components/MainWindow/Position.js +++ b/js/components/MainWindow/Position.js @@ -33,6 +33,9 @@ const Position = ({ step="1" value={displayedPosition} onInput={setPosition} + onChange={ + () => {} /* React complains without this, can probably rename onInput to onChange */ + } onMouseUp={seekToPercentComplete} onMouseDown={setPosition} title="Seeking Bar" diff --git a/js/components/MainWindow/__snapshots__/index.test.js.snap b/js/components/MainWindow/__snapshots__/index.test.js.snap index 1ed149fc..1e17af5d 100644 --- a/js/components/MainWindow/__snapshots__/index.test.js.snap +++ b/js/components/MainWindow/__snapshots__/index.test.js.snap @@ -319,6 +319,7 @@ exports[`MainWindow renders to snapshot 1`] = ` id="position" max="100" min="0" + onChange={[Function]} onInput={[Function]} onMouseDown={[Function]} onMouseUp={[Function]} diff --git a/js/index.js b/js/index.js index 07186b0e..ba500396 100644 --- a/js/index.js +++ b/js/index.js @@ -12,6 +12,7 @@ import xmms from "../skins/XMMS-Turquoise.wsz"; import zaxon from "../skins/ZaxonRemake1-0.wsz"; import green from "../skins/Green-Dimension-V2.wsz"; import MilkdropWindow from "./components/MilkdropWindow"; +import screenshotInitialState from "./screenshotInitialState"; import Webamp from "./webamp"; import { STEP_MARQUEE, @@ -24,7 +25,7 @@ import { import { hideAbout, - skinUrl, + skinUrl as configSkinUrl, initialTracks, initialState, milkdrop @@ -39,6 +40,14 @@ const NOISY_ACTION_TYPES = new Set([ SET_BAND_VALUE ]); +let screenshot = false; +let skinUrl = configSkinUrl; +if ("URLSearchParams" in window) { + const params = new URLSearchParams(location.search); + screenshot = params.get("screenshot"); + skinUrl = params.get("skinUrl") || skinUrl; +} + function supressDragAndDrop(e) { e.preventDefault(); e.dataTransfer.effectAllowed = "none"; @@ -136,7 +145,7 @@ Raven.context(() => { const webamp = new Webamp({ initialSkin, - initialTracks, + initialTracks: screenshot ? null : initialTracks, availableSkins: [ { url: base, name: "" }, { url: green, name: "Green Dimension V2" }, @@ -162,7 +171,7 @@ Raven.context(() => { enableHotkeys: true, __extraWindows, __initialWindowLayout, - __initialState: initialState, + __initialState: screenshot ? screenshotInitialState : initialState, __customMiddlewares: [ravenMiddleware] }); diff --git a/js/screenshotInitialState.js b/js/screenshotInitialState.js new file mode 100644 index 00000000..e4750f5e --- /dev/null +++ b/js/screenshotInitialState.js @@ -0,0 +1,67 @@ +const defaultTracksState = { + "0": { + selected: false, + title: "Llama Whipping Intro", + artist: "DJ Mike Llama", + duration: "5", + url: "" + }, + "1": { + selected: false, + title: "Rock Is Dead", + artist: "Marilyn Manson", + duration: "191", // 3:11 + url: "" + }, + "2": { + selected: true, + title: "Spybreak! (Short One)", + artist: "Propellerheads", + duration: "240", // 4:00 + url: "" + }, + "3": { + selected: false, + title: "Bad Blood", + artist: "Ministry", + duration: "300", // 5:00 + url: "" + } +}; + +const initialState = { + equalizer: { + sliders: { + "60": 52, + "170": 74, + "310": 83, + "600": 91, + "1000": 74, + "3000": 54, + "6000": 23, + "12000": 19, + "14000": 34, + "16000": 75, + preamp: 56 + } + }, + media: { + status: "PLAYING", + kbps: 128, + khz: 44, + length: 5, + timeElapsed: 1, // This does not seem to work + channels: 2, + name: "1. DJ Mike Llama - Llama Whippin' Intro" + }, + playlist: { + tracks: defaultTracksState, + trackOrder: [0, 1, 2, 3], + currentTrack: 0 + }, + display: { + working: false + } +}; + +export default initialState;