Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

serviceWorker.unregister();
serviceWorker.register();

if (module.hot && !window.frameElement) {
console.log('HMR enabled');
Expand Down
10 changes: 5 additions & 5 deletions src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const isLocalhost = Boolean(
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
),
);

export function register(config) {
Expand All @@ -43,7 +43,7 @@ export function register(config) {
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit http://bit.ly/CRA-PWA'
'worker. To learn more, visit http://bit.ly/CRA-PWA',
);
});
} else {
Expand Down Expand Up @@ -71,7 +71,7 @@ function registerValidSW(swUrl, config) {
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See http://bit.ly/CRA-PWA.'
'tabs for this page are closed. See http://bit.ly/CRA-PWA.',
);

// Execute callback
Expand Down Expand Up @@ -121,7 +121,7 @@ function checkValidServiceWorker(swUrl, config) {
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
'No internet connection found. App is running in offline mode.',
);
});
}
Expand Down
56 changes: 15 additions & 41 deletions src/themes/DVDScreensaver/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, useReducer, useLayoutEffect } from 'react';
import React, { useRef, useState, useLayoutEffect } from 'react';
import styled from 'styled-components';
import useWindowSize from 'react-use/lib/useWindowSize';
import { choose } from 'src/lib';
Expand All @@ -15,39 +15,22 @@ const colors = [
'purple',
];

export const initState = {
color: 'white',
velocity: { x: 2, y: 2 },
};

export const reducer = (state = initState, action = {}) => {
switch (action.type) {
case 'SET':
return action.payload;
case 'CLEAR':
return initState;
default:
return state;
}
};
function DVDScreensaver({ className }) {
const ref = useRef();
const velocity = useRef({ x: 2, y: 2 });
const { width: windowWidth, height: windowHeight } = useWindowSize();
const [state, dispatch] = useReducer(reducer, initState);
const [color, setColor] = useState(colors[0]);
useLayoutEffect(() => {
const { velocity } = state;
let myRaf;
// let canceled = false;
let vx = velocity.x;
let vy = velocity.y;
let raf;
let vx = velocity.current.x;
let vy = velocity.current.y;
let {
left: logoLeft,
top: logoTop,
width: logoWidth,
height: logoHeight,
} = ref.current.getBoundingClientRect();
function animate() {
// if (canceled) return;
let shouldUpdate = true;
if (logoLeft < 0) {
logoLeft = 0;
Expand All @@ -63,34 +46,25 @@ function DVDScreensaver({ className }) {
vy = -Math.abs(vy);
} else {
shouldUpdate = false;
logoLeft += vx;
logoTop += vy;
ref.current.style.transform = `translate(${logoLeft}px, ${logoTop}px)`;
}
if (shouldUpdate) {
dispatch({
type: 'SET',
payload: {
velocity: {
x: vx,
y: vy,
},
color: choose(colors),
},
});
velocity.current = { x: vx, y: vy };
setColor(choose(colors));
}
myRaf = requestAnimationFrame(animate);
logoLeft += vx;
logoTop += vy;
ref.current.style.transform = `translate(${logoLeft}px, ${logoTop}px)`;
raf = requestAnimationFrame(animate);
}
myRaf = requestAnimationFrame(animate);
raf = requestAnimationFrame(animate);
return () => {
// canceled = true;
cancelAnimationFrame(myRaf);
cancelAnimationFrame(raf);
};
}, [windowWidth, windowHeight]);
return (
<div className={className}>
<div ref={ref} className="logo">
<DVDLogo color={state.color} />
<DVDLogo color={color} />
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/themes/WannaCry/WannaCryWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function WannaCryWindow({
window.
</p>
<p>
After your payment, click &lt;Check Payment&gt;. Best teim to
After your payment, click &lt;Check Payment&gt;. Best time to
check: 9:00am - 11:00am GMT from Monday to Friday.
</p>
<p>
Expand All @@ -160,7 +160,7 @@ function WannaCryWindow({
<div className="manual">
<p className="darkred">
We strongly recommend you to not remove this software, and
disable your anti-virus for a while, intil you pay and the
disable your anti-virus for a while, until you pay and the
payment gets processed. If your anti-virus gets updated and
removes this software automatically, it will not be able to
recover your files even if you pay!
Expand Down