Commit Graph

106 Commits

Author SHA1 Message Date
Guangcong Luo
26f4a8c776 Use <script nomodule> for polyfills
This should make PS marginally slower on really old browsers,
marginally faster on modern browsers, neither of which should be
remotely noticeable.

The intended actual impact is to make it easier to maintain
(`battle-dex` is clearly the wrong place for polyfills) and easier
to reuse outside of PS.
2020-07-23 13:15:27 -07:00
Guangcong Luo
c1135497e0
Remove SoundManager dependency (#1563)
All sound stuff is now handled directly by BattleSound, using the
HTML5 audio API.

The main complicated thing we do with sound is loop music with an intro.
This is unfortunately not supported by ANY sound library out there
(I had to manually add support for it myself to soundManager!)

https://github.com/scottschiller/SoundManager2/pull/13

In the end, I don't think the existing libraries out there actually
give us anything I care about.
2020-07-23 12:51:47 -07:00
Annika
367ed82e56
Support configurable URLs (#1543) 2020-07-21 15:27:21 -07:00
Guangcong Luo
de7b91fe09
Use DexSearch for the teambuilder search engine (#1503)
This will prevent us from needing to maintain two search engines in
the future.

The new DexSearch doesn't have too much in the way of new features so
far, but it does show filtered things in categories, and list illegal
results in-filter even after sorting.

These are really minor differences, though; the main thing is just that
its architecture should make it much easier to maintain, and in
particular, to add more filters.
2020-05-05 20:36:10 -07:00
Guangcong Luo
4188f62310 Improve error message for macOS desktop permissions
Fixes #6485
2020-04-07 21:28:35 -04:00
Guangcong Luo
a176317913 Refactor CSS, add CSS guide
`style/STYLING.html` is now a guide of generic CSS classes that can be
used by bots and chat plugins.

CSS classes that can be used by bots and chat plugins are now in a new
`battle-log.css` (previously just a section of `battle.css`)

Several PS styling patterns (specifically, `message-log`, `option`, and
`blocklink`) have been refactored into CSS classes, so that they can
be used by bots and chat plugins (why yes, I do plan on using 2/3 of
them in the log viewer).

Past CSS has been super messy. This refactor tries to make it neater
by adhering to these rules:

- Instead of trying to use e.g. `.setmenu button` selectors (to save
  `class=` on every individual list item), give up and just put
  `.option` directly on list items. This drastically cuts down on all
  the hacks necessary to have `.button` work inside `.setmenu`.

...That's it. That's the only change. It massively cuts down on CSS
complexity. It does slightly complicate the DOM, which I'm not a _huge_
fan of, but CSS unpredictability is nearly impossible to catch and
debug, so it's massively worth it.
2020-03-15 22:49:36 -07:00
Ben Davies
e3fcaa492c
Properly set the encoding to UTF-8 on all HTML pages (#1467)
This adds the BOM to all HTTP pages as per the HTML5 spec and ensures
all pages use UTF-8 as their meta charset (which is still kept for
compatibility with older browsers).
2020-02-23 00:13:56 -08:00
Ben Davies
29bab1bfdf Fix SockJS when using the desktop client (#1360)
* Patch SockJS v1.4.0 to work with nw.js

* Document how to upgrade SockJS in UPGRADING-SOCKJS.md
2019-09-04 14:54:03 -05:00
Ben Davies
02eaeecf46 Implement connection timeouts (#1358)
* Use SockJS' timeout config option

This sets timeouts on connections to 5 minutes, matching the server's
heartbeat interval to close sockets that shouldn't be open anymore.

* Update SockJS client to v1.4.0

This fixes an issue where SockJS would parse the entire HTTP response
received as JSON, not the response's body alone.
2019-09-03 21:31:24 -05:00
Guangcong Luo
5c983df6d3 Massively improve tooltips
- Tooltips work in replays now
- Calculation is better (correctly handles more corner cases)
- Explanations are better (better messages for Magic Room etc)
- Tooltips for sidebar pokemon
- Support "locking" tooltips with long-click / long-tap
- Can copy/paste from locked tooltips
- Increased font size
2019-02-18 22:38:13 -06:00
Guangcong Luo
b6dcc4da35 Remove jQuery-JSON dependency
We now just use JSON.parse and JSON.stringify - it's supported by all
browsers supported by the client.

Tools.safeJSON has also been moved to Storage.safeJSON, since it's not
used in replays at all.
2018-10-14 22:07:55 -05:00
Guangcong Luo
5120e59f5e Drop jslider dependency
jslider was incredibly buggy, and most likely the cause of the problems
with the teambuilder on mobile, and required some pretty ridiculous
hacks, and leaked memory.

We're now using HTML5 sliders, like we are with the volume controls.

HTML5 sliders aren't supported by IE9, but they're supported by most
other browsers PS cares about. If not, well, they won't look too ugly
probably...
2017-12-21 05:05:22 -06:00
Guangcong Luo
bf45602b4b Make base page slightly smaller
The biggest change is probably that the meta charset tag is now in the
first 1024 bytes, making the page actually valid HTML.

In addition, everything has been unindented, and some extraneous tags
have been removed.
2017-11-23 01:32:05 -05:00
Guangcong Luo
a8d78b397c Add homescreen app manifest for Android Chrome
Android Chrome fixed the keyboard issue, so we can finally use the
no-URL-bar version of the homescreen app.
2017-10-29 21:16:05 -04:00
Guangcong Luo
5d363f4c44 Lighten cyan/blue usernames slightly 2017-10-21 14:51:12 -04:00
Guangcong Luo
644d5ccf91 Support Google login (two-factor auth) (#999)
This doesn't support setting accounts up for Google login: that still
has to be manually done via the database by setting the email field to
`username@gmail.com@`, where the second `@` denotes that it's using
Gmail login.

If the email field does end in `@`, `getassertion` will note this by
sending `;;@gmail`, to convey that the server is expecting a Google
login token rather than a password.

Upon receiving `;;@gmail`, the client will replace the password box will
with a Google login button, and then send the resulting Google login
token to the server in the `password` field. The server will validate
the "password" using the Google server libraries, and otherwise handle
the login as normal.

Note that Google login requires various features that a paranoid person
might disable; most notably 3rd-party cookies.

Fixes Zarel/Pokemon-Showdown#3394
2017-09-13 16:20:38 -04:00
Felix Rilling
cde8151838 Update Backbone and lodash #906 (#907) 2017-04-24 22:02:17 -07:00
Guangcong Luo
1c18bf0f4d Move config.js to /config/ 2016-10-20 13:16:06 -04:00
Guangcong Luo
fb19307927 Update SockJS to 1.1.1
Note that it's had to be modified slightly for compatibility for our
version of nwjs.
2016-09-05 06:46:30 -04:00
Guangcong Luo
98403d0c71 Update PSdex link 2016-09-05 06:46:30 -04:00
Guangcong Luo
094b9effa1 Implement Retina logo 2016-04-02 03:13:09 -04:00
Guangcong Luo
78334b7a15 Split off client-topbar.js from client.js
client.js is still kind of huge, but oh well. Progress!
2016-01-18 01:42:30 -08:00
Harshvardhan
9109de7925 Added support for all power-boosting items
Removed redundancy from code

Moved to tooltips file

Reduced code

Reduced code

Reduced code

Reduced globals to 1

Minor error corrections

Added filename to index.template.html
2015-12-29 12:16:41 +05:30
Guangcong Luo
2768569b5a Add Credits to main menu footer 2015-12-26 10:22:44 -05:00
Guangcong Luo
04a27253e3 Teambuilder: Properly support gen 1-2 learnsets
This also adds a cached learnset format to teambuilder-tables.js,
which replaces and is slightly smaller than learnsets.js and also
has slightly better performance.
2015-12-24 11:33:25 -05:00
Guangcong Luo
4981a223b0 Teambuilder: Improve past gen support
This is a large collection of changes that greatly improve past gen
support in the teambuilder.

- Tier lists are now compiled separately from each gen (build-indexes
  is really slow about this, which isn't particularly surprising),
  as well as for Doubles.

- Learnsets are now compiled separately from each gen. TODO: make an
  optimized learnsets.js with gen 1-2 support for client.

- Types in the pokemon list now account for old gens.

- Abilities no longer display in the pokemon list in gen 1-2

- SpA/SpD are replaced by Spc in the pokemon list in gen 1

Also included: A small optimization to the number of DOM nodes for the
teambuilder display, which should improve performance.
2015-12-24 11:33:25 -05:00
Guangcong Luo
a76b0b95ef Build: Minify pokedex.js + formats-data.js, moves.js
The client-relevant parts of formats-data.js have been combined into
pokedex.js. pokedex.js and moves.js are now minified on the client.
2015-12-22 12:11:40 -05:00
Guangcong Luo
7fa72c1d20 Convert teambuilder from utilichart.js to search.js
The teambuilder is now running on search.js! Not all new features I'd
like to be in are in, but we've now reached feature parity, and most
of the bugs I found during testing have been fixed.

New in search.js is on-demand DOM loading, which basically means
much faster performance because instead of trying to load every single
row of e.g. the pokemon list at once, we just load the part that's
visible, and load the rest only when you scroll it into view.

Also new in search.js is a dexsearch-like feature, replacing the old
details-search system. The new filter system is simpler and more powerful
and has the same API as /dexsearch, although not all the more advanced
dexsearch features are supported.

On-demand DOM loading makes teambuilder loading pretty much completely
instantaneous. There are other small differences in how selection of
pokemon/items/abilities/moves works, but it should overall make more
sense.
2015-12-22 00:06:27 -06:00
Guangcong Luo
72ff236cef Hardcode logo img dimensions
Very minor optimization to layout performance, but I'll take it.
2015-12-12 23:04:29 -05:00
Guangcong Luo
211da6e8b1 Major update to background storage and menu colors
When loading a background, we use Color Thief to get a six-color
palette from the image, for use on the main menu buttons.

Only hue and lightness are extracted.

https://github.com/lokesh/color-thief/

Backgrounds are now stored in localStorage in the current origin,
rather than the prefs origin. This allows faster loading, as well
as different backgrounds for different origins, which other
servers should like since it means their backgrounds get seen
at least once before possibly being replaced.

Special thanks to Joim for the base code.
2015-12-12 04:01:00 -06:00
Guangcong Luo
b718a335a2 News tracking 2015-11-30 02:11:27 -05:00
Guangcong Luo
cf8bb24e71 Refactor data storage
Data (teams and prefs) are now always stored in localStorage in the
`https://play.pokemonshowdown.com` origin. Data storage at a low
level has been mostly rewritten for this, and moved to storage.js.

Tools.prefs has been renamed Storage.prefs, although the API
Tools.prefs(prefName) is still available, and recommended for
battle.js (because storage.js isn't available in replays). All
other pref functionality, such as setting prefs and saving prefs,
should only be used in Storage.prefs.

If the browser blocks third-party cookies in a detectable way,
data is instead stored in the local origin.

As a final safety measure, prefs/teams are mirrored in the local origin
in case third-party cookies are blocked in an undetectable way.

This refactor also replaces the 'init:loadprefs' and 'init:loadteams'
events with a new load tracking system that's basically a simplified
implementation of Promises, documented in the comments for
Tools.makeLoadTracker().
2015-11-28 04:36:41 -05:00
Guangcong Luo
f90f650372 Remove a workaround for some old malware
This malware is probably no longer around, and even if it is, the
rest of the file has been changed enough that the previous
workaround probably doesn't work anymore, anyway.
2015-10-22 04:35:20 -04:00
Guangcong Luo
28f7956d8c Various micro-optimizations to index.template.html
In particular, the header comment was cut down from 2KB to 1KB.
Sadly still not within the spec requirement of 512bytes to the
meta charset, but closer!
2015-10-22 03:08:13 -04:00
Guangcong Luo
bdcbded0bb Update Font Awesome to 4.4.0
Font Awesome 3 -> 4 was a backwards-incompatible change, so this
update is pretty invasive. I tested everything we use it for and it
still works, though. Including supporting both Font Awesome versions
in battle.js.
2015-09-25 02:46:34 -05:00
urkerab
a1c674851a Make it possible to minimise the Latest News box 2015-09-09 12:33:09 +01:00
Guangcong Luo
51476ce695 Remove scrollbar from News 2015-08-01 00:54:54 -04:00
Guangcong Luo
d6173c2485 We don't use IRC anymore 2015-07-25 16:53:55 -04:00
Guangcong Luo
a78d233785 Add link for 128x128 app icon 2015-07-15 00:42:29 -04:00
Guangcong Luo
e2a8627b11 Native resolution for mobile
We now support resolutions down to 320px width, down from the
previous 640px.
2015-07-15 00:42:07 -04:00
Guangcong Luo
5abc202006 Don't cache old tournament JS files 2015-07-02 12:47:51 -04:00
Guangcong Luo
a6e56e969a Update jQuery to 2.1.4 2015-06-28 00:50:16 -04:00
Guangcong Luo
d2b5a0bad3 Support some CSS in sanitized HTML 2015-06-27 02:46:00 -04:00
Guangcong Luo
f5b3d7c0c3 Add 'Forum' link to bottom left linkbar 2015-06-12 14:29:34 -04:00
Guangcong Luo
6c42d72548 Update jQuery 2015-06-07 23:42:03 -04:00
Guangcong Luo
3aa8b47ae5 Merge pull request #380 from xfix/disable-chrome-frame
Disable Chrome Frame
2015-05-20 05:24:14 +00:00
Konrad Borowski
22502eb07e Disable Chrome Frame
Chrome Frame is not supported for two years, which means removing
support for it on Pokémon Showdown should be safe.
2015-05-19 20:08:45 +02:00
Konrad Borowski
d9f3ca74be Remove useless </small> from index.html 2015-05-15 12:23:01 +02:00
Morfent
d2bc6dd260 Update jQuery to version 2.1.3 2015-02-06 05:07:58 -04:00
Guangcong Luo
88a5a2e5e9 Chrome frame is deprecated
We now redirect to the Windows download for old IE versions
2014-07-11 18:35:52 -05:00