Skip to content
Open
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
17 changes: 13 additions & 4 deletions SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

Use this md to tell us the bugs you solved and also explain the approach you had while solving them. Make them bulleted like

1. Accessibility - **Something here**
2. Aesthetics - **Something here**
3. Testing - **Something here**
4. Technicality Improvements - **Something here**
1. Accessibility -
* on clicking menuicon the slide-menu will toggle its position(process:added eventlistener and toggled the class)
2. Aesthetics -
* aligned the feed to center
* aligned the silde-menu so that it does not collapse with header
* fixed the slide-menu to left side
3. Testing -
* Added the test to check if all urls are defined(process: by expecting them not to be undefined)
* Added the test to check if all names are defined(process: by expecting them not to be undefined)
* Added the test to check if nav is hidden by default(process:Selected the transform property and split the matrix and checked if the value is less than zero)
* Added the test to check intial entries are not empty(process: called the loadfeed function and checked the status to be equal to success)
4. Technicality Improvements -
* on selecting one of the items of feed-list corresponding feeds will be displayed(process:on selecting called the loadfeed function and removed the previous feed and appended the corresponding feed)
76 changes: 63 additions & 13 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
var allFeeds = [{
id:0,
name: 'CSS Tricks',
url: 'http://feeds.feedburner.com/CssTricks'
}, {
id:1,
name: 'HTML5 Rocks',
url: 'http://feeds.feedburner.com/html5rocks'
}, {
id:2,
name: 'Linear Digressions',
url: 'http://feeds.feedburner.com/udacity-linear-digressions'
}];

function init() {
loadFeed(0);
$('body').removeClass('menu-hidden');
feeditem = Handlebars.compile($('.tpl-feed-item').html());
loadFeed(0,(result) => {
var allfeed = $('.feed');
allfeed[0].innerHTML="";
if(result.status==="ok")
{
result.items.forEach((item) => {
allfeed.append(feeditem(item));
});
}
});
}

