diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..13d996c --- /dev/null +++ b/.eslintrc @@ -0,0 +1,110 @@ +root: true + +env: + browser: true + node: true + +ecmaFeatures: + globalReturn: false + +globals: + $: false + +rules: + # Default rules recommended by ESLint (http://eslint.org/docs/rules/): + comma-dangle: [2, "never"] + no-cond-assign: 2 + no-console: 2 + no-constant-condition: 2 + no-control-regex: 2 + no-debugger: 2 + no-dupe-args: 2 + no-dupe-keys: 2 + no-duplicate-case: 2 + no-empty-character-class: 2 + no-empty: 2 + no-ex-assign: 2 + no-extra-boolean-cast: 2 + no-extra-semi: 2 + no-func-assign: 2 + no-inner-declarations: [2, "both"] + no-invalid-regexp: 2 + no-irregular-whitespace: 2 + no-negated-in-lhs: 2 + no-obj-calls: 2 + no-regex-spaces: 2 + no-sparse-arrays: 2 + no-unreachable: 2 + use-isnan: 2 + valid-typeof: 2 + no-unexpected-multiline: 2 + + # Best Practice Rules: + block-scoped-var: 2 + consistent-return: 2 + curly: [2, "all"] + dot-location: [1, "property"] + dot-notation: 1 + eqeqeq: [2, "allow-null"] + guard-for-in: 2 + no-caller: 2 + no-eq-null: 2 + no-eval: 2 + no-extend-native: 2 + no-fallthrough: 2 # recommended + no-floating-decimal: 1 + no-implicit-coercion: 1 + no-implied-eval: 2 + no-lone-blocks: 1 + no-loop-func: 1 + no-multi-str: 1 + no-native-reassign: 2 + no-new: 2 + no-octal: 2 # recommended + no-redeclare: [2, {"builtinGlobals": true}] # recommended + no-void: 2 + no-with: 2 + radix: 2 + strict: [2, "global"] + vars-on-top: 1 + wrap-iife: [1, "inside"] + + # Variable Declaration Rules + no-delete-var: 2 + no-shadow-restricted-names: 2 + no-shadow: 1 + no-undef: 2 + no-undefined: 2 + no-unused-vars: [1, {"vars": "local", "args": "after-used"}] + no-use-before-define: 2 + + # Stylistic Rules + brace-style: [1, "1tbs", {"allowSingleLine": true}] + camelcase: [1, {"properties": "never"}] + comma-spacing: 1 + comma-style: [2, "last"] + consistent-this: [1, "self"] + eol-last: 1 + func-style: [2, "expression"] + indent: [1, 4] + key-spacing: [1, {"beforeColon": false, "afterColon": true}] + linebreak-style: 2 + max-len: [1, 120] + new-cap: [2, {"capIsNewExceptions": ["HmacSHA256"]}] + newline-after-var: 1 + no-array-constructor: 1 + no-mixed-spaces-and-tabs: 1 + no-nested-ternary: 1 + no-new-object: 1 + no-spaced-func: 2 + no-trailing-spaces: 1 + object-curly-spacing: [1, "always"] + one-var: [1, {"initialized": "never"}] + padded-blocks: [1, "never"] + quotes: [1, "single"] + semi: [2, "always"] + space-after-keywords: [1, "always"] + space-before-blocks: [1, "always"] + space-before-function-paren: [1, "never"] + spaced-comment: [1, "always"] + space-infix-ops: 1 diff --git a/.gitignore b/.gitignore index 4cda9e1..ddb5035 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,6 @@ ajax/tmp.php **.sql ajax/sendPointsCorrection.php -pointsCenter.built.js -css/pointsCenter.built.css -css/pointsCenter.built.min.css +build bower_components node_modules diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index f4faa24..0000000 --- a/.jscsrc +++ /dev/null @@ -1,131 +0,0 @@ -{ - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch" - ], - "requireSpaceAfterKeywords": [ - "return" - ], - "disallowSpaceAfterKeywords": [ - "if", - "for", - "while", - "do", - "switch", - "try", - "catch" - ], - "disallowSpaceBeforeBlockStatements": true, - "requireParenthesesAroundIIFE": true, - "requireSpacesInConditionalExpression": true, - "disallowSpacesInFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "requireSpacesInNamedFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "requireSpacesInFunctionDeclaration": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "requireMultipleVarDecl": "onevar", - "requireBlocksOnNewline": 1, - "disallowSpacesInsideParentheses": true, - "requireSpacesInsideObjectBrackets": "all", - "disallowSpacesInsideArrayBrackets": "all", - "disallowSpaceAfterObjectKeys": true, - "requireCommaBeforeLineBreak": true, - "requireOperatorBeforeLineBreak": true, - "disallowSpaceAfterPrefixUnaryOperators": true, - "disallowSpaceBeforePostfixUnaryOperators": true, - "requireSpaceBeforeBinaryOperators": [ - "=", - "+=", - "-=", - "*=", - "/=", - "%=", - "<<=", - ">>=", - ">>>=", - "&=", - "|=", - "^=", - "+=", - "+", - "-", - "*", - "/", - "%", - "<<", - ">>", - ">>>", - "&", - "|", - "^", - "&&", - "||", - "===", - "==", - ">=", - "<=", - "<", - ">", - "!=", - "!==" - ], - "disallowSpaceBeforeBinaryOperators": [ - ",", - ":" - ], - "requireSpaceAfterBinaryOperators": true, - "disallowImplicitTypeConversion": [ - "numeric", - "boolean", - "binary" - ], - "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties", - "disallowKeywords": [ - "with" - ], - "disallowMultipleLineStrings": true, - "disallowMultipleLineBreaks": true, - "validateLineBreaks": "LF", - "validateQuoteMarks": "'", - "disallowMixedSpacesAndTabs": "smart", - "disallowTrailingWhitespace": true, - "disallowTrailingComma": true, - "disallowKeywordsOnNewLine": [ - "else" - ], - "maximumLineLength": { - "value": 120, - "tabSize": 1, - "allowUrlComments": true, - "allowRegex": true - }, - "safeContextKeyword": [ - "self" - ], - "requireDotNotation": true, - "disallowYodaConditions": true -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 5c924a7..0000000 --- a/.jshintrc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "browser": true, - "esnext": true, - "globals": { - "require": false, - "define": false - }, - "latedef": true, - "quotmark": "single", - "smarttabs": true, - "trailing": true, - "undef": true, - "unused": true, - "forin": true, - "indent": 1 -} \ No newline at end of file diff --git a/.sass-lint.yml b/.sass-lint.yml new file mode 100644 index 0000000..d624bf2 --- /dev/null +++ b/.sass-lint.yml @@ -0,0 +1,11 @@ +rules: + property-sort-order: 0 + force-element-nesting: 0 + nesting-depth: + - 1 + - max-depth: 4 + no-important: 0 + no-qualifying-elements: 0 + leading-zero: + - 1 + - include: true \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index ce4343b..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,120 +0,0 @@ -module.exports = function(grunt) { - 'use strict'; - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - bower: { - target: { - rjsConfig: 'pointsCenter.build.js', - options: { - exclude: ['qunit', 'almond'] - } - } - }, - requirejs: { - compile: { - options: { - baseUrl: './', - mainConfigFile: 'pointsCenter.build.js', - include: 'pointsCenter.build.js', - name: 'bower_components/almond/almond', - out: 'pointsCenter.built.js', - optimize: 'uglify', - uglify: { - toplevel: true, - ascii_only: true, - beautify: false, - max_line_length: 10000 - }, - inlineText: true, - useStrict: false, - skipPragmas: false, - skipModuleInsertion: false, - optimizeAllPluginResources: false, - findNestedDependencies: false, - removeCombined: false, - fileExclusionRegExp: /^\./, - preserveLicenseComments: false, - logLevel: 0 - } - } - }, - qunit: { - files: ['test/tests.html'] - }, - jshint: { - files: ['gruntfile.js', 'js/pointsCenter.js'], - options: { - // options here to override JSHint defaults - 'browser': true, - 'esnext': true, - 'quotmark': 'single', - 'smarttabs': true, - 'trailing': true, - 'undef': true, - 'unused': true, - 'strict': true, - globals: { - define: true, - console: true, - module: true - } - } - }, - watch: { - files: ['<%= jshint.files %>'], - tasks: ['jshint', 'qunit'] - }, - cssmin: { - combine: { - options: { - banner: '/* Slivka Points Center minified css (includes Bootstrap, Bootstrap-theme, typeahead, nprogress, bootstrap-multiselect, and add2home) */', - keepSpecialComments: 0, - report: 'gzip' - }, - files: { - 'css/<%= pkg.name %>.built.css': [ - 'css/bootstrap.css', - 'css/bootstrap-theme.css', - 'css/font-awesome.css', - 'css/font-awesome-social.css', - 'css/typeahead.js-bootstrap.css', - 'css/nprogress.css', - 'css/bootstrap-multiselect.css', - 'css/add2home.css', - 'css/pointsCenter.css' - ] - } - }, - minify: { - expand: true, - src: ['css/<%= pkg.name %>.built.css'], - dest: '', - ext: '.built.min.css' - } - }, - compress: { - main: { - options: { - mode: 'gzip' - }, - expand: true, - src: ['css/<%= pkg.name %>.built.min.css'], - dest: '', - ext: '.built.min.css.gz' - } - } - }); - - grunt.loadNpmTasks('grunt-bower-requirejs'); - grunt.loadNpmTasks('grunt-contrib-requirejs'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-qunit'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); - grunt.loadNpmTasks('grunt-contrib-compress'); - - grunt.registerTask('test', ['jshint', 'qunit']); - - grunt.registerTask('default', ['jshint', 'requirejs', 'cssmin']); - -}; diff --git a/ajax/PointsCenter.php b/ajax/PointsCenter.php index 59d11f2..bb811aa 100644 --- a/ajax/PointsCenter.php +++ b/ajax/PointsCenter.php @@ -211,6 +211,8 @@ public function getSlivkans() { $absentSlivkans = self::fetchAllQuery('SELECT nu_email FROM absences WHERE qtr=:qtr', PDO::FETCH_COLUMN); + $nicknames = self::fetchAllQuery("SELECT nu_email,nickname FROM nicknames", PDO::FETCH_GROUP | PDO::FETCH_COLUMN); + $slivkans = self::fetchAllQuery( "SELECT CONCAT(first_name, ' ', last_name) AS full_name, slivkans.nu_email,gender,wildcard,committee,photo,suite,year @@ -226,23 +228,28 @@ public function getSlivkans() $n = count($slivkans); for ($i=0; $i<$n; $i++) { $slivkans[$i]["tokens"] = explode(" ", $slivkans[$i]["full_name"]); - } + if (array_key_exists($slivkans[$i]["nu_email"], $nicknames)) { + $slivkans[$i]["tokens"] = array_merge($slivkans[$i]["tokens"], $nicknames[$slivkans[$i]["nu_email"]]); + } + } return $slivkans; } - public function getNicknames() - { - return self::fetchAllQuery("SELECT nu_email,nickname FROM nicknames", PDO::FETCH_NAMED); - } - public function getFellows() { - return self::fetchAllQuery( + $fellows = self::fetchAllQuery( "SELECT full_name,position,about,photo FROM fellows WHERE qtr_final IS NULL" ); + + # add tokens for typeahead.js + $n = count($fellows); + for ($i=0; $i<$n; $i++) { + $fellows[$i]["tokens"] = explode(" ", $fellows[$i]["full_name"]); + } + return $fellows; } public function updateFellowPhoto($fellow, $photo) @@ -306,6 +313,17 @@ public function getRecentEvents() ); } + public function eventNameExists($event_name) + { + return count(self::fetchAllQuery( + "SELECT event_name + FROM events + WHERE qtr=:qtr AND event_name=:event_name", + PDO::FETCH_COLUMN, + array(":event_name" => $event_name) + )) > 0; + } + public function getCommitteeEvents($committee) { if ($committee == "Facilities") { @@ -513,11 +531,17 @@ public function getSlivkanBonusPoints($nu_email) $other_points = 0; } - $other_breakdown = array( - array($bonus['other1_name'] | '', $bonus['other1'] | 0), - array($bonus['other2_name'] | '', $bonus['other2'] | 0), - array($bonus['other3_name'] | '', $bonus['other3'] | 0) - ); + $other_breakdown = array(); + + if (!empty($bonus['other1_name'])) { + $other_breakdown[] = array($bonus['other1_name'], $bonus['other1']); + } + if (!empty($bonus['other2_name'])) { + $other_breakdown[] = array($bonus['other2_name'], $bonus['other2']); + } + if (!empty($bonus['other3_name'])) { + $other_breakdown[] = array($bonus['other3_name'], $bonus['other3']); + } return array( "helper" => $helper_points, diff --git a/ajax/eventNameExists.php b/ajax/eventNameExists.php new file mode 100644 index 0000000..eb58a21 --- /dev/null +++ b/ajax/eventNameExists.php @@ -0,0 +1,7 @@ +eventNameExists($_GET['event_name']); + +echo json_encode(array('eventNameExists' => $eventNameExists)); diff --git a/ajax/getSlivkans.php b/ajax/getSlivkans.php index fad444c..ba53e20 100644 --- a/ajax/getSlivkans.php +++ b/ajax/getSlivkans.php @@ -3,9 +3,8 @@ $points_center = new \Slivka\PointsCenter(); $qtrs = $points_center->getQuarters(); $slivkans = $points_center->getSlivkans(); -$nicknames = $points_center->getNicknames(); $fellows = $points_center->getFellows(); $quarter_info = $points_center->getQuarterInfo(); $im_teams = $quarter_info['im_teams']; -echo json_encode(array("qtrs"=>$qtrs,"slivkans"=>$slivkans,"nicknames"=>$nicknames,"fellows"=>$fellows,"im_teams"=>$im_teams)); +echo json_encode(array("qtrs"=>$qtrs,"slivkans"=>$slivkans,"fellows"=>$fellows,"im_teams"=>$im_teams)); diff --git a/base.php b/base.php index 512e336..22cccd8 100644 --- a/base.php +++ b/base.php @@ -7,7 +7,7 @@ - + Admin Dashboard -
-
-
-
-
-

Quarter

-
- - - - - + + + +
Current Quarter - - + Edit + +
+
+
+
+

Configuration

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Housing Selection + ? + Toggle
VP NameEdit
VP EmailEdit
VP Copies EmailEdit
Point Submission
Email Notifications
Toggle
Mailbot EmailEdit
Mailbot PasswordEdit
+
+
+
+
-

Configuration

+

+ Add/Update Photo +

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Housing Selection - ? - Toggle
VP NameEdit
VP EmailEdit
VP Copies EmailEdit
Point Submission
Email Notifications
Toggle
Mailbot EmailEdit
Mailbot PasswordEdit
-
-
-
- -
-
-

- Add/Update Photo -

-
-
- -
- - Successfully uploaded photo! -
- + -
-
- - -
+
+ + Successfully uploaded photo!
-
- - -
-
- - + +
+
+ +
- - - 0) { ?> -
-
-

- Open Points Corrections -

+ - - - - - - - - - - - - - - - -
NU EmailEvent
- -
-
-

Committee / Committee Points

-
-
-
-
- -
-
- Edit -
+ + 0) { ?> +
+
+

+ Open Points Corrections +

+
+ + + + + + + + + + + + + + + +
NU EmailEvent
+
+ +
+
+

Committee / Committee Points

+
+
+
+
+ +
+
+ Edit
-
-
-

Suite

-
-
-
-
- -
-
- Edit -
+
+
+
+

Suite

+
+
+
+
+
- - + + +
diff --git a/spc-breakdown.php b/spc-breakdown.php index 803a0a8..1a7054d 100644 --- a/spc-breakdown.php +++ b/spc-breakdown.php @@ -14,116 +14,139 @@ }
-
-
- - -
-
- - -
- -
- - +
+ + +
+
+ + +
+
+ + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeEventsIMsHelperCommitteeOtherTotal
Subtotal
Events
IMs
Helper
Committee
Other
Total
-
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeSubtotal
Events
IMs
Helper
Committee
Other
Total
+
+
+
+
+
+
+
+
+
+ + + + + + + + +
Events Attended
+
+
+ + + + + + + + +
Events Unattended
- + + + + diff --git a/spc-committee-headquarters.php b/spc-committee-headquarters.php index c4d7e7c..27f1031 100644 --- a/spc-committee-headquarters.php +++ b/spc-committee-headquarters.php @@ -23,13 +23,12 @@ function getFullName($slivkans, $nu_email) } ?> - @@ -48,37 +47,38 @@ function getFullName($slivkans, $nu_email)
Committee Headquarters -
-
-

Click to edit values.

+
+
+
+

Click to edit values.

+
+
+
+
Colors:
+ + + + + + + +
AttendeePoint TakerOther PointsNone
+
+ +
-
-
Colors:
- - - - - - - -
AttendeePoint TakerOther PointsNone
-
- - -
-
+
- + - - @@ -245,25 +245,25 @@ class="btn btn-link btn-block" target="_blank">Submit non-event-related helper p
-
- {{#contributions}} + <% if (contributions) { %>
- - + +
    + <% forEach(contributions_list, function(c) { %> +
  • + <% }) %> +
- {{/contributions}} + <% } %>
- +
diff --git a/spc-correction.php b/spc-correction.php index a228cd6..783c2fe 100644 --- a/spc-correction.php +++ b/spc-correction.php @@ -1,5 +1,5 @@
-
+
diff --git a/spc-submission.php b/spc-submission.php index ff0d84e..e3a4222 100644 --- a/spc-submission.php +++ b/spc-submission.php @@ -74,12 +74,8 @@
- + -
@@ -154,14 +150,16 @@
Additional inputs appear automatically.
-
- -
- - +
+
+ +
+ + +
+
+
-
-
@@ -207,3 +205,17 @@
+ + diff --git a/spc-table.php b/spc-table.php index d64cc9e..61a1f8a 100644 --- a/spc-table.php +++ b/spc-table.php @@ -9,11 +9,9 @@ $points_table = $points_center->getPointsTable($showall); ?> - -
-
+
-
+

Hover over names for info, click arrows to sort.

-
Name
Name
-
+
+
@@ -88,15 +88,15 @@ function getFullName($slivkans, $nu_email) $totalsColumns = array("Bonus", "Total");//, "Total (adjusted)"); for ($i=0; $i -
-
+
+
-
+
+
- - +
Colors:
+ + - +
Colors: Point Committee HelperNoneNone
-