Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
API Spark PI Challenge
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
});
<div class="pi-page">
<aside>
Page #<br/>
{{page.id}}
</aside>
<article>
{{page.content}}
</article>
</div>
import Ember from 'ember';
export default Ember.Route.extend({
model() {
let check;
let pages = [];
for (var i = 0; i < 1000; i++) {
$.get(`https://apidigits.apispark.net/v1/digits/${i}`).then(function(data) {
check = data.content.match(/12345/);
if (check != null) {
pages.pushObject({ "id": data.id, "content": data.content });
}
});
}
return pages;
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.pi-page:after {
content: "";
display: table;
clear: both;
}
.pi-digits {
word-wrap: break-word;
}
.pi-page aside {
float: left;
width: 15%;
margin-right: 5%;
}
.pi-page article {
float: left;
width: 80%;
}
<div class="pi-digits">
{{#each model as |page|}}
{{pi-page page=page}}
{{/each}}
</div>
{{yield}}
{
"version": "0.6.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.1/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.1/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment