import React from 'react'
import {
    Card,
    CardHeader,
    CardContent
} from '@material-ui/core'

class CloudCache extends React.Component {
    constructor() {
        super()
        this.state = {

        }
    }

    copyToClipboard(element) {
        const range = document.createRange();
        const selection = window.getSelection();

        // Clear selection from any previous data.
        selection.removeAllRanges();

        // Make the range select the entire content of the contentHolder paragraph.
        range.selectNodeContents(document.querySelector(element));

        // Add that range to the selection.
        selection.addRange(range);

        // Copy the selection to clipboard.
        document.execCommand('copy');

        // Clear selection if you want to.
        selection.removeAllRanges();
    }


    handleExpandChange = (expanded) => {
        this.setState({ expanded: expanded });
    };

    handleToggle = (event, toggle) => {
        this.setState({ expanded: toggle });
    };

    handleExpand = () => {
        this.setState({ expanded: true });
    };

    handleReduce = () => {
        this.setState({ expanded: false });
    };

    render() {
        return (
            <div>
                <div className="method">
                    <a id="CloudCache-constructor" name="CloudObject-constructor" className="section-anchor" />
                    <Card style={{marginBottom:16}}>
                        <CardHeader
                            title="Initialise a Cloud Cache"
                            style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}}
                        />
                        <CardContent>
                            <div className="method-example" id="api-summary-example">

                                <span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_cache")}>

                                </span>
                                <pre id="pre_cache">
                                    <span className="code-red">{`var`}</span>{` cache = `}<span className="code-red">{`new`}</span>{` CB.CloudCache(`}<span className="code-yellow">{`"cacheName"`}</span>{`);`}
                                </pre>
                            </div>{/* method-example */}
                        </CardContent>
                        <CardHeader title="CloudCache( cacheName )" subheaderTypographyProps={{ style: { fontSize: '12px !important' }  }} subheader="Instantiate a Cloud Cache" />
                        <CardContent
                       >
                            <div className="method-description">
                                <div className="method-list">
                                    <h6>Argument</h6>
                                    <dl className="argument-list">
                                        <dt>cacheName</dt>
                                        <dd className>string <span>The name of the cache you want to initialise.</span></dd>
                                        <div className="clearfix" />
                                    </dl>
                                    <h6>Returns</h6>
                                    <p>A CloudCache Object containing details of Cache being created.</p>
                                </div>
                            </div>
                        </CardContent>

                    </Card>
                    <a id="CloudCache-clear" name="CloudObject-constructor" className="section-anchor" />
                    <Card style={{marginBottom:16}}>
                        <CardHeader
                            title="Clear a Cloud Cache"
                            style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}}
                        />
                        <CardContent>
                            <div className="method-example" id="api-summary-example">

                                <span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_cclear")}>

                                </span>
                                <pre id="pre_cclear">
                                    <span className="code-red">{`var`}</span>{` cache = `}<span className="code-red">{`new`}</span>{` CB.CloudCache(`}<span className="code-yellow">{`"cacheName"`}</span>{`); 
cache.clear( {
    success: `}<span className="code-red">{`function`}</span>{`(obj) {
        //clears the cache
    },
    error: `}<span className="code-red">{`function`}</span>{`(err) {
        //error in clearing cache
    }});`
                                    }
                                </pre>
                            </div>{/* method-example */}
                        </CardContent>
                        <CardHeader title="CloudCache.clear( callback )" subheaderTypographyProps={{ style: { fontSize: '12px !important' }  }} subheader="Clears an existing Cloud Cache" />
                        <CardContent
                       >
                            <div className="method-description">
                                <div className="method-list">
                                    <h6>Argument</h6>
                                    <dl className="argument-list">
                                        <dt>callback</dt>
                                        <dd className>object <span>The callback actions you want to perform.</span></dd>
                                        <div className="clearfix" />
                                    </dl>
                                    <h6>Returns</h6>
                                    <p>void</p>
                                </div>
                            </div>
                        </CardContent>

                    </Card>
                    <a id="CloudCache-delete" name="CloudObject-constructor" className="section-anchor" />
                    <Card style={{marginBottom:16}}>
                        <CardHeader
                            title="Delete a Cloud Cache"
                            style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}}
                        />
                        <CardContent>
                            <div className="method-example" id="api-summary-example">

                                <span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_cdel")}>

                                </span>
                                <pre id="pre_cdel">
                                    <span className="code-red">{`var`}</span>{` cache = `}<span className="code-red">{`new`}</span>{` CB.CloudCache(`}<span className="code-yellow">{`"cacheName"`}</span>{`);
cache.delete( {
    success: `}<span className="code-red">{`function`}</span>{`(obj) {
        //deletes the cache
    },
    error: `}<span className="code-red">{`function`}</span>{`(err) {
        //error in deleting cache
    }});`
                                    }
                                </pre>
                            </div>{/* method-example */}
                        </CardContent>
                        <CardHeader title="CloudCache.delete( callback )" subheaderTypographyProps={{ style: { fontSize: '12px !important' }  }} subheader="Deletes a Cloud Cache" />
                        <CardContent
                       >
                            <div className="method-description">
                                <div className="method-list">
                                    <h6>Argument</h6>
                                    <dl className="argument-list">
                                        <dt>callback</dt>
                                        <dd className>object <span>The callback actions you want to perform.</span></dd>
                                        <div className="clearfix" />
                                    </dl>
                                    <h6>Returns</h6>
                                    <p>void</p>
                                </div>
                            </div>
                        </CardContent>

                    </Card>
                </div>
            </div>
        );
    }
}

export default CloudCache;