Skip to content

[WIP] Frontend Refector/Advanced Information #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

DirectXMan12
Copy link

@DirectXMan12 DirectXMan12 commented Oct 11, 2017

This completely refactors the frontend, and stars adding some of the information available on the wiki version to the frontend. Many of the features used are only available in "evergreen" browsers (Chrome, Firefox, FF, Edge), but they should all be either transpilable or polyfill-able if it's desired to support older browsers.

NB: this (currently) won't work on FF (and maybe Edge, haven't checked) due to missing polyfills. Should work fine in Chrome, and probably Safari. Let me know if it looks weird on your browser.

TODO:

  • refactor for code cleanliness (the code is currently very unorganized)
  • allow deleting of "saved" sectors
  • insert Custom Elements polyfill for current versions of FF (FF doesn't quite have custom elements yet, but they're close)
  • expose advanced information on things besides worlds and stars
  • a couple of minor UI nice-to-haves
    • jump-to-world from table currently jumps to the system, not the specific world within the system
  • document that double-click opens system info (or find a better way to distinguish between movement and system info -- drag-and-drop generally doesn't work amazingly when implemented in JS, and you can't use the HTML5 drag-and-drop API with SVG).

Strech Goals:

these would allow replacing the wiki versions without losing functionality

  • Editing/note-taking from the main page
  • All-in-one saving from the front page

This splits the main JS off into js/core.js, switches the doctype
to be modern HTML (instead of xhtml, which is basically dead :-( ),
fixes the indentation (some parts were 1-space indented, others were
not), and re-indents to a more-visible 2-space indent.
Net-new CSS is in css/new.css to make it easier to find parts that are
no longer needed.

Spacing is a *tad* bit off, but otherwise this should look identical.

- Remove uses of <br/> and &nbsp; for layout
- Split into logical chunks with backwards-compatible HTML semantic tags
  (header, section, footer, address)
- use ::before for address
- clean up CSS a bit
Instead of manually setting display characteristics in JS, we now have
a class in CSS for "closed".  The button simply toggles the presence of
this class.  Furthermore, we can use CSS3 animations to remove the need
for JS-based animations, and let the browser handle the tricky bits of
canceling animations, etc.
This reworks seed fetching to use the fetch API (a polyfill will be
needed for IE), but no more jQuery.  It also adds an error bar,
which allows us to display fetch errors (and others, in the future).
Seed generation is simply generating a random number in the range
[1, 2**32), and then base36 encoding it.  This is fairly trivial in
JS, so we move it client-side.
This commit reworks sector-gen layout.  The tabs are now displayed
via a custom element, and don't require jquery.  Fetching and display
of the various tables now use custom elements, as does the sector display.

This commit does not touch starmap display, which will thus not work
properly.

TODO:
- add waiting dialog back in
This introduces an SVG hex grid for the starmap.  This does not
implement the stars themselves.
This commit enables SVG star display and movement between hexes.
We no longer depend on anything jQuery-related, so we can remove
all of the last vestiges of it.
This displays worlds on the starmap overview (with some nice CSS tricks
to have them orbit), and lays the groundwork for more advanced data
views.
This extracts the grid position and the corresponding SVG generation
into its own classes, following the StarSystem pattern.  This makes the
code a bit cleaner and easier to read and update.
We now use a virtually-sized SVG canvas of [columns*100, rows*100], set
the viewBox on the SVG element to the actual size of the grid that fits
in that canvas (automatically determining the cell size), and let the
browser handle the scaling.

Additionally, the items inside each star are positioned relative to its
group, and not globally, and then the group itself it translated around.
This displays the sector info pane.  It does little other than display
the system at a larger view, currently.

TODO:
- clean up the code a bit
- fix up the styles a bit
These are some temporary changes to SectorGen to get things working
while hacking.  Expect them to go away in favor of something a bit more
elegant (`tag_names` will be replaced by a "view", most likely, and
`systems` will be the only thing sent).
@DirectXMan12 DirectXMan12 changed the title [WIP] Refector/Advanced Information [WIP] Frontend Refector/Advanced Information Oct 11, 2017
@DirectXMan12
Copy link
Author

P.S. From a front-end perspective, these changes make #9 basically complete -- you'd just need backend changes. If you want to play around, change the columns and rows field on the <star-map> using the dev tools on your browser and see how it updates.

@@ -13,7 +13,7 @@ use CGI qw(:standard);
use Data::Dumper;
use DBI;
use JSON;
use SWN2WIKI;
#use SWN2WIKI;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to just leave this out than include it commented-out?

-Content_Disposition => 'attachment;filename=SWN_Generator_'.$token.'.zip',
);
print $zipfile;
#$sector->{npcs} = $npcs;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be commented or removed also?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant