|
| 1 | +(function(i, s, o, g, r, a, m) { |
| 2 | + i['GoogleAnalyticsObject'] = r; |
| 3 | + i[r] = i[r] || function() { |
| 4 | + (i[r].q = i[r].q || []).push(arguments) |
| 5 | + }, i[r].l = 1 * new Date(); |
| 6 | + a = s.createElement(o), |
| 7 | + m = s.getElementsByTagName(o)[0]; |
| 8 | + a.async = 1; |
| 9 | + a.src = g; |
| 10 | + m.parentNode.insertBefore(a, m) |
| 11 | +})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); |
| 12 | + |
| 13 | +ga('create', 'UA-68861516-1', 'auto'); |
| 14 | +ga('send', 'pageview'); |
| 15 | + |
| 16 | +var PD = { |
| 17 | + promprtForId: function promprtForId() { |
| 18 | + var local = window.localStorage |
| 19 | + if (!local.getItem('student-id')) { |
| 20 | + var id = prompt("please enter your guc student id: 37-*****") |
| 21 | + local.setItem('student-id', id); |
| 22 | + } |
| 23 | + }, |
| 24 | + sendActivity: function sendActivity(activity) { |
| 25 | + var local = window.localStorage |
| 26 | + if (!local.getItem('student-id')) { |
| 27 | + var id = prompt("please enter your guc student id: 37-*****") |
| 28 | + local.setItem('student-id', id); |
| 29 | + } |
| 30 | + activity.meta = activity.meta || {}; |
| 31 | + activity.meta['student-id'] = local.getItem('student-id'); |
| 32 | + activity.event = activity.event || 'python-debugger.editor'; |
| 33 | + activity.action = activity.action || 'run'; |
| 34 | + |
| 35 | + $.post('http://www.kodr.in/api/activity', activity).done(function() { |
| 36 | + console.log('sucess'); |
| 37 | + }).fail(function(xhr) { |
| 38 | + console.log('could not send', xhr); |
| 39 | + }); |
| 40 | + |
| 41 | + }, |
| 42 | + logout: function logout() { |
| 43 | + var local = window.localStorage |
| 44 | + if (local.getItem('student-id')) { |
| 45 | + local.removeItem('student-id'); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +PD.promprtForId(); |
0 commit comments