/* This function performs everything necessary to load a
Expand All @@ -20,22 +31,24 @@ function init() {
* which will be called after everything has run successfully.
*/
function loadFeed(id, cb) {

// console.log(id);
$.ajax({
type: "GET",
url: 'https://api.rss2json.com/v1/api.json',
data: {
rss_url: 'http://feeds.feedburner.com/CssTricks'
rss_url: allFeeds[id].url
},
success: function (result, status) {
if (cb) {
cb( /*something*/ );
console.log(status);
cb(result,status);
}
},
error: function (result, status, err) {
//run only the callback without attempting to parse result due to error
if (cb) {
cb();
// console.log(status);
cb(result,status);
}
},
dataType: "json"
Expand All @@ -52,15 +65,52 @@ $(function () {
allFeeds.forEach(function (feed) {
feedList.append(feedItemTemplate(feed));
});
var click0 = $(`a[data-id="0"]`);
click0.on('click',function (){
loadFeed(0,(result) => {
var allfeed = $('.feed');
allfeed[0].innerHTML="";
result.items.forEach((item) => {
allfeed.append(feeditem(item));
});
});
})
var click1 = $(`a[data-id="1"]`);
click1.on('click',function (){
loadFeed(1,(result) => {
var allfeed = $('.feed');
allfeed[0].innerHTML="";
result.items.forEach((item) => {
allfeed.append(feeditem(item));
});
});
})
var click2 = $(`a[data-id="2"]`);
click2.on('click',function (){
loadFeed(2,(result) => {
var allfeed = $('.feed');
allfeed[0].innerHTML="";
result.items.forEach((item) => {
// console.log(item);
allfeed.append(feeditem(item));
});
});
})

feedList.on('click', function () {
var item = $(this);
$('body').addClass( /*A class here*/ );
loadFeed(item.data('id'));
return false;
});
// feedList.on('click', function () {
// var item = $(this);
// $('body').addClass( /*A class here*/ );
// loadFeed(item.data('id'));
// return false;
// });

/* When the menu icon is clicked on, we need to toggle a class
* on the body to perform the hiding/showing of our menu.
*/

var menu = document.querySelector('.menuiconimg');
menu.addEventListener('click',(e) => {
var body = document.querySelector('body');
body.classList.toggle('menu-hidden');
})
}());
35 changes: 28 additions & 7 deletions feedreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ $(function () {
it('are defined', function () {
let expect = chai.expect;
expect(allFeeds).to.not.be.undefined;
expect(allFeeds.length).to.be.above(0);
expect(allFeeds.length).to.be.equal(3);
});


// This test checks whether all the url field are defined and are not empty.
it('should have defined Urls', function () {
// Test here

let expect = chai.expect;
allFeeds.forEach((feed) => {
expect(feed.url).to.not.be.undefined;
});
});

// This test check whether all the feed names are defined and are not empty.
it('should have defined names', function () {
// Test here

let expect = chai.expect;
allFeeds.forEach((feed) => {
expect(feed.name).to.not.be.undefined;
});
});
});

Expand All @@ -48,29 +54,44 @@ $(function () {
// Test to check node hidden by default.
it('should be hidden by default', () => {
// test here
let expect = chai.expect;
var css = $('.slide-menu').css('transform');
var values = css.match(/-?[\d\.]+/g);
for(var i=0;i<values.length;i++)
{
values[i]=Number(values[i]);
// console.log(values[i]);
}
expect(values[4]).to.be.below(0);
});

// A test that ensures the menu changes visibility when the menu icon is clicked.
// This test have two expectations: does the menu display itself when clicked, and does it hide when clicked again?
it('should change visibility when the menu icon is clicked', (done) => {
let expect=chai.expect;
done();
});

})

describe('Initial Entries', () => {
let feedContainer, id;

// Test to check the entries are not empty.
it(`should not be empty for feeds`, (done) => {
done();
})
it(`should not be empty for feed0`, (done) => {
let expect=chai.expect;
loadFeed(0,(result,status) => {
expect(status).to.be.equal("success");
return done();
});
});
})


describe('New Feed Selection', () => {

// A test that ensures when a new feed is loaded by the loadFeed function that the content actually changes.
it(`should change content for feeds`, (done) => {

done();
})
})
Expand Down
4 changes: 2 additions & 2 deletions icomoon.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

/*
.icon-list:before {
content: "\e600";
}
} */
34 changes: 24 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="icomoon.css">
<link rel="stylesheet" href="style.css" content-type="text/css">
<!--Only for testing <link href="https://unpkg.com/mocha@4.0.1/mocha.css" rel="stylesheet" /> -->
<link href="https://unpkg.com/mocha@4.0.1/mocha.css" rel="stylesheet" />

</head>
<body class="menu-hidden">
<div id='mocha'></div>
<div class="header">
<a href="#" class="menu-icon-link">
<i class="icon-list"></i>
</a>
<div class="menuicon">
<!-- <a href="#" class="menu-icon-link"> -->
<!-- <i class="icon-list"></i> -->
<img src="menuicon1.svg" alt="menuicon" class="menuiconimg">
<!-- </a> -->
</div>
<div class="text-center">
<h1 class="header-title" aria-describedby="The heading of the present feed">Feeds</h1>
</div>
Expand All @@ -24,9 +26,12 @@ <h1 class="header-title" aria-describedby="The heading of the present feed">Feed
<div class="slide-menu">
<ul class="feed-list"></ul>
</div>

<!-- <div class="feed0" data-id="0" id="0"></div>
<div class="feed1" data-id="1" id="1"></div>
<div class="feed2" data-id="2" id="2"></div> -->
<div id='mocha'></div>
<div class="feed">
<a class="entry-link" href="https://css-tricks.com/the-magic-of-react-based-multi-step-forms/">
<a class="entry-link" href="https://css-tricks.com/the-magic-of-react-based-multi-step-forms/">
<article class="entry">
<h2>The Magic of React-Based Multi-Step Forms</h2>
<p>Nathan Sebhastian</p>
Expand Down Expand Up @@ -103,17 +108,26 @@ <h2>A Funny Thing Happened on the Way to the JavaScript</h2>
</li>
</script>

<script class="tpl-feed-item" type="text/x-handlebars-template">
<a class="entry-link" href="{{link}}">
<article class="entry">
<h2>{{title}}</h2>
<p>{{author}}</p>
</article>
</a>
</script>

<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
<script src="http://cdn.jsdelivr.net/handlebarsjs/2.0.0/handlebars.min.js"></script>
<script src="app.js"></script>
<!-- Only for testing <script src="https://unpkg.com/chai@4.1.2/chai.js"></script>
<script src="https://unpkg.com/chai@4.1.2/chai.js"></script>
<script src="https://unpkg.com/mocha@4.0.1/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="feedreader.js"></script>
<script>
mocha.checkLeaks();
mocha.setup({ignoreLeaks: true});
mocha.run();
</script> -->
</script>

</body>
</html>
Loading