Advertisement
Guest User

gtvtemp

a guest
Jan 26th, 2012
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Copyright 2010 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. //      http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14.  
  15. /**
  16.  * @fileoverview Classes for DataProvider
  17.  *
  18.  *
  19.  */
  20.  
  21. var gtv = gtv || {
  22.   jq: {}
  23. };
  24.  
  25. /**
  26.  * DataProvider class. Defines a provider for all data (Categories, Images & Videos) shown in the template.
  27.  */
  28. gtv.jq.DataProvider = function() {
  29. };
  30.  
  31. /**
  32.  * Returns all data shown in the template..
  33.  * @return {object} with the following structure:
  34.  *    - categories -> [category1, category2, ..., categoryN].
  35.  *    - category -> {name, videos}.
  36.  *    - videos -> {thumb, title, subtitle, description, sources}
  37.  *    - sources -> [source1, source2, ..., sourceN]
  38.  *    - source -> string with the url | {src, type, codecs}
  39.  */
  40. gtv.jq.DataProvider.prototype.getData = function() {
  41.   function getRandom(max) {
  42.     return Math.floor(Math.random() * max);
  43.   }
  44.  
  45.   function getThumbId(small) {
  46.     var num = getRandom(15);
  47.     if (num == 0) {
  48.       num = 1;
  49.     }
  50.     if (num < 10) {
  51.       num = '0' + num;
  52.     }
  53.     return num.toString();
  54.   }
  55.  
  56.   var categories = [
  57.     'Dev Events',
  58.     'Technology',
  59.     'Conferences',
  60.     'Keynotes',
  61.     'Talks',
  62.     'Events'];
  63.  
  64.   var sources = [
  65.     {
  66.       src: 'http://commondatastorage.googleapis.com/gtv_template_assets/'
  67.            + 'IO2010-Keynote-day1.mp4',
  68.       title: '2010 Day 1 Keynote',
  69.       desc: 'Moscone Center'
  70.     },
  71.     {
  72.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  73.           + 'IO2010-Keynote-day2-android.mp4',
  74.       title: '2010 Day 2 Keynote',
  75.       desc: 'Moscone Center'
  76.     },
  77.     {
  78.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  79.           + 'IO2009-Keynote-day1.mp4',
  80.       title: '2009 Day 1 Keynote',
  81.       desc: 'Moscone Center'
  82.     },
  83.     {
  84.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  85.           + 'GDD2010-Highlights.mp4',
  86.       title: '2010 Highlights',
  87.       desc: 'Google Developer Day'
  88.     },
  89.     {
  90.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  91.           + 'GDD2010-BR-Keynote.mp4',
  92.       title: '2010 Keynote',
  93.       desc: 'Brazil'
  94.     },
  95.     {
  96.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  97.           + 'ChromeFrame.mp4',
  98.       title: 'Using Google Chrome Frame',
  99.       desc: 'Alex Russell'
  100.     },
  101.     {
  102.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  103.           + 'CWS-HowTo.mp4',
  104.       title: 'Uploading your App',
  105.       desc: 'Moscone Center'
  106.     },
  107.     {
  108.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  109.           + 'CWS-GettingStarted.mp4',
  110.       title: 'Getting Started with Apps for the Chrome Web Store',
  111.       desc: 'Arne Roomann-Kurrik'
  112.     },
  113.     {
  114.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  115.           + 'Chrome-Accessibility.mp4',
  116.       title: 'Google Chrome Extensions and Accessibility',
  117.       desc: 'Rachel Shearer'
  118.     },
  119.     {
  120.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  121.           + 'CF1-AppsMarketplace-Part1.mp4',
  122.       title: 'Campfire Part 1',
  123.       desc: 'Moscone Center'
  124.     },
  125.     {
  126.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  127.           + 'CF1-AppsMarketplace-Part2.mp4',
  128.       title: 'Campfire Part 1',
  129.       desc: 'Moscone Center'
  130.     },
  131.     {
  132.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  133.           + 'CF1-AppsMarketplace-Part3.mp4',
  134.       title: 'Campfire Part 1',
  135.       desc: 'Moscone Center'
  136.     },
  137.     {
  138.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  139.           + 'CF1-AppsMarketplace-Part4.mp4',
  140.       title: 'Campfire Part 1',
  141.       desc: 'Moscone Center'
  142.     },
  143.     {
  144.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  145.         + 'CF1-AppsMarketplace-Part5.mp4',
  146.       title: 'Campfire Part 1',
  147.       desc: 'Moscone Center'
  148.     },
  149.     {
  150.       src:'http://commondatastorage.googleapis.com/gtv_template_assets/'
  151.         + 'CF1-AppsMarketplace-Part6.mp4',
  152.       title: 'Campfire Part 1',
  153.       desc: 'Moscone Center'
  154.     }
  155.   ];
  156.  
  157.   var data = {
  158.     categories: []
  159.   };
  160.  
  161.   for (var i=0; i<categories.length; i++) {
  162.     var category = {
  163.       name: categories[i],
  164.       videos: []
  165.     };
  166.  
  167.     for (var j=0; j<25; j++) {
  168.       var videoInfo = sources[getRandom(sources.length)];
  169.       var video = {
  170.         thumb: 'images/thumbs/thumb' + getThumbId() + '.jpg',
  171.         title: videoInfo.title,
  172.         subtitle: videoInfo.desc,
  173.         description: [],
  174.         sources: [videoInfo.src]
  175.       };
  176.       category.videos.push(video);
  177.     }
  178.  
  179.     data.categories.push(category);
  180.   }
  181.  
  182.   return data;
  183. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement