Getting Started with Mobile Application Development

Tags

, , ,


MobAppWeb3

MobAppWeb

MobAppWeb1 MobAppWeb2

Many factors play a part in your mobile strategy, such as your team’s development skills, required device functionality, the importance of security, offline capability, interoperability, and so on. In the end, it’s not just a question of what your app will
do, but how you’ll get it there. The Mobile SDK offers three ways to create mobile apps:
• Native apps are specific to a given mobile platform (iOS or Android) and use the development tools and language that the respective platform supports (for example, Xcode and Objective-C with iOS, Eclipse and Java with Android). Native
apps look and perform best but require the most development effort.
• HTML5 apps use standard web technologies—typically HTML5, JavaScript and CSS—to deliver apps through a mobile Web browser. This “write once, run anywhere” approach to mobile development creates cross-platform mobile applications
that work on multiple devices. While developers can create sophisticated apps with HTML5 and JavaScript alone, some challenges remain, such as session management, secure offline storage, and access to native device functionality (such as camera, calendar, notifications, and so on).
• Hybrid apps combine the ease of HTML5 Web app development with the power of the native platform. This combined approach produces an application that can leverage the device’s native capabilities and be delivered through the app store.

Mobile SDK NHH

Mobile development is a constantly moving target. Every six months, there’s a new mobile operating system, with unique features only accessible with native APIs. The containers bring those to hybrid apps soon thereafter, with the web making tremendous leaps every few years. Based on current technology, here’s a summary of Mobile Development Options:

Native HTML5 Hybrid
App Features
Graphics Native APIs HTML, Canvas, SVG HTML, Canvas, SVG
Performance Fast Slow Slow
Native look and feel Native Emulated Emulated
Distribution Appstore Web Appstore
Device Access
Camera Yes No Yes
Notifications Yes No Yes
Contacts, calendar Yes No Yes
Offline storage Secure file storage Shared SQL Secure file system, shared SQL
Geolocation Yes Yes Yes
Gestures
Swipe Yes Yes Yes
Pinch, spread Yes No Yes
Connectivity Online and offline Mostly online Online and offline
Development skills ObjectiveC, Java HTML5, CSS, Javascript HTML5, CSS, Javascript

Getting Started with Android Location Services – Part 1


Location information is becoming increasingly important in the world of mobile development. The capability to easily retrieve and provide location data to apps is becoming a major feature of today’s mobile platforms.

Android provides this functionality with its location service.
Android’s location service provides access to facilities that can be used to determine a device’s current location.

METHODS USED TO DETERMINE LOCATION

GPS Provider
The Global Positioning System (GPS) uses a system of satellites orbiting the planet to help a receiver (an Android handset in this case) determine its current location. The term GPS refers to the entire GPS system, which consists of satellites, receivers, and the control stations that monitor and adjust it.constellation-sm II-IIA-sm

Limitations

  • Although GPS can provide the most accurate location data, it does have limitations that may be difficult to work around. First is the fact that a GPS receiver needs a clear path to a GPS satellite. This means that GPS receivers are unlikely to work indoors, and may even have problems outside in areas where the sky is not visible (such as dense forests). Additionally because multiple GPS satellites are needed to produce location information, it may take a substantial amount of time to acquire a location.  For these reasons, other sources of location information are sometimes needed.
  • Objects that obstruct a GPS signal may cause the signal to be reflected before it reaches the GPS receiver. GPS signals that are reflected off of objects have a different path from the GPS satellite to the GPS receiver and cause the distance calculation to be erroneous. These types of errors are called multipath errors and can cause the location to appear to jump from one place to another. This is often seen in urban areas where GPS signals frequently bounce off of tall buildings.

Network Provider
Network location provider can provide location information using cell
towers or based on wireless network information.

Using Wireless Network Access Points

  • Although it does require that the Wi-Fi radio is active, the Wi-Fi radio often consumes less battery power than the GPS hardware.
  • Wi-Fi-based location detection works by having a device track what Wi-Fi access points it can detect and the current signal strength of those access points. The device then makes a query to the Google location service (which is different from the Android location service) which provides location data based on the Wi-Fi information.
  • The Wi-Fi information collected by the device includes the mandatory access control (MAC) addresses of the Wi-Fi access points that are in range and the strength of the signal being received from those access points.
  • To provide location information based on visible Wi-Fi access
    points, the Google location service must obtain information
    about Wi-Fi access points and their locations. This information
    is collected by Android devices when a user enables use
    of Google’s location service in the Location Settings screen.Eg. Refer to the image below:

Google Location Service

  • Pressing Agree on this screen allows the device to record
    Wi-Fi information as well as current location information
    (possibly provided by GPS) and transmit this information to
    Google. This essentially allows Google use each and every
    Android device as a way to update the Wi-Fi location information
    and constantly maintain up-to-date data.

Limitations

  • First, to determine the location, Wi-Fi networks must be in range. Additionally, the networks must have a publicly broadcasted service set identifier (SSID) that has been configured to be detected by Android.
  • Access points that have an SSID that ends in _nomap will not have their information sent to the Google location service. Additionally, changes to the location of Wi-Fi access points can cause inaccuracies in the location data that is produced. For example, many people now have wireless networks in their homes for daily use. Assuming an Android device has been configured to use the Google location service, Android would have sent the access point MAC address and location to the Google location service. If the user were to change the location of that access point (take it to a vacation home, for example), the location service might determine the device to be in the wrong location when the Wi-Fi location source is used.

Using Cell IDs

  • To function properly, a cellular device must be in contact with a cell tower. As a device moves, it may connect to a different cell tower as the signal strength of an approaching cell tower becomes stronger. Knowing the unique ID of the tower that a device is currently connected to and possibly the towers that a device was previously connected to, can provide insight to where the device is
    located assuming the location of a given cell tower is known.
  • When a device needs to find its current location, it sends the ID of the cell tower it is currently connected to, as well as historic information about past cell towers it has used, to the Google location service. With this information, the Google location service can provide information about the device’s current location based on the data it has about the cell tower network. If the IDs of multiplecell towers are sent to the Google location service, it can use triangulation to provide increased location accuracy. The Google location service cannot do this if the device submits only a single cell tower ID.

Limitations

  • The limitations for using cell tower IDs are similar to the limitations that exist when using Wi-Fi networks to determine location. However, because the location of cell towers is less likely to change than the location of wireless access points, some of the complications that may exist when using Wi-Fi access points are removed.
  • Like Wi-Fi access point data, the Google location service must have data on the cell tower IDs that are sent by a device in order to provide location data.

So much so for part 1 of this discussion. We’ll explore more technical stuff in part 2 mainly, Android Location API components and usage of the Location API to determine a device’s current location.

How to Get Started with Google Cloud Infrastructure?

Tags

, ,


The key to getting started with Google Cloud Infrastructure is to understand the Big Picture, overall Technical Architecture and possible Solution Scenarios that are currently supported by the platform:

Mobile Apps Technical Architecture and Solution Scenarios

Requirements

Typical requirements for a compelling mobile solution include:

  • Support for Android and iOS devices through native applications
  • Storage, retrieval, and processing data outside of mobile devices
  • Orchestrating push notification to Android and IOS devices
  • Geo-location awareness and geo-proximity search
  • User authentication
  • High scalability mobile-app-10image00architecture-diag 

Web Application Technical Architecture and Solution Scenarios

Requirements

Building a Web Application using AngularJS and Google Cloud Platform. AngularJS is a popular open source JavaScript client-side MVC framework supporting the rapid development of client-side applications.

Notes

A recent and significant change in web application frameworks has been the shift from Model-View-Controller (MVC) on the server to the MVC on the client.

Solution Overview

cloud-endpoints endpoints-architecture

Next Steps

Set up your development environment using Eclipse and explore Google App Engine SDK, check out - https://developers.google.com/eclipse/docs/download

Top 20 Startup Project Categories

Tags


We did a review of the most Popular Startup Project categories and came up with a consolidated list of final project categories as listed below:

