code is duplicated to meet various conditions
$begingroup$
The use case that this code tries to meet is
There will be an interview session where the video calling is done between two participants, interviewer(ER) and interviewee(EE)
For this i need to have a video element and reference that video element using ref. For ER its a localStreamRef
and for EE its remoteStreamRef
. To use ref, i need to have that video element already because attaching the stream in the video element is done inside componentDidMount
by listening to the sockets from there.
The conditions that i have to fulfill is, if the event is
- event1 - Show ER and EE screen
- event2 - Only EE screen
- event3 - Only ER screen
- event4 - ER, EE and Screen Recording screen(this is also a video
element) - event5 - ER and SS
- event6 - EE and SS
- event7 - SS only
To achieve this i did the code following way but its too much repeated
import React from "react";
import isElectron from "is-electron";
import styled from "styled-components";
const Wrapper = styled.div``;
const PowerPoint = styled.div`
color: #fff;
text-align: center;
background: #2d3561;
position: relative;
& > video {
position: absolute;
top: 0;
left: 0;
width: 100%;
object-fit: cover;
}
`;
const VideoPanel = styled.video`
max-width: 100%;
width: 400px;
height: auto;
transition: all 0.3s ease;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
${props =>
props.left &&
`
position: absolute;
bottom: 50px;
left: 50px;
z-index: 1;
transition: all 1s ease;
width: 400px;
`};
${props =>
props.right &&
`
position: absolute;
bottom: 50px;
right: 50px;
z-index: 1;
transition: all 1s ease;
`}
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
width: 100%;
height: 100%;
}
`;
const VideoPanels = styled.div`
width: 100%;
height: auto;
position: absolute;
top: 80%;
left: 0;
width: 100%;
transform: translateY(-50%);
transition: all 0.3s ease;
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
${VideoPanel} {
width: 100%;
height: 100%;
}
}
`;
const user = JSON.parse(localStorage.getItem("user"));
const Studio = ({ interviewer, interviewee, ...props }) => {
const [hotkeys, setHotkeys] = React.useState("event4");
React.useEffect(() => {
return () => {
window.ipcRenderer.removeAllListeners("eventListened");
};
}, );
React.useEffect(
() => {
console.log("user", user);
console.log(
"remoteJoined",
props.isRemoteJoined,
user !== null && user.data.isInterviewer
);
if (
isElectron() &&
props.isRemoteJoined &&
(user !== null && user.data.isInterviewer)
) {
window.ipcRenderer.on("eventListened", (event, hotkeys) => {
setHotkeys(hotkeys);
});
}
},
[props.isRemoteJoined]
);
const renderVideo = () => {
switch (hotkeys) {
case "event1":
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
left
/>
<VideoPanel
ref={interviewee}
autoPlay
muted="muted"
id="remote-media"
className="fullscreen"
/>
</React.Fragment>
);
case "event2": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
style={{ display: "none" }}
/>
<VideoPanel
ref={interviewee}
autoPlay
className="fullscreen"
id="remote-media interviewee-for-now"
/>
</React.Fragment>
);
}
case "event3": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
className="fullscreen"
/>
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event4": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" left />
<VideoPanel ref={interviewee} autoPlay id="remote-media" right />
</React.Fragment>
);
}
case "event5": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event6": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
style={{ display: "none" }}
/>
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</React.Fragment>
);
}
default:
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanels
className={
hotkeys === "event2" || hotkeys === "event3" ? "fullscreen" : ""
}
>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</VideoPanels>
</React.Fragment>
);
}
};
console.log("hotkeys", hotkeys !== "event1");
return (
<React.Fragment>
<Wrapper>{renderVideo()}</Wrapper>
</React.Fragment>
);
};
export default Studio;
My question is, in the renderVideo
, the code are too much duplicated due to many conditions. The styling to show the screen is done in that way. How can this code be refactored to make it clean and remove code duplication?
javascript react.js
$endgroup$
add a comment |
$begingroup$
The use case that this code tries to meet is
There will be an interview session where the video calling is done between two participants, interviewer(ER) and interviewee(EE)
For this i need to have a video element and reference that video element using ref. For ER its a localStreamRef
and for EE its remoteStreamRef
. To use ref, i need to have that video element already because attaching the stream in the video element is done inside componentDidMount
by listening to the sockets from there.
The conditions that i have to fulfill is, if the event is
- event1 - Show ER and EE screen
- event2 - Only EE screen
- event3 - Only ER screen
- event4 - ER, EE and Screen Recording screen(this is also a video
element) - event5 - ER and SS
- event6 - EE and SS
- event7 - SS only
To achieve this i did the code following way but its too much repeated
import React from "react";
import isElectron from "is-electron";
import styled from "styled-components";
const Wrapper = styled.div``;
const PowerPoint = styled.div`
color: #fff;
text-align: center;
background: #2d3561;
position: relative;
& > video {
position: absolute;
top: 0;
left: 0;
width: 100%;
object-fit: cover;
}
`;
const VideoPanel = styled.video`
max-width: 100%;
width: 400px;
height: auto;
transition: all 0.3s ease;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
${props =>
props.left &&
`
position: absolute;
bottom: 50px;
left: 50px;
z-index: 1;
transition: all 1s ease;
width: 400px;
`};
${props =>
props.right &&
`
position: absolute;
bottom: 50px;
right: 50px;
z-index: 1;
transition: all 1s ease;
`}
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
width: 100%;
height: 100%;
}
`;
const VideoPanels = styled.div`
width: 100%;
height: auto;
position: absolute;
top: 80%;
left: 0;
width: 100%;
transform: translateY(-50%);
transition: all 0.3s ease;
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
${VideoPanel} {
width: 100%;
height: 100%;
}
}
`;
const user = JSON.parse(localStorage.getItem("user"));
const Studio = ({ interviewer, interviewee, ...props }) => {
const [hotkeys, setHotkeys] = React.useState("event4");
React.useEffect(() => {
return () => {
window.ipcRenderer.removeAllListeners("eventListened");
};
}, );
React.useEffect(
() => {
console.log("user", user);
console.log(
"remoteJoined",
props.isRemoteJoined,
user !== null && user.data.isInterviewer
);
if (
isElectron() &&
props.isRemoteJoined &&
(user !== null && user.data.isInterviewer)
) {
window.ipcRenderer.on("eventListened", (event, hotkeys) => {
setHotkeys(hotkeys);
});
}
},
[props.isRemoteJoined]
);
const renderVideo = () => {
switch (hotkeys) {
case "event1":
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
left
/>
<VideoPanel
ref={interviewee}
autoPlay
muted="muted"
id="remote-media"
className="fullscreen"
/>
</React.Fragment>
);
case "event2": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
style={{ display: "none" }}
/>
<VideoPanel
ref={interviewee}
autoPlay
className="fullscreen"
id="remote-media interviewee-for-now"
/>
</React.Fragment>
);
}
case "event3": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
className="fullscreen"
/>
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event4": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" left />
<VideoPanel ref={interviewee} autoPlay id="remote-media" right />
</React.Fragment>
);
}
case "event5": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event6": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
style={{ display: "none" }}
/>
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</React.Fragment>
);
}
default:
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanels
className={
hotkeys === "event2" || hotkeys === "event3" ? "fullscreen" : ""
}
>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</VideoPanels>
</React.Fragment>
);
}
};
console.log("hotkeys", hotkeys !== "event1");
return (
<React.Fragment>
<Wrapper>{renderVideo()}</Wrapper>
</React.Fragment>
);
};
export default Studio;
My question is, in the renderVideo
, the code are too much duplicated due to many conditions. The styling to show the screen is done in that way. How can this code be refactored to make it clean and remove code duplication?
javascript react.js
$endgroup$
add a comment |
$begingroup$
The use case that this code tries to meet is
There will be an interview session where the video calling is done between two participants, interviewer(ER) and interviewee(EE)
For this i need to have a video element and reference that video element using ref. For ER its a localStreamRef
and for EE its remoteStreamRef
. To use ref, i need to have that video element already because attaching the stream in the video element is done inside componentDidMount
by listening to the sockets from there.
The conditions that i have to fulfill is, if the event is
- event1 - Show ER and EE screen
- event2 - Only EE screen
- event3 - Only ER screen
- event4 - ER, EE and Screen Recording screen(this is also a video
element) - event5 - ER and SS
- event6 - EE and SS
- event7 - SS only
To achieve this i did the code following way but its too much repeated
import React from "react";
import isElectron from "is-electron";
import styled from "styled-components";
const Wrapper = styled.div``;
const PowerPoint = styled.div`
color: #fff;
text-align: center;
background: #2d3561;
position: relative;
& > video {
position: absolute;
top: 0;
left: 0;
width: 100%;
object-fit: cover;
}
`;
const VideoPanel = styled.video`
max-width: 100%;
width: 400px;
height: auto;
transition: all 0.3s ease;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
${props =>
props.left &&
`
position: absolute;
bottom: 50px;
left: 50px;
z-index: 1;
transition: all 1s ease;
width: 400px;
`};
${props =>
props.right &&
`
position: absolute;
bottom: 50px;
right: 50px;
z-index: 1;
transition: all 1s ease;
`}
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
width: 100%;
height: 100%;
}
`;
const VideoPanels = styled.div`
width: 100%;
height: auto;
position: absolute;
top: 80%;
left: 0;
width: 100%;
transform: translateY(-50%);
transition: all 0.3s ease;
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
${VideoPanel} {
width: 100%;
height: 100%;
}
}
`;
const user = JSON.parse(localStorage.getItem("user"));
const Studio = ({ interviewer, interviewee, ...props }) => {
const [hotkeys, setHotkeys] = React.useState("event4");
React.useEffect(() => {
return () => {
window.ipcRenderer.removeAllListeners("eventListened");
};
}, );
React.useEffect(
() => {
console.log("user", user);
console.log(
"remoteJoined",
props.isRemoteJoined,
user !== null && user.data.isInterviewer
);
if (
isElectron() &&
props.isRemoteJoined &&
(user !== null && user.data.isInterviewer)
) {
window.ipcRenderer.on("eventListened", (event, hotkeys) => {
setHotkeys(hotkeys);
});
}
},
[props.isRemoteJoined]
);
const renderVideo = () => {
switch (hotkeys) {
case "event1":
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
left
/>
<VideoPanel
ref={interviewee}
autoPlay
muted="muted"
id="remote-media"
className="fullscreen"
/>
</React.Fragment>
);
case "event2": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
style={{ display: "none" }}
/>
<VideoPanel
ref={interviewee}
autoPlay
className="fullscreen"
id="remote-media interviewee-for-now"
/>
</React.Fragment>
);
}
case "event3": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
className="fullscreen"
/>
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event4": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" left />
<VideoPanel ref={interviewee} autoPlay id="remote-media" right />
</React.Fragment>
);
}
case "event5": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event6": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
style={{ display: "none" }}
/>
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</React.Fragment>
);
}
default:
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanels
className={
hotkeys === "event2" || hotkeys === "event3" ? "fullscreen" : ""
}
>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</VideoPanels>
</React.Fragment>
);
}
};
console.log("hotkeys", hotkeys !== "event1");
return (
<React.Fragment>
<Wrapper>{renderVideo()}</Wrapper>
</React.Fragment>
);
};
export default Studio;
My question is, in the renderVideo
, the code are too much duplicated due to many conditions. The styling to show the screen is done in that way. How can this code be refactored to make it clean and remove code duplication?
javascript react.js
$endgroup$
The use case that this code tries to meet is
There will be an interview session where the video calling is done between two participants, interviewer(ER) and interviewee(EE)
For this i need to have a video element and reference that video element using ref. For ER its a localStreamRef
and for EE its remoteStreamRef
. To use ref, i need to have that video element already because attaching the stream in the video element is done inside componentDidMount
by listening to the sockets from there.
The conditions that i have to fulfill is, if the event is
- event1 - Show ER and EE screen
- event2 - Only EE screen
- event3 - Only ER screen
- event4 - ER, EE and Screen Recording screen(this is also a video
element) - event5 - ER and SS
- event6 - EE and SS
- event7 - SS only
To achieve this i did the code following way but its too much repeated
import React from "react";
import isElectron from "is-electron";
import styled from "styled-components";
const Wrapper = styled.div``;
const PowerPoint = styled.div`
color: #fff;
text-align: center;
background: #2d3561;
position: relative;
& > video {
position: absolute;
top: 0;
left: 0;
width: 100%;
object-fit: cover;
}
`;
const VideoPanel = styled.video`
max-width: 100%;
width: 400px;
height: auto;
transition: all 0.3s ease;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
${props =>
props.left &&
`
position: absolute;
bottom: 50px;
left: 50px;
z-index: 1;
transition: all 1s ease;
width: 400px;
`};
${props =>
props.right &&
`
position: absolute;
bottom: 50px;
right: 50px;
z-index: 1;
transition: all 1s ease;
`}
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
width: 100%;
height: 100%;
}
`;
const VideoPanels = styled.div`
width: 100%;
height: auto;
position: absolute;
top: 80%;
left: 0;
width: 100%;
transform: translateY(-50%);
transition: all 0.3s ease;
&.fullscreen {
position: absolute;
top: 0;
left: 0;
transform: translateY(0);
${VideoPanel} {
width: 100%;
height: 100%;
}
}
`;
const user = JSON.parse(localStorage.getItem("user"));
const Studio = ({ interviewer, interviewee, ...props }) => {
const [hotkeys, setHotkeys] = React.useState("event4");
React.useEffect(() => {
return () => {
window.ipcRenderer.removeAllListeners("eventListened");
};
}, );
React.useEffect(
() => {
console.log("user", user);
console.log(
"remoteJoined",
props.isRemoteJoined,
user !== null && user.data.isInterviewer
);
if (
isElectron() &&
props.isRemoteJoined &&
(user !== null && user.data.isInterviewer)
) {
window.ipcRenderer.on("eventListened", (event, hotkeys) => {
setHotkeys(hotkeys);
});
}
},
[props.isRemoteJoined]
);
const renderVideo = () => {
switch (hotkeys) {
case "event1":
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
left
/>
<VideoPanel
ref={interviewee}
autoPlay
muted="muted"
id="remote-media"
className="fullscreen"
/>
</React.Fragment>
);
case "event2": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
id="local-media"
style={{ display: "none" }}
/>
<VideoPanel
ref={interviewee}
autoPlay
className="fullscreen"
id="remote-media interviewee-for-now"
/>
</React.Fragment>
);
}
case "event3": {
return (
<React.Fragment>
<PowerPoint style={{ display: "none" }}>
<video autoPlay id="screenshare" style={{ display: "none" }} />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
className="fullscreen"
/>
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event4": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" left />
<VideoPanel ref={interviewee} autoPlay id="remote-media" right />
</React.Fragment>
);
}
case "event5": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel
ref={interviewee}
autoPlay
id="remote-media"
style={{ display: "none" }}
/>
</React.Fragment>
);
}
case "event6": {
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanel
ref={interviewer}
autoPlay
muted="muted"
style={{ display: "none" }}
/>
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</React.Fragment>
);
}
default:
return (
<React.Fragment>
<PowerPoint>
<video autoPlay id="screenshare" />
</PowerPoint>
<VideoPanels
className={
hotkeys === "event2" || hotkeys === "event3" ? "fullscreen" : ""
}
>
<VideoPanel ref={interviewer} autoPlay muted="muted" />
<VideoPanel ref={interviewee} autoPlay id="remote-media" />
</VideoPanels>
</React.Fragment>
);
}
};
console.log("hotkeys", hotkeys !== "event1");
return (
<React.Fragment>
<Wrapper>{renderVideo()}</Wrapper>
</React.Fragment>
);
};
export default Studio;
My question is, in the renderVideo
, the code are too much duplicated due to many conditions. The styling to show the screen is done in that way. How can this code be refactored to make it clean and remove code duplication?
javascript react.js
javascript react.js
asked 11 mins ago
SerenitySerenity
1494
1494
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f215390%2fcode-is-duplicated-to-meet-various-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f215390%2fcode-is-duplicated-to-meet-various-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown