Skip to content

Commit

Permalink
Merge branch 'master' of github.com:santeacademie/bigbrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
Julienblc committed Feb 21, 2022
2 parents 7fbc359 + 559ca05 commit fc054e0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
14 changes: 7 additions & 7 deletions build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import TamperController from '../../../core/controller/TamperController';
import TamperRequest from '../../../core/router/TamperRequest';
declare class ReachCounter extends TamperController {
loaded: boolean;
hashTryReachField: string;
focusedFieldKey: string | undefined;
run: (request: TamperRequest) => void;
_grabFieldKey: () => string | undefined;
_grabFieldKey: (regexField: RegExp, searchFieldKey: string) => string | undefined;
_launchTryReach: () => void;
_addButtonToPopover: () => void;
_subOneTryReach: ($item: any) => void;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@santeacademie/bigbrowser",
"version": "2.6",
"version": "2.7",
"description": "Better browser for your own good",
"main": "build/index.js",
"types": "build/types/index.d.ts",
Expand Down
28 changes: 11 additions & 17 deletions src/lib/controller/Pipedrive/ReachCounter/ReachCounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,28 @@ import TamperRequest from '@core/router/TamperRequest';

class ReachCounter extends TamperController {
loaded = false;
hashTryReachField = 'a9a1a17c4397010006c2aa550dca0cab13ed3419';
focusedFieldKey: string | undefined = undefined;

run = (request: TamperRequest): void => {
setTimeout(() => {
this._launchTryReach();
}, 3500);
};

_grabFieldKey = (): string | undefined => {
_grabFieldKey = (regexField: RegExp, searchFieldKey: string): string | undefined => {
let foundField: string | undefined = undefined;

$('.gridHeader__cell').each((index: number, element: HTMLElement) => {
if (foundField) {
return;
}

if (
$(element)
.text()
.trim()
.match(/^tentative/i)
) {
if ($(element).text().trim().match(regexField)) {
const field = $(element).data().field;
const fieldKey = field.split('.')[0];

if (field.indexOf('.') < 0) {
foundField = field;
if (fieldKey == searchFieldKey) {
foundField = fieldKey;
}
}
});
Expand All @@ -47,13 +43,11 @@ class ReachCounter extends TamperController {

const $body: any = $('body');

this.hashTryReachField = this._grabFieldKey() ?? this.hashTryReachField;

$body.on('click', 'td.gridRow__cell:not(".gridRow__cell--editing") button', (event: JQuery.ClickEvent) => {
const $this = $(event.target);
this.hashTryReachField = this._grabFieldKey() ?? '';
this.focusedFieldKey = this._grabFieldKey(/^tentative/i, $this.parents('td:eq(0)').data('field'));

if ($this.parents('td:eq(0)').data('field') == this.hashTryReachField) {
if (this.focusedFieldKey) {
setTimeout(() => {
this._addButtonToPopover();
}, 1000);
Expand All @@ -72,7 +66,7 @@ class ReachCounter extends TamperController {
};

_addButtonToPopover = (): void => {
const $item: any = $('.changeFieldValue.' + this.hashTryReachField + ' .item');
const $item: any = $('.changeFieldValue.' + this.focusedFieldKey + ' .item');
$item.find('.valueWrap').prepend(`
<div style="display:flex;justify-content:space-between;margin-bottom:3px;">
<button style="padding:5px 10px;cursor: pointer;" class="sub-one-tryreach">-1</button>
Expand All @@ -84,7 +78,7 @@ class ReachCounter extends TamperController {
};

_subOneTryReach = ($item: any): void => {
const $select: any = $item.find('select[name="' + this.hashTryReachField + '"]');
const $select: any = $item.find('select[name="' + this.focusedFieldKey + '"]');
const index: any = $select.prop('selectedIndex');

if (index > 1) {
Expand All @@ -95,7 +89,7 @@ class ReachCounter extends TamperController {
};

_addOneTryReach = ($item: any): void => {
const $select: any = $item.find('select[name="' + this.hashTryReachField + '"]');
const $select: any = $item.find('select[name="' + this.focusedFieldKey + '"]');
const index: any = $select.prop('selectedIndex');

if (index < $select.find('option').length - 1) {
Expand Down

0 comments on commit fc054e0

Please sign in to comment.