.text {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 16px; /* fallback */
max-height: 32px; /* fallback */
-webkit-line-clamp: 2; /* number of lines to show */
-webkit-box-orient: vertical;
}
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam consectetur
venenatis blandit. Praesent vehicula, libero non pretium vulputate, lacus arcu
facilisis lectus, sed feugiat tellus nulla eu dolor. Nulla porta bibendum
lectus quis euismod. Aliquam volutpat ultricies porttitor. Cras risus nisi,
accumsan vel cursus ut, sollicitudin vitae dolor. Fusce scelerisque eleifend
lectus in bibendum. Suspendisse lacinia egestas felis a volutpat.
</div>
const obj = {
0: { 0: "01.01.2019", 1: 11111.01 },
1: { 0: "02.01.2019", 1: 22222.02 },
2: { 0: "03.01.2019", 1: 33333.03 }
};
const result = Object.keys(obj).map((value, index) => Object.values(obj[value]));
import React from "react";
import { render } from "react-dom";
import "./index.css";
const data = [
{ index: 0, product: "Bread", category: "Food", price: 1 },
{
index: 1,
product: 'F. Dostoyevsky "Crime and Punishment"',
category: "Books",
price: 8
},
{ index: 2, product: "iPhone", category: "Electronics", price: 699 },
{ index: 3, product: "Milk", category: "Food", price: 2 },
{ index: 4, product: "TV", category: "Electronics", price: 1099 }
];
class TableRow extends React.Component {
render() {
return (
<tr>
<td>{this.props.index}</td>
<td>{this.props.product}</td>
<td>{this.props.category}</td>
<td>
{"$"}
{this.props.price}
</td>
</tr>
);
}
}
class Table extends React.Component {
constructor(props) {
super(props);
this.state = {
index: true,
product: true,
category: true,
price: true,
data: props.data
};
}
sortByIndex() {
var getIndex = !this.state.index;
var data = this.state.data;
data.sort((a, b) => {
if (!getIndex) {
return b.index - a.index;
} else {
return a.index - b.index;
}
});
this.setState({ data, index: getIndex });
}
sortByProductName() {
var getProduct = !this.state.product;
var data = this.state.data;
data.sort((a, b) => {
if (!getProduct) {
return b.product > a.product;
} else {
return a.product > b.product;
}
});
this.setState({ data, product: getProduct });
}
sortByCategory() {
var getCategory = !this.state.category;
var data = this.state.data;
data.sort((a, b) => {
if (!getCategory) {
return b.category > a.category;
} else {
return a.category > b.category;
}
});
this.setState({ data, category: getCategory });
}
sortByPrice() {
var getPrice = !this.state.price;
var data = this.state.data;
data.sort((a, b) => {
if (!getPrice) {
return b.price - a.price;
} else {
return a.price - b.price;
}
});
this.setState({ data, price: getPrice });
}
render() {
return (
<table className="table">
<tr>
<th onClick={this.sortByIndex.bind(this)}>
Index <i className={this.state.index ? "fa fa-caret-up" : "fa fa-caret-down"} aria-hidden="true" />{" "}
</th>
<th onClick={this.sortByProductName.bind(this)}>
Product <i className={this.state.product ? "fa fa-caret-up" : "fa fa-caret-down"} aria-hidden="true" />{" "}
</th>
<th onClick={this.sortByCategory.bind(this)}>
Category <i className={this.state.category ? "fa fa-caret-up" : "fa fa-caret-down"} aria-hidden="true" />{" "}
</th>
<th onClick={this.sortByPrice.bind(this)}>
Price <i className={this.state.price ? "fa fa-caret-up" : "fa fa-caret-down"} aria-hidden="true" />{" "}
</th>
</tr>
<tbody>{this.state.data.map((element, i) => <TableRow key={Math.random()} index={element.index} product={element.product} category={element.category} price={element.price} />)}</tbody>
</table>
);
}
}
render(<Table data={data} />, document.getElementById("root"));
if(typeof name !== ‘string) throw ‘Name should be string’
let newBuff = Buffer.from('New String');
console.log(newBuff.toString('utf8')); // New String
var StringDecoder = require('string_decoder').StringDecoder;
var d = new StringDecoder('utf8');
var b = Buffer('abc');
console.log(b); // <Buffer 61 62 63>
console.log(d.write(b)); // abc
server.post("/uploads", (req, res) => {
new formidable.IncomingForm()
.parse(req)
.on("file", function(name, file) {
console.log("Got file:", name);
})
.on("field", function(name, field) {
console.log("Got a field:", name);
})
.on("error", function(err) {
next(err);
})
.on("end", function() {
res.end();
});
});
fetch("https://jsonplaceholder.typicode.com/albums")
.then(response => {
console.log(response.headers.get("Content-Type")); // application/json; charset=utf-8
console.log(response.status); // 200
return response.json();
})
.then(res => {
console.log(res); // iliakan
})
.catch(console.log);
var fs = require("fs"),
request = require("request");
const download = (uri, filename, callback) => {
request.head(uri, (err, res, body) => {
request(uri)
.pipe(fs.createWriteStream(filename))
.on("close", callback);
});
};
download(
"http://fs.moviestape.net/video/1c4ed0ac8b7d5b4de6c5d58e2ea31a63/serials/Narcos/s01/Narcos.S01E01.mp4",
"./downloads/filename.mp4",
() => {
console.log("done");
}
);
item
.then((response) => {
item = response;
success = true;
})
async createItem() {
this.isLoading = true;
try {
let res = await this.$fetch(`/api/items/${this.params.id}/new/`, {
method: "POST",
body: JSON.stringify(this.createItemBody)
});
let json = await res.json();
await this.dispatch("fetchSecondItem", id);
this.items.push(json);
this.dispatch("notification", {
type: "success",
message: "Item was created."
});
this.isLoading = true;
this.resetForm();
} catch (err) {
this.isLoading = false;
console.log(err);
}
}