Skip to content

Commit

Permalink
my characters page folders
Browse files Browse the repository at this point in the history
  • Loading branch information
emfmesquita committed Dec 8, 2017
1 parent 2ecd4da commit 9398520
Show file tree
Hide file tree
Showing 27 changed files with 962 additions and 82 deletions.
108 changes: 53 additions & 55 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
{
"parser": "babel-eslint",
"plugins": [
"react"
],
"env": {
"amd": true,
"browser": true,
"jquery": true,
"node": true,
"es6": true,
"worker": true
},
"rules": {

"eqeqeq": 2,
"comma-dangle": 1,
"no-console": 0,
"no-debugger": 1,
"no-extra-semi": 1,
"no-extra-parens": 1,
"no-irregular-whitespace": 0,
"no-undef": 0,
"no-unused-vars": 0,
"semi": 1,
"semi-spacing": 1,
/*"valid-jsdoc": [
"parser": "babel-eslint",
"plugins": [
"react"
],
"env": {
"amd": true,
"browser": true,
"jquery": true,
"node": true,
"es6": true,
"worker": true
},
"rules": {
"eqeqeq": 2,
"comma-dangle": 1,
"no-console": 0,
"no-debugger": 1,
"no-extra-semi": 1,
"no-extra-parens": 1,
"no-irregular-whitespace": 0,
"no-undef": 0,
"no-unused-vars": 0,
"semi": 1,
"semi-spacing": 1,
/*"valid-jsdoc": [
2,
{ "requireReturn": false }
],*/

"react/display-name": 2,
"react/forbid-prop-types": 1,
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 1,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": 1,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 0,
"react/jsx-no-undef": 1,
"react/sort-prop-types": 1,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-danger": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 1,
"react/no-set-state": 0,
"react/no-unknown-property": 1,
"react/prop-types":0,
"react/react-in-jsx-scope": 0,
"react/require-extension": "off",
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/jsx-wrap-multilines": 1
}
"react/display-name": 2,
"react/forbid-prop-types": 1,
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 1,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": 1,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 0,
"react/jsx-no-undef": 1,
"react/sort-prop-types": 1,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-danger": 0,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 1,
"react/no-set-state": 0,
"react/no-unknown-property": 1,
"react/prop-types": 0,
"react/react-in-jsx-scope": 0,
"react/require-extension": "off",
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/jsx-wrap-multilines": 1
}
}
13 changes: 9 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
"javascript.validate.enable": false,
"editor.formatOnSave": true,
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/build": true
}
"**/.git": true
},
"explorer.openEditors.visible": 0,
"files.exclude": {
"node_modules/": true,
"build/": true
},
"workbench.iconTheme": "vscode-icons",
"window.zoomLevel": 0
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beyondhelp",
"version": "0.4.0",
"version": "0.5.0",
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
Expand Down
21 changes: 21 additions & 0 deletions public/extensioncontentstyle.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
.BH-character-list {
list-style: none !important;
list-style-image: none !important;
padding: 0 !important;
margin: 0 !important;
}

a.BH-homebrew-character-action,
a.BH-homebrew-character-action:hover,
a.BH-homebrew-character-action:focus,
a.BH-homebrew-character-action:active,
a.BH-homebrew-character-action:visited {
color: #ee8600 !important;
}

.BH-character-multiple-select {
font-size: 15px !important;
height: 100% !important;
overflow: hidden !important;
}

