import React from "react";
import ReactDOM from "react-dom";
//import { Link } from "react-router-dom";
//import { MainPage } from "../../pages/main";
import Accordion from "../Acardion";
import ModalForm from "../Modal";
import "./style.css";
class FullCard extends React.Component {
ui = {
name: "Имя",
category: "Категория:",
versions: "Доступные версии",
uses: " USE:",
decription: "Описание:",
site: "Сайт:",
InstallButton: {
text: "Установить"
}
};
styleUseinfo = {
mobile: {
position: "fixed",
bottom: "0px",
left: "0px",
width: "100vw",
background: "#FFF",
borderTop: "1px solid #CDC",
paddingTop: "5px"
},
nomob: { margin: "5px", width: "100vw", display: "inline" }
};
langs = [
{ title: "RU", link: "" },
{ title: "EN", link: "" },
{ title: "DE", link: "" }
];
isMobile() {
return navigator.userAgentData.mobile;
}
IntstallPackageParamms = {
NamePackage: this.props.PackageName.Name,
Version: "",
USE: [],
TargetUses: {}
};
toBack() {
document.getElementById("pTitle").textContent = "Главная";
document.getElementById("containerInfo").style.display = "none";
}
vInstall() {
//document.getElementById("containerInfo").display = "block";
if (this.IntstallPackageParamms.Version !== "") {
ReactDOM.render(
{" "}
{this.ui.category}{" "}
{this.props.PackageName.Name.split("/")[0]}
{this.ui.versions}:
{this.IntstallPackageParamms.Version}
{this.IntstallPackageParamms.USE.map((u, j) => (
{this.chech_targent(u)}
))}
{this.ui.decription}{" "}
{this.props.PackageName.Description}
this.vInstall()}
>
{this.ui.InstallButton.text}
,
document.getElementById("containerInfo")
);
} else {
let statblVer = "";
for (let v = 0; v < this.props.PackageName.version.length; v++) {
if (this.props.PackageName.version[v].split("[U]")[1] === "") {
statblVer = this.props.PackageName.version[v].split("[U]")[0];
}
}
this.IntstallPackageParamms.Version = statblVer;
this.vInstall();
/* ReactDOM.render(
Error
,
document.getElementById("containerInfo")
);*/
}
}
addUse(use) {
if (
document.getElementById(use).style.background === "#0F0" ||
document.getElementById(use).style.background === "rgb(0, 255, 0)"
) {
document.getElementById(use).style.background = "#FFF";
for (let i = 0; i < this.IntstallPackageParamms.USE.length; i++) {
console.log(i);
if (use === this.IntstallPackageParamms.USE[i]) {
this.IntstallPackageParamms.USE.slice(i, i); // delete this.IntstallPackageParamms.USE[i];
}
}
} else {
document.getElementById(use).style.background = "#0F0";
this.IntstallPackageParamms.USE[
this.IntstallPackageParamms.USE.length
] = use;
}
console.log(this.IntstallPackageParamms);
}
addVersion(version) {
console.log(typeof version);
if (this.IntstallPackageParamms.Version !== "") {
if (this.IntstallPackageParamms.Version !== version) {
document.getElementById(
this.IntstallPackageParamms.Version
).style.background = "#FFF";
this.IntstallPackageParamms.Version = version;
document.getElementById(
version
).style.background = document
.getElementById(version)
.style.border.split("2px solid")[1];
} else {
document.getElementById(
this.IntstallPackageParamms.Version
).style.background = "#FFF";
this.IntstallPackageParamms.Version = "";
}
} else {
this.IntstallPackageParamms.Version = version;
document.getElementById(
version
).style.background = document
.getElementById(version)
.style.border.split("2px solid")[1];
console.log(this.IntstallPackageParamms);
}
}
checkVersion(item) {
//console.log(item.split("[U]")[1] === "");
console
.log
//this.props.Ipkgthis.props.PackageName.Name.split("/")[1])
();
if (item.split("[U]")[1] === "") {
return (
this.addVersion(item.split("[U]")[0])}
>
{item.split("[U]")[0]}
);
} else {
return (
this.addVersion(item.split("[M]")[0])}
>
{item.split("[M]")[0]}
);
}
}
chech_targent(t) {
let lt = "";
if (t.split("+").length > 1) {
lt = t.split("+")[1];
} else {
lt = t;
}
let targets = ["single_target_", "modules_", "cpu_flags"];
if (lt.split("single_target_").length > 1) {
this.IntstallPackageParamms.TargetUses[
String(t.split("single_target_")[0]).toUpperCase()
] = String(t.split("single_target_")[1]);
return (
String(t.split("single_target_")[0]).toUpperCase() +
"=\t" +
String(t.split("single_target_")[1])
);
}
if (lt.split("modules_").length > 1) {
this.IntstallPackageParamms.TargetUses[
String(t.split("_modules_")[0]).toUpperCase()
] = String(t.split("_modules_")[1]);
return (
String(t.split("_modules_")[0]).toUpperCase() +
"=\t" +
String(t.split("_modules_")[1])
);
} else if (lt.split("cpu_flags").length > 1) {
this.IntstallPackageParamms.TargetUses["CPU_FLAGS"] = String(
t.split("cpu_flags_")[1]
);
return "CPU_FLAGS=\t" + String(t.split("cpu_flags_")[1]);
} else {
return t;
}
}
VuseInfo(use) {
//console.log(use);
//console.log(this.props.useDes);
//console.log(Object.keys(this.props.uses));
//document.getElementById(uId).style.background = "orange";
if (use.split("+").length > 1) {
use = use.split("+")[1];
}
if (
use in this.props.useDes.LocalUSE ||
use in this.props.useDes.GlobalUSE
//use.split("+")[1] in this.props.useDes.LocalUSE ||
//use.split("+")[1] in this.props.useDes.GlobalUSE
) {
if (use in this.props.useDes.LocalUSE) {
document.getElementById(
"useInfo"
).textContent = this.props.useDes.LocalUSE[use];
console.log(use);
} else if (use in this.props.useDes.GlobalUSE) {
document.getElementById(
"useInfo"
).textContent = this.props.useDes.GlobalUSE[use];
console.log(use);
} /*/else {
document.getElementById("useInfo").textContent = this.props.useDes[
use.split("+")[1]
];
console.log(this.props.useDes[use.split("+")[1]]);
}*/
//document.getElementById(uId).style.background = "orange";
//alert(this.props.useDes[use]);
} else {
document.getElementById("useInfo").textContent = use;
}
//document.getElementById("useInfo").textContent = use;
}
clear_VuseInfo() {
document.getElementById("useInfo").textContent = "";
}
render() {
this.IntstallPackageParamms.USE = [];
//document.getElementById("HomePage").style.display = "block";
return (
// Карточка пакета с возможностью установки
{this.props.PackageName.Name.split("/")[1]}
this.toBack()}
>
{"X"}
{" "}
{this.ui.category}{" "}
{this.props.PackageName.Name.split("/")[0]}
{this.ui.versions}:
{this.props.PackageName.version.map((v) => this.checkVersion(v))}
{this.props.PackageName.USE.map((u, j) => (
this.VuseInfo(this.props.PackageName.USE[j])
}
onMouseOut={() => this.clear_VuseInfo()}
onClick={() => this.addUse(this.props.PackageName.USE[j])}
>
{this.chech_targent(u)}
))}
Оверлеи:
{this.props.PackageName.repo}
{this.ui.decription} {this.props.PackageName.Description}
{this.ui.site}
this.vInstall()}
>
{this.ui.InstallButton.text}
);
}
}
export default FullCard;