Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the ui toggling #39

Merged
merged 2 commits into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions examples/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-family: Helvetica Neue, serif;
}

div {
#test-button {
background-color: #0000FF;
width: 200px;
padding: 30px;
Expand All @@ -26,25 +26,24 @@ <h1>Skift: A/B test basic example</h1>
<p>This is an A/B split test</p>
<p>Below there's a div. It will be blue originally, and orange if you're in the A/B test.</p>

<div id="test-button">This is the original div</div>
<button id="test-button">This is the original div</button>
<button onclick="skift.reset();">Reset</button>

<script type="text/javascript">
skift
.create('name-of-a-test')
.setCondition(() => {
return true;
})
.addVariation({
name: 'control', // No setup required.
})
.addVariation({
name: 'name-of-a-variation',
setup() {
document.getElementById('test-button').style.backgroundColor = '#ffcc00';
}
})
.setup();
skift.config({
uiCondition: () => true
});

skift.create('name-of-a-test').setCondition(() => {
return true;
}).addVariation({
name: 'control' // No setup required.
}).addVariation({
name: 'name-of-a-variation',
setup() {
document.getElementById('test-button').style.backgroundColor = '#ffcc00';
}
}).setup();
</script>
</body>
</html>
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ const ui = uiFactory(

$(() => {
if (shouldShowUI()) {
return;
ui.show();
}

setTimeout(() => ui.show(), 1000);
});

export {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function reset(): void {

export function shouldShowUI() {
return (
!_config.globalCondition(userAgentInfo) ||
!_config.uiCondition(userAgentInfo)
_config.globalCondition(userAgentInfo) === true &&
_config.uiCondition(userAgentInfo) === true
);
}