-
Notifications
You must be signed in to change notification settings - Fork 13
/
users.html
350 lines (330 loc) · 16 KB
/
users.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="images/favicon.png">
<title>Countly Code Generator</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron top">
<div class="container">
<div id="logo">
<span class="image"></span>
<span class="text">Code Generator</span>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<p id="buttons">
<a href="index.html" id="back" class="btn btn-default">← Back</a>
</p>
<h2 class="text-center">Add information about user</h2>
</div>
</div>
<div class='section'>
<span class='label'>Provide information about user</span>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for='name'>Name:</label>
<input type="text" class="form-control property" id='name' placeholder="John Smith">
</div>
</div><!-- /.col-lg-6 -->
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" class="form-control property" id="username" placeholder="john.smith">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control property" id="email"
placeholder="[email protected]">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="organization">Company/Organization:</label>
<input type="text" class="form-control property" id="organization" placeholder="My Company">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="phone">Phone:</label>
<input type="tel" class="form-control property" id="phone" placeholder="+123123123123">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="picture">Picture URL:</label>
<input type="url" class="form-control property" id="picture"
placeholder="https://s.gravatar.com/avatar/a1e5582704a2ec5791bf0fde12737152">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="gender">Gender:</label>
<select class="form-control property" id="gender">
<option value=''>-- select gender</option>
<option value='M'>Male</option>
<option value='F'>Female</option>
</select>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="byear">Birth year:</label>
<input type="number" class="form-control property" id="byear" placeholder="1987">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section segments'>
<span class='label'>Provide some optional custom user properties</span>
<div class="row segment">
<a class="close close-button" aria-label="Close"><span aria-hidden="true">×</span></a>
<div class="col-md-4">
<div class="form-group">
<label>Key:</label>
<input type="text" class="form-control segment-key" placeholder="twitter">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-4">
<div class="form-group">
<label>Action:</label>
<select class="form-control segment-action">
<option value="set">set</option>
<option value="set_once">set if no value</option>
<option value="increment">increment</option>
<option value="multiply">multiply</option>
<option value="max">set if higher than existing</option>
<option value="min">set if lower than existing</option>
<option value="push_unique">add to array</option>
<option value="pull">remove from array</option>
</select>
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-4">
<div class="form-group">
<label>Value:</label>
<input type="text" class="form-control segment-val" placeholder="@johnsmith">
</div>
</div><!-- /.col-lg-6 -->
</div>
<p class='text-right'><button type="button" class="btn btn-default" id="add-segment">Add another
property</button></p>
</div>
<div class="row" id='generate-code'>
<div class="col-md-12">
<p class='text-center'>
<div class="dropup">
<button class="btn btn-success dropdown-toggle" type="button" id="dropdownMenu"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Generate for
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu"></ul>
</div>
</p>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<footer>
<p><a href='http://count.ly'>Count.ly</a></p>
</footer>
</div> <!-- /container -->
<div class="modal fade" id="end-modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<div class="btn-group" role="group" style="margin-bottom: 20px;">
<a href="" class="btn btn-default" target='_blank' id="sdk-repo">SDK Repository</a>
<a href="" class="btn btn-default" target='_blank' id="sdk-docs">SDK Documentation</a>
<a href="" class="btn btn-default" target='_blank' id="sdk-download">Download SDK</a>
</div>
<h4 class="modal-title text-center">Use this snippet to add information about user</h4>
</div>
<div class="modal-body">
<p><textarea id='end-code' class="no-translate" readonly onclick="this.select();"></textarea></p>
</div>
<div class="modal-footer">
<p class='text-center'>
<button type="button" class="btn btn-success" id="copy"
data-clipboard-target="#end-code">Copy</button>
<button type="button" class="btn btn-success" id="download">Download</button>
<button type="button" class="btn btn-primary" id="gotit">Close</button>
</p>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<script src="https://global.localizecdn.com/localize.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
<script src="js/sdks.js"></script>
<script src="js/users.js"></script>
<script src="js/common.js"></script>
<script src="js/Blob.js"></script>
<script src="js/FileSaver.min.js"></script>
<script src="js/clipboard.min.js"></script>
<script>
$(document).ready(function () {
var params = parseParams(location.search);
if (params.sdk && sdks[params.sdk]) {
$("#generate-code .dropup").addClass("hidden");
$("#generate-code").append('<p class="text-center"><button type="button" class="btn btn-success" id="generate">Generate for ' + sdks[params.sdk].name + '</button></p>');
//$("#buttons").append('<a href="users.html?sdk='+params.sdk+' id="next" class="btn btn-default">Next: Add user info →</a>');
$("#back").attr("href", "events.html?sdk=" + params.sdk);
}
new Clipboard('#copy');
var exampleStringSegments = [
["twitter", "@johnsmith"],
["selected_theme", "Dark"],
["html_in_emails", "yes"],
["registered", "yes"],
["interests", "hockey"]
];
var exampleNumberSegments = [
["highest_score", "100"],
["level", "1"],
["experience", "50"],
["battery", "-10"]
];
var sdk;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function applyStringSegmentExample(elem) {
var example = exampleStringSegments[getRandomInt(0, exampleStringSegments.length - 1)];
elem.find(".segment-key").attr("placeholder", example[0]);
elem.find(".segment-val").attr("placeholder", example[1]);
}
function applyNumberSegmentExample(elem) {
var example = exampleNumberSegments[getRandomInt(0, exampleNumberSegments.length - 1)];
elem.find(".segment-key").attr("placeholder", example[0]);
elem.find(".segment-val").attr("placeholder", example[1]);
}
applyStringSegmentExample($(".segment"));
$(".segments .segment:first .close-button").hide();
for (var slug in sdks) {
if (users[slug])
$(".dropdown-menu").append('<li><a href="#" id="' + slug + '">' + sdks[slug].name + '</a></li>');
}
$("#add-segment").click(function () {
var segment = $(".segments .segment:first").clone();
segment.find(".segment-key").val("");
segment.find(".segment-val").val("");
segment.find(".segment-action").val("set");
segment.find(".close-button").show();
applyStringSegmentExample(segment);
segment.insertBefore($("#add-segment").parent());
});
$(".segments").on("click", ".close-button", function (e) {
$(this).parent().remove();
});
$(".segments").on("change", ".segment-action", function (e) {
var segment = $(this).closest(".segment");
if ($(this).val() == "increment" || $(this).val() == "multiply" || $(this).val() == "min" || $(this).val() == "max") {
segment.find(".segment-val").attr("type", "number");
applyNumberSegmentExample(segment);
}
else {
segment.find(".segment-val").attr("type", "text");
applyStringSegmentExample(segment);
}
});
function generate(sdk) {
$(".alert").remove();
$("#sdk-repo").attr("href", sdks[sdk].repo);
$("#sdk-docs").attr("href", sdks[sdk].docs);
$("#sdk-download").attr("href", sdks[sdk].download);
var data = {};
var hasInfo = false;
$(".property").each(function () {
if ($(this).val() != "") {
hasInfo = true;
if (this.id == "byear")
data[this.id] = parseInt($(this).val());
else
data[this.id] = $(this).val();
}
});
var hasSegments = false;
var segments = {};
$(".segment").each(function () {
if ($(this).find(".segment-key").val() != "" && $(this).find(".segment-val").val() != "") {
hasSegments = true;
segments[$(this).find(".segment-key").val()] = { action: $(this).find(".segment-action").val(), value: $(this).find(".segment-val").val() };
}
});
if (hasSegments)
data.custom = segments;
if (!hasInfo && !hasSegments) {
$("#name").parent().prepend('<div class="alert alert-danger" role="alert">Please provide at least one value</div>');
return;
}
$("#end-code").val(users[sdk](data));
$('#end-modal').modal();
}
$(".dropdown-menu li a").click(function () {
generate(this.id);
});
$("#generate").click(function () {
generate(params.sdk);
});
$("#gotit").click(function () {
$('#end-modal').modal('hide');
});
$("#download").click(function () {
var data = $("#end-code").val();
try {
var blob = new Blob([data], { type: "text/plain;charset=utf-8" });
saveAs(blob, sdk + "-event.txt");
} catch (e) {
alert(data);
}
});
});
</script>
</body>
</html>