Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix for issue546 - jslint errors in the code examples (getting-started-guide) #548

Closed
wants to merge 2 commits into from

4 participants

@dmitris

RE #546

This pull requests fixes or at least sliences all the JSLint errors and warnings in examples/getting-started-guide. The fixes for the developer-guide are stil TODO (dmitris@d466d17 is the first one)

@dmitris

Let me know if this is right way to fix the jslint issues and worth to continue.

@drewfish
Owner

Hi Dmitri,

This looks great! We're already doing a lot of /*jslint anon:true, sloppy:true, nomen:true, node:true*/ in other places in Mojito, so that approach is valid. (If we change our mind about that, we'll have a lot of other things to change as well.)

One thing: so far in Mojito we've been trying to honor plusplus:false, so that means changing the for (...; ...; i++) to for (...; ...; i += 1).

@dmitris

what about the idiom:

var x, y, z, i = 0;
for (; i < 10; i += 1) {}

I read that it is done to save a few bites (minification). What should we change it to? I did in several examples:

var x, y, z, i;
for (i = 0; i < 10; ...

is it right?

@caridy
Owner

Can we close this? /cc @zhouyaoji @drewfish @lzhan

@drewfish
Owner

The following examples have jslint errors:

  • developer-guide/binding_events
  • developer-guide/configure_routing
  • developer-guide/device_views
  • developer-guide/framed_assets
  • developer-guide/framed_config
  • developer-guide/generating_urls
  • developer-guide/hello
  • developer-guide/htmlframe_mojit
  • developer-guide/inter-mojit
  • developer-guide/locale_i18n
  • developer-guide/model_yql
  • developer-guide/multiple_mojits
  • developer-guide/scroll_views
  • developer-guide/simple_assets
  • developer-guide/simple_config
  • developer-guide/simple_logging
  • developer-guide/simple_view
  • developer-guide/using_cookies
  • developer-guide/using_parameters
  • getting-started-guide/part2/basic_yql
  • getting-started-guide/part3/intl-templates
  • getting-started-guide/part4/paged-yql
  • getting-started-guide/part5/flickr-list
  • input/cookies
  • input/get
  • input/merged
  • input/post
  • input/route
  • performance/string
  • sandbox/bindercomm
  • sandbox/binderrender
  • sandbox/bindertime
  • sandbox/controller-state
  • sandbox/lazy_load
  • sandbox/metabubble
  • sandbox/server_side
  • sandbox/strangeloop
  • sandbox/view_refresh
  • sandbox/yuiconf
  • simple/part3
  • simple/part4
  • simple/part5
  • simple/part6
  • simple/part7
  • simple/part8
@caridy
Owner

Can we close this PR? /ping @zhouyaoji @drewfish

@drewfish
Owner

We still have a lot of examples that are failing jslint.

@imalberto imalberto closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 210 additions and 152 deletions.
  1. +27 −25 examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js
  2. +26 −24 examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js
  3. +3 −1 examples/developer-guide/binding_events/mojits/PagerMojit/binders/index.js
  4. +2 −2 examples/developer-guide/yui_module/autoload/storage-lite.client.js
  5. +2 −1  examples/developer-guide/yui_module/mojits/Notepad/binders/index.js
  6. +1 −0  examples/getting-started-guide/part1/hello/mojits/HelloMojit/controller.server.js
  7. +3 −3 examples/getting-started-guide/part2/basic_yql/index.js
  8. +1 −1  examples/getting-started-guide/part2/basic_yql/mojits/Flickr/controller.server.js
  9. +11 −8 examples/getting-started-guide/part2/basic_yql/mojits/Flickr/models/model.server.js
  10. +3 −3 examples/getting-started-guide/part3/intl-templates/index.js
  11. +6 −3 examples/getting-started-guide/part3/intl-templates/mojits/Flickr/controller.server.js
  12. +2 −1  examples/getting-started-guide/part3/intl-templates/mojits/Flickr/lang/Flickr.js
  13. +1 −1  examples/getting-started-guide/part3/intl-templates/mojits/Flickr/lang/Flickr_de.js
  14. +10 −8 examples/getting-started-guide/part3/intl-templates/mojits/Flickr/models/model.server.js
  15. +2 −1  examples/getting-started-guide/part3/intl-templates/server.js
  16. +3 −3 examples/getting-started-guide/part4/paged-yql/index.js
  17. +9 −7 examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/binders/index.js
  18. +15 −12 examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/controller.common.js
  19. +1 −0  examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/lang/PagedFlickr_de.js
  20. +1 −0  examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/lang/PagedFlickr_en-US.js
  21. +11 −10 examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/models/model.common.js
  22. +2 −1  examples/getting-started-guide/part4/paged-yql/server.js
  23. +14 −13 examples/getting-started-guide/part5/flickr-list/models/flickr.common.js
  24. +2 −0  examples/getting-started-guide/part5/flickr-list/mojits/FlickrBrowser/assets/logmutator.js
  25. +2 −0  examples/getting-started-guide/part5/flickr-list/mojits/FlickrBrowser/binders/index.js
  26. +1 −0  examples/getting-started-guide/part5/flickr-list/mojits/FlickrBrowser/controller.common.js
  27. +7 −5 examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/binders/index.js
  28. +2 −0  examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/binders/message.js
  29. +4 −2 examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/controller.common.js
  30. +2 −0  examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/lang/FlickrDetail_de.js
  31. +2 −0  examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/lang/FlickrDetail_en-US.js
  32. +8 −5 examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/binders/index.js
  33. +22 −12 examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/controller.common.js
  34. +1 −0  examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/lang/PagedFlickr_de.js
  35. +1 −0  examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/lang/PagedFlickr_en-US.js
View
52 examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js
@@ -1,33 +1,35 @@
-YUI.add('addons-viewengine-ejs', function(Y, NAME) {
+/*jslint anon:true, sloppy:true, nomen:true, node:true, stupid: true */
- var ejs = require('ejs'),
- fs = require('fs');
- function EjsAdapter(viewId) {
- this.viewId = viewId;
- }
- EjsAdapter.prototype = {
+YUI.add('addons-viewengine-ejs', function(Y, NAME) {
- render: function(data, mojitType, tmpl, adapter, meta, more) {
- var me = this,
- handleRender = function(output) {
+ var ejs = require('ejs'),
+ fs = require('fs');
+ function EjsAdapter(viewId) {
+ this.viewId = viewId;
+ }
+ EjsAdapter.prototype = {
+ render: function(data, mojitType, tmpl, adapter, meta, more) {
+ var me, handleRender, result;
+ me = this;
+ handleRender = function(output) {
output.addListener('data', function(c) {
- adapter.flush(c, meta);
+ adapter.flush(c, meta);
});
output.addListener('end', function() {
- if (!more) {
- adapter.done('', meta);
- }
+ if (!more) {
+ adapter.done('', meta);
+ }
});
- };
- Y.log('Rendering template "' + tmpl + '"', 'mojito', NAME);
- var result = ejs.render(this.compiler(tmpl),data);
- console.log(result);
- adapter.done(result,meta);
- },
- compiler: function(tmpl) {
- return fs.readFileSync(tmpl, 'utf8');
- }
- };
- Y.namespace('mojito.addons.viewEngines').ejs = EjsAdapter;
+ };
+ Y.log('Rendering template "' + tmpl + '"', 'mojito', NAME);
+ result = ejs.render(this.compiler(tmpl), data);
+ console.log(result);
+ adapter.done(result, meta);
+ },
+ compiler: function(tmpl) {
+ return fs.readFileSync(tmpl, 'utf8');
+ }
+ };
+ Y.namespace('mojito.addons.viewEngines').ejs = EjsAdapter;
}, '0.1.0', {requires: []});
View
50 examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js
@@ -1,28 +1,30 @@
+/*jslint anon:true, sloppy:true, nomen:true, node:true */
+
YUI.add('myMojit', function(Y, NAME) {
- Y.mojito.controllers[NAME] = {
+ Y.mojito.controllers[NAME] = {
- init: function(config) {
- this.config = config;
- },
- default_ve: function(ac) {
- ac.done({
- "title": "Handlebars at work!",
- "view_engines": [
- {"name": "EJS"},
- {"name": "Jade"},
- {"name": "dust"},
- {"name": "underscore" }
- ],
- "ul": { "title": 'Here are some of the other available rendering engines:' },
- });
- },
- added_ve: function(ac) {
- ac.done({
- "title": "EJS at work!",
- "view_engines": [ "Jade", "Dust","underscore" ],
- "ul": { "title": 'In addition to Handlebars and EJS, you can also use these rendering engines:' }
- });
- }
- };
+ init: function(config) {
+ this.config = config;
+ },
+ default_ve: function(ac) {
+ ac.done({
+ "title": "Handlebars at work!",
+ "view_engines": [
+ {"name": "EJS"},
+ {"name": "Jade"},
+ {"name": "dust"},
+ {"name": "underscore" }
+ ],
+ "ul": { "title": 'Here are some of the other available rendering engines:' }
+ });
+ },
+ added_ve: function(ac) {
+ ac.done({
+ "title": "EJS at work!",
+ "view_engines": [ "Jade", "Dust", "underscore" ],
+ "ul": { "title": 'In addition to Handlebars and EJS, you can also use these rendering engines:' }
+ });
+ }
+ };
}, '0.0.1', {requires: ['mojito', 'myMojitModelFoo']});
View
4 examples/developer-guide/binding_events/mojits/PagerMojit/binders/index.js
@@ -4,7 +4,9 @@
* See the accompanying LICENSE file for terms.
*/
-YUI.add('PagerMojitBinder', function (Y, NAME) {
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
+YUI.add('PagerMojitBinder', function(Y, NAME) {
var API_KEY = '9cc79c8bf1942c683b0d4e30b838ee9c';
/**
View
4 examples/developer-guide/yui_module/autoload/storage-lite.client.js
@@ -15,7 +15,7 @@
* @module gallery-storage-lite
*/
-YUI.add('gallery-storage-lite', function (Y) {
+YUI.add('gallery-storage-lite', function(Y) {
// -- Shorthand ----------------------------------------------------------------
var d = Y.config.doc,
@@ -297,7 +297,7 @@ if (storageMode === MODE_HTML5 || storageMode === MODE_GECKO) {
}
}, true);
- Y.on('domready', function () {
+ Y.on('domready', function() {
d.body.appendChild(storageDriver);
storageDriver.load(USERDATA_PATH);
View
3  examples/developer-guide/yui_module/mojits/Notepad/binders/index.js
@@ -4,7 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
-YUI.add('NotepadBinderIndex', function (Y, NAME) {
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+YUI.add('NotepadBinderIndex', function(Y, NAME) {
Y.namespace('mojito.binders')[NAME] = {
View
1  examples/getting-started-guide/part1/hello/mojits/HelloMojit/controller.server.js
@@ -4,6 +4,7 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add('HelloMojit', function(Y, NAME) {
/**
View
6 examples/getting-started-guide/part2/basic_yql/index.js
@@ -16,13 +16,13 @@ process.chdir(__dirname);
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
- var server = require('./server.js');
- var YUI = require('mojito').YUI;
+ var server = require('./server.js'),
+ YUI = require('mojito').YUI;
YUI().use('mojito-server', function(Y) {
var app = server(Y);
// Signal the app is ready, providing the token and app references.
process.emit("application-ready", token, app);
- });
+ });
};
View
2  examples/getting-started-guide/part2/basic_yql/mojits/Flickr/controller.server.js
@@ -4,6 +4,7 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add('Flickr', function(Y, NAME) {
/**
@@ -11,7 +12,6 @@ YUI.add('Flickr', function(Y, NAME) {
*
* @module Flickr
*/
-
Y.namespace('mojito.controllers')[NAME] = {
/**
View
19 examples/getting-started-guide/part2/basic_yql/mojits/Flickr/models/model.server.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true, plusplus: true */
+
YUI.add('FlickrModel', function(Y) {
var API_KEY = '9cc79c8bf1942c683b0d4e30b838ee9c';
@@ -12,6 +14,11 @@ YUI.add('FlickrModel', function(Y) {
*
* @module FlickrModel
*/
+ function buildFlickrUrlFromRecord(record) {
+ return 'http://farm' + record.farm +
+ '.static.flickr.com/' + record.server +
+ '/' + record.id + '_' + record.secret + '.jpg';
+ }
Y.mojito.models.flickr = {
@@ -27,12 +34,12 @@ YUI.add('FlickrModel', function(Y) {
Y.YQL(q, function(rawYqlData) {
Y.log(rawYqlData);
var rawPhotos = rawYqlData.query.results.photo,
- rawPhoto = null
+ rawPhoto = null,
photos = [],
photo = null,
- i = 0;
+ i;
- for (; i<rawPhotos.length; i++) {
+ for (i = 0; i < rawPhotos.length; i++) {
rawPhoto = rawPhotos[i];
photo = {
title: rawPhoto.title,
@@ -53,11 +60,7 @@ YUI.add('FlickrModel', function(Y) {
};
- function buildFlickrUrlFromRecord(record) {
- return 'http://farm' + record.farm
- + '.static.flickr.com/' + record.server
- + '/' + record.id + '_' + record.secret + '.jpg';
- }
+
// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
}, '0.0.1', {requires: ['yql', 'jsonp-url']});
View
6 examples/getting-started-guide/part3/intl-templates/index.js
@@ -16,13 +16,13 @@ process.chdir(__dirname);
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
- var server = require('./server.js');
- var YUI = require('mojito').YUI;
+ var server = require('./server.js'),
+ YUI = require('mojito').YUI;
YUI().use('mojito-server', function(Y) {
var app = server(Y);
// Signal the app is ready, providing the token and app references.
process.emit("application-ready", token, app);
- });
+ });
};
View
9 examples/getting-started-guide/part3/intl-templates/mojits/Flickr/controller.server.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('Flickr', function(Y, NAME) {
/**
@@ -22,12 +24,13 @@ YUI.add('Flickr', function(Y, NAME) {
*/
index: function(ac) {
ac.models.flickr.getFlickrImages('mojito', function(images) {
- var dateString = ac.intl.formatDate(new Date());
- var data = {
+ var dateString, data;
+ dateString = ac.intl.formatDate(new Date());
+ data = {
images: images,
date: dateString,
greeting: ac.intl.lang("TITLE"),
- url: ac.url.make('flickr','index')
+ url: ac.url.make('flickr', 'index')
};
ac.done(data);
});
View
3  examples/getting-started-guide/part3/intl-templates/mojits/Flickr/lang/Flickr.js
@@ -4,8 +4,9 @@
* See the accompanying LICENSE file for terms.
*/
-YUI.add("lang/Flickr", function(Y) {
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+YUI.add("lang/Flickr", function(Y) {
Y.Intl.add(
"Flickr", // associated module
View
2  examples/getting-started-guide/part3/intl-templates/mojits/Flickr/lang/Flickr_de.js
@@ -4,8 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add("lang/Flickr_de", function(Y) {
-
Y.Intl.add(
"Flickr", // associated module
View
18 examples/getting-started-guide/part3/intl-templates/mojits/Flickr/models/model.server.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true, plusplus: true*/
+
YUI.add('FlickrModel', function(Y) {
var API_KEY = '9cc79c8bf1942c683b0d4e30b838ee9c';
@@ -13,6 +15,12 @@ YUI.add('FlickrModel', function(Y) {
* @module FlickrModel
*/
+ function buildFlickrUrlFromRecord(record) {
+ return 'http://farm' + record.farm +
+ '.static.flickr.com/' + record.server +
+ '/' + record.id + '_' + record.secret + '.jpg';
+ }
+
Y.mojito.models.flickr = {
/**
@@ -29,9 +37,8 @@ YUI.add('FlickrModel', function(Y) {
rawPhoto = null,
photos = [],
photo = null,
- i = 0;
-
- for (; i<rawPhotos.length; i++) {
+ i;
+ for (i = 0; i < rawPhotos.length; i++) {
rawPhoto = rawPhotos[i];
photo = {
title: rawPhoto.title,
@@ -52,11 +59,6 @@ YUI.add('FlickrModel', function(Y) {
};
- function buildFlickrUrlFromRecord(record) {
- return 'http://farm' + record.farm
- + '.static.flickr.com/' + record.server
- + '/' + record.id + '_' + record.secret + '.jpg';
- }
// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
}, '0.0.1', {requires: ['yql', 'jsonp-url']});
View
3  examples/getting-started-guide/part3/intl-templates/server.js
@@ -4,4 +4,5 @@
* See the accompanying LICENSE file for terms.
*/
-module.exports = require('mojito').createServer({dir:__dirname});
+/*jslint nomen: true*/
+module.exports = require('mojito').createServer({dir: __dirname});
View
6 examples/getting-started-guide/part4/paged-yql/index.js
@@ -16,13 +16,13 @@ process.chdir(__dirname);
* @param {object} token Token used to identify the application.
*/
module.exports = function(config, token) {
- var server = require('./server.js');
- var YUI = require('mojito').YUI;
+ var server = require('./server.js'),
+ YUI = require('mojito').YUI;
YUI().use('mojito-server', function(Y) {
var app = server(Y);
// Signal the app is ready, providing the token and app references.
process.emit("application-ready", token, app);
- });
+ });
};
View
16 examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/binders/index.js
@@ -4,10 +4,11 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
function getPage(href) {
- return href.split('/').pop().split('=').pop()
+ return href.split('/').pop().split('=').pop();
}
Y.namespace('mojito.binders')[NAME] = {
@@ -17,12 +18,13 @@ YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
},
bind: function(node) {
- var self = this;
+ var self = this,
+ paginator;
this.node = node;
- var paginator = function(evt) {
+ paginator = function(evt) {
- var tgt = evt.target;
- var page = getPage(tgt.get('href'));
+ var tgt = evt.target,
+ page = getPage(tgt.get('href'));
evt.halt();
@@ -32,11 +34,11 @@ YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
route: {page: page}
}
});
-
+
};
this.node.all('#paginate a').on('click', paginator, this);
}
-
+
};
}, '0.0.1', {requires: []});
View
27 examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/controller.common.js
@@ -4,10 +4,20 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('PagedFlickr', function(Y, NAME) {
var PAGESIZE = 9;
+ function selfUrl(ac, page) {
+ // No real link for pages before page 1
+ if (page < 1) { return '#'; }
+ var params = ac.params.url();
+ params.page = page; // provide the page we want to createa URL to
+ return ac.url.make('flickr', 'index', Y.QueryString.stringify(params));
+ }
+
Y.namespace('mojito.controllers')[NAME] = {
index: function(ac) {
@@ -22,7 +32,7 @@ YUI.add('PagedFlickr', function(Y, NAME) {
// The "page" parameter is base-1, but the model's "start"
// parameter is base-0.
- start = (page-1) * PAGESIZE;
+ start = (page - 1) * PAGESIZE;
ac.models.flickr.getFlickrImages('mojito', start, PAGESIZE, function(err, images) {
@@ -39,28 +49,21 @@ YUI.add('PagedFlickr', function(Y, NAME) {
date: dateString,
greeting: ac.intl.lang("TITLE") || 'title',
prev: {
- url: selfUrl(ac, page-1 ),
+ url: selfUrl(ac, page - 1),
title: ac.intl.lang("PREV") || 'prev'
},
next: {
- url: selfUrl(ac, page+1),
+ url: selfUrl(ac, page + 1),
title: ac.intl.lang("NEXT") || 'next'
}
};
ac.done(data);
-
+
});
}
};
-
- function selfUrl(ac, page) {
- // No real link for pages before page 1
- if (page < 1) { return '#'; }
- var params = ac.params.url();
- params.page = page; // provide the page we want to createa URL to
- return ac.url.make('flickr', 'index', Y.QueryString.stringify(params));
- }
+
}, '0.0.1', {requires: [
View
1  examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/lang/PagedFlickr_de.js
@@ -4,6 +4,7 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add("lang/PagedFlickr_de", function(Y) {
Y.Intl.add(
View
1  examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/lang/PagedFlickr_en-US.js
@@ -4,6 +4,7 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add("lang/PagedFlickr_en-US", function(Y) {
Y.Intl.add(
View
21 examples/getting-started-guide/part4/paged-yql/mojits/PagedFlickr/models/model.common.js
@@ -4,15 +4,22 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true, plusplus: true*/
YUI.add('PagedFlickrModel', function(Y) {
var API_KEY = '9cc79c8bf1942c683b0d4e30b838ee9c';
+ function buildFlickrUrlFromRecord(record) {
+ return 'http://farm' + record.farm +
+ '.static.flickr.com/' + record.server +
+ '/' + record.id + '_' + record.secret + '.jpg';
+ }
+
Y.mojito.models.flickr = {
getFlickrImages: function(queryString, start, count, callback) {
var q;
- start = parseInt(start) || 0;
- count = parseInt(count) || 10;
+ start = parseInt(start, 10) || 0;
+ count = parseInt(count, 10) || 10;
// The YQL docs say that the second number is the end, but in practice
// it appears to be the count.
// http://developer.yahoo.com/yql/guide/paging.html#remote_limits
@@ -27,12 +34,12 @@ YUI.add('PagedFlickrModel', function(Y) {
rawPhoto = null,
photos = [],
photo = null,
- i = 0;
+ i;
// Sometimes YQL returns more than the requested amount.
rawPhotos.splice(count);
- for (; i<rawPhotos.length; i++) {
+ for (i = 0; i < rawPhotos.length; i++) {
rawPhoto = rawPhotos[i];
photo = {
title: rawPhoto.title,
@@ -52,11 +59,5 @@ YUI.add('PagedFlickrModel', function(Y) {
};
- function buildFlickrUrlFromRecord(record) {
- return 'http://farm' + record.farm
- + '.static.flickr.com/' + record.server
- + '/' + record.id + '_' + record.secret + '.jpg';
- }
-
// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
}, '0.0.1', {requires: ['yql', 'jsonp-url']});
View
3  examples/getting-started-guide/part4/paged-yql/server.js
@@ -4,4 +4,5 @@
* See the accompanying LICENSE file for terms.
*/
-module.exports = require('mojito').createServer({dir:__dirname});
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+module.exports = require('mojito').createServer({dir: __dirname});
View
27 examples/getting-started-guide/part5/flickr-list/models/flickr.common.js
@@ -4,15 +4,22 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true, plusplus: true*/
YUI.add('ModelFlickr', function(Y, NAME) {
var API_KEY = '9cc79c8bf1942c683b0d4e30b838ee9c';
+ function buildFlickrUrlFromRecord(record) {
+ return 'http://farm' + record.farm +
+ '.static.flickr.com/' + record.server +
+ '/' + record.id + '_' + record.secret + '.jpg';
+ }
+
Y.mojito.models.flickr = {
getFlickrImages: function(queryString, start, count, callback) {
var q;
- start = parseInt(start) || 0;
- count = parseInt(count) || 10;
+ start = parseInt(start, 10) || 0;
+ count = parseInt(count, 10) || 10;
// The YQL docs say that the second number is the end, but in practice
// it appears to be the count.
// http://developer.yahoo.com/yql/guide/paging.html#remote_limits
@@ -23,12 +30,12 @@ YUI.add('ModelFlickr', function(Y, NAME) {
return;
}
var rawPhotos = rawYqlData.query.results.photo,
- rawPhoto = null,
- photos = [],
- photo = null,
- i = 0;
+ rawPhoto = null,
+ photos = [],
+ photo = null,
+ i;
- for (; i < rawPhotos.length; i++) {
+ for (i = 0; i < rawPhotos.length; i++) {
rawPhoto = rawPhotos[i];
photo = {
id: rawPhoto.id,
@@ -63,11 +70,5 @@ YUI.add('ModelFlickr', function(Y, NAME) {
};
- function buildFlickrUrlFromRecord(record) {
- return 'http://farm' + record.farm
- + '.static.flickr.com/' + record.server
- + '/' + record.id + '_' + record.secret + '.jpg';
- }
-
// TODO: remove 'jsonp-url' requirement when YUI fix for bug http://yuilibrary.com/projects/yui3/ticket/2530251 is deployed.
}, '0.0.1', {requires: ['yql', 'jsonp-url']});
View
2  examples/getting-started-guide/part5/flickr-list/mojits/FlickrBrowser/assets/logmutator.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('flickr-logger-mutator', function(Y) {
/*
View
2  examples/getting-started-guide/part5/flickr-list/mojits/FlickrBrowser/binders/index.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('FlickrBrowserBinderIndex', function(Y, NAME) {
/**
View
1  examples/getting-started-guide/part5/flickr-list/mojits/FlickrBrowser/controller.common.js
@@ -3,6 +3,7 @@
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add('FlickrBrowser', function(Y, NAME) {
View
12 examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/binders/index.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('FlickrDetailBinderIndex', function(Y, NAME) {
/**
@@ -21,7 +23,7 @@ YUI.add('FlickrDetailBinderIndex', function(Y, NAME) {
* @class Binder
* @constructor
*/
-
+
Y.namespace('mojito.binders')[NAME] = {
/**
@@ -33,10 +35,10 @@ YUI.add('FlickrDetailBinderIndex', function(Y, NAME) {
this.mojitProxy = mojitProxy;
this.mojitProxy.listen('flickr-image-detail', function(payload) {
Y.log('on flickr-image-detail ' + payload.data.id, 'debug', NAME);
- var urlParams = Y.mojito.util.copy(mojitProxy.context);
- var routeParams = {
- image: payload.data.id
- };
+ var urlParams = Y.mojito.util.copy(mojitProxy.context),
+ routeParams = {
+ image: payload.data.id
+ };
mojitProxy.refreshView({
params: {
url: urlParams,
View
2  examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/binders/message.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('FlickrDetailBinderMessage', function(Y, NAME) {
/**
View
6 examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/controller.common.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('FlickrDetail', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
@@ -15,13 +17,13 @@ YUI.add('FlickrDetail', function(Y, NAME) {
// a little paranoia about inputs
if (!image.match(/^\d+$/)) {
ac.assets.addCss('./message.css');
- ac.done({ type: 'error', message: ac.intl.lang('ERROR_BAD_IMAGE_ID') }, { view: { name:'message' } });
+ ac.done({ type: 'error', message: ac.intl.lang('ERROR_BAD_IMAGE_ID') }, { view: { name: 'message'} });
return;
}
if ('0' === image) {
ac.assets.addCss('./message.css');
- ac.done({ type: 'info', message: ac.intl.lang('INFO_NO_IMAGE_CHOSEN') }, { view: { name:'message' } });
+ ac.done({ type: 'info', message: ac.intl.lang('INFO_NO_IMAGE_CHOSEN') }, { view: { name: 'message'} });
return;
}
View
2  examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/lang/FlickrDetail_de.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add("lang/FlickrDetail_de", function(Y) {
Y.Intl.add(
View
2  examples/getting-started-guide/part5/flickr-list/mojits/FlickrDetail/lang/FlickrDetail_en-US.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add("lang/FlickrDetail_en-US", function(Y) {
Y.Intl.add(
View
13 examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/binders/index.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
/**
@@ -21,7 +23,7 @@ YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
* @class Binder
* @constructor
*/
-
+
Y.namespace('mojito.binders')[NAME] = {
/**
@@ -40,10 +42,11 @@ YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
*/
bind: function(node) {
node.all('.pic a').on('click', function(evt) {
- var url = evt.currentTarget.get('href');
+ var imageID, matches, url;
+ url = evt.currentTarget.get('href');
Y.log('on click ' + url, 'debug', NAME);
- var matches = url.match(/image\/(\d+)/);
- var imageID = matches[1];
+ matches = url.match(/image\/(\d+)/);
+ imageID = matches[1];
if (imageID) {
evt.halt();
@@ -51,7 +54,7 @@ YUI.add('PagedFlickrBinderIndex', function(Y, NAME) {
// to the server, we persist the image choice.
node.all('#paginate a').each(function(pageLink) {
var pageUrl = pageLink.get('href');
- pageLink.set('href', pageUrl.replace(/\/image\/\d+/, '/image/'+imageID));
+ pageLink.set('href', pageUrl.replace(/\/image\/\d+/, '/image/' + imageID));
});
Y.log('broadcast flickr-image-chosen ' + imageID, 'debug', NAME);
View
34 examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/controller.common.js
@@ -4,6 +4,8 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
YUI.add('PagedFlickr', function(Y, NAME) {
/**
@@ -20,6 +22,19 @@ YUI.add('PagedFlickr', function(Y, NAME) {
* @class Controller
* @constructor
*/
+
+ function selfUrl(ac, mojitType, mods) {
+ var k,
+ params = Y.mojito.util.copy(ac.params.merged());
+ for (k in mods) {
+ // jslint says: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
+ if (mods.hasOwnProperty(k)) {
+ params[k] = mods[k];
+ }
+ }
+ return ac.url.make(mojitType, 'index', Y.QueryString.stringify(params));
+ }
+
Y.namespace('mojito.controllers')[NAME] = {
/**
@@ -28,6 +43,7 @@ YUI.add('PagedFlickr', function(Y, NAME) {
* @param ac {Object} The action context that provides access
* to the Mojito API.
*/
+
index: function(ac) {
Y.log(ac.params.all());
@@ -43,10 +59,10 @@ YUI.add('PagedFlickr', function(Y, NAME) {
// The "page" parameter is base-1, but the model's "start"
// parameter is base-0.
- start = (page-1) * PAGESIZE;
+ start = (page - 1) * PAGESIZE;
ac.models.flickr.getFlickrImages('mojito', start, PAGESIZE, function(err, images) {
- var dateString, data;
+ var dateString, data;
// on model error, fail fast
if (err) {
@@ -58,11 +74,11 @@ YUI.add('PagedFlickr', function(Y, NAME) {
date: dateString,
greeting: ac.intl.lang("TITLE"),
prev: {
- url: selfUrl(ac, 'flickr', { page: page-1 } ),
+ url: selfUrl(ac, 'flickr', { page: page - 1 }),
title: ac.intl.lang("PREV") || 'prev'
},
next: {
- url: selfUrl(ac, 'flickr', { page: page+1 } ),
+ url: selfUrl(ac, 'flickr', { page: page + 1 }),
title: ac.intl.lang("NEXT") || 'next'
}
};
@@ -73,7 +89,7 @@ YUI.add('PagedFlickr', function(Y, NAME) {
data.images = images;
if (page > 1) {
- data.prev.url = selfUrl(ac, 'flickr', { page: page-1 });
+ data.prev.url = selfUrl(ac, 'flickr', { page: page - 1 });
data.has_prev = true;
}
ac.done(data);
@@ -82,12 +98,6 @@ YUI.add('PagedFlickr', function(Y, NAME) {
}
};
- function selfUrl(ac, mojitType, mods) {
- var params = Y.mojito.util.copy(ac.params.merged());
- for (var k in mods) {
- params[k] = mods[k];
- }
- return ac.url.make(mojitType, 'index', Y.QueryString.stringify(params));
- }
+
}, '0.0.1', {requires: ['mojito-intl-addon', 'mojito-util', 'querystring-stringify', 'ModelFlickr'], lang: ['de', 'en-US']});
View
1  examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/lang/PagedFlickr_de.js
@@ -4,6 +4,7 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add("lang/PagedFlickr_de", function(Y) {
Y.Intl.add(
View
1  examples/getting-started-guide/part5/flickr-list/mojits/PagedFlickr/lang/PagedFlickr_en-US.js
@@ -4,6 +4,7 @@
* See the accompanying LICENSE file for terms.
*/
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
YUI.add("lang/PagedFlickr_en-US", function(Y) {
Y.Intl.add(
Something went wrong with that request. Please try again.