├── public
├── _redirects
├── favicon.png
├── logo192.png
├── logo512.png
├── robots.txt
├── manifest.json
└── index.html
├── .gitignore
├── src
├── index.js
├── components
│ ├── firebase.js
│ ├── authpageillustration.svg
│ └── notfound.svg
├── index.css
├── App.js
├── pages
│ ├── notfoundpage.jsx
│ ├── authpage.jsx
│ ├── deploypage.jsx
│ ├── projectspage.jsx
│ └── editorpage.jsx
├── App.css
└── serviceWorker.js
├── package.json
└── README.md
/public/_redirects:
--------------------------------------------------------------------------------
1 | /* /index.html 200
--------------------------------------------------------------------------------
/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jaagrav/Xper/HEAD/public/favicon.png
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jaagrav/Xper/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jaagrav/Xper/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "Xper",
3 | "name": "Xper - RealTime Code Editor",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#1A202E",
24 | "background_color": "#0E1218"
25 | }
26 |
--------------------------------------------------------------------------------
/src/components/firebase.js:
--------------------------------------------------------------------------------
1 | import firebase from "firebase"
2 |
3 | var firebaseConfig = {
4 | apiKey: "AIzaSyBjuzaHS-svU9tHSQTY2gr4KMnpP16iuQM",
5 | authDomain: "the-coder-b3e19.firebaseapp.com",
6 | databaseURL: "https://the-coder-b3e19.firebaseio.com",
7 | projectId: "the-coder-b3e19",
8 | storageBucket: "the-coder-b3e19.appspot.com",
9 | messagingSenderId: "978497464036",
10 | appId: "1:978497464036:web:359cac492154b35006eef1",
11 | measurementId: "G-9N4YJHX2J7"
12 | };
13 | // Initialize Firebase
14 | firebase.initializeApp(firebaseConfig);
15 | firebase.analytics();
16 |
17 | export default firebase;
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@500&family=Orbitron&display=swap');
2 |
3 | * {
4 | margin: 0;
5 | padding: 0;
6 | box-sizing: border-box;
7 | -webkit-user-drag: none;
8 | text-decoration: none;
9 | user-select: none;
10 | }
11 | body {
12 | margin: 0;
13 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
14 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
15 | sans-serif;
16 | -webkit-font-smoothing: antialiased;
17 | -moz-osx-font-smoothing: grayscale;
18 | background-color: #0E1218;
19 | }
20 |
21 | code {
22 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
23 | monospace;
24 | }
25 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import './App.css';
3 | import {BrowserRouter as Router, Route, Redirect, Switch} from 'react-router-dom';
4 |
5 | import Authpage from './pages/authpage';
6 | import Projectspage from './pages/projectspage';
7 | import Editorpage from './pages/editorpage';
8 | import Deploypage from './pages/deploypage';
9 | import Notfoundpage from './pages/notfoundpage';
10 |
11 | function App() {
12 | return (
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | );
26 | }
27 |
28 | export default App;
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webdev",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@material-ui/core": "^4.11.0",
7 | "@material-ui/icons": "^4.9.1",
8 | "@material-ui/lab": "^4.0.0-alpha.56",
9 | "@testing-library/jest-dom": "^4.2.4",
10 | "@testing-library/react": "^9.3.2",
11 | "@testing-library/user-event": "^7.1.2",
12 | "ace-builds": "^1.4.12",
13 | "firebase": "^7.23.0",
14 | "react": "^16.13.1",
15 | "react-ace": "^9.1.4",
16 | "react-dom": "^16.13.1",
17 | "react-router-dom": "^5.2.0",
18 | "react-scripts": "3.4.3",
19 | "sweetalert2": "^10.5.1"
20 | },
21 | "scripts": {
22 | "start": "react-scripts start",
23 | "build": "react-scripts build",
24 | "test": "react-scripts test",
25 | "eject": "react-scripts eject"
26 | },
27 | "eslintConfig": {
28 | "extends": "react-app"
29 | },
30 | "browserslist": {
31 | "production": [
32 | ">0.2%",
33 | "not dead",
34 | "not op_mini all"
35 | ],
36 | "development": [
37 | "last 1 chrome version",
38 | "last 1 firefox version",
39 | "last 1 safari version"
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/pages/notfoundpage.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { Link } from 'react-router-dom'
3 |
4 | import { makeStyles } from '@material-ui/core/styles';
5 |
6 | import NotFoundIllustration from '../components/notfound.svg'
7 |
8 | const useStyles = makeStyles((theme) => ({
9 | brandingName: {
10 | position: 'absolute',
11 | fontFamily: "'Orbitron', sans-serif",
12 | height: "fit-content",
13 | width: "fit-content",
14 | fontSize: '45px',
15 | color: '#50C0FF',
16 | margin: 'auto',
17 | top: '15px',
18 | left: '15px',
19 | },
20 | nfi: {
21 | position: "absolute",
22 | margin: 'auto',
23 | width: 'calc(100% - 40%)',
24 | top: '0',
25 | right: '0',
26 | left: '0',
27 | bottom: '0',
28 | },
29 | notfound: {
30 | position: "absolute",
31 | height: 'fit-content',
32 | width: 'fit-content',
33 | margin: 'auto',
34 | color: '#50C0FF',
35 | right: '0',
36 | left: '0',
37 | bottom: 50,
38 | fontFamily: "'Orbitron', sans-serif",
39 | fontSize: '45px',
40 | }
41 | }))
42 | function Notfoundpage() {
43 | document.title = 'Not Found - Xper';
44 |
45 | const classes = useStyles();
46 |
47 | return (
48 |
49 |
Xper
50 |

51 |
Not Found
52 |
53 | )
54 | }
55 |
56 | export default Notfoundpage;
57 |
--------------------------------------------------------------------------------
/src/pages/authpage.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { useHistory } from 'react-router-dom';
3 |
4 | import firebase from '../components/firebase';
5 |
6 | import Button from '@material-ui/core/Button';
7 | import { makeStyles } from '@material-ui/core/styles';
8 |
9 | import Illustration1 from '../components/authpageillustration.svg';
10 |
11 | const useStyles = makeStyles((theme) => ({
12 | authButton: {
13 | height: "fit-content",
14 | width: "fit-content",
15 | backgroundColor: "#1A202E",
16 | color: "#50C0FF",
17 | padding: "10px 10px",
18 | "&:hover": {
19 | backgroundColor: "#1D2431"
20 | },
21 | position: "absolute",
22 | margin: "auto",
23 | top: "50px",
24 | right: "0",
25 | left: "0",
26 | bottom: "0",
27 | },
28 | brandingName: {
29 | fontFamily: "'Orbitron', sans-serif",
30 | color: "#50C0FF",
31 | height: "fit-content",
32 | width: "fit-content",
33 | fontSize: "3rem",
34 | position: "absolute",
35 | margin: "auto",
36 | top: "0",
37 | right: "0",
38 | left: "0",
39 | bottom: "100px",
40 | },
41 | topBar: {
42 | height: "7px",
43 | width: "100%",
44 | position: "absolute",
45 | margin: "auto",
46 | top: "0",
47 | right: "0",
48 | left: "0",
49 | backgroundColor: "#50C0FF"
50 | }
51 | }));
52 |
53 | function Authpage() {
54 | document.title = "Auth - Xper";
55 | const classes = useStyles();
56 | let history = useHistory();
57 |
58 | let handleSignIn = e => {
59 | var provider = new firebase.auth.GoogleAuthProvider();
60 | firebase.auth().signInWithPopup(provider)
61 | }
62 |
63 | firebase.auth().onAuthStateChanged(firebaseUser => {
64 | if (firebaseUser)
65 | history.push("/");
66 | });
67 |
68 | return (
69 |
70 |
71 |
Xper
72 |
73 |

74 |
75 | )
76 | }
77 |
78 | export default Authpage;
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | ## Xper
3 |
4 | Xper is a realtime code editor where you can both write and save your code in realtime! The unique thing about Xper is it updates your deployed code in realtime, which means you can code on your computer and immediately be able to check how it looks like on your phone, tablet, and literally everywhere else. Xper is developed in React, which makes it a lightning fast code editor considering everything is being saved remotely. Check it out in the links given below,
5 |
6 | Live at: https://xperbycoder.netlify.app
7 | Source Code: https://github.com/Jaagrav/Xper
8 |
9 | You can create issues in case you detect a bug, and if you know how to fix it, you can work on it yourself and make a PR, I will accept all the PRs that deserve to be accepted, so now you can also become a contributor for Xper!!
10 |
11 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
12 |
13 | ## Available Scripts
14 |
15 | In the project directory, you can run:
16 |
17 | ### `yarn start`
18 |
19 | Runs the app in the development mode.
20 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
21 |
22 | The page will reload if you make edits.
23 | You will also see any lint errors in the console.
24 |
25 | ### `yarn test`
26 |
27 | Launches the test runner in the interactive watch mode.
28 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
29 |
30 | ### `yarn build`
31 |
32 | Builds the app for production to the `build` folder.
33 | It correctly bundles React in production mode and optimizes the build for the best performance.
34 |
35 | The build is minified and the filenames include the hashes.
36 | Your app is ready to be deployed!
37 |
38 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
39 |
40 | ### `yarn eject`
41 |
42 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
43 |
44 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
45 |
46 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
47 |
48 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
49 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .auth-illustration {
2 | position: absolute;
3 | width: 45%;
4 | margin: auto;
5 | bottom: 0;right: 0;
6 | z-index: -1;
7 | max-width: 645px;
8 | }
9 |
10 | @media (max-width: 600px) {
11 | .auth-illustration {
12 | width: 70%;
13 | }
14 | }
15 |
16 | .MuiList-root.MuiMenu-list.MuiList-padding, .MuiSpeedDialAction-fab, .MuiButtonBase-root.MuiFab-root.MuiSpeedDialAction-fab.MuiSpeedDialAction-fabClosed.MuiFab-sizeSmall {
17 | background: #1A202E !important;color: #62B0FF !important;
18 | }
19 |
20 | .MuiButtonBase-root.MuiFab-root.MuiSpeedDial-fab.MuiFab-primary, .MuiSpeedDial-root.MuiSpeedDial-directionDown.makeStyles-speedDial-6, .MuiFab-label {
21 | height: 30px !important;
22 | background: transparent !important;
23 | box-shadow: none !important;
24 | width: 30px !important;
25 | padding: 0;
26 | display: flex !important;
27 | }
28 |
29 | #htmlEditor,#cssEditor,#jsEditor {
30 | position: absolute;
31 | height: 100% !important;
32 | width: 100% !important;
33 | margin: auto;
34 | top: 0;right: 0;left: 0;bottom: 0;
35 | display: none;
36 | background-color: #0E1218;
37 | }
38 | #htmlEditor {
39 | display: block;
40 | }
41 | .ace_text-layer > .ace_line {
42 | color: #fff !important;
43 | }
44 | .ace-nord-dark .ace_gutter-active-line, .ace-nord-dark .ace_marker-layer .ace_selection, .ace-nord-dark .ace_marker-layer .ace_active-line {
45 | background-color: #1A202E;
46 | }
47 | .ace-nord-dark .ace_entity.ace_name.ace_function, .ace-nord-dark .ace_meta, .ace-nord-dark .ace_support.ace_type{
48 | color: #62B0FF !important;
49 | }
50 | .ace-nord-dark .ace_variable, .ace-nord-dark .ace_variable.ace_language{
51 | color: rgb(255, 79, 132) !important;
52 | }
53 | .ace-nord-dark .ace_string, .ace-nord-dark .ace_constant.ace_numeric {
54 | color: #ffcc41 !important;
55 | }
56 | .ace-nord-dark .ace_support.ace_function {
57 | color: #5bdb9b !important;
58 | }
59 | .ace-nord-dark .ace_keyword {
60 | color: rgb(154, 76, 218) !important;
61 | }
62 |
63 | .swal2-popup{
64 | background-color: #0E1218 !important;
65 | }
66 | .swal2-title {
67 | color: #62B0FF !important;
68 | font-family: 'Comfortaa', sans-serif;
69 | }
70 | .swal2-html-container{
71 | color: #fff !important;
72 | font-family: 'Comfortaa', sans-serif;
73 | }
74 | .swal2-styled.swal2-confirm {
75 | background-color: #62B0FF !important;color: #0E1218 !important;
76 | font-family: 'Comfortaa', sans-serif;
77 | }
78 | .swal2-styled.swal2-cancel{
79 | background-color: #FF6D6D !important;color: #fff !important;
80 | font-family: 'Comfortaa', sans-serif;
81 | }
82 |
83 | @media (min-width: 600px) {
84 | ::-webkit-scrollbar {
85 | height: 10px;
86 | width: 10px;
87 | appearance: none;
88 | background-color: #0E1218;
89 | }
90 |
91 | ::-webkit-scrollbar-thumb {
92 | appearance: none;
93 | border-radius: 10px;
94 | background-color: #1A202E;
95 | }
96 |
97 | ::-webkit-scrollbar-thumb:hover {
98 | appearance: none;
99 | border-radius: 10px;
100 | background-color: #262f44;
101 | }
102 | }
103 |
104 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
16 |
20 |
21 |
22 |
23 |
27 |
31 |
32 |
33 |
37 |
41 |
42 |
46 |
50 |
51 |
52 |
53 |
54 |
58 |
59 |
68 | Xper
69 |
70 |
71 |
72 |
73 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/src/pages/deploypage.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { useHistory } from 'react-router-dom';
3 |
4 | import firebase from '../components/firebase';
5 |
6 | import { makeStyles } from '@material-ui/core/styles';
7 | import Backdrop from '@material-ui/core/Backdrop';
8 | import CircularProgress from '@material-ui/core/CircularProgress';
9 | import Button from '@material-ui/core/Button';
10 |
11 | const useStyles = makeStyles((theme) => ({
12 | iframe: {
13 | position: 'absolute',
14 | margin: 'auto',
15 | height: '100%',
16 | width: '100%',
17 | top: '0',
18 | right: '0',
19 | left: '0',
20 | bottom: '0',
21 | outline: 0,
22 | border: 0,
23 | backgroundColor: 'white',
24 | },
25 | seeCode: {
26 | position: 'absolute',
27 | margin: 'auto',
28 | right: 15,
29 | bottom: 15,
30 | color: "#1A202E",
31 | backgroundColor: '#50C0FF !important'
32 | }
33 | }))
34 | function Deploypage(props) {
35 | document.title = "Deploy - Xper";
36 |
37 | let history = useHistory();
38 |
39 | const classes = useStyles(); const iframeRef = React.useRef();
40 |
41 | let userID = props.match.params.UID, projectID = props.match.params.projectID;
42 |
43 | const [open, setOpen] = React.useState(true);
44 |
45 | React.useEffect(() => {
46 | firebase.database().ref("WebDev/" + userID + "/" + projectID).once("value").then(snap => {
47 | if (snap.key === projectID) {
48 | var old_element = document.getElementsByClassName(classes.iframe)[0];
49 | var new_element = old_element.cloneNode(true);
50 | old_element.parentNode.replaceChild(new_element, old_element);
51 | let output = new_element.contentWindow.document;
52 | let htmlDoc = "" + snap.val().html + "";
53 | try {
54 | // output.contentWindow.location.reload(true);
55 | output.open();
56 | output.write(htmlDoc);
57 | output.close();
58 | setOpen(false);
59 | document.title = output.title + ' - Xper';
60 | } catch (e) {
61 | //Fuck You error
62 | console.log(e)
63 | }
64 | }
65 | }).catch(error => {
66 | console.warn('Contents not found!');
67 | history.push("/notfound")
68 | })
69 | firebase.database().ref("WebDev/" + userID).on("child_changed", snap => {
70 | if (snap.key === projectID) {
71 | var old_element = document.getElementsByClassName(classes.iframe)[0];
72 | var new_element = old_element.cloneNode(true);
73 | old_element.parentNode.replaceChild(new_element, old_element);
74 | let output = new_element.contentWindow.document;
75 | let htmlDoc = "" + snap.val().html + "";
76 | try {
77 | // output.contentWindow.location.reload(true);
78 | output.open();
79 | output.write(htmlDoc);
80 | output.close();
81 | document.title = output.title + ' - Xper';
82 | setOpen(false);
83 | } catch (e) {
84 | //Fuck You error
85 | console.log(e)
86 | }
87 | }
88 | })
89 | }, [])
90 | return (
91 |
92 |
93 |
94 |
95 |
100 |
101 |
102 | )
103 | }
104 |
105 | export default Deploypage;
106 |
--------------------------------------------------------------------------------
/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.0/8 are considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl, {
104 | headers: { 'Service-Worker': 'script' },
105 | })
106 | .then(response => {
107 | // Ensure service worker exists, and that we really are getting a JS file.
108 | const contentType = response.headers.get('content-type');
109 | if (
110 | response.status === 404 ||
111 | (contentType != null && contentType.indexOf('javascript') === -1)
112 | ) {
113 | // No service worker found. Probably a different app. Reload the page.
114 | navigator.serviceWorker.ready.then(registration => {
115 | registration.unregister().then(() => {
116 | window.location.reload();
117 | });
118 | });
119 | } else {
120 | // Service worker found. Proceed as normal.
121 | registerValidSW(swUrl, config);
122 | }
123 | })
124 | .catch(() => {
125 | console.log(
126 | 'No internet connection found. App is running in offline mode.'
127 | );
128 | });
129 | }
130 |
131 | export function unregister() {
132 | if ('serviceWorker' in navigator) {
133 | navigator.serviceWorker.ready
134 | .then(registration => {
135 | registration.unregister();
136 | })
137 | .catch(error => {
138 | console.error(error.message);
139 | });
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/src/pages/projectspage.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Link, useHistory } from 'react-router-dom';
3 |
4 | import firebase from '../components/firebase';
5 |
6 | import Swal from 'sweetalert2';
7 |
8 | import { makeStyles } from '@material-ui/core/styles';
9 | import Fab from '@material-ui/core/Fab';
10 | import IconButton from '@material-ui/core/IconButton';
11 | import AddIcon from '@material-ui/icons/Add';
12 | import Avatar from '@material-ui/core/Avatar';
13 | import Menu from '@material-ui/core/Menu';
14 | import MenuItem from '@material-ui/core/MenuItem';
15 | import Card from '@material-ui/core/Card';
16 | import CardActions from '@material-ui/core/CardActions';
17 | import CardContent from '@material-ui/core/CardContent';
18 | import Button from '@material-ui/core/Button';
19 | import Typography from '@material-ui/core/Typography';
20 | import DeleteIcon from '@material-ui/icons/Delete';
21 | import LanguageIcon from '@material-ui/icons/Language';
22 | import LaunchIcon from '@material-ui/icons/Launch';
23 | import Backdrop from '@material-ui/core/Backdrop';
24 | import CircularProgress from '@material-ui/core/CircularProgress';
25 |
26 | const useStyles = makeStyles((theme) => ({
27 | header: {
28 | position: 'absolute',
29 | height: '50px',
30 | width: '100%',
31 | margin: 'auto',
32 | top: 0,
33 | right: 0,
34 | left: 0,
35 | backgroundColor: '#50C0FF'
36 | },
37 | brandingName: {
38 | position: 'absolute',
39 | fontFamily: "'Orbitron', sans-serif",
40 | height: "fit-content",
41 | width: "fit-content",
42 | fontSize: '25px',
43 | fontWeight: '600',
44 | color: '#1A202E',
45 | margin: 'auto',
46 | top: '0',
47 | left: '15px',
48 | bottom: '0'
49 | },
50 | fabBtn: {
51 | position: 'absolute',
52 | color: '#1A202E',
53 | backgroundColor: '#50C0FF !important',
54 | margin: 'auto',
55 | right: '15px',
56 | bottom: '15px'
57 | },
58 | photoURL: {
59 | height: '50px',
60 | width: '50px',
61 | position: 'absolute',
62 | margin: 'auto',
63 | top: '0',
64 | right: '5px',
65 | bottom: '0'
66 | },
67 | menu: {
68 | color: '#50C0FF',
69 | fontFamily: "'Comfortaa', sans-serif",
70 | },
71 | projectsContainer: {
72 | position: 'absolute',
73 | height: 'calc(100% - 50px)',
74 | width: '100%',
75 | margin: 'auto',
76 | right: 0,
77 | left: 0,
78 | top: '50px',
79 | overflowX: 'hidden',
80 | overflowY: 'auto'
81 | },
82 | projectsGrid: {
83 | padding: '15px',
84 | height: 'fit-content',
85 | width: '100%',
86 | display: 'grid',
87 | gridGap: '15px',
88 | gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))'
89 | },
90 | root: {
91 | position: 'relative',
92 | height: "fit-content",
93 | width: "100%",
94 | backgroundColor: "#1A202E",
95 | },
96 | title: {
97 | fontSize: 30,
98 | fontFamily: "'Comfortaa', sans-serif",
99 | color: "#50C0FF",
100 | whiteSpace: "nowrap",
101 | overflow: "hidden",
102 | textOverflow: "ellipsis"
103 | },
104 | pos: {
105 | fontSize: 17,
106 | color: "#fff",
107 | fontFamily: "'Comfortaa', sans-serif",
108 | },
109 | deleteBtn: {
110 | color: "#FF6D6D"
111 | },
112 | openBtn: {
113 | color: "#50C0FF"
114 | },
115 | noProjects: {
116 | height: "fit-content",
117 | width: "fit-content",
118 | position: "absolute",
119 | margin: "auto",
120 | top: 0,
121 | bottom: 0,
122 | left: 0,
123 | right: 0,
124 | fontFamily: "'Comfortaa', sans-serif",
125 | fontSize: '34px',
126 | textAlign: "center",
127 | color: '#1A202E',
128 | display: "none"
129 | }
130 | }));
131 | function Projectspage() {
132 | document.title = "Projects - Xper"
133 | const classes = useStyles();
134 | let history = useHistory();
135 |
136 | let firebaseRef = React.useRef();
137 | let myUID = React.useRef();
138 |
139 | const [displayName, setDisplayName] = React.useState("");
140 | const [userPhoto, setUserPhoto] = React.useState("");
141 |
142 | const [anchorEl, setAnchorEl] = React.useState(null);
143 |
144 | const handleClick = (event) => {
145 | setAnchorEl(event.currentTarget);
146 | };
147 |
148 | const handleClose = () => {
149 | setAnchorEl(null);
150 | };
151 |
152 | const [open, setOpen] = React.useState(false);
153 | const startBackdrop = (instruct) => {
154 | setOpen(instruct);
155 | };
156 |
157 | const [projects, setProjects] = React.useState([]);
158 |
159 | const noProjects = React.useRef();
160 |
161 | const makeNewProject = (e) => {
162 | startBackdrop(true);
163 | const date = new Date();
164 | const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
165 | const created = date.getDate() + " " + months[date.getMonth()] + ", " + date.getFullYear();
166 | if (firebase.auth) {
167 | firebaseRef.current.push({
168 | name: "Untitled",
169 | html: `
170 |
171 |
172 | Document Title
173 |
174 |
175 | HTML goes here
176 |
177 | `,
178 | css: `body{
179 |
180 | }`,
181 | js: `//JavaScript goes here`,
182 | created: created
183 | })
184 | .then(snap => {
185 | history.push("/edit/" + myUID.current + "/" + snap.key);
186 | })
187 | }
188 | }
189 |
190 | React.useEffect(() => {
191 | startBackdrop(true);
192 | firebase.auth().onAuthStateChanged(firebaseUser => {
193 | if (firebaseUser) {
194 | // console.log(firebaseUser)
195 | setUserPhoto(firebaseUser.photoURL);
196 | setDisplayName(firebaseUser.displayName);
197 | myUID.current = firebaseUser.uid;
198 | firebaseRef.current = firebase.database().ref("WebDev/" + firebaseUser.uid);
199 | loadProjects();
200 | }
201 | else history.push("/auth");
202 | });
203 | }, []);
204 |
205 | function loadProjects() {
206 | firebaseRef.current.once("value").then(snap => {
207 | startBackdrop(false);
208 | // const key = snap.key;
209 | // const project = { ...snap.val(), key: key };
210 | // setProjects(prevProjects => [...prevProjects, project]);
211 | // console.log(snap.val())
212 | try {
213 | noProjects.current.style.display = 'block';
214 | } catch (e) {
215 | //fuck you error
216 | }
217 | let tempProjects = [];
218 | for (let i in snap.val()) {
219 | const key = i;
220 | const project = { ...snap.val()[i], key: key };
221 | tempProjects.push(project);
222 | try {
223 | noProjects.current.style.display = 'none';
224 | } catch (e) {
225 | //fuck you error
226 | }
227 | }
228 | setProjects(tempProjects);
229 |
230 | })
231 | }
232 |
233 | function deleteProject(projectToBeDeleted) {
234 | Swal.fire({
235 | title: 'Are you sure?',
236 | text: "You won't be able to revert this!",
237 | icon: 'warning',
238 | showCancelButton: true,
239 | confirmButtonColor: '#3085d6',
240 | cancelButtonColor: '#d33',
241 | confirmButtonText: 'Yes, delete it!'
242 | }).then((result) => {
243 | if (result.isConfirmed) {
244 | firebaseRef.current.child(projectToBeDeleted).remove(); loadProjects();
245 | Swal.fire(
246 | 'Deleted!',
247 | 'Your file has been deleted.',
248 | 'success'
249 | )
250 | }
251 | })
252 | }
253 |
254 | return (
255 |
256 |
257 |
258 |
259 |
260 |
Xper
261 |
262 |
263 |
264 |
274 |
275 |
276 |
Looks like you don't have any projects
Click on the add button to create your first project!
277 |
278 | {projects.map(project => (
279 |
280 |
281 |
282 |
283 | {project.name}
284 |
285 |
286 | Created: {project.created}
287 |
288 |
289 |
290 | } size="small" onClick={() => { startBackdrop(true); history.push("/edit/" + myUID.current + "/" + project.key + "/") }}>Open
291 | } size="small" onClick={() => { window.open(("/deploy/" + myUID.current + "/" + project.key + "/"), "_blank") }}>Visit
292 | } size="small" onClick={() => { deleteProject(project.key) }}>Delete
293 |
294 |
295 | ))}
296 |
297 |
298 |
299 |
300 |
301 |
302 | )
303 | }
304 |
305 | export default Projectspage
306 |
--------------------------------------------------------------------------------
/src/components/authpageillustration.svg:
--------------------------------------------------------------------------------
1 |
66 |
--------------------------------------------------------------------------------
/src/pages/editorpage.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { useHistory, Link } from 'react-router-dom';
3 |
4 | import firebase from '../components/firebase';
5 |
6 | import AceEditor from "react-ace";
7 | import "ace-builds/src-noconflict/theme-nord_dark";
8 | import "ace-builds/src-noconflict/ext-language_tools";
9 | import "ace-builds/src-noconflict/mode-html";
10 | import "ace-builds/src-noconflict/mode-css";
11 | import "ace-builds/src-noconflict/mode-javascript";
12 |
13 | import { makeStyles } from '@material-ui/core/styles';
14 | import Avatar from '@material-ui/core/Avatar';
15 | import SpeedDial from '@material-ui/lab/SpeedDial';
16 | import SpeedDialAction from '@material-ui/lab/SpeedDialAction';
17 | import FileCopyIcon from '@material-ui/icons/FileCopyOutlined';
18 | import SaveIcon from '@material-ui/icons/Save';
19 | import ShareIcon from '@material-ui/icons/Share';
20 | import HomeRoundedIcon from '@material-ui/icons/HomeRounded';
21 | import PlayArrowRoundedIcon from '@material-ui/icons/PlayArrowRounded';
22 | import Tooltip from '@material-ui/core/Tooltip';
23 | import Zoom from '@material-ui/core/Zoom';
24 | import Snackbar from '@material-ui/core/Snackbar';
25 | import MuiAlert from '@material-ui/lab/Alert';
26 | import Backdrop from '@material-ui/core/Backdrop';
27 | import CircularProgress from '@material-ui/core/CircularProgress';
28 | import LaunchIcon from '@material-ui/icons/Launch';
29 |
30 | function Alert(props) {
31 | return ;
32 | }
33 |
34 | const useStyles = makeStyles((theme) => ({
35 | header: {
36 | position: 'absolute',
37 | height: '50px',
38 | width: '100%',
39 | margin: 'auto',
40 | top: 0,
41 | right: 0,
42 | left: 0,
43 | backgroundColor: '#50C0FF',
44 | zIndex: 1
45 | },
46 | brandingName: {
47 | position: 'absolute',
48 | fontFamily: "'Orbitron', sans-serif",
49 | height: "fit-content",
50 | width: "fit-content",
51 | fontSize: '25px',
52 | fontWeight: '600',
53 | color: '#1A202E',
54 | margin: 'auto',
55 | top: '0',
56 | left: '15px',
57 | bottom: '0'
58 | },
59 | photoURL: {
60 | height: '50px',
61 | width: '50px',
62 | position: 'absolute',
63 | margin: 'auto',
64 | top: '0',
65 | right: '5px',
66 | bottom: '0'
67 | },
68 | root: {
69 | transform: 'translateZ(0px)',
70 | flexGrow: 1,
71 | },
72 | exampleWrapper: {
73 | position: 'relative',
74 | marginTop: theme.spacing(3),
75 | height: 380,
76 | },
77 | radioGroup: {
78 | margin: theme.spacing(1, 0),
79 | },
80 | speedDial: {
81 | position: 'absolute',
82 | top: 5,
83 | right: 0
84 | },
85 | codeName: {
86 | position: 'absolute',
87 | margin: 'auto',
88 | fontSize: '1rem',
89 | fontWeight: '600',
90 | fontFamily: '"Comfortaa", sans-serif',
91 | top: '0',
92 | bottom: '0',
93 | right: '60px',
94 | height: '30px',
95 | color: '#1A202E !important',
96 | textAlign: 'right',
97 | backgroundColor: 'transparent',
98 | outline: 'none',
99 | border: 'none'
100 | },
101 | editorsTabs: {
102 | position: 'absolute',
103 | width: '369px',
104 | display: 'grid',
105 | gridTemplateColumns: 'repeat(3, minmax(100px, 1fr))',
106 | zIndex: 2,
107 | [theme.breakpoints.down("sm")]: {
108 | width: '100%',
109 | top: '50px',
110 | zIndex: 0,
111 | },
112 | },
113 | tabs: {
114 | cursor: 'pointer',
115 | height: '100%',
116 | width: '100%',
117 | fontSize: '1rem',
118 | color: '#50C0FF',
119 | fontFamily: '"Comfortaa", sans-serif',
120 | textAlign: 'center',
121 | padding: '16px 0',
122 | marginRight: '3px',
123 | display: 'inline-block',
124 | backgroundColor: "#1A202E",
125 | "&.selected": {
126 | backgroundColor: "#0E1218 !important",
127 | cursor: 'auto'
128 | },
129 | "&:hover": {
130 | backgroundColor: "#262f44",
131 | }
132 | },
133 | dragToOutput: {
134 | position: 'absolute',
135 | margin: 'auto',
136 | cursor: 'w-resize',
137 | height: '50px',
138 | width: '50px',
139 | backgroundColor: '#1A202E',
140 | borderRadius: '50px',
141 | display: 'flex',
142 | justifyContent: 'center',
143 | alignItems: 'center',
144 | bottom: 15,
145 | right: 477,
146 | [theme.breakpoints.down("sm")]: {
147 | right: 15,
148 | },
149 | zIndex: '2'
150 | },
151 | editor: {
152 | position: 'absolute',
153 | height: 'calc(100% - 50px)',
154 | width: '100%',
155 | margin: 'auto',
156 | top: '50px',
157 | right: '0',
158 | left: '0',
159 | zIndex: '0',
160 | [theme.breakpoints.down("sm")]: {
161 | height: 'calc(100% - 100px)',
162 | top: '100px',
163 | },
164 | },
165 | iframe: {
166 | position: 'absolute',
167 | height: '100%',
168 | margin: 'auto',
169 | right: '0',
170 | top: '0',
171 | bottom: '0',
172 | outline: 0,
173 | border: 0,
174 | backgroundColor: 'white',
175 | zIndex: 4,
176 | [theme.breakpoints.down("sm")]: {
177 | transition: '0.4s', width: '0%',
178 | },
179 | },
180 | editors: {
181 | position: 'absolute',
182 | height: '100%',
183 | width: '100%',
184 | margin: 'auto',
185 | top: 0,
186 | left: 0,
187 | bottom: 0,
188 |
189 | }
190 | }));
191 |
192 | function Editorpage(props) {
193 | document.title = "Code Editor - Xper";
194 | const classes = useStyles();
195 | let history = useHistory();
196 | let mouseDown = false;
197 | let codeName = React.useRef();
198 | let html = '', css = '', js = '';
199 | let htmlTabRef = React.useRef(), cssTabRef = React.useRef(), jsTabRef = React.useRef();
200 | let htmlEditorRef = React.useRef(), cssEditorRef = React.useRef(), jsEditorRef = React.useRef(), editors = React.useRef();
201 | let dragToIframeRef = React.useRef();
202 |
203 | let firebaseRef = React.useRef();
204 | const [loadCode, setLoadCode] = React.useState(false);
205 |
206 | const [displayName, setDisplayName] = React.useState("");
207 | const [userPhoto, setUserPhoto] = React.useState("");
208 | const [letEdit, setLetEdit] = React.useState(false);
209 |
210 | let userID = props.match.params.UID, projectID = props.match.params.projectID;
211 |
212 | React.useEffect(() => {
213 | firebase.auth().onAuthStateChanged(firebaseUser => {
214 | // else if (snap.exists()) history.push("/notfound")
215 | if (firebaseUser) {
216 | if (firebaseUser.uid === userID) {
217 | // console.log(firebaseUser);
218 | setUserPhoto(firebaseUser.photoURL);
219 | setDisplayName(firebaseUser.displayName);
220 | firebaseRef.current = firebase.database().ref("WebDev/" + userID + "/" + projectID)
221 | firebaseRef.current.once("value").then(snap => {
222 | if (snap.key === projectID) {
223 | html = snap.val().html;
224 | css = snap.val().css;
225 | js = snap.val().js;
226 | setLoadCode(!loadCode);
227 | codeName.current.value = snap.val().name;
228 | htmlEditorRef.current.editor.setValue(html, 1);
229 | cssEditorRef.current.editor.setValue(css, 1);
230 | jsEditorRef.current.editor.setValue(js, 1);
231 | updateIframe();
232 | }
233 | }).catch(error => {
234 | console.warn('Contents not found!');
235 | history.push("/notfound")
236 | })
237 | }
238 | else {
239 | firebase.database().ref("WebDev/" + userID).once('value').then(snap => {
240 | if (!snap.exists())
241 | history.push("/notfound")
242 | })
243 | firebase.database().ref("WebDev/" + userID + "/" + projectID).once("value").then(snap => {
244 | if (snap.key === projectID && snap.exists()) {
245 | html = snap.val().html;
246 | css = snap.val().css;
247 | js = snap.val().js;
248 | setLoadCode(!loadCode);
249 | console.log(html, css, js);
250 | codeName.current.disabled = true;
251 | codeName.current.value = snap.val().name;
252 | setLetEdit(true);
253 | htmlEditorRef.current.editor.setValue(html, 1);
254 | cssEditorRef.current.editor.setValue(css, 1);
255 | jsEditorRef.current.editor.setValue(js, 1);
256 | var old_element = document.getElementsByClassName(classes.iframe)[0];
257 | var new_element = old_element.cloneNode(true);
258 | old_element.parentNode.replaceChild(new_element, old_element);
259 | let output = new_element.contentWindow.document;
260 | let htmlDoc = "" + html + "";
261 | try {
262 | // output.contentWindow.location.reload(true);
263 | output.open();
264 | output.write(htmlDoc);
265 | output.close();
266 | } catch (e) {
267 | //Fuck You error
268 | // console.log(e)
269 | }
270 | } else history.push("/notfound");
271 | }).catch(error => {
272 | console.warn('Contents not found!', error);
273 | })
274 | }
275 | }
276 | else
277 | history.push("/auth");
278 | });
279 | if (window.innerWidth >= 1024) {
280 | let widthOfIframe = Math.floor(((477 - 20) / window.innerWidth) * 100);
281 | document.getElementsByClassName(classes.iframe)[0].style.width = widthOfIframe + "%";
282 | editors.current.style.width = (100 - widthOfIframe) + "%";
283 | htmlEditorRef.current.editor.resize();
284 | cssEditorRef.current.editor.resize();
285 | jsEditorRef.current.editor.resize();
286 | }
287 | }, []);
288 |
289 | // window.addEventListener('resize', e => {
290 | // console.log("Window Resized!")
291 | // if (window.innerWidth > 1000)
292 | // window.location.reload(true);
293 | // });
294 |
295 | function openTab(tabName) {
296 | htmlTabRef.current.classList.remove("selected");
297 | cssTabRef.current.classList.remove("selected");
298 | jsTabRef.current.classList.remove("selected");
299 | htmlEditorRef.current.refEditor.style.display = "none";
300 | cssEditorRef.current.refEditor.style.display = "none";
301 | jsEditorRef.current.refEditor.style.display = "none";
302 | switch (tabName) {
303 | case 'html':
304 | htmlTabRef.current.classList.add("selected");
305 | htmlEditorRef.current.refEditor.style.display = "block";
306 | break;
307 | case 'css':
308 | cssTabRef.current.classList.add("selected");
309 | cssEditorRef.current.refEditor.style.display = "block";
310 | break;
311 | case 'js':
312 | jsTabRef.current.classList.add("selected");
313 | jsEditorRef.current.refEditor.style.display = "block";
314 | break;
315 | default: console.log("Shit")
316 | }
317 | }
318 |
319 | function updateIframe() {
320 | try {
321 | firebaseRef.current.child("html").set(html)
322 | firebaseRef.current.child("css").set(css)
323 | firebaseRef.current.child("js").set(js)
324 | var old_element = document.getElementsByClassName(classes.iframe)[0];
325 | var new_element = old_element.cloneNode(true);
326 | old_element.parentNode.replaceChild(new_element, old_element);
327 | let output = new_element.contentWindow.document;
328 | let htmlDoc = "" + html + "";
329 | try {
330 | // output.contentWindow.location.reload(true);
331 | output.open();
332 | output.write(htmlDoc);
333 | output.close();
334 | } catch (e) {
335 | //Fuck You error
336 | console.log(e)
337 | }
338 | } catch (e) {
339 | //Fuck you error
340 | }
341 | }
342 | function dragToShowIframe(e) {
343 | let mousePos = window.innerWidth - (e.clientX + 30);
344 | if (mouseDown && e.clientX > 40 && e.clientX < window.innerWidth - 40) {
345 | dragToIframeRef.current.style.right = mousePos + "px";
346 | let widthOfIframe = Math.floor(((mousePos - 20) / window.innerWidth) * 100);
347 | document.getElementsByClassName(classes.iframe)[0].style.width = widthOfIframe + "%";
348 | editors.current.style.width = (100 - widthOfIframe) + "%";
349 | htmlEditorRef.current.editor.resize();
350 | cssEditorRef.current.editor.resize();
351 | jsEditorRef.current.editor.resize();
352 | }
353 | }
354 |
355 | function htmlChanged(e) {
356 | html = e;
357 | updateIframe();
358 | }
359 | function cssChanged(e) {
360 | css = e;
361 | updateIframe();
362 | }
363 | function jsChanged(e) {
364 | js = e;
365 | updateIframe();
366 | }
367 |
368 | let iframeOpen = false;
369 | function openOutput() {
370 | if (window.innerWidth <= 1024) {
371 | console.log("Open Output")
372 | iframeOpen = !iframeOpen;
373 | document.getElementsByClassName(classes.iframe)[0].style.width = iframeOpen ? "100%" : "0%";
374 |
375 | setTimeout(() => {
376 | htmlEditorRef.current.editor.resize();
377 | cssEditorRef.current.editor.resize();
378 | jsEditorRef.current.editor.resize();
379 | }, 1000)
380 | }
381 | else {
382 | console.log("Do nothing")
383 | }
384 | }
385 |
386 | function changeCodeName(e) {
387 | firebaseRef.current.child("name").set(e.target.value);
388 | }
389 |
390 |
391 |
392 | function Speeddialreturn() {
393 | const [openSnackbar, setOpenSnackBar] = React.useState(false);
394 | const [snackBarText, setSnackBarText] = React.useState("Link Copied");
395 | const handleClose = (event, reason) => {
396 | if (reason === 'clickaway') {
397 | return;
398 | }
399 |
400 | setOpenSnackBar(false);
401 | };
402 |
403 | const [open, setOpen] = React.useState(false);
404 | function copyLink(e) {
405 | console.log("Copy Link")
406 | const copyTxt = document.createElement("input");
407 | copyTxt.value = "https://codersweb.netlify.app/" + e + "/" + userID + "/" + projectID;
408 | document.body.parentNode.appendChild(copyTxt);
409 | copyTxt.select();
410 | document.execCommand("copy")
411 | document.body.parentNode.removeChild(copyTxt);
412 | setSnackBarText(e.substring(0, 1).toUpperCase() + e.substring(1) + " Link Copied!")
413 | setOpenSnackBar(true);
414 | }
415 |
416 | function shareLink() {
417 | if (navigator.share) {
418 | navigator
419 | .share({
420 | title: codeName.current.value + " - Xper",
421 | url: "https://codersweb.netlify.app/edit/" + userID + "/" + projectID
422 | })
423 | .then(() => {
424 | console.log("Thanks for sharing!");
425 | })
426 | .catch(console.error);
427 | } else {
428 | console.log("support na re");
429 | copyLink("edit")
430 | }
431 | }
432 |
433 | const actions = [
434 | { icon: { history.push('/') }} />, name: 'Home' },
435 | { icon: { window.open(("/deploy/" + userID + "/" + projectID + "/"), "_blank") }} />, name: 'Open Deployed Site' },
436 | { icon: { copyLink("deploy") }} />, name: 'Copy Deploy Link' },
437 | { icon: , name: 'Share Code Link' },
438 | { icon: , name: 'Save' },
439 | ];
440 | return (
441 |
442 |
443 |
444 | {snackBarText}
445 |
446 |
447 |
}
451 | onClose={() => { setOpen(false) }}
452 | onOpen={() => { setOpen(true) }}
453 | open={open}
454 | direction={"down"}
455 | onClick={() => {/*do nothing*/ }}
456 | >
457 | {
458 | actions.map((action) => (
459 |
464 | ))
465 | }
466 |
467 |
468 | )
469 | }
470 |
471 | function Loader() {
472 | const [openLoader, setOpenLoader] = React.useState(true);
473 |
474 | React.useEffect(() => {
475 | firebase.database().ref("WebDev/" + userID + "/" + projectID).once("value").then(snap => {
476 | setOpenLoader(false);
477 | });
478 | }, [])
479 |
480 | return (
481 |
482 |
483 |
484 | )
485 | }
486 | return (
487 | { mouseDown = false; }} onMouseMove={dragToShowIframe}>
488 |
489 |
490 |
Xper
491 |
492 |
493 |
494 |
495 |
{ openTab('html') }}>HTML
496 |
{ openTab('css') }}>CSS
497 |
{ openTab('js') }}>JS
498 |
499 |
570 |
{ mouseDown = true; }} ref={dragToIframeRef}>
571 |
574 |
575 |
576 | )
577 | }
578 |
579 | export default Editorpage;
580 |
--------------------------------------------------------------------------------
/src/components/notfound.svg:
--------------------------------------------------------------------------------
1 |
64 |
--------------------------------------------------------------------------------