-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpopup.html
152 lines (132 loc) · 4.65 KB
/
popup.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<style>
* { margin:0; padding:0; font: 15px arial,sans-serif; color:#333; }
body { overflow:hidden; padding: 10px; min-width: 450px;}
input[type=text], select{ color: #666; border: 1px solid #ddd; padding: 8px; }
input[type=text]{ width: 90%; }
form {width:400px; margin: auto;}
h1 { margin-bottom: 10px; font-size: 18px}
.row{padding-bottom: 8px;color: #666;}
input[type=submit]{
border: 1px solid #29691D;
color: white;
text-shadow: 0 1px rgba(0, 0, 0, 0.1);
background-image: -webkit-linear-gradient(top,#3D9400,#398A00);
padding: 5px;
font-weight: bold;
cursor: pointer;
}
input[type=submit].disabled { background-image: -webkit-linear-gradient(top,#9bc181,#a3c988); }
select[id=startTime]{ margin-right: 8px; }
#ajax-loader { visibility: hidden; }
.plus { cursor: pointer; float: right; text-decoration: none; color: #666; font-weight: bold; line-height: 30px; text-align: center;}
.history { padding: 10px; display: none; }
.history a { text-decoration: none; }
.history a:hover { text-decoration: underline; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
<script type="text/javascript">
function showLoading(show){
if(show){
$("#ajax-loader").css("visibility", "visible");
$('#trackButton').attr('disabled', 'disabled');
$('#trackButton').addClass("disabled");
} else {
$("#ajax-loader").css("visibility", "hidden");
$('#trackButton').removeAttr("disabled");
$('#trackButton').removeClass("disabled");
}
}
function hideLoading(){
showLoading(false);
}
function updateUIWithHistory(localStorageSetting){
var history = chrome.extension.getBackgroundPage().getHistory(localStorageSetting);
$("#" + localStorageSetting + "Container").html("<a href=\"#\">" + history.reverse().join("</a><br/><a href=\"#\">") + "</a>");
}
function showOrHideHistoryContainer(historyContainer){
var id = historyContainer.attr("id");
var plus = $("#" + id.substring(0, id.indexOf("Container")));
if(historyContainer.css("display") == "block"){
historyContainer.hide("blind", {}, 500);
plus.html("▾");
} else {
historyContainer.show("blind", {}, 500);
plus.html("▴");
}
}
$(function() {
for( var i = 0; i < 24; i++ )
for( var j = 0; j < 60; j+= 15 ) {
var val = pad( i ) + ":" + pad( j );
$( "#startTime" ).append( $( '<option>', { value : val } ).text( val ) );
$( "#endTime" ).append( $( '<option>', { value : val } ).text( val ) );
}
var track = chrome.extension.getBackgroundPage().restoreTrack();
$("#client").val(track.client);
$("#project").val(track.project);
$("#description").val(track.description);
$("#startTime").val(track.startTime);
$("#endTime").val(track.endTime);
$("#trackForm").submit(function(){
showLoading(true);
chrome.extension.getBackgroundPage().track({
client: $("#client").val(),
project: $("#project").val(),
description: $("#description").val(),
startTime: $("#startTime").val(),
endTime: $("#endTime").val(),
}, hideLoading);
return false;
});
$("#client").focus();
$(".plus").click(function(){
showOrHideHistoryContainer($("#" + $(this).attr("id") + "Container"));
});
updateUIWithHistory("clientsHistory");
updateUIWithHistory("projectsHistory");
updateUIWithHistory("descriptionsHistory");
});
$(".history a").live("click", function(){
var historyContainer = $(this).parent();
historyContainer.prev().val($(this).text());
showOrHideHistoryContainer(historyContainer);
});
function pad( num ) {
var str = '' + num;
while( str.length < 2 ) str = '0' + str;
return str;
}
</script>
</head>
<body>
<form id="trackForm">
<h1>Track your activity</h1>
<div class="row">
<a id="clientsHistory" class="plus" title="Show history">▾</a>
<input type="text" id="client" placeholder="Client..." />
<div id="clientsHistoryContainer" class="history"></div>
</div>
<div class="row">
<a id="projectsHistory" class="plus" title="Show history">▾</a>
<input type="text" id="project" placeholder="Project..." />
<div id="projectsHistoryContainer" class="history"></div>
</div>
<div class="row">
<a id="descriptionsHistory" class="plus" title="Show history">▾</a>
<input type="text" id="description" placeholder="Description..." />
<div id="descriptionsHistoryContainer" class="history"></div>
</div>
<div class="row">
From: <select id="startTime"></select>
To: <select id="endTime"></select>
</div>
<div>
<input id="trackButton" type="submit" value="Track">
<img id="ajax-loader" src="images/ajax-loader.gif">
</div>
</form>
</body>