go-tour: fixing jshint warnings for a healthier codebase

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/112160043
diff --git a/static/js/controllers.js b/static/js/controllers.js
index e17b842..f634eae 100755
--- a/static/js/controllers.js
+++ b/static/js/controllers.js
@@ -10,32 +10,32 @@
 angular.module('tour.controllers', []).
 
 // Navigation controller
-controller('EditorCtrl', ['$scope', '$routeParams', '$location', 'TOC', 'I18n', 'Run', 'Fmt', 'editor',
-    function($scope, $routeParams, $location, TOC, I18n, Run, Fmt, editor) {
+controller('EditorCtrl', ['$scope', '$routeParams', '$location', 'toc', 'i18n', 'run', 'fmt', 'editor',
+    function($scope, $routeParams, $location, toc, i18n, run, fmt, editor) {
         var lessons = [];
-        TOC.lessons.then(function(v) {
+        toc.lessons.then(function(v) {
             lessons = v;
             $scope.gotoPage($scope.curPage);
-        })
+        });
 
-        $scope.TOC = TOC;
+        $scope.toc = toc;
         $scope.lessonId = $routeParams.lessonId;
         $scope.curPage = parseInt($routeParams.pageNumber);
         $scope.curFile = 0;
 
         $scope.nextPage = function() {
             $scope.gotoPage($scope.curPage + 1);
-        }
+        };
         $scope.prevPage = function() {
             $scope.gotoPage($scope.curPage - 1);
-        }
+        };
         $scope.gotoPage = function(page) {
             var l = $routeParams.lessonId;
             if (page >= 1 && page <= lessons[$scope.lessonId].Pages.length) {
                 $scope.curPage = page;
             } else {
-                l = (page < 1) ? TOC.prevLesson(l) : TOC.nextLesson(l);
-                if (l == '') { // If there's not previous or next
+                l = (page < 1) ? toc.prevLesson(l) : toc.nextLesson(l);
+                if (l === '') { // If there's not previous or next
                     $location.path('/list');
                     return;
                 }
@@ -43,18 +43,18 @@
             }
             $location.path('/' + l + '/' + page);
             $scope.openFile($scope.curFile);
-        }
+        };
         $scope.openFile = function(file) {
             $scope.curFile = file;
             editor.paint();
-        }
+        };
 
         function log(mode, text) {
-            $(".output.active").html('<pre class="' + mode + '">' + text + '</pre>');
+            $('.output.active').html('<pre class="' + mode + '">' + text + '</pre>');
         }
 
         function clearOutput() {
-            $(".output.active").html('');
+            $('.output.active').html('');
         }
 
         function file() {
@@ -62,18 +62,20 @@
         }
 
         $scope.run = function() {
-            log('info', I18n.L('waiting'));
+            log('info', i18n.l('waiting'));
             var f = file();
-            Run(f.Content, $(".output.active > pre")[0], {path: f.Name});
+            run(f.Content, $('.output.active > pre')[0], {
+                path: f.Name
+            });
         };
 
         $scope.format = function() {
-            log('info', I18n.L('waiting'));
-            Fmt(file().Content).then(
+            log('info', i18n.l('waiting'));
+            fmt(file().Content).then(
                 function(data) {
-                    if (data.data.Error != '') {
+                    if (data.data.Error !== '') {
                         log('stderr', data.data.Error);
-                        return
+                        return;
                     }
                     clearOutput();
                     file().Content = data.data.Body;
@@ -83,4 +85,4 @@
                 });
         };
     }
-]);
+]);
\ No newline at end of file
diff --git a/static/js/directives.js b/static/js/directives.js
index 8171370..4c2f5c1 100755
--- a/static/js/directives.js
+++ b/static/js/directives.js
@@ -37,24 +37,22 @@
 }).
 
 // autofocus sets the focus on the given element when the condition is true.
-directive('autofocus', ['TOC',
-    function(TOC) {
-        return function(scope, elm, attrs) {
-            elm.attr('tabindex', 0);
-            scope.$watch(function() {
-                return scope.$eval(attrs.autofocus)
-            }, function(val) {
-                if (val == true) $(elm).focus();
-            });
-        }
-    }
-]).
+directive('autofocus', function() {
+    return function(scope, elm, attrs) {
+        elm.attr('tabindex', 0);
+        scope.$watch(function() {
+            return scope.$eval(attrs.autofocus);
+        }, function(val) {
+            if (val === true) $(elm).focus();
+        });
+    };
+}).
 
 // syntax-checkbox activates and deactivates
 directive('syntaxCheckbox', ['editor',
     function(editor) {
-        return function(scope, elm, attrs) {
-            elm.click(function(evt) {
+        return function(scope, elm) {
+            elm.click(function() {
                 editor.toggleSyntax();
                 scope.$digest();
             });
@@ -84,21 +82,21 @@
                     left: x
                 });
                 editor.x = x;
-            }
+            };
 
             elm.draggable({
-                axis: "x",
-                drag: function(event, ui) {
+                axis: 'x',
+                drag: function(event) {
                     moveTo(event.clientX);
                     return true;
                 },
-                containment: "parent",
+                containment: 'parent',
             });
 
             if (editor.x !== undefined) {
-                moveTo(editor.x)
+                moveTo(editor.x);
             }
-        }
+        };
     }
 ]).
 
