Commit 4ca44fc272b68a25667fb325a067e5a6bfc8d63d
Exists in
master
and in
1 other branch
merge
Showing 3 changed files Inline Diff
scripts/FlashcardDirective.js
View file @
4ca44fc
angular.module('flashy.FlashcardDirective', []). | 1 | 1 | angular.module('flashy.FlashcardDirective', []). | |
2 | 2 | |||
directive('flashcard', | 3 | 3 | directive('flashcard', | |
function($http, $state, $window) { | 4 | 4 | function($http, $state, $window) { | |
return { | 5 | 5 | return { | |
templateUrl: '/app/templates/flashcard.html', | 6 | 6 | templateUrl: '/app/templates/flashcard.html', | |
restrict: 'E', | 7 | 7 | restrict: 'E', | |
scope: { | 8 | 8 | scope: { | |
flashcard: '=flashcardObj', // flashcard-obj in parent html | 9 | 9 | flashcard: '=flashcardObj', // flashcard-obj in parent html | |
refresh: '&' // eval refresh in parent html | 10 | 10 | refresh: '&' // eval refresh in parent html | |
}, | 11 | 11 | }, | |
link: function(scope, element) { | 12 | 12 | //link: function(scope, element) { | |
$('.tooltipped').tooltip(); | 13 | 13 | // $('.tooltipped').tooltip(); | |
/* Handles width of the card */ | 14 | 14 | // /* Handles width of the card */ | |
} | 15 | 15 | //} | |
}; | 16 | 16 | }; | |
} | 17 | 17 | } | |
); | 18 | 18 | ); | |
19 | 19 | |||
scripts/SettingsController.js
View file @
4ca44fc
angular.module('flashy.SettingsController', ['ui.router']). | 1 | 1 | angular.module('flashy.SettingsController', ['ui.router']). | |
2 | 2 | |||
controller('SettingsController', function($scope, $http) { | 3 | 3 | controller('SettingsController', function($scope, $http) { | |
$scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) { | 4 | 4 | $scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) { | |
5 | 5 | |||
}; | 6 | 6 | }; | |
console.log('checking to see if chrome'); | 7 | 7 | console.log('checking to see if chrome'); | |
if (!chrome) { return; } | 8 | 8 | if (!chrome) { return; } | |
console.log('chrome'); | 9 | 9 | console.log('chrome'); | |
$scope.registerCallback = function(registrationId) { | 10 | 10 | $scope.registerCallback = function(registrationId) { | |
if (chrome.runtime.lastError) { | 11 | 11 | if (chrome.runtime.lastError) { | |
console.log('Registration failed'); | 12 | 12 | console.log('Registration failed'); | |
} | 13 | 13 | } | |
14 | 14 | |||
sendRegistrationId(registrationId, function(succeed) { | 15 | 15 | sendRegistrationId(registrationId, function(succeed) { | |
if (succeed) { | 16 | 16 | if (succeed) { | |
chrome.storage.local.set({registered: true}); | 17 | 17 | chrome.storage.local.set({registered: true}); | |
} | 18 | 18 | } | |
}); | 19 | 19 | }); | |
}; | 20 | 20 | }; | |
21 | 21 | |||
function sendRegistrationId(registrationId, callback) { | 22 | 22 | function sendRegistrationId(registrationId, callback) { | |
console.log('registration id: ' + registrationId); | 23 | 23 | console.log('registration id: ' + registrationId); | |
$http.post('/api/subscribe/', JSON.stringify({ | 24 | 24 | $http.post('/api/subscribe/', JSON.stringify({ | |
'registration_id': registrationId | 25 | 25 | 'registration_id': registrationId | |
})); | 26 | 26 | })); | |
callback(true); | 27 | 27 | callback(true); | |
} | 28 | 28 | } | |
29 | 29 | |||
console.log("gonna try to launch service worker now"); | 30 | 30 | console.log("gonna try to launch service worker now"); | |
if ('serviceWorker' in navigator) { | 31 | 31 | if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('scripts/service-worker.js').then( | 32 | 32 | navigator.serviceWorker.register('scripts/service-worker.js').then( | |
33 | ||||
34 | console.log('gonna try to launch service worker now'); | |||
35 | navigator.serviceWorker.register('scripts/service-worker.js').then( | |||
function(serviceWorkerRegistration) { | 33 | 36 | function(serviceWorkerRegistration) { | |
serviceWorkerRegistration.pushManager.subscribe().then( | 34 | 37 | serviceWorkerRegistration.pushManager.subscribe().then( | |
function(pushSubscription) { | 35 | 38 | function(pushSubscription) { | |
console.log('sub id: ', pushSubscription.subscriptionId); | 36 | 39 | console.log('sub id: ', pushSubscription.subscriptionId); | |
console.log('endpoint: ', pushSubscription.endpoint); | 37 | 40 | console.log('endpoint: ', pushSubscription.endpoint); | |
// The push subscription details needed by the application | 38 | 41 | // The push subscription details needed by the application | |
// server are now available, and can be sent to it using, | 39 | 42 | // server are now available, and can be sent to it using, | |
// for example, an XMLHttpRequest. | 40 | 43 | // for example, an XMLHttpRequest. | |
}, function(error) { | 41 | 44 | }, function(error) { | |
// During development it often helps to log errors to the | 42 | 45 | // During development it often helps to log errors to the | |
// console. In a production environment it might make sense to | 43 | 46 | // console. In a production environment it might make sense to | |
// also report information about errors back to the | 44 | 47 | // also report information about errors back to the | |
// application server. | 45 | 48 | // application server. | |
console.log('sub error: ', error); | 46 | 49 | console.log('sub error: ', error); | |
} | 47 | 50 | } | |
); | 48 | 51 | ); | |
}); | 49 | 52 | }); | |
50 | 53 | |||
} else { | 51 | 54 | } else { |
templates/flashcard.html
View file @
4ca44fc
<div class="card flashy smallify black-text text-darken-2" ng-init="startShrink = false" | 1 | 1 | <div class="card flashy smallify black-text text-darken-2" | |
ng-class="{'shrinky': startShrink, 'in-deck':flashcard.isInDeck()}"> | 2 | 2 | ng-class="{'in-deck':flashcard.isInDeck()}"> | |
<div class="valign-wrapper"> | 3 | 3 | <div class="valign-wrapper"> | |
<div class="card-content valign center-align" ng-bind-html="flashcard.formatted_text"></div> | 4 | 4 | <div class="card-content valign center-align" ng-bind-html="flashcard.formatted_text"></div> | |
</div> | 5 | 5 | </div> | |
<div class="card-overlay"> | 6 | 6 | <div class="card-overlay"> | |
<div class="top-box no-user-select" ng-show="!flashcard.isInDeck()" | 7 | 7 | <div class="top-box no-user-select" ng-show="!flashcard.isInDeck()" | |
ng-click="flashcard.pull()"> | 8 | 8 | ng-click="flashcard.pull()"> | |
<div class="center-me"><i class="mdi-content-add-circle-outline medium"></i></div> | 9 | 9 | <div class="center-me"><i class="mdi-content-add-circle-outline medium"></i></div> | |
</div> | 10 | 10 | </div> | |
<div class="top-box no-user-select" ng-show="flashcard.isInDeck()" | 11 | 11 | <div class="top-box no-user-select" ng-show="flashcard.isInDeck()" | |
ng-click="flashcard.unpull()"> | 12 | 12 | ng-click="flashcard.unpull()"> | |
<div class="center-me"><i class="mdi-content-remove-circle-outline medium"></i></div> | 13 | 13 | <div class="center-me"><i class="mdi-content-remove-circle-outline medium"></i></div> | |
</div> | 14 | 14 | </div> | |
<div class="bottom-box no-user-select"> | 15 | 15 | <div class="bottom-box no-user-select"> | |
<div class="left-box tooltipped" data-position="bottom" data-tooltip="Info"> | 16 | 16 | <div class="left-box tooltipped" data-position="bottom" data-tooltip="Info"> | |
<div class="center-me"><i class="mdi-action-info-outline small"></i></div> | 17 | 17 | <div class="center-me"><i class="mdi-action-info-outline small"></i></div> | |
</div> | 18 | 18 | </div> | |
<div class="right-box tooltipped" ng-click="flashcard.hide()" data-position="bottom" data-tooltip="Hide"> | 19 | 19 | <div class="right-box tooltipped" ng-click="flashcard.hide()" data-position="bottom" data-tooltip="Hide"> | |
<div class="center-me"><i class="mdi-action-delete small"></i></div> | 20 | 20 | <div class="center-me"><i class="mdi-action-delete small"></i></div> | |
</div> | 21 | 21 | </div> | |
22 | 22 | |||
</div> | 23 | 23 | </div> | |
</div> | 24 | 24 | </div> | |
<div ng-show="flashcard.isInDeck()" class="green-text" style="position:absolute; top:-9px;right:0px"> | 25 | 25 | <div ng-show="flashcard.isInDeck()" class="green-text" style="position:absolute; top:-9px;right:0px"> | |
<div class="center-me tooltipped" data-position="bottom" data-tooltip="In deck"><i | 26 | 26 | <div class="center-me tooltipped" data-position="bottom" data-tooltip="In deck"><i | |
class="mdi-action-done small"></i></div> | 27 | 27 | class="mdi-action-done small"></i></div> | |
</div> | 28 | 28 | </div> | |
<div ng-show="$root.debug_flashcard" style="position:absolute; bottom:0px; right:5px;"> | 29 | 29 | <div ng-show="$root.debug_flashcard" style="position:absolute; bottom:0px; right:5px;"> | |
<span class="center-me">score:{{flashcard.score}}</span> | 30 | 30 | <span class="center-me">score:{{flashcard.score}}</span> | |
</div> | 31 | 31 | </div> | |
</div> | 32 | 32 | </div> | |
33 | 33 |