Permalink
Browse files

Fixing Lint errors

  • Loading branch information...
operatino committed Oct 2, 2014
1 parent e5bcaad commit 6dc309e8eb189ec9b96cf3ca1eba351792ced8bb
View
@@ -1,5 +1,4 @@
{
"es3": true,
"eqeqeq": true,
"expr": true,
"forin": true,
@@ -20,5 +19,5 @@
"browser": true,
"scripturl": true,
"jquery": true,
"predef": [ "define", "Prism" ]
"predef": [ "define", "Prism", "SourceGetSections"]
}
View
@@ -38,6 +38,7 @@ module.exports = function(grunt) {
// routing files are added into exceptions to avoid adding extra rules for express framework
core: ["core/**/*.js", "!core/routes/*.js"]
},
copy: {
js: {
expand: true,
@@ -1,3 +1,5 @@
'use strict';
define([
"jquery",
"sourceModules/module",
@@ -78,7 +78,7 @@ define([
var newItem = this.menuItemTemplate.clone();
if (typeof className === 'string' && className !== '') {
newItem.addClass(id);
newItem.addClass(className);
}
actionsArr.forEach(function(action, index){
@@ -92,7 +92,7 @@ define([
if (ctx) {
action.callback.apply(ctx);
} else {
action.callback()
action.callback();
}
});
@@ -43,10 +43,10 @@ define(["sourceModules/module", "sourceModules/utils"], function(module, utils)
function phantomHook(event) {
console.log('PhantomJS hook: %s', event);
if (typeof window.callPhantom == 'function') {
if (typeof window.callPhantom === 'function') {
window.callPhantom({message: event});
}
};
}
function generateSuccessEvent(eventName) {
if (debug && utils.isDevelopmentMode()) {
@@ -186,7 +186,7 @@ define(["sourceModules/module", "sourceModules/utils"], function(module, utils)
generateSuccessEvent('allPluginsFinish');
phantomHook('allPluginsFinish');
}, defaultPluginTimeout)
}, defaultPluginTimeout);
return;
}
View
@@ -1,11 +1,13 @@
'use strict';
define([
"jquery",
"sourceModules/module"
'jquery',
'sourceModules/module'
], function($, module) {
function Notification() {
if ($('.source_ntf').length === 0) {
$('.source_container').append('<div class="source_ntf"></div>')
$('.source_container').append('<div class="source_ntf"></div>');
this.$el = $('.source_ntf');
}
@@ -12,16 +12,18 @@
define([
'jquery',
'sourceModules/module',
'text!/api/specs/raw'
], function ($, module, data) {
'text!/api/specs/raw'], function ($, module, data) {
function ParseFileTree() {
this.json = $.parseJSON(data.toString());
}
/* наследуем от Module */
ParseFileTree.prototype = module.createInstance();
ParseFileTree.prototype.constructor = ParseFileTree;
//getSpecificCat = a || [a,b] - Get only listed category, categories
//getCatInfo = bool - Turn on cat info parsing
/**
* Abstract pages tree parser
*
@@ -70,7 +72,7 @@ define([
if (typeof targetSubCatObj === 'object') {
//Need to collect only spec pages objects
if ( checkCatInfo(targetSubCatObj, currentSubCat, getCatInfo) && checkCat(currentCat, getSpecificCat, toCheckCat) ) {
if ( _this.checkCatInfo(targetSubCatObj, currentSubCat, getCatInfo) && _this.checkCat(currentCat, getSpecificCat, toCheckCat) ) {
//Checking if object is already there
if (typeof fileTree[currentSubCat] !== 'object') {
fileTree[currentCat + '/' + currentSubCat] = targetSubCatObj;
@@ -123,7 +125,7 @@ define([
}
}
} else if (checkCat(currentCat, getSpecificCat, toCheckCat)) {
} else if (_this.checkCat(currentCat, getSpecificCat, toCheckCat)) {
//Turn off cat checking in this process, to get all inner folders
//Except other cats in specific cat search mode
@@ -163,7 +165,7 @@ define([
};
var checkCatInfo = function (targetSubCatObj, currentSubCat, getCatInfo) {
ParseFileTree.prototype.checkCatInfo = function (targetSubCatObj, currentSubCat, getCatInfo) {
if (targetSubCatObj) {
//If cat info needed
@@ -1,4 +1,7 @@
function SourceGetSections() {
// Defining strict inside func, because PhantomJS stops evaluating this script if it's on top
'use strict';
var config = {
// include params from opt@argument first
code: 'source_example',
@@ -17,7 +20,6 @@ function SourceGetSections() {
root = false
;
// add attemps limit
function getSections() {
sections = [].slice.call(document.getElementsByClassName(config.h2));
@@ -32,11 +34,8 @@ function SourceGetSections() {
}
else {
return JSON.stringify([{
"error": "Spec page parsing error.",
"url": url
"error": "Spec page parsing error."
}]);
setTimeout(getSections, 200);
}
}
@@ -53,8 +52,6 @@ function SourceGetSections() {
elem = (elem)? elem.nextElementSibling : null;
}
// console.log('Spec starts...#level', elem);
// this.html = getHTML(elem); // @Array with code
// this.ID = returnId();
this.header = section.header || getHeader(elem);
@@ -82,11 +79,11 @@ function SourceGetSections() {
this.html.push(getHTML(elem));
}
else if (flag === 'H3') {
if (prevFlag == 'H4') {
if (prevFlag === 'H4') {
root = true;
}
if (prevFlag == 'H3' || prevFlag == 'H4') {
if (prevFlag === 'H3' || prevFlag === 'H4') {
prevFlag = null;
elem = elem.previousElementSibling;
break;
@@ -97,24 +94,24 @@ function SourceGetSections() {
this.nested.push(new Spec({header: getHeader(elem), next: true}));
}
else if (flag === 'H4') {
if (prevFlag == flag) {
if (prevFlag === flag) {
prevFlag = null;
elem = elem.previousElementSibling;
break;
}
_h4++;
prevFlag = flag;
this.nested.push(new Spec({header: getHeader(elem), next: true}))
this.nested.push(new Spec({header: getHeader(elem), next: true}));
}
if (elem) elem = elem.nextElementSibling;
}
}
// HELPERS
function returnId() {
return [_h2, _h3, _h4].join('.');
}
// function returnId() {
// return [_h2, _h3, _h4].join('.');
// }
function getHeader(elem) {
return elem.innerText || 'API: cannot get header.';
@@ -129,25 +126,27 @@ function SourceGetSections() {
}
function isH2(tag, cls) {
return (tag == 'H2' && cls.match(RegExp('\\b'+ config.h2 + '\\b')))? 'H2' : false;
return (tag === 'H2' && cls.match(new RegExp('\\b'+ config.h2 + '\\b')))? 'H2' : false;
}
function isH3(tag, cls) {
return (tag == 'H3')? 'H3' : false;
function isH3(tag) {
return (tag === 'H3')? 'H3' : false;
}
function isH4(tag, cls) {
return (tag == 'H4')? 'H4': false;
function isH4(tag) {
return (tag === 'H4')? 'H4': false;
}
function isCode(tag, cls) {
return ((tag == 'SECTION' || tag == 'DIV') && cls.match(RegExp('\\b'+ config.code + '\\b')))? 'CODE' : false;
return ((tag === 'SECTION' || tag === 'DIV') && cls.match(new RegExp('\\b'+ config.code + '\\b')))? 'CODE' : false;
}
/* Start parser */
this.output = getSections();
}
SourceGetSections.prototype.get = function(){
'use strict';
return this.output;
};
@@ -1,3 +1,5 @@
'use strict';
/**
* Flatten given data
*
@@ -20,11 +22,11 @@ module.exports = function(data) {
var newKey = prev ? prev + keyAppend : key;
if (typeof value === 'object' && !isSpecFile) {
return step(value, newKey)
return step(value, newKey);
}
output[newKey] = value;
})
});
};
step(_data);
View
@@ -1,3 +1,5 @@
'use strict';
var express = require('express');
var path = require('path');
var parseData = require("./parseData");
@@ -210,22 +212,23 @@ apiRouter.route('/specs/raw')
apiRouter.route('/specs')
.get(function (req, res) {
getSpecs(req, res, parseSpecs)
getSpecs(req, res, parseSpecs);
});
apiRouter.route('/specs/html')
.get(function (req, res) {
getHTML(req, res, parseHTMLData)
getHTML(req, res, parseHTMLData);
})
.post(function (req, res) {
postHTML(req, res, htmlDataPath);
})
/* jshint es5:false */
.delete(function (req, res) {
deleteHTML(req, res, htmlDataPath);
});
// Activating router
app.use('/api', apiRouter);
global.app.use('/api', apiRouter);
/* Main API router */
@@ -255,12 +258,12 @@ apiTestRouter.get('/', function(req, res) {
apiTestRouter.route('/specs')
.get(function (req, res) {
getSpecs(req, res, parseSpecsTest)
getSpecs(req, res, parseSpecsTest);
});
apiTestRouter.route('/specs/html')
.get(function (req, res) {
getHTML(req, res, parseHTMLDataTest)
getHTML(req, res, parseHTMLDataTest);
})
.post(function (req, res) {
postHTML(req, res, htmlDataTestPath);
@@ -270,5 +273,5 @@ apiTestRouter.route('/specs/html')
});
// Activating router
app.use('/api-test', apiTestRouter);
global.app.use('/api-test', apiTestRouter);
/* /Test API router */
View
@@ -1,5 +1,6 @@
'use strict';
var fs = require('fs');
var path = require('path');
var util = require('util');
var flattenTillSpec = require('./flattenTillSpec');
@@ -124,7 +125,7 @@ ParseData.prototype._filter = function(filterArr, filterFunc){
*/
ParseData.prototype.filterFields = function(value, inOut, filterArr) {
return this._filter(filterArr, function(filterItem) {
return !!value[filterItem] === inOut;
return Boolean(value[filterItem]) === inOut;
});
};
@@ -159,7 +160,7 @@ ParseData.prototype.filterTags = function(value, inOut, filterArr) {
*/
ParseData.prototype.filterCats = function(value, key, inOut, filterArr) {
return this._filter(filterArr, function(filterItem) {
return !key.lastIndexOf(filterItem, 0) === inOut;
return Boolean(key.lastIndexOf(filterItem, 0)) !== inOut;
});
};
@@ -220,7 +221,7 @@ ParseData.prototype.getFilteredData = function(filterConf, array, data) {
if ( !(filterObj && filterObj.forceTags && _this.filterTags(value, true, filterObj.forceTags)) ) {
return;
}
};
}
if (array) {
output.push(value);
Oops, something went wrong.

0 comments on commit 6dc309e

Please sign in to comment.