summaryrefslogtreecommitdiff
path: root/js
AgeCommit message (Collapse)Author
2016-01-17Add missing copyright header to js/app.jsJuuso Lapinlampi
Adds "Copyright (c) 2016 Luminarys <postmaster@gensok.io>" to js/app.js with the Expat license embedded.
2016-01-17Replace old JavaScript with simpler vanilla versionLuminarys
Pomf's old JavaScript is a frozen dependency hell with an old version of Zepto. The amount of code included has reached the point of unmaintainability, where nobody really understands very well how the code works. This code gets rid of all the previous client-side JavaScript and replaces it with new, vanilla JavaScript. No dependencies required. This new JavaScript should be quite a bit faster too. Browser backwards compatibility has not been tested yet, however it is expected that IE10 and later will work, improving our current backwards compatibility. Reviewed-by: Eliot Whalan <ewhal@pantsu.cat> [wub@partyvan.eu: Added Git commit message and fixed Git branching. Reverted /* outline-offset: -2px;*/ removal.] Signed-off-by: Juuso Lapinlampi <wub@partyvan.eu>
2016-01-06Merge branch 'fix-eslint-warnings-2' of wubthecaptain/pomfJuuso Lapinlampi
Lint our spaghetti JavaScript code to be at least slightly more readable. Configuration used is ESLint 1.7.x and airbnb/legacy. It's been so long I cannot remember every change that was done, but long story short: all the ESLint errors are now gone, at least at the date of last commit. moep contributed some ideas for patches: some were implemented, some were discarded as the time and patience for merging this ran out. Thus, there are still ESLint warnings about anonymous functions. I don't feel like spending much more time on this. The future Pomf 2.1 development branch will replace the JavaScript code in its entirety, courtesy of luminarys@. Suggested-by: moep Tested-by: Eliot Whalan <ewhal@pantsu.cat> OK ewhal@, maybe a vague OK from luminarys@ a long time ago
2015-11-18Refactor cheesesteak.js EventEmitter emit functionJuuso Lapinlampi
Previous commit c950e85 came with a workaround to resolve a TypeError in EventEmitter.prototype.emit for-loop. That workaround sacrificed some readability for bug fixing due to technical debt. bursey came up with a better solution on IRC which seems to work and improves readability. Something needs to emit an event that wasn't bound with "on", thus the event was not in the _events object. Airbnb ES5 style guide requires to have all variables at top, so we leave the len variable undefined at the top to be defined later. After the _events check, we define len to avoid the TypeError issue while conforming to Airbnb ES5 style guide and improving readability. This commit also adds comments to document the function. Suggested-by: bursey (#/g/partyvan @ Partyvan IRC)
2015-11-18Workaround undefined length TypeError in cheesesteakJuuso Lapinlampi
this._events[evt].length would run into JavaScript scope issues in EventEmitter.prototype.emit function for-loop. This is an attempt to work around the issue to resolve an innocent looking TypeError. The code seems to work without this patch, but I can't spot if this is some dead code or know what to do with it. Due to technical debt, some sacrifice had to be made in readability for fixing this bug. This bug was introduced in commit 575b78b. For future improvement, this function and other functions in the file should be refactored or replaced with a more efficient implementation.
2015-11-18Rename identifier "$" to "cabinet" in cabinet.jsJuuso Lapinlampi
Very short identifier names usually make the code harder to read and potentially less maintainable. Fixes two ESLint id-length errors using airbnb/legacy config. Suggested-by: avail <avail@pomf.se>
2015-11-18Rename local variables to unique private namesJuuso Lapinlampi
When a local variable shares the same name with a variable in its scope, it can cause confusion to the reader and make it impossible to access the global variable. Disallow shadowing. Fixes ESLint no-shadow errors using airbnb/legacy config. Suggested-by: marc <mharnos@gmail.com>
2015-11-18Remove unused JavaScript variables (no-unused-vars)Juuso Lapinlampi
Quoting ESLint: > Variables that are declared and not used anywhere in the code are most > likely an error due to incomplete refactoring. Such variables take up > space in the code and can lead to confusion by readers. This commit removes them. Fixes ESLint no-unused-vars errors using airbnb/legacy config. Suggested-by: marc <mharnos@gmail.com>
2015-10-27Revert default max-file-size from 120MiB to 10MiBJuuso Lapinlampi
ewhal@ didn't understand how changing the maximum file size works, so he edited the JavaScript code directly to set the default to his desired 120MiB. For all clones, this may not be viable and it's not a sane default in my opinion. This doesn't change the fact that the maximum file size remains to be what it's configured in the configuration (Gruntfile.js). This bug was introduced in commit ec0154b, and potentially others. Vague OK from ewhal@ many weeks ago.
2015-10-13Remove all JSHint tools and headersJuuso Lapinlampi
JSHint is "deprecated" in favor of ESLint. Personally I have not used JSHint ever since switching to ESLint. Vague OK from ewhal@
2015-10-11Fix JSCS missing newline errorsJuuso Lapinlampi
Using preset "airbnb".
2015-10-11Merge branch 'eslint-vars-on-top' into fix-eslint-warnings-2Juuso Lapinlampi
Fixes ESLint vars-on-top errors using airbnb/legacy config.
2015-10-11Merge branch 'eslint-id-length' into fix-eslint-warnings-2Juuso Lapinlampi
Fixes ESLint id-length warnings. An exception is given to var "i", because Airbnb's style guide says this is OK. A bug is in eslint-config-airbnb, which the Airbnb style guide authors have not as of today accepted to merge to fix the bug. var "$" will be fixed later.
2015-10-11Merge branch 'refactor-cheesesteak' into fix-eslint-warnings-2Juuso Lapinlampi
Events now fire faster. Fixes ESLint func-names warnings using airbnb/legacy config.
2015-10-09Lint cheesesteak.js vars to top of functionJuuso Lapinlampi
Fixes ESLint vars-on-top errors using airbnb/legacy config.
2015-10-09Add missing newline introduced in previous commitJuuso Lapinlampi
Before this, JSCS would print an error about missing newline. This was introduced in previous commit 24ce733.
2015-10-09Lint pomf.js vars declarations to top of functionJuuso Lapinlampi
Fixes ESLint vars-on-top errors using airbnb/legacy config.
2015-10-09Lint cheesesteak.js and cabinet.js id-length < 2Juuso Lapinlampi
Fixes ESLint id-length errors using airbnb/legacy config. Variable "i" is ignored as an exception. I've also avoided creating new errors with these changes, so this also fixes some no-unused-vars and avoids creating vars-on-top errors.
2015-10-09Lint pomf.js ID length to > 2 charactersJuuso Lapinlampi
Fixes ESLint id-length errors using airbnb/legacy config. Some arguments were also unused, so this will also avoid introducing new no-unused-vars lint errors.
2015-10-07Fix incorrect progress/load event listenersJuuso Lapinlampi
This is a symptom of copy-paste code. A file would be uploaded, but it would return the "Something went wrong" error message without telling why. Me, ewhal@ and bursey on IRC tried had a look to see what was wrong, but none of us could catch this subtle bug. It wasn't until alchimist@ (cenci0) looked at this and found the issue. Thanks. This bug was introduced in commit 2751811.
2015-10-04Revert "Remove previously added missing brace/bracket commas"Juuso Lapinlampi
The unofficial Airbnb config (eslint-config-airbnb-es5) previously thought this to be an error and so it was removed. The official Airbnb config (airbnb/legacy) now works just like the ES6 config (airbnb). Fixes ESLint comma-dangle errors using airbnb/legacy config. This reverts commit 49d58d98f5866bb9ccc9069a16d131486f04bba2.
2015-10-04Remove extra whitespace in variable declarationsJuuso Lapinlampi
This is something I would disagree with, because this commit in my opinion reduces readability. I am not going to reinvent the wheel and write for humans, because I enjoy being a slave to ESLint. Any complaints about this commit should be directed at Airbnb to fix their style guide. Alternatively, a documented standard style guide should be created for pantsu.cat, extending the Airbnb config. This fixes ESLint no-multi-spaces errors using airbnb/legacy config.
2015-10-04Merge branch 'follow-airbnb-jquery' into fix-eslint-warnings-2Juuso Lapinlampi
Prefix jQuery object variables with a $
2015-10-04Merge branch 'eslint-undef' into fix-eslint-warnings-2Juuso Lapinlampi
2015-09-28Add missing var declaration to EventEmitterJuuso Lapinlampi
Previous commit 11e9d2d forgot to add the var declaration here. Fixes ESLint no-undef warnings using Airbnb ES5 config.
2015-09-28Add missing var declarations to undefined variablesJuuso Lapinlampi
Fixes ESLint no-undef warnings using Airbnb ES5 config.
2015-09-28Fix unexpected use of undefined with Boolean()Juuso Lapinlampi
Airbnb style guide recommends checking booleans this way or using (!!window.FormData). The latter is more confusing for many. While !! is indeed 0.2% faster than Boolean(), it's called micro-optimization. There is no noticeable difference to the user in our use scenario and I prefer more readable code any day. Fixes ESLint no-undefined warning using Airbnb ES5 config. Reference: https://jsperf.com/boolean-conversion-speed
2015-09-28Remove dead uploadstart emitter startUpload()Juuso Lapinlampi
The loadstart even is only triggered once to indicate the progress has begun (initialize the progress bar). Essentially, this is dead code for two reasons: 1. It never gets emitted because initProgressBar() gets emitted first. 2. No JavaScript file in pomf core uses the non-standard uploadstart event.
2015-09-28Name and comment addEventListener functionsJuuso Lapinlampi
Using anonymous functions with event handlers is painfully slow according to benchmarks. Anonymous functions are up to 99% slower. It is also illegal to use anonymous functions in this way according to Airbnb ES5 style guide. Fixes some ESLint func-names errors using Airbnb ES5 config. Reference: https://jsperf.com/event-handler-vs-anonymous-function/3
2015-09-28Fix assignments to function parameters in JavaScriptJuuso Lapinlampi
Fixes ESLint no-param-reassing warning.
2015-09-28Prefix cheesesteak.js jQuery object variables with a $Juuso Lapinlampi
This fixes Airbnb ES5 style guide violations.
2015-09-28Remove previously added missing brace/bracket commasJuuso Lapinlampi
Until the code has been converted to ES6 in it's entirety, let's stick to Airbnb's ES5 style guide so that ESLint won't complain. This reverts commit e6f354a.
2015-09-28Remove extra newline padding from pomf.jsJuuso Lapinlampi
This newline was accidentally introduced in commit a17c446. Fixes ESLint warning padded-blocks using Airbnb ES5 config.
2015-09-28Add pomf.js parseInt() radix 10Juuso Lapinlampi
Fixes ESLint radix warning using Airbnb ES5 config.
2015-09-27Prefix jQuery object variables with a $Juuso Lapinlampi
While JSCS and ESLint do not detect this yet as of today, my eyes do. The Airbnb style guide wants to do this. This commit doesn't prefix cabinet.js, but the next commit will while addressing another issue.
2015-09-27Fix JS switch ... case indentationJuuso Lapinlampi
This is a surprising one. JSHint and JSCS do not seem to mind the previous indentation, but ESLint throws an error when using the Airbnb style guide. The style guide itself doesn't seem to mention anything about this directly. What ever it is, this one pleases all three linters. Fixes ESLint indent warnings using Airbnb ES5 config.
2015-09-27cheesesteak.js: Use _this to save reference to thisJuuso Lapinlampi
Fixes JSCS safeContextKeyword warnings using Airbnb preset.
2015-09-27Remove extra quotes to follow Airbnb JavaScript styleJuuso Lapinlampi
Fixes JSCS disallowQuotedKeysInObjects warnings using Airbnb preset.
2015-09-27Add missing commas before closing bracket/curly braceJuuso Lapinlampi
This adds commas to cheesesteak.js. Something to note, the Airbnb ES5 style guide opposes a trailing comma. The latest ES6 edition endorses adding a trailing comma, explaining it leads to cleaner Git diffs. Endorse the ES6 standard, that's also the Airbnb preset in JSCS. Fixes JSCS requireTrailingComma warnings using Airbnb preset.
2015-09-27Fix cheesesteak.js comments to follow Airbnb styleJuuso Lapinlampi
Airbnb says to use /** ... */ for multiline comments and // for single line comments. Fixes JSCS requirePaddingNewLinesBeforeLineComments and validateIndentation warnings using Airbnb preset.
2015-09-27Use individual Javascript var declarationsJuuso Lapinlampi
Thanks to ASI (Automatic Semicolon Insertion) in JavaScript, not using individual var declarations can actually cause subtle bugs. Fixes JSCS disallowMultipleVarDecl warnings using Airbnb preset. Reference: http://benalman.com/news/2012/05/multiple-var-statements-javascript/
2015-09-27Change double quotes to single quotes in cheesesteak.jsJuuso Lapinlampi
Fixes JSCS validateQuoteMarks warnings using Airbnb preset.
2015-09-27Fix illegal trailing whitespace in JavaScriptJuuso Lapinlampi
Fixes JSCS disallowTrailingWhitespace warnings using Airbnb preset.
2015-09-27Add missing newlines after blocksJuuso Lapinlampi
Fixes JSCS requirePaddingNewLinesAfterBlocks warnings using Airbnb preset.
2015-09-27Fix redeclaration of "res" variable in pomf.jsJuuso Lapinlampi
Fixes ESLint warning no-redeclare.
2015-09-27Fix irregular whitespace in cheesesteak.jsJuuso Lapinlampi
Fixes ESLint warnings about no-irregular-whitespace.
2015-09-27Remove unused expression (hits[file.name] = 0)Juuso Lapinlampi
Fixes ESLint no-unused-expressions warning.
2015-09-27Use strict node === node.parentNode comparisonJuuso Lapinlampi
Fixes ESLint no-cond-assign warning. -- Sat, 26 Sep 2015 -- 10:38:42 +bursey | while (node = node.parentNode) is invalid 10:38:54 +bursey | should be while (node == node.parentNode) 10:40:38 +bursey | weird actually 10:40:55 +bursey | Elements tend to be "true" in js 10:41:16 +bursey | but if the parentNode is undefined, then it's | false 10:41:50 +bursey | thus it doesn't loop infinitely 10:43:00 +bursey | actually, use === instead of ==
2015-09-27Fix JavaScript units[] array coding styleJuuso Lapinlampi
Reduces confusion and improves readability, despite not having yet agreed on which JavaScript style guide to use.
2015-09-27Replace copy-pasted pomf.js errors with constantsJuuso Lapinlampi
Introduces client-side UPLOAD_ERR_MAX_SIZE and UPLOAD_ERR_FAILED constants. This reduces code duplication, which means less code smell.