Category Details Approx. number of students w/ interest
Data Data science / machine learning / big data / crowdsourcing / search 11529
Developer Productivity / developer tools 7964
Location Mobile / location-based / maps / transportation / travel / lodging / restaurants 7181
Entertainment Entertainment / movies / music / games 5667
Commerce Retail / e-commerce / local commerce 5191
Robotics Robotics / drones / telepresence 5143
Infrastructure Data centers / infrastructure / computer hardware / networking 4999
Payments Payments / currency / crowdfunding / finance 4899
Fitness Fitness / sports / health / nutrition 4634
Communications Texting / communications / telephony / video chat / file sharing / p2p 4548
Energy Clean energy / electric vehicles / energy efficiency / oil / gas 4317
Education Higher education / K-12 education / MOOCs 4159
Ads Advertising / marketing 3450
3D Printing 3D printing / CNC 3047
Medicine Genomics / medicine / healthcare / pharmaceuticals / biotech 2934
News/Blogs Print media / blogs / microblogs 2202
Social Social networking / marriage / dating / friendship / meetups 1875
Supply Chain Supply chain / operations research 1800
Semiconductors Semiconductors / circuit engineering 1566
Law/Government Law / regulation / government 1430

How to Bring Campus Ideas to Life?


Most of us have dreamt about taking the Projects or Ideas that we developed during our campus lives to real life implementation. But things haven’t worked out as we wished due to lack of funds or other constraints. No worries, iElite offers a Solution to bring Campus Ideas to life via Crowd-Funding.

So how does Crowd Funding work?
Simple! The Crowd-Funding platform connects A Student or a group of Students with an innovative idea to a Potential Sponsor or Investor.

Any Prerequisites for Student Groups?
Ideally, students pursuing BTech / BE / MCA / BCA who have a strong interest in Innovative Projects or Ideas would be preferred.

How does an Investor Shortlist Ideas?
The Investor would evaluate the merit of the idea visa-vis current market conditions and agree to Sponsor the ‘Idea’ subject to Pre-conditions.

What would be those Pre-Conditions?
Commitment of the Team (Student Group) to the ‘Idea’, a Specific timeline to complete the product or Idea for eg 12-18 months and protection of the investment made by the Sponsor / Investor.

What kind of Ideas from the Student groups would generally get funded?
Ideas that Solve a compelling Social Problem would get first preference. However, Business ideas are also welcome on a case-to-case basis.

What Technology Domains would get Preference?
Ideally ideas related to Web based Platform, Mobile Devices, Robotics and Location Based Services (GPS etc) would be encouraged. That said, other technology domains will also be considered if the Student Group / Team can manage the project with minimal supervision or guidance.

Whom do we talk to or reach out to for more information?
For additional info and queries, email to suraj.jayraman@gmail.com.

How to embed videos in your site via YouTube Data API?

Tags


YouTube Data API via JSON: embedding videos in your site

Video_list

The YouTube Data API normally outputs information about videos, playlists, subscriptions, user profiles and more in the format of Atom feeds. However, due to cross-domain restrictions, it’s not very easy to retrieve and parse XML data on remote servers from within JavaScript. Because of this, most Google Data APIs also provide JSON as an alternative output format. JSON is short for JavaScript Object Notation and enables cross-domain retrieval of data from the Data APIs.

Capabilities

Read-only unauthenticated access to public data served from the YouTube Data API.

Requirements

Nothing! Well, a browser and a web server that’ll serve static HTML

How does it work?

You only need two things:

These bits of information are combined together to create a <script> tag. An example:

<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/users/GoogleDevelopers/uploads?alt=json-in-script&format=5&callback=showMyVideos">
</script>

Adding this tag to your page will retrieve a feed of the embeddable videos belong to the user GoogleDevelopers and, after the feed is retrieved, call the showMyVideos function with the data returned.

What’s the callback function look like?

The callback function can be really simple or very complex depending on what you would like to do with the data returned. Let’s start off with a simple example that creates an unordered list of the videos in theGoogleDevelopers account.

function showMyVideos(data) {
  var feed = data.feed;
  var entries = feed.entry || [];
  var html = ['<ul>'];
  for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t;
    html.push('<li>', title, '</li>');
  }
  html.push('</ul>');
  document.getElementById('videos').innerHTML = html.join('');
}

The complete picture

Demo:

  • Google+ Developers Live: Sign-in Best Practices Episode #2
  • Implementing Content Experiments in Google Analytics
  • Mobile Web Thursdays: Developer Workflow
  • GDL Italia – Offline HTML5 Agenda (parte 4)
  • Skia Path Ops : High Performance Set Operations for Geometry
  • DART, Una visión de los nuevos estilos de programacion
  • Chrome Apps: In App Payments
  • YouTube Developers Live: Introduction to Invideo Programming
  • AdWords API Intro
  • Google+ Sign-In Best Practices: Greeting the user and reflecting their profile.
  • Google Drive SDK: Floreysoft!
  • Maps Shortcuts: Driving Geometry Overlays with D3.js
  • Developing on a Chromebook with Codenvy
  • Google Compute Engine – Ten Minute Test Drive: Set Up your own Web Server
  • Chrome Mobile: StackOverflow Office Hours
  • GDL Italia – Google Cloud Platform in the real world
  • GDL Italia – Google Prediction API, machines that learn
  • Cloud Platform, la computación en la nube desde Compute Engine
  • All about Chrome Academy
  • Chrome Apps Office Hours: Behind Reditr
  • Apps Script Crash Course: Import/Export Apps Script Code
  • Off the Charts: Campaigns and Attribution for Android Applications using Google Analytics
  • Chrome Mobile: WebRTC
  • GDL Italia – Google Cloud Storage overview
  • GDL Italia – Google Compute Engine overview

Source:

<html>
<head>
<title>My Videos</title>
<script type="text/javascript">
function showMyVideos(data) {
  var feed = data.feed;
  var entries = feed.entry || [];
  var html = ['<ul>'];
  for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t;
    html.push('<li>', title, '</li>');
  }
  html.push('</ul>');
  document.getElementById('videos').innerHTML = html.join('');
}
</script>
</head>
<body>
<div id="videos" />
<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/users/GoogleDevelopers/uploads?alt=json-in-script&format=5&callback=showMyVideos">
</script>
</body>
</html>

Making it more attractive

YouTube is all about videos. Videos should contain pictures and sound– so why are we just outputting a boring list of videos? You have a good point, so let’s jazz this up a bit!

The following example uses the value of the MediaRSS thumbnails, MediaRSS content and MediaRSS player. These values are in each video entry as media$group.media$thumbnail[] andmedia$group.media$player.

Demo:

  • Google+ Developers L…
  • Implementing Content…
  • Mobile Web Thursdays…
  • GDL Italia – Offline…
  • Skia Path Ops : High…
  • DART, Una visión de …
  • Chrome Apps: In App …
  • YouTube Developers L…
  • AdWords API Intro…
  • Google+ Sign-In Best…
  • Google Drive SDK: Fl…
  • Maps Shortcuts: Driv…
  • Developing on a Chro…
  • Google Compute Engin…
  • Chrome Mobile: Stack…
  • GDL Italia – Google …
  • GDL Italia – Google …
  • Cloud Platform, la c…
  • All about Chrome Aca…
  • Chrome Apps Office H…
  • Apps Script Crash Co…
  • Off the Charts: Camp…
  • Chrome Mobile: WebRT…
  • GDL Italia – Google …
  • GDL Italia – Google …
  • YouTube API, la ener…
  • The Independent Web …
  • Google Developers Li…
  • Escaping the Passwor…
  • GDL Italia – Mobile …

Source:

<html>
<head>
<title>My Videos</title>
<style>
.titlec {
  font-size: small;
}
ul.videos li {
  float: left;
  width: 10em;
  margin-bottom: 1em;
}
ul.videos
{
  margin-bottom: 1em;
  padding-left : 0em;
  margin-left: 0em;
  list-style: none;
}
</style>
<script type="text/javascript" src="http://swfobject.googlecode.com/svn/trunk/swfobject/swfobject.js"></script>
<script type="text/javascript">
function loadVideo(playerUrl, autoplay) {
  swfobject.embedSWF(
      playerUrl + '&rel=1&border=0&fs=1&autoplay=' + 
      (autoplay?1:0), 'player', '290', '250', '9.0.0', false, 
      false, {allowfullscreen: 'true'});
}

function showMyVideos2(data) {
  var feed = data.feed;
  var entries = feed.entry || [];
  var html = ['<ul>'];
  for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t.substr(0, 20);
    var thumbnailUrl = entries[i].media$group.media$thumbnail[0].url;
    var playerUrl = entries[i].media$group.media$content[0].url;
    html.push('<li onclick="loadVideo(\'', playerUrl, '\', true)">',
              '<span>', title, '...</span><br /><img src="', 
              thumbnailUrl, '" width="130" height="97"/>', '</span></li>');
  }
  html.push('</ul><br style="clear: left;"/>');
  document.getElementById('videos2').innerHTML = html.join('');
  if (entries.length > 0) {
    loadVideo(entries[0].media$group.media$content[0].url, false);
  }
}
</script>
</head>
<body>
<div id="playerContainer" style="width: 20em; height: 180px; float: left;">

</div>
<div id="videos2"></div>
<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/users/GoogleDevelopers/uploads?alt=json-in-script&callback=showMyVideos2&max-results=30">
</script>
</body>
</html>

On your own

The easiest way to get started using the JSON output from the YouTube Data API is to copy and paste one of the examples above and modify it to fit your needs. While the JSON output from the API looks very similar to the XML output, it’s still often helpful to use a debugger such as Firebug to look at the JSON returned from the server and find the data you need for your application. If you have any questions about how to use the JSON output feature, please post a message on the YouTube APIs developer forum.

The example above currently includes the videos from the GoogleDevelopers YouTube channel. You can easily change the source by changing the script tag’s src attribute, or by adding a function that does dynamic script injection. Here’s some example script tags:

30 videos which match the word ‘puppy’:

<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/api/videos?q=puppy&alt=json-in-script&callback=showMyVideos2&max-results=30&format=5">
</script>

Most viewed videos this week:

<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed?time=this_week&alt=json-in-script&callback=showMyVideos2&max-results=30&format=5">
</script>

Most viewed videos in Japan today:

<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/api/standardfeeds/JP/most_viewed?time=today&alt=json-in-script&callback=showMyVideos2&max-results=30&format=5">
</script>

Videos which are tagged with the word ‘goldendoodle’:

<script 
    type="text/javascript" 
    src="http://gdata.youtube.com/feeds/api/videos/-/goldendoodle?alt=json-in-script&callback=showMyVideos2&max-results=30&format=5">
</script>

For more information on the types of feeds availalble, please see the Reference Guide.

A more advanced YouTube Video Browser allows the user to browse thumbnails of related videos, select standard feeds and query the feeds using search terms.

Want something a little easier?

The AJAX Search Video Bar allows you to embed a bar of your YouTube videos onto your site with ease.

Demo:

powered by

Source:

Head over to the Video Bar wizard and configure some of the Video Bar parameters. It’ll generate the code for you.

Here’s what the code for the bar above looks like:

<html>
<head>
<title>My Videos</title>
</head>
<body>
  <!--
  // The Following div element will end up holding the actual videobar.
  // You can place this anywhere on your page.
  -->
  <div id="videoBar-bar">
    <span style="color:#676767;font-size:11px;margin:10px;padding:4px;">Loading...</span>

  </div>

  <!-- Ajax Search Api and Stylesheet
  // Note: If you are already using the AJAX Search API, then do not include it
  //       or its stylesheet again
  -->
  <script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-vbw"
    type="text/javascript"></script>
  <style type="text/css">
    @import url("http://www.google.com/uds/css/gsearch.css");
  </style>

  <!-- Video Bar Code and Stylesheet -->
  <script type="text/javascript">
    window._uds_vbw_donotrepair = true;
  </script>
  <script src="http://www.google.com/uds/solutions/videobar/gsvideobar.js?mode=new"
    type="text/javascript"></script>
  <style type="text/css">
    @import url("http://www.google.com/uds/solutions/videobar/gsvideobar.css");
  </style>
  <style type="text/css">
    .playerInnerBox_gsvb .player_gsvb {
      width : 320px;
      height : 260px;
    }
  </style>
  <script type="text/javascript">
    function LoadVideoBar() {
    var videoBar;
    var options = {
        largeResultSet : !true,
        horizontal : true,
        autoExecuteList : {
          cycleTime : GSvideoBar.CYCLE_TIME_MEDIUM,
          cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
          executeList : ["ytchannel:GoogleDevelopers"]
        }
      }
    videoBar = new GSvideoBar(document.getElementById("videoBar-bar"),
                              GSvideoBar.PLAYER_ROOT_FLOATING,
                              options);
    }
    // arrange for this function to be called during body.onload
    // event processing
    GSearch.setOnLoadCallback(LoadVideoBar);
  </script>
<!-- ++End Video Bar Wizard Generated Code++ -->
</body>
</html>

How to build an Online Store using Vendor APIs?


I was amazed to find a very simple way of putting together a Web based online store using Javascript, jQuery and Gilt API. The Gilt API offers a number of ways for you to retrieve a list of items on sale. To look up a particular brand of boots – for example. The code below demonstrates the following technical aspects:
a)Looking up Products by Product ID
b)Looking up Products by Brand
c)Looking up Products by Category
d)Looking up Products by Price Range

  1. gilt.js

window.GILT = {};

window.GILT.indexProducts = function(products) {
var productById = {};
var productIdsByBrand = {};
var productIdsByCategory = {};
var productIdsByPriceRange = {
“less than $50″: [],
“from $50 to less than $100″: [],
“from $100 to less than $200″: [],
“$200 or more”: []
};

// loop through each product
for(var pIdx = 0; pIdx < products.length; pIdx++) {
var product = products[pIdx];

// index current product by ID
productById[product.id] = product;

// index current product by brand
var productBrand = product.brand;
if(!(productIdsByBrand[productBrand] instanceof Array)) {
productIdsByBrand[productBrand] = [];
}
productIdsByBrand[productBrand].push(product.id);

// index current product by categories
for(var cIdx = 0; cIdx < product.categories.length; cIdx ++) {
var category = product.categories[cIdx];
if(!(productIdsByCategory[category] instanceof Array)) {
productIdsByCategory[category] = [];
}
productIdsByCategory[category].push(product.id);
}

// index current product by price range
for(var sIdx = 0; sIdx < product.skus.length; sIdx ++) {
var sku = product.skus[sIdx];
var salePrice = Math.floor(parseFloat(sku.sale_price));

if(salePrice < 50) {
productIdsByPriceRange["less than $50"].push(product.id);
} else if(salePrice < 100) {
productIdsByPriceRange["from $50 to less than $100"].push(product.id);
} else if(salePrice < 200) {
productIdsByPriceRange["from $100 to less than $200"].push(product.id);
} else {
productIdsByPriceRange["$200 or more"].push(product.id);
}
}
}

window.GILT.productById = productById;
window.GILT.productIdsByBrand = productIdsByBrand;
window.GILT.productIdsByCategory = productIdsByCategory;
window.GILT.productIdsByPriceRange = productIdsByPriceRange;
};

$(window).on(“products”, function(e, p) {
$(“.label.loading”).hide();
$(“.label.loading”).after(“<span>” + p.products.length + ” products loaded</span>”);
// $(“.dataresult”).parent().hide();
$(“.selects”).show();

GILT.indexProducts(p.products);

$.each(GILT.productIdsByBrand, function(key) {
$(“select.brand”).append(“<option>” + key + “</option>”);
});

$.each(GILT.productIdsByCategory, function(key) {
$(“select.category”).append(“<option>” + key + “</option>”);
});

$.each(GILT.productIdsByPriceRange, function(key) {
$(“select.price”).append(“<option>” + key + “</option>”);
});

$(window).trigger(“html_loaded”);
});

$(document).ready(function() {
$.getScript(“https://raw.github.com/gilt/codecademy/master/extra/build_html.js&#8221;, function() {
$(“.label.loading”).show();
$.getScript(“https://raw.github.com/gilt/codecademy/master/data/active_products.js&#8221;);
});
});

$(window).on(“html_loaded”, function(e) {
$(“.submit_button”).click(function(e) {
window.run($(“select.brand”).val(), $(“select.category”).val(), $(“select.price”).val(), function(result) {
$(“.dataresult”).html(JSON.stringify(result, undefined, 2));
});
});
});