@media print {
.BH-Monster-button {
display: none !important;
Expand Down
5 changes: 3 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Beyond Help",
"version": "0.4.0",
"version": "0.5.0",
"description": "Chrome extension with helpers to https://www.dndbeyond.com/.",
"background": {
"scripts": [
Expand Down Expand Up @@ -40,11 +40,12 @@
"permissions": [
"activeTab",
"commands",
"cookies",
"notifications",
"storage",
"tabs",
"webRequest",
"https://www.dndbeyond.com/*"
"*://*.dndbeyond.com/*"
],
"icons": {
"16": "icon-16.png",
Expand Down
9 changes: 8 additions & 1 deletion src/background/extensionbackground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BadgeService from "../services/BadgeService";
import NotificationService from "../services/NotificationService";
import UserService from "../services/UserService";

/* global chrome */

Expand All @@ -16,10 +17,16 @@ chrome.webRequest.onCompleted.addListener((details) => chrome.tabs.sendMessage(d
});

// listen when a monster is added from AddMonsterButton, adds a notification
chrome.runtime.onMessage.addListener((request, sender) => {
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// if it's a reload request just ignores
if (request.reload) return;

// request to fetch the current user username
if (request.username) {
UserService.getCurrentUsername().then(sendResponse);
return true;
}

NotificationService.createNotification(request.notificationid, request.notification);
BadgeService.updateBadgeCount();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react';

import MonsterContentData from "./MonsterContentData";
import NotificationService from "../services/NotificationService";
import StorageService from '../services/StorageService';
import NotificationService from "../../services/NotificationService";
import StorageService from '../../services/StorageService';

class AddMonsterButton extends Component {
constructor(props) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import MonsterContentData from "./MonsterContentData";

class ParseData {
class MonsterParseData {
constructor(insertFunction: string, target: JQuery<HTMLElement>, monsterData: MonsterContentData) {
this.insert = target[insertFunction].bind(target);
this.monsterData = monsterData;
}
}

export default ParseData;
export default MonsterParseData;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from "jquery";
import MonsterContentData from "./MonsterContentData";
import ParseData from "./ParseData";
import MonsterParseData from "./MonsterParseData";

const isOnMonsterList = function (path: string) {
return path === "/monsters";
Expand All @@ -14,7 +14,7 @@ const isOnMonsterDetail = function (path: string) {
return path.startsWith("/monsters/");
};

const parseList = function (isHomebrew): ParseData[] {
const parseList = function (isHomebrew): MonsterParseData[] {
const parseDataArray = [];
$(".more-info-monster:not(.bh-processed)").find(".mon-stat-block").each((idx, el) => {
// gather monster info from page
Expand All @@ -35,12 +35,12 @@ const parseList = function (isHomebrew): ParseData[] {
// target
const target = $(el);

parseDataArray.push(new ParseData("before", target, monsterData));
parseDataArray.push(new MonsterParseData("before", target, monsterData));
});
return parseDataArray;
};

const parseDetail = function (): ParseData[] {
const parseDetail = function (): MonsterParseData[] {
const path = window.location.pathname;
const id = path.substring(path.lastIndexOf("/") + 1);
const name = $(".mon-stat-block__name-link").text().trim();
Expand All @@ -50,11 +50,11 @@ const parseDetail = function (): ParseData[] {
const diceHp = jqHpAttribute.find(".mon-stat-block__attribute-data-extra").text().trim();
const hp = jqHpAttribute.find(".mon-stat-block__attribute-data-value").text().trim();

return [new ParseData("before", $(".mon-stat-block"), new MonsterContentData(id, name, hp, diceHp))];
return [new MonsterParseData("before", $(".mon-stat-block"), new MonsterContentData(id, name, hp, diceHp))];
};

class ParseService {
static parseMonsters(): ParseData[] {
class MonsterParseService {
static parseMonsters(): MonsterParseData[] {
const path = window.location.pathname;

const isMonsterList = isOnMonsterList(path);
Expand All @@ -71,4 +71,4 @@ class ParseService {
}
}

export default ParseService;
export default MonsterParseService;
25 changes: 25 additions & 0 deletions src/contentscript/dialogs/ContentDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { Component } from 'react';

/**
* Dialog on content page.
*/
class ContentDialog extends Component {
render() {
return (
<div id={this.props.dialogId} className="ddb-modal" title="Delete Folder" style={{ display: "none" }}>
<div className="ddb-modal-form">
<div className="ddb-modal-header">
<div className="ddb-modal-header-text">
{this.props.message}
</div>
</div>
<a className="ajax-post button" href="javascript:void(0)" onClick={this.props.onConfirm}>
{this.props.confirmText || "Yes"}
</a>
</div>
</div>
);
}
}

export default ContentDialog;
22 changes: 22 additions & 0 deletions src/contentscript/dialogs/ContentDialogService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import PageScriptService from "../../services/PageScriptService";

class ContentDialogService {
/**
* Opens a dialog on content page.
* @param {string} id target element id
*/
static open(id: string) {
const dialogOptions = `{ width: "auto", beforeClose: () => $("body").css("overflow", "inherit")}`;
PageScriptService.run(`$("#${id}").dialog(${dialogOptions}); $("body").css("overflow", "hidden");`);
}

/**
* Closes a dialog on content page.
* @param {string} id target element id
*/
static close(id: string) {
PageScriptService.run(`$("#${id}").dialog("close");`);
}
}

export default ContentDialogService;
Loading

0 comments on commit 9398520

Please sign in to comment.