-2

On Google's homepage for Android (http://developer.android.com/index.html), they use a "carousel" control of some sort to create a type of slideshow where you can click on the left or right arrows to view different content within the slideshow.

I would like to use the same thing, so I figure I could just view the javascript sources in my Google chrome browser, download it along with the css files and just reuse it. It may even be an open source javascript control on the Internet, so if I can figure out which one it is, I'll just go to the site where it is hosted.

The problem I have is trying to figure out the javascript code. Using Chrome, none of the javascript files that are shown indicate anything used to create or manage the carousel. Is it possible that javascript can be downloaded and run inside the browser without it even showing up as a source?

Johann
  • 27,536
  • 39
  • 165
  • 279
  • 3
    And what if it's not OSS? You can't just lift code from someone elses site. Anyhow there are loads of free carousels with examples already out there why not just find and use one of those? – Lloyd Aug 10 '13 at 08:52
  • Stackoverflow is not a place to be discussing ethics. It's about technical issues. – Johann Aug 10 '13 at 08:58
  • *"Is it possible that javascript can be downloaded and run inside the browser without it even showing up as a source?"* Technically yes, if the JS is loaded via Ajax for example and evaluated dynamically. But I don't think they are doing this. It's more likely that they heavily obfuscated/minimized the code and you don't recognize the carousel part. – Felix Kling Aug 10 '13 at 08:59
  • 1
    @AndroidDev: Every place is a potential place to be discussing ethics. If you appear to be doing something shady, don't act all surprised when you get called on it. – cHao Aug 10 '13 at 09:17
  • Even hackers are welcomed to SO. If someone is trying to hack into a bank, I'll be more than glad to see their question and post an answer. When a hacker posts a question that some anti-hacker developer never thought about when writing their anti-hacking code, it helps expose flaws in software design. And as for "lifting" javascript code, spare me your arguments. Even Google developers lift code and modify it, making improvements in it. Only novice developers like you post such comments on SO addressing ethics. – Johann Aug 10 '13 at 10:23
  • 2
    @AndroidDev — Please don't equate a concern about ethics with a lack of technical expertise. Accusing people of being novices when they bring up the subject of ethics is rude. – Quentin Aug 10 '13 at 12:15
  • @AndroidDev: Google's developers don't steal code; they find open-source code they can *legally* reuse, or they write their own. I'm sure Google even trains people on what's OK to reuse and what's not, for the same reason that you should be concerned about it, even if you're a sociopath and ethics don't concern you: *because doing the wrong thing could cost $millions*. Only amateurs ignore the rules, and even they can only semi-safely do so because the chance of their being caught and sued is very low -- no significant number of people will ever see the end result, and it'll never make money. – cHao Aug 10 '13 at 19:48
  • As for tying a concern about ethics to being a "novice"? It's been my experience that novices are the main ones that *don't* make ethics a part of the equation. A true professional understands that every decision has consequences -- for him/her, for the team, for the employer, for customers, and for the art in general. – cHao Aug 10 '13 at 20:06

2 Answers2

0

Have you looked at docs.js included on this page
Below is part of this js which manages carousel

    /*
    * Slideshow 1.0
    * Used on /index.html and /develop/index.html for carousel
    *
    * Sample usage:
    * HTML -
    * <div class="slideshow-container">
    * <a href="" class="slideshow-prev">Prev</a>
    * <a href="" class="slideshow-next">Next</a>
    * <ul>
    * <li class="item"><img src="images/marquee1.jpg"></li>
    * <li class="item"><img src="images/marquee2.jpg"></li>
    * <li class="item"><img src="images/marquee3.jpg"></li>
    * <li class="item"><img src="images/marquee4.jpg"></li>
    * </ul>
    * </div>
    *
    * <script type="text/javascript">
    * $('.slideshow-container').dacSlideshow({
    * auto: true,
    * btnPrev: '.slideshow-prev',
    * btnNext: '.slideshow-next'
    * });
    * </script>
    *
    * Options:
    * btnPrev: optional identifier for previous button
    * btnNext: optional identifier for next button
    * btnPause: optional identifier for pause button
    * auto: whether or not to auto-proceed
    * speed: animation speed
    * autoTime: time between auto-rotation
    * easing: easing function for transition
    * start: item to select by default
    * scroll: direction to scroll in
    * pagination: whether or not to include dotted pagination
    *
    */ 

(function($) {
$.fn.dacTabbedList = function(o) {
//Options - see above
o = $.extend({
speed : 250,
easing: null,
nav_id: null,
frame_id: null
}, o || {});
//Set up a carousel for each
return this.each(function() {
var curr = 0;
var running = false;
var animCss = "margin-left";
var sizeCss = "width";
var div = $(this); 
...
harrybvp
  • 2,445
  • 2
  • 22
  • 30
0

They are using carousel.js.

It wasn't that hard to find really. It's under scripts in doc.js

But to answer your original question, How to hide Javascript code explains it pretty well. You can't completely hide it, but you can make it harder to find.

Community
  • 1
  • 1
geekchic
  • 2,371
  • 4
  • 29
  • 41
  • Not sure how I missed that. Initially I was looking for some javascript for their vertical navigation ("accordion") menu (http://developer.android.com/guide/components/index.html) but I couldn't find that, therefore i assumed it was either dynamically downloaded or possibly done entirely in CSS without javascript. So I must have assumed the same was done for their carousel. – Johann Aug 10 '13 at 09:02