2.gilt_app.js

// in this final function you will get three values
// that are going to be set by the three dropdowns
// that you can see in the Result tab
function run(brand, category, price, done) {
// “brand” will be set to the value of the first dropdown
// this will be the selected brand
//
// “category” will be set to the value of the second dropdown
// this will be the selected category

// “price” will be set to the value of the third dropdown
// this will be the selected price range

// you will have access to the data that you created in the
// previous exercises:
//
// GILT.productById
// GILT.productIdsByBrand
// GILT.productIdsByCategory
// GILT.productIdsByPriceRange
//
// Note: to access these objects you must prepend their name with
// the GILT prefix as in the above examples.

// we set allProducts to an array of all the product IDs
var allProductIds = Object.keys(GILT.productById);

// productIdsForBrand is set to the product IDs of the selected
// brand OR is going to be undefined if no brand is selected
var productIdsForBrand = GILT.productIdsByBrand[brand];

// productIdsForCategory is set to the product IDs of the selected
// category OR is going to be undefined if no category is selected
var productIdsForCategory = GILT.productIdsByCategory[category];

// productIdsForPriceRange is set to the product IDs of the selected
// price range OR is going to be undefined if no price is selected
var productIdsForPriceRange = GILT.productIdsByPriceRange[price];

// you are going to fill the selectedProducts array with the
// product objects that belongs to the brand, the category and
// the price renge selected from the interface
var selectedProducts = [];

// 1. loop through the allProductIds array

// 2. for each product ID check that it is contained in the
// productIdsForBrand, productIdsForCategory and the
// productIdsForPriceRange arrays using the provided
// isProductInCollection function

// 3. if the product ID satisfies the requirements, get the
// corresponding product object from the GILT.productById
// object

// 4. append the product object to the selectedProducts array

done(selectedProducts);
}

// This function returns true if the productId is contained in
// the productCollection array OR if the productCollection
// array is undefined, returns false otherwise.
function isProductInCollection(productId, productCollection) {
if(typeof productId === “string”) {
productId = parseInt(productId, 10);
}
if(typeof productCollection === “undefined”) {
return true;
}
return(productCollection.indexOf(productId) > -1);
}

3. Additionally you need an Index.html file to reference the above said Javascript files and JQuery CDN Path.

Drop it in Apache htdocs/gilt folder and run!

gilt1 gilt2 gilt3

 

How to Search for YouTube Content?


Here’s a sample code snippet that illustrates a simple approach to search for YouTube content. This example searches for YouTube Videos that is related to Gangnam Style.

The example code has two parts (a) HTML – Search.html (b) JAVASCRIPT – Search.js. Check them out.

(a) Search.html that invokes apis.google.com/js/client.js?onload=onClientLoad

(b) Search.js
// Your use of the YouTube API must comply with the Terms of Service:
// https://developers.google.com/youtube/terms

// Helper function to display JavaScript value on HTML page.
function showResponse(response) {
var responseString = JSON.stringify(response, ”, 2);
document.getElementById(‘response’).innerHTML += responseString;
}

// Called automatically when JavaScript client library is loaded.
function onClientLoad() {
gapi.client.load(‘youtube’, ‘v3′, onYouTubeApiLoad);
}

// Called automatically when YouTube API interface is loaded (see line 9).
function onYouTubeApiLoad() {
// This API key is intended for use only in this lesson.
// See http://goo.gl/PdPA1 to get a key for your own applications.
gapi.client.setApiKey(‘AIzaSyCR5In4DZaTP6IEZQ0r1JceuvluJRzQNLE’);

search();
}

function search() {
// Use the JavaScript client library to create a search.list() API call.
var request = gapi.client.youtube.search.list({
part: ‘snippet’, q:’gangnamstyle’

});

// Send the request to the API server,
// and invoke onSearchRepsonse() with the response.
request.execute(onSearchResponse);
}

// Called automatically with the response of the YouTube API request.
function onSearchResponse(response) {
showResponse(response);
}

Follow

Get every new post delivered to your Inbox.