These are chat archives for gdg-hudson-valley/android-guide

7th
Feb 2015
John Shea
@johnshea
Feb 07 2015 15:35
On the Udacity page for lesson 1, "Create Project Sunshine", the first item on the navbar is for "Welcome to Developing Android Apps", the code behind it is
<li data-node-key="1643858568" data-ng-repeat="morsel in morsels" class="subway-nav-station ng-scope is-viewed is-current" data-ng-class="getStyleClassesForMorsel(morsel)" style=""> <span> <!-- ngIf: morsel.model=='Exercise' --> <a href="" class="subway-nav-video" data-ng-click="goToMorsel(morsel)">&nbsp; <span class="subway-nav-station-content text-break-word ng-binding">Welcome to Developing Android Apps</span> </a> </span> </li>
Where in the source code can I find "morsels" defined with values and function "goToMorsel"?
Nitya Narasimhan
@nitya
Feb 07 2015 15:43
@johnshea I can come look at this later this evening (am not at my desk right now) but why are you looking at the website code? I am guessing you want to automate capture of the links?? Just a quick scan (and the appearance of -ng- attribute names) indicates they are using AngularJS to write their front end. Angular controllers will contain these function declarations - and those have probably been minified and concatenated into the single file downloaded to client at load time. So chances are that it won’t be easy to “read” that source.
@johnshea this is not hopefully preventing you from actually finishing lesson 2?
John Shea
@johnshea
Feb 07 2015 15:44
@nitya you guessed right :) I can already pull all the subchapters with jquery. Now I was trying to get the video links too.
Nitya Narasimhan
@nitya
Feb 07 2015 15:45
PS. when you see “morsel in morsels” it means angular is running a repeat look looking for incoming data array (morsels) with each item allocated to a single data (morsel). The morsels data is most likely being pulled in dynamically from a call to the Udacity server so chances of you see it cached are slim
John Shea
@johnshea
Feb 07 2015 15:45
@nitya no worries about lesson 2. I already finished it and had some time to work on the android book
Nitya Narasimhan
@nitya
Feb 07 2015 15:45
@johnshea very nifty — you rock!! Thanks for all the help on the book and please go for it. I can come look at it this evening and see if I can help further?
John Shea
@johnshea
Feb 07 2015 15:46
i was in the developer console and looked thru all the js files but don't see "morsels" or "goToMorsel" defined anywhere. Is Angulas doing something dynamic?
i wanted to see how morsel was defined and how it was calling "goToMorsels" so I can generate the link for the book without having to click on each one and then copy URL of video
Nitya Narasimhan
@nitya
Feb 07 2015 15:47
@johnshea yes — but I can tell more when I am back at desk later this evening?
John Shea
@johnshea
Feb 07 2015 15:47
sure...np..when (and if) you have time
Nitya Narasimhan
@nitya
Feb 07 2015 15:47
@johnshea that would be SOOOOOO nice so I am all for it.
John Shea
@johnshea
Feb 07 2015 15:48
I understand this is above-n-beyond normal book editing so only if you feel inclined
Nitya Narasimhan
@nitya
Feb 07 2015 15:48
@johnshea grins understood
@johnshea have to run now — ttyl
John Shea
@johnshea
Feb 07 2015 15:49
if it helps in the list item is data-node-key="1643858568" which it is using as part of the link
and the link in the book is https://www.udacity.com/course/viewer#!/c-ud853/l-1395568821/m-1643858568
but the subchapters with exam/extra stuff have additional data in the URL so I was curious how the morsel contained it to build links
3rd link for "are you ready for the course?" has https://www.udacity.com/course/viewer#!/c-ud853/l-1395568821/e-2162698696/m-2205438564
Nitya Narasimhan
@nitya
Feb 07 2015 15:53
@johnshea will be you online this evening? can chat more then — but yes, the way this works (single page app) is that the prefix (up to viewer) is static but the rest of the path is dynamically composed from data provided at that handler/route. So I am guessing morsels is a data array that contains each chapter’s description and the relevant path snippet, and the click handler basically creates this completed path on the fly
@johnshea and now I HAVE to hop off (I do love discussions like this so its tempting to reply but I am being glared at by my 6yo here so have to run)
John Shea
@johnshea
Feb 07 2015 15:55
@nitya go enjoy your kid time...more important than this
@nitya I will try to be on this evening but not sure...send me a msg w/ a rough time and I will try and make it
Nitya Narasimhan
@nitya
Feb 07 2015 15:56
@johnshea will do. I’ll leave you a message on gitter when I am back online .