Skip to content

Commit

Permalink
added copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0Michine committed Feb 14, 2017
1 parent bbaa968 commit ca1ae8e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
13 changes: 12 additions & 1 deletion src/app.common/models/CalendarEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "moment-timezone";
import { TimeSpanInfo } from "./TimeSpanInfo";

export class CalendarEvent {
static toCalendarEvent(timeSpan: TimeSpanInfo, location: string) {
static exportToICS(timeSpan: TimeSpanInfo, location: string) {
const startTime = moment().hours(timeSpan.startHour).minutes(timeSpan.startMinute).seconds(0);
const endTime = moment().hours(timeSpan.endHour).minutes(timeSpan.endMinute).seconds(0);
const mail = "me@gmail.com";
Expand Down Expand Up @@ -33,4 +33,15 @@ export class CalendarEvent {

window.open(`data:text/calendar;charset=utf8,${encodeURI(icsMSG)}`);
}

static copyToClipboard(timeSpan: TimeSpanInfo, location: string) {
let copyFrom = document.createElement("textarea");
copyFrom.textContent = "copy content";
document.body.appendChild(copyFrom);
copyFrom.focus();
document.execCommand('SelectAll');
document.execCommand('Copy');
document.execCommand("copy");
document.body.removeChild(copyFrom);
}
}
44 changes: 26 additions & 18 deletions src/app/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,32 @@ export class Layout extends React.Component<LayoutProps, any> {
<Range rangeSize={48} valueMin={valueMin} valueMax={valueMax} onChange={({valueMin, valueMax}) => changeSelectedTimeSpan(valueMin, valueMax)} />
</div>
<div className={style.timeSpanSelector}>
<span>{startTime.format("HH:mm")} - {endTime.format("HH:mm")} ({duration.as("hours")})</span>
{/*<div className={style.timeSpanSelectorInput}>
<Input placeholder="hh" />
</div><span> : </span>
<div className={style.timeSpanSelectorInput}>
<Input placeholder="mm" />
</div><span> - </span>
<div className={style.timeSpanSelectorInput}>
<Input placeholder="hh" />
</div><span> : </span>
<div className={style.timeSpanSelectorInput}>
<Input placeholder="mm" />
</div>*/}
<div className="pull-right">
<button
className={`btn btn-default btn-material ${ buttonDisabled ? "disabled" : ""}`}
onClick={() => CalendarEvent.toCalendarEvent(selectedTimeSpan, timeLines[0].timeZoneId)}
>Export ot .ics</button>
<div className="bottom-panel-container">
<div className="">
<span>{startTime.format("HH:mm")} - {endTime.format("HH:mm")} ({duration.as("hours")})</span>
</div>
{/*<div className={style.timeSpanSelectorInput}>
<Input placeholder="hh" />
</div><span> : </span>
<div className={style.timeSpanSelectorInput}>
<Input placeholder="mm" />
</div><span> - </span>
<div className={style.timeSpanSelectorInput}>
<Input placeholder="hh" />
</div><span> : </span>
<div className={style.timeSpanSelectorInput}>
<Input placeholder="mm" />
</div>*/}
<div className="">
<button
className={`btn btn-default btn-material ${ buttonDisabled ? "disabled" : ""}`}
onClick={() => CalendarEvent.copyToClipboard(selectedTimeSpan, timeLines[0].timeZoneId)}
>Copy</button>
<button
className={`btn btn-default btn-material ${ buttonDisabled ? "disabled" : ""}`}
onClick={() => CalendarEvent.exportToICS(selectedTimeSpan, timeLines[0].timeZoneId)}
>Export ot .ics</button>
</div>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ div#app.app-options {
width: 850px;
background-color: #fff;
border: 1px solid #ccc;
}

.bottom-panel-container {
display: flex;
align-items: center;
justify-content: space-between;
}
3 changes: 2 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"storage",
"management",
"notifications",
"contextMenus"
"contextMenus",
"clipboardWrite"
]
}

0 comments on commit ca1ae8e

Please sign in to comment.