Skip to content

Commit

Permalink
Merge pull request #6 from pierroberto/donate
Browse files Browse the repository at this point in the history
Donate button
  • Loading branch information
pierroberto authored Sep 9, 2020
2 parents f7bf1f2 + 71fd1f6 commit 7a4f342
Show file tree
Hide file tree
Showing 19 changed files with 213 additions and 220 deletions.
8 changes: 3 additions & 5 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"manifest_version": 2,
"name": "Pin tabs - Tab Manager",
"short_name": "Keep tabs history",
"version": "1.2.0",
"description":
"Pin Tabs allows the user to pin one or more tabs for short periods, keep track of the expired tabs in the history and save energy",
"version": "1.3.1",
"description": "Pin Tabs allows the user to pin one or more tabs for short periods, keep track of the expired tabs in the history and save energy",
"browser_action": {
"default_title": "Show the list of pinned tabs",
"default_popup": "pages/popup.html"
Expand Down Expand Up @@ -35,6 +34,5 @@
"48": "assets/list.png",
"128": "assets/list128.png"
},
"content_security_policy":
"script-src 'self' https://ssl.google-analytics.com; object-src 'self'"
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'"
}
68 changes: 33 additions & 35 deletions src/pages/background/actions.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@

//BOOKMARKS ACTIONS
export const refreshBookmark = (data, time) => ({
type: 'REFRESH',
type: "REFRESH",
urlList: data,
expiry: time
})
});

export const deleteAllBookmark = () => ({
type: 'DELETE-ALL',
})
type: "DELETE-ALL"
});

export const deleteOneBookmark = (url) => ({
type: 'DELETE-ONE',
export const deleteOneBookmark = url => ({
type: "DELETE-ONE",
url: url
})
});

export const addBookmark = (url) => ({
type: 'ADD',
export const addBookmark = url => ({
type: "ADD",
urlList: url,
expiry: new Date().getTime()
})
});

export const addFromButton = (flag) => ({
type: 'DELETE-ONE',
export const addFromButton = flag => ({
type: "DELETE-ONE",
addFromButton: flag
})
});

export const searchBookmark = (text) => ({
type: 'SEARCH',
export const searchBookmark = text => ({
type: "SEARCH",
textSearched: text
})
});

export const emptySearch = () => ({
type: 'EMPTY-SEARCH'
})
type: "EMPTY-SEARCH"
});

//SETTINGS actions

export const toggleButton = (flag) => ({
type: 'TOGGLE-BUTTON',
export const toggleButton = flag => ({
type: "TOGGLE-BUTTON",
toggleButton: flag
})
});

export const expireDate = (date) => ({
type: 'UPDATE-DATE',
export const expireDate = date => ({
type: "UPDATE-DATE",
expireDate: date
})
});

export const toggleButtonHistory = (flag) => ({
type: 'TOGGLE-BUTTON-HISTORY',
export const toggleButtonHistory = flag => ({
type: "TOGGLE-BUTTON-HISTORY",
toggleButtonHistory: flag
})

});

// ANIMATION ACTIONS

export const buttonCog = (flag) => ({
type: 'TOGGLE-COG',
export const buttonCog = flag => ({
type: "TOGGLE-COG",
buttonCog: flag
})
});

export const toggleSearch = (classValue) => ({
type: 'TOGGLE-SEARCH',
export const toggleSearch = classValue => ({
type: "TOGGLE-SEARCH",
toggleSearch: classValue
})
});
20 changes: 11 additions & 9 deletions src/pages/background/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import store from './store';
import store from "./store";

store.subscribe (() => {
store.getState().bookmark.tabs.map(infoTab => {
chrome.alarms.create(infoTab.tab[0].url, {when: infoTab.expiry + store.getState().settings.expireDate})
store.subscribe(() => {
store.getState().bookmark.tabs.map(infoTab => {
chrome.alarms.create(infoTab.tab[0].url, {
when: infoTab.expiry + store.getState().settings.expireDate
});
});
});

chrome.alarms.onAlarm.addListener(function (data) {
chrome.alarms.onAlarm.addListener(function(data) {
const elementExpired = store.getState().bookmark.tabs.filter(el => {
return el.tab[0].url === data.name
})
store.dispatch({type:'EXPIRY', url: elementExpired[0].tab[0].url})
})
return el.tab[0].url === data.name;
});
store.dispatch({ type: "EXPIRY", url: elementExpired[0].tab[0].url });
});
18 changes: 8 additions & 10 deletions src/pages/background/localStorage.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
export const saveState = (state) => {
export const saveState = state => {
try {
const serializedState = JSON.stringify(state);
localStorage.setItem('state', serializedState);
localStorage.setItem("state", serializedState);
} catch (e) {
console.error('Error saving state', e);
console.error("Error saving state", e);
}
}
};

export const loadState = () => {
try {
const serializedState = localStorage.getItem('state');
if(serializedState === null) {
const serializedState = localStorage.getItem("state");
if (serializedState === null) {
return undefined;
}
return JSON.parse(serializedState);
} catch (e) {

}
}
} catch (e) {}
};
18 changes: 9 additions & 9 deletions src/pages/background/reducers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {combineReducers} from 'redux';
import bookmark from './reducers/bookmarks';
import settings from './reducers/settings';
import animation from './reducers/animations';
import { combineReducers } from "redux";
import bookmark from "./reducers/bookmarks";
import settings from "./reducers/settings";
import animation from "./reducers/animations";

export default combineReducers ({
bookmark : bookmark,
settings : settings,
animation: animation,
})
export default combineReducers({
bookmark: bookmark,
settings: settings,
animation: animation
});
16 changes: 7 additions & 9 deletions src/pages/background/reducers/animations.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@

const defaultState = {
buttonCog: false
}
};

const animation = (state=defaultState,action) => {
const animation = (state = defaultState, action) => {
switch (action.type) {
case 'TOGGLE-COG':
case "TOGGLE-COG":
return {
...state,
buttonCog: action.buttonCog
}
case 'TOGGLE-SEARCH':
};
case "TOGGLE-SEARCH":
return {
...state,
toggleSearch: action.toggleSearch
}
};
default:
return state;
}

}
};

export default animation;
23 changes: 10 additions & 13 deletions src/pages/background/reducers/settings.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@

const defaultState = {
button: false,
buttonHystory: true,
expireDate: 86400000 // 1 day
};

}

const settings = (state=defaultState,action) => {
const settings = (state = defaultState, action) => {
switch (action.type) {
case 'TOGGLE-BUTTON':
case "TOGGLE-BUTTON":
return {
...state,
button: action.toggleButton
}
case 'TOGGLE-BUTTON-HISTORY':
};
case "TOGGLE-BUTTON-HISTORY":
return {
...state,
buttonHistory: action.toggleButtonHistory
}
case 'UPDATE-DATE':
};
case "UPDATE-DATE":
return {
...state,
expireDate: action.expireDate
}

};
}
return state
}
return state;
};

export default settings;
40 changes: 20 additions & 20 deletions src/pages/background/store.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { applyMiddleware, createStore } from 'redux'
import { wrapStore, alias } from 'react-chrome-redux'
import { createLogger } from 'redux-logger'
import thunk from 'redux-thunk'
import reducer from './reducers'
import throttle from 'lodash/throttle';
import { saveState, loadState } from './localStorage';
const store = createStore(
reducer,
loadState()
);
import { applyMiddleware, createStore } from "redux";
import { wrapStore, alias } from "react-chrome-redux";
import { createLogger } from "redux-logger";
import thunk from "redux-thunk";
import reducer from "./reducers";
import throttle from "lodash/throttle";
import { saveState, loadState } from "./localStorage";
const store = createStore(reducer, loadState());

store.subscribe(throttle(() => {
saveState({
bookmark: store.getState().bookmark,
settings: store.getState().settings,
animation: store.getState().animation
})
}), 1000);
store.subscribe(
throttle(() => {
saveState({
bookmark: store.getState().bookmark,
settings: store.getState().settings,
animation: store.getState().animation
});
}),
1000
);

wrapStore(store, {
portName: 'COUNTING',
})
portName: "COUNTING"
});

export default store;
16 changes: 7 additions & 9 deletions src/pages/content/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
bottom: 20px;
height: 50px;
width: 50px;
box-shadow: 6px 6px 18px 0 rgba(0,0,0,0.3);
box-shadow: 6px 6px 18px 0 rgba(0, 0, 0, 0.3);
border-radius: 100%;
background-color: #33C3F0;
background-color: #33c3f0;
cursor: pointer;
z-index: 99999;
}
Expand All @@ -22,8 +22,8 @@
padding: 10px 20px;
right: 70px;
top: 50%;
color: #33C3F0;
box-shadow: 6px 6px 18px 0 rgba(0,0,0,0.1);
color: #33c3f0;
box-shadow: 6px 6px 18px 0 rgba(0, 0, 0, 0.1);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 3px;
Expand All @@ -32,7 +32,7 @@
}

.popup:before {
content: '';
content: "";
position: absolute;
top: 50%;
right: 0;
Expand All @@ -42,7 +42,6 @@
border-top: 7px solid transparent;
border-bottom: 7px solid transparent;
border-left: 7px solid white;

}

.popup-visibility-show {
Expand All @@ -65,18 +64,17 @@
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
transform: translate(-50%, -50%);
width: 2px;
height: 20px;
background-color: white;

}

.y-line {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
transform: translate(-50%, -50%);
width: 20px;
height: 2px;
background-color: white;
Expand Down
Loading

0 comments on commit 7a4f342

Please sign in to comment.