This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const copyToClipboard = str => { | |
const el = document.createElement('textarea'); // Create a <textarea> element | |
el.value = str; // Set its value to the string that you want copied | |
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof | |
el.style.position = 'absolute'; | |
el.style.left = '-9999px'; // Move outside the screen to make it invisible | |
document.body.appendChild(el); // Append the <textarea> element to the HTML document | |
const selected = | |
document.getSelection().rangeCount > 0 // Check if there is any content selected previously | |
? document.getSelection().getRangeAt(0) // Store selection if found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const copyToClipboard = str => { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style.position = 'absolute'; | |
el.style.left = '-9999px'; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const copyToClipboard = str => { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"lang": "en", | |
"title": "Index", | |
"stylesheets": ["./css/style.css"], | |
"scripts": ["./js/main.js"], | |
"charset": "utf-8", | |
"description": "This is a page", | |
"keywords": "page, sample", | |
"author": "None", | |
"favicon": "./images/favicon.png", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'code': '<div class="row">\r\n' | |
' <div class="card">\r\n' | |
' <div class="section">\r\n' | |
' <h3>Card Title</h3>\r\n' | |
' <p>Card content...</p>\r\n' | |
' </div>\r\n' | |
' </div>\r\n' | |
' <div class="card">\r\n' | |
' <div class="section">\r\n' | |
' <h3>Card Title</h3>\r\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="search" className="searchBox" onChange={event => { | |
if(event.currentTarget.value) this.searchPost(event.currentTarget.value); | |
else this.viewAll(); | |
}}/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const posts = (state = {data: [], selected: []}, action) => { | |
let posts = {data: [], selected: []}; | |
switch(action.type){ | |
case VIEW_ALL: | |
Object.assign(posts.data, state.data); | |
posts.selected = []; | |
return posts; | |
case SEARCH_POST: | |
Object.assign(posts.data, state.data); | |
let search = new JsSearch.Search('date-added'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import necessary packages... | |
class App extends Component { | |
// Constructor and methods... | |
// Mounting the component causes an action | |
componentDidMount(){ | |
fetch("https://jsonbin.io/b/59f721644ef213575c9f6531") | |
.then( response => response.json()) | |
.then( data => { | |
let posts = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let posts = '', postLinks = ''; | |
if(this.state.posts && this.state.posts.data){ | |
posts = this.state.posts.data.map(post => {return <Post post={post} key={"post_"+post.id}/>;}); | |
postLinks = this.state.posts.data.map(post => {return <a href={"#"+post.id} key={"post_link_"+post.id} className="button">{post.title}</a>}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentDidMount(){ | |
fetch("https://jsonbin.io/b/59f721644ef213575c9f6531") | |
.then( response => response.json()) | |
.then( data => { this.setState({posts: data})}); | |
} |
NewerOlder