Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/publish-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false

- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
run: |
npm install
npm run build

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: dist/deploy # The folder the action should deploy.
34 changes: 34 additions & 0 deletions .github/workflows/scheduled-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Merge upstream branches every Thursday 00:00
on:
schedule:
- cron: '0 4,8,12,16 * * 3'
- cron: '0 0,8,16 * * 4'
workflow_dispatch:

jobs:
merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
token: ${{secrets.GHPAGE_SECRET}}
- name: Merge upstream
run: |
git config --global user.name 'GitHub Action by Anthony'
git config --global user.email '[email protected]'

# "git checkout master" is unnecessary, already here by default
git pull --unshallow # this option is very important, you would get
# complains about unrelated histories without it.
# (but actions/checkout@v2 can also be instructed
# to fetch all git depth right from the start)

git remote set-url origin https://${{secrets.GHPAGE_SECRET}}@github.com/anthonychwong/gbgwcalculator

git remote add upstream https://github.com/rmkane/gbgwcalculator.github.io.git
git fetch upstream

git checkout master
git merge --no-edit upstream/master
git push origin master
21 changes: 12 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (grunt) {

meta: {
src: 'src',
dest: 'dist',
dest: 'dist/deploy',
banner: '/*\n <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/'
},

Expand All @@ -23,7 +23,7 @@ module.exports = function (grunt) {
sourceMap : true
},
dev: {
files: {'<%= meta.dest %>/js/bundle.js': '<%= meta.src %>/js/**/*.js'},
files: {'<%= meta.dest %>/dist/js/bundle.js': '<%= meta.src %>/js/**/*.js'},
options: {
beautify: true,
mangle: false,
Expand All @@ -33,7 +33,7 @@ module.exports = function (grunt) {
},
prod: {
files: {
'<%= meta.dest %>/js/bundle.min.js': [
'<%= meta.dest %>/dist/js/bundle.min.js': [
'<%= meta.src %>/js/data.js',
'<%= meta.src %>/js/globals.js',
'<%= meta.src %>/js/data-store.class.js',
Expand All @@ -49,7 +49,7 @@ module.exports = function (grunt) {
less: {
build: {
files: {
'<%= meta.dest %>/css/bundle.css': [
'<%= meta.dest %>/dist/css/bundle.css': [
'<%= meta.src %>/css/gbgw-icons.css',
'<%= meta.src %>/css/style.css',
'<%= meta.src %>/css/themes/dark.css'
Expand All @@ -64,7 +64,7 @@ module.exports = function (grunt) {
},
build: {
files: {
'<%= meta.dest %>/css/bundle.min.css': [
'<%= meta.dest %>/dist/css/bundle.min.css': [
'<%= meta.src %>/css/gbgw-icons.css',
'<%= meta.src %>/css/style.css',
'<%= meta.src %>/css/themes/dark.css'
Expand All @@ -80,25 +80,28 @@ module.exports = function (grunt) {
cwd: '<%= meta.src %>/data',
src: '**/*.json',
flatten: true,
dest: '<%= meta.dest %>/data',
dest: '<%= meta.dest %>/dist/data',
},{
expand: true,
cwd: '<%= meta.src %>/assets/icons',
src: '**/*.png',
flatten: true,
dest: '<%= meta.dest %>/assets',
dest: '<%= meta.dest %>/dist/assets',
}, {
expand: true,
cwd: '<%= meta.src %>/assets/third-party',
src: [ '**/*.svg', '**/*.jpg' ],
flatten: true,
dest: '<%= meta.dest %>/assets',
dest: '<%= meta.dest %>/dist/assets',
}, {
expand: true,
cwd: '<%= meta.src %>/css/fonts',
src: '*',
flatten: true,
dest: '<%= meta.dest %>/css/fonts',
dest: '<%= meta.dest %>/dist/css/fonts',
}, {
src: '<%= meta.src %>/../index.html',
dest: '<%= meta.dest %>/index.html',
}]
}
},
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Build and Deploy](https://github.com/anthonychwong/gbgwcalculator/workflows/Build%20and%20Deploy/badge.svg)

# GBGW Calculator

## About
Expand Down Expand Up @@ -32,4 +34,4 @@ For version history, please view the [change log](./CHANGELOG.md).
* [AutoRiceCooker @ GitHub](https://github.com/autoricecooker)
* [Acylos @ Reddit](https://www.reddit.com/user/Acylos)
* [SmilyT1 @ GamePress](https://gamepress.gg/user/684586)
* And many others @ [GBGW: Newtype Labs](https://discord.gg/6aMUnBD)
* And many others @ [GBGW: Newtype Labs](https://discord.gg/6aMUnBD)
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ <h1>GBGW Calculator v1.3.0</h1>
</div>
</div>
</header>
<div style="width: calc(1380px + 1em); margin: auto">
<h3>Share selected parts and gear</h3>
<div class="share-link-display" style="overflow-wrap: anywhere;"></div>
</div>
<div class="container js-container"></div>
<footer>
<div class="notice">
Expand Down
43 changes: 39 additions & 4 deletions src/js/gunpla-calculator.class.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GunplaCalculator {
class GunplaCalculator {
constructor(dataStoreManager) {
this.dataStoreManager = dataStoreManager;

Expand Down Expand Up @@ -30,6 +30,7 @@ class GunplaCalculator {
this.searchPart = '';
this.sort = '';
this.currentPart = '';
this.shareLinkDisplay = document.querySelector('.share-link-display');
}

init() {
Expand All @@ -49,6 +50,7 @@ class GunplaCalculator {
this._initApplyMapBonus();
this._initSearchPart();
this._initRemove();
this._initSharedData();
}

_generateSkillIcon(exData) {
Expand Down Expand Up @@ -151,7 +153,39 @@ class GunplaCalculator {
this._showPartList(slot);
this._displayPartInfo(input);
}


_showShareLink(){
var selected = {};

const inputs = this.inputs;
for (let input in inputs) {
if (inputs.hasOwnProperty(input) && inputs[input]) {
selected[inputs[input].dataset.part]=inputs[input].dataset.partname;
}
}

var result = JSON.stringify(selected);
var curLink = new URL(window.location.href);
var genLink = curLink.protocol + "//" + curLink.host + curLink.pathname + "?d=" + window.btoa(result);

this.shareLinkDisplay.innerHTML = '<a href="' + genLink + '">' + genLink + '</a>';
}

_initSharedData(){
var curLink = new URL(window.location.href);
var selected = {};

var nextUrlParam = curLink.searchParams.entries().next();
if(!nextUrlParam.done){
selected = JSON.parse(window.atob(nextUrlParam.value[1]));

for(let key in selected){
this._handleInputClick(document.querySelector(".js-input-"+key));
this._handlePartSelection(document.querySelector('div[data-partname="' + selected[key] + '"]'));
}
}
}

_checkFilter(part) {
const filters = this.filters;
if (this.filters.attr && part.attribute && part.attribute != this.filters.attr) {
Expand Down Expand Up @@ -282,6 +316,7 @@ class GunplaCalculator {
}
}
this._calculate(partData);
this._showShareLink();
}

_getPartSlotClass(dataset, forcePart) {
Expand Down Expand Up @@ -775,7 +810,7 @@ class GunplaCalculator {
}

_displayPartInfo(part) {
if (part && part.dataset.partname && MainSlot.indexOf(part.dataset.part) > -1) {
if (part && part.dataset.partname && MainSlot.indexOf(part.dataset.part) > -1) {
const wordTag = JSON.parse(part.dataset.wt),
ex = JSON.parse(part.dataset.ex);
let markMultiplier = 0;
Expand Down Expand Up @@ -955,4 +990,4 @@ GunplaCalculator.normalizeString = (str) => {
};
GunplaCalculator.containsNormalized = (str, term) => {
return GunplaCalculator.normalizeString(str).indexOf(GunplaCalculator.normalizeString(term)) !== -1;
};
};