Private
Public Access
1
0

add google analytics and facebook scripts && improve url share method w/ fb && enforce https in prod

This commit is contained in:
2016-12-11 15:10:25 +01:00
parent c0d75e43f3
commit 875d2d71db
11 changed files with 113 additions and 34 deletions

View File

@@ -160,6 +160,27 @@ class MineSeeker extends React.Component {
}
}
/**
* @see https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus
* @see https://developers.facebook.com/docs/sharing/reference/send-dialog
* @see https://developers.facebook.com/docs/plugins/share-button/
*/
clickFBShare() {
let display = 'popup';
FB.getLoginStatus(function (response) {
display = response.status === 'connected'
? 'dialog'
: 'popup';
});
FB.ui({
method: 'send',
display: display,
link: window.location.href + '/' + this.state.gameAssoc,
});
}
wInit(session, data, gridClient) {
this.setState({session: session});
@@ -184,14 +205,17 @@ class MineSeeker extends React.Component {
overlaySubTitle: this.state.gameAssoc
?
<div>
<h3>Share this unique link w/ your opponent</h3>
<div className="clippy">
<input id="foo"
defaultValue={window.location.href + '/' + this.state.gameAssoc}/>
<button className="btn">
<img src="/bundles/mineseeker/images/clippy.svg" alt="Copy to clipboard"/>
</button>
</div>
{this.state.env !== 'dev' &&
<a onClick={this.clickFBShare.bind(this)}>Share in Facebook message</a>
}
{this.state.env === 'dev' &&
<a href={"/play/" + this.state.gameAssoc} target="_blank">Play w/ me!</a>
}
</div>
: '',
renderGridFields: this.state.gameAssoc
@@ -349,7 +373,7 @@ class MineSeeker extends React.Component {
/** After rendering */
componentDidMount() {
this.connectWithWebsocket();
}
/**