Personal portfolio website for Regina Carvalho. Built with Famous.js library.

data.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. angular.module('goApp.data', [])
  2. .service('Data', [ '$rootScope', '$http', function($rootScope, $http) {
  3. "use strict";
  4. var data = [];
  5. var data_loaded = false;
  6. var lang = 0;
  7. var lang_set = false;
  8. $http({
  9. method: 'GET',
  10. url: 'data.json'
  11. }).success(function(json_data) {
  12. data = json_data;
  13. data_loaded = true;
  14. console.log('> Loaded data.json');
  15. $rootScope.$broadcast('data:loaded', data);
  16. });
  17. this.setLang = function(n){
  18. lang = n;
  19. lang_set = true;
  20. $rootScope.$broadcast('data:lang_set', data);
  21. };
  22. this.getLang = function(){
  23. return lang;
  24. };
  25. this.isLangSet = function(){
  26. return lang_set;
  27. };
  28. this.get = function() {
  29. return data;
  30. };
  31. this.getPageData = function(link){
  32. var page_data = "";
  33. if (data_loaded) {
  34. for (var i = 0; i < data.navigation.length; i++) {
  35. if(data.navigation[i].link == "submenu"){
  36. for (var a = 0; a < data.navigation[i].submenu.length; a++) {
  37. if(data.navigation[i].submenu[a].link == "submenu"){
  38. for (var b = 0; b < data.navigation[i].submenu[a].submenu.length; b++) {
  39. if(data.navigation[i].submenu[a].submenu[b].link == link){
  40. page_data = data.navigation[i].submenu[a].submenu[b];
  41. }
  42. }
  43. } else if(data.navigation[i].submenu[a].link == link){
  44. page_data = data.navigation[i].submenu[a];
  45. }
  46. }
  47. } else if(data.navigation[i].link == link){
  48. page_data = data.navigation[i];
  49. }
  50. }
  51. if(page_data){
  52. console.log(page_data);
  53. }
  54. }
  55. return page_data;
  56. };
  57. this.getNavigation = function() {
  58. return data.navigation;
  59. };
  60. this.getBackgrounds = function() {
  61. return data.backgrounds;
  62. };
  63. }]);