@@ -121,20 +119,20 @@
                     height: 0
                 });
                 editor.y = y;
-            }
+            };
             elm.draggable({
-                axis: "y",
-                drag: function(event, ui) {
+                axis: 'y',
+                drag: function(event) {
                     moveTo(event.clientY);
                     return true;
                 },
-                containment: "parent",
+                containment: 'parent',
             });
 
             if (editor.y !== undefined) {
                 moveTo(editor.y);
             }
-        }
+        };
     }
 ]).
 
@@ -149,41 +147,41 @@
                 // hide all non active lessons before displaying the toc.
                 var visible = toc.css('display') != 'none';
                 if (!visible) {
-                    toc.find(".toc-lesson:not(.active) .toc-page").hide();
-                    toc.find(".toc-lesson.active .toc-page").show();
+                    toc.find('.toc-lesson:not(.active) .toc-page').hide();
+                    toc.find('.toc-lesson.active .toc-page').show();
                 }
-                toc.toggle("slide", {
-                    direction: "right"
+                toc.toggle('slide', {
+                    direction: 'right'
                 }, speed);
 
                 // if fullscreen hide the rest of the content when showing the atoc.
                 var fullScreen = toc.width() == $(window).width();
-                if (fullScreen) $('#editor-container')[visible ? 'show' : 'hide']()
+                if (fullScreen) $('#editor-container')[visible ? 'show' : 'hide']();
             });
         }
-    }
+    };
 }).
 
 // side bar with dynamic table of contents
-directive('tableOfContents', ['TOC', '$routeParams',
-    function(TOC, $routeParams) {
+directive('tableOfContents', ['$routeParams', 'toc',
+    function($routeParams, toc) {
         var speed = 250;
         return {
             restrict: 'A',
             templateUrl: '/static/partials/toc.html',
-            link: function(scope, elm, attrs) {
-                scope.toc = TOC;
+            link: function(scope, elm) {
+                scope.toc = toc;
                 scope.params = $routeParams;
 
                 scope.toggleLesson = function(id) {
-                    var l = $("#toc-l-" + id + " .toc-page");
+                    var l = $('#toc-l-' + id + ' .toc-page');
                     l[l.css('display') == 'none' ? 'slideDown' : 'slideUp']();
-                }
+                };
 
                 scope.$watch(function() {
                     return scope.params.lessonId + scope.params.lessonId;
-                }, function(lesson) {
-                    $(".toc-lesson:not(#toc-l-" + scope.params.lessonId + ") .toc-page").slideUp(speed);
+                }, function() {
+                    $('.toc-lesson:not(#toc-l-' + scope.params.lessonId + ') .toc-page').slideUp(speed);
                 });
 
                 scope.hideTOC = function(fullScreenOnly) {
@@ -191,11 +189,11 @@
                     if (fullScreenOnly && !fullScreen) {
                         return;
                     }
-                    $(".toc").toggle("slide", {
-                        direction: "right"
+                    $('.toc').toggle('slide', {
+                        direction: 'right'
                     }, speed);
-                }
+                };
             }
         };
     }
-]);
+]);
\ No newline at end of file
diff --git a/static/js/services.js b/static/js/services.js
index ac9c4f4..d7cd01f 100755
--- a/static/js/services.js
+++ b/static/js/services.js
@@ -9,28 +9,32 @@
 angular.module('tour.services', []).
 
 // Internationalization
-factory('I18n', ['Translation',
-    function(Translation) {
+factory('i18n', ['translation',
+    function(translation) {
         return {
-            L: function(key) {
-                if (Translation[key]) {
-                    return Translation[key]
-                }
-                return "(no translation for " + key + ")";
+            l: function(key) {
+                if (translation[key]) return translation[key];
+                return '(no translation for ' + key + ')';
             }
-        }
+        };
     }
 ]).
 
 // Running code
-factory('Run', function() {
-    return function(code, output, options) {
-        window.transport.Run(code, PlaygroundOutput(output), options);
+factory('run', ['$window',
+    function(win) {
+        return function(code, output, options) {
+            // PlaygroundOutput is defined in playground.js which is prepended
+            // to the generated script.js in gotour/tour.go.
+            // The next line removes the jshint warning.
+            // global PlaygroundOutput
+            win.transport.Run(code, PlaygroundOutput(output), options);
+        };
     }
-}).
+]).
 
 // Formatting code
-factory('Fmt', ['$http',
+factory('fmt', ['$http',
     function($http) {
         return function(body) {
             var params = $.param({
@@ -41,46 +45,47 @@
             };
             return $http.post('/fmt', params, {
                 headers: headers
-            })
-        }
+            });
+        };
     }
 ]).
 
 // Editor context service, kept through the whole app.
-factory('editor', function() {
-    var ctx = {
-        syntax: false,
-        toggleSyntax: function() {
-            ctx.syntax = !ctx.syntax
-            ctx.paint();
-        },
-        paint: function() {
-            var mode = ctx.syntax && 'text/x-go' || 'text/x-go-comment';
-            // Wait for codemirror to start.
-            var set = function() {
-                if ($('.CodeMirror').length > 0) {
-                    cm = $('.CodeMirror')[0].CodeMirror;
-                    if (cm.getOption('mode') == mode) {
-                        cm.refresh();
-                        return;
+factory('editor', ['$window',
+    function(win) {
+        var ctx = {
+            syntax: false,
+            toggleSyntax: function() {
+                ctx.syntax = !ctx.syntax;
+                ctx.paint();
+            },
+            paint: function() {
+                var mode = ctx.syntax && 'text/x-go' || 'text/x-go-comment';
+                // Wait for codemirror to start.
+                var set = function() {
+                    if ($('.CodeMirror').length > 0) {
+                        var cm = $('.CodeMirror')[0].CodeMirror;
+                        if (cm.getOption('mode') == mode) {
+                            cm.refresh();
+                            return;
+                        }
+                        cm.setOption('mode', mode);
                     }
-                    cm.setOption('mode', mode);
-                }
-                window.setTimeout(set, 10);
-            };
-            set();
-        },
-    };
-    return ctx;
-}).
+                    win.setTimeout(set, 10);
+                };
+                set();
+            },
+        };
+        return ctx;
+    }
+]).
 
 // Table of contents management and navigation
-factory('TOC', ['$http', '$q', 'TableOfContents',
-    function($http, $q, TableOfContents) {
-        var modules = TableOfContents;
+factory('toc', ['$http', '$q', '$log', 'tableOfContents',
+    function($http, $q, $log, tableOfContents) {
+        var modules = tableOfContents;
 
         var lessons = {};
-        var waitingFor = 0;
 
         var prevLesson = function(id) {
             var mod = lessons[id].module;
@@ -122,7 +127,7 @@
                 moduleQ.resolve(modules);
                 lessonQ.resolve(lessons);
             }, function(error) {
-                console.error('error loading lesson ', lesson, ': ', error);
+                $log.error('error loading lessons : ', error);
                 moduleQ.reject(error);
                 lessonQ.reject(error);
             }
@@ -136,6 +141,6 @@
             lessons: lessonQ.promise,
             prevLesson: prevLesson,
             nextLesson: nextLesson
-        }
+        };
     }
-]);
+]);
\ No newline at end of file
diff --git a/static/js/values.js b/static/js/values.js
index 556bee4..3d35864 100644
--- a/static/js/values.js
+++ b/static/js/values.js
@@ -7,7 +7,7 @@
 angular.module('tour.values', []).
 
 // List of modules with description and lessons in it.
-value('TableOfContents', [{
+value('tableOfContents', [{
     'id': 'mechanics',
     'title': 'Using the tour',
     'description': '<p>Welcome to a tour of the <a href="http://golang.org">Go programming language</a>. The tour covers the most important features of the language, mainly:</p>',
@@ -29,23 +29,23 @@
     'lessons': ['concurrency']
 }]).
 
-// Translation
-value('Translation', {
-    "off": "off",
-    "on": "on",
-    "syntax": "Syntax-Highlighting",
-    "lineno": "Line-Numbers",
-    "reset": "Reset Slide",
-    "format": "Format Source Code",
-    "kill": "Kill Program",
-    "run": "Run",
-    "compile": "Compile and Run",
-    "more": "Options",
-    "toc": "Table of Contents",
-    "prev": "Previous",
-    "next": "Next",
-    "waiting": "Waiting for remote server...",
-    "errcomm": "Error communicating with remote server.",
+// translation
+value('translation', {
+    'off': 'off',
+    'on': 'on',
+    'syntax': 'Syntax-Highlighting',
+    'lineno': 'Line-Numbers',
+    'reset': 'Reset Slide',
+    'format': 'Format Source Code',
+    'kill': 'Kill Program',
+    'run': 'Run',
+    'compile': 'Compile and Run',
+    'more': 'Options',
+    'toc': 'Table of Contents',
+    'prev': 'Previous',
+    'next': 'Next',
+    'waiting': 'Waiting for remote server...',
+    'errcomm': 'Error communicating with remote server.',
 }).
 
 // Config for codemirror plugin
@@ -58,18 +58,18 @@
         indentWithTabs: true,
         lineWrapping: true,
         extraKeys: {
-            "Shift-Enter": function() {
+            'Shift-Enter': function() {
                 $('#run').click();
             },
-            "PageDown": function() {
+            'PageDown': function() {
                 return false;
             },
-            "PageUp": function() {
+            'PageUp': function() {
                 return false;
             },
-            "Shift-Space": function() {
+            'Shift-Space': function() {
                 $('#format').click();
             },
         }
     }
-});
+});
\ No newline at end of file
diff --git a/static/partials/editor.html b/static/partials/editor.html
index e912888..20f5c11 100644
--- a/static/partials/editor.html
+++ b/static/partials/editor.html
@@ -2,28 +2,28 @@
     <div class="relative-content" ng->
         <div vertical-slide left="#left-side" right="#right-side"></div>
         <div id="right-side">
-            <div class="relative-content" autofocus="TOC.lessons[lessonId].Pages[curPage-1].Files.length==0">
-                <div class="slide-content" ng-bind-html-unsafe="TOC.lessons[lessonId].Pages[curPage-1].Content"></div>
+            <div class="relative-content" autofocus="toc.lessons[lessonId].Pages[curPage-1].Files.length==0">
+                <div class="slide-content" ng-bind-html-unsafe="toc.lessons[lessonId].Pages[curPage-1].Content"></div>
 
                 <div class="bar module-bar">
                     <a href="" class="prev-page" ng-click="prevPage()">&lt;</a>
-                    <span>{{curPage}}/{{TOC.lessons[lessonId].Pages.length}}</span>
+                    <span>{{curPage}}/{{toc.lessons[lessonId].Pages.length}}</span>
                     <a href="" class="next-page" ng-click="nextPage()">&gt;</a>
                 </div>
             </div>
         </div>
 
         <div id="left-side" class="relative-content">
-            <div id="explorer" ng-class="{hidden: TOC.lessons[lessonId].Pages[curPage-1].Files.length==0}">
-                <a class="menu-button" ng-repeat="f in TOC.lessons[lessonId].Pages[curPage-1].Files" ng-click="openFile($index)" ng-class="{active: $index==curFile}">{{f.Name}}</a>
+            <div id="explorer" ng-class="{hidden: toc.lessons[lessonId].Pages[curPage-1].Files.length==0}">
+                <a class="menu-button" ng-repeat="f in toc.lessons[lessonId].Pages[curPage-1].Files" ng-click="openFile($index)" ng-class="{active: $index==curFile}">{{f.Name}}</a>
             </div>
 
-            <div class="relative-content" ng-class="{hidden: TOC.lessons[lessonId].Pages[curPage-1].Files.length==0}">
+            <div class="relative-content" ng-class="{hidden: toc.lessons[lessonId].Pages[curPage-1].Files.length==0}">
 
                 <div id="top-part">
                     <div class="relative-content">
                         <div id="file-editor">
-                            <textarea ui-codemirror ng-model="TOC.lessons[lessonId].Pages[curPage-1].Files[curFile].Content"></textarea>
+                            <textarea ui-codemirror ng-model="toc.lessons[lessonId].Pages[curPage-1].Files[curFile].Content"></textarea>
                         </div>
                     </div>
                 </div>
@@ -39,7 +39,7 @@
                             <a syntax-checkbox ng-class="{active: editor.syntax}" class="menu-button syntax-checkbox">Syntax</a>
                         </div>
 
-                        <div class="output" ng-repeat="f in TOC.lessons[lessonId].Pages[curPage-1].Files" ng-class="{active: $index==curFile}" ng-bind-html-unsafe="f.Output">
+                        <div class="output" ng-repeat="f in toc.lessons[lessonId].Pages[curPage-1].Files" ng-class="{active: $index==curFile}" ng-bind-html-unsafe="f.Output">
                         </div>
                     </div>
                 </div>