Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DataShareBusiness.js 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. (function()
  2. {
  3. angular.module('appSdk')
  4. .factory('DataShareBusiness', ['$location', function ($location) {
  5. var data = {
  6. Groups: null,
  7. SearchSeparator: "~",
  8. CurrentGroups: [],
  9. setCurrentGroup: function(group)
  10. {
  11. data.CurrentGroups = [];
  12. while (group != null) {
  13. data.CurrentGroups.push(group);
  14. group = group.Parent;
  15. }
  16. data.CurrentGroups.reverse();
  17. $location.search(data.getSearchString(-1));
  18. },
  19. getCurrentGroup: function()
  20. {
  21. if (data.CurrentGroups.length == 0) {
  22. return null;
  23. }
  24. return data.CurrentGroups[data.CurrentGroups.length - 1];
  25. },
  26. getSearchString: function(group)
  27. {
  28. if (group == -1 && data.CurrentGroups.length != 0) {
  29. group = data.CurrentGroups[data.CurrentGroups.length - 1];
  30. }
  31. if (group == null) {
  32. return "";
  33. }
  34. var search = [];
  35. while (group != null){
  36. search.push(group.Name);
  37. group = group.Parent;
  38. }
  39. return search.reverse().join(data.SearchSeparator);
  40. },
  41. getGroupUrl: function(group)
  42. {
  43. var search = data.getSearchString(group);
  44. return "#" + $location.path() + $location.hash() + "?" + search;
  45. },
  46. setFromSearchString: function(string)
  47. {
  48. if (string == null) {
  49. data.setCurrentGroup(null);
  50. return;
  51. }
  52. var group = {Groups: data.Groups};
  53. var names = string.split(data.SearchSeparator);
  54. names.forEach(function(name)
  55. {
  56. var g = group.Groups.find(function(g)
  57. {
  58. return g.Name == name;
  59. });
  60. if (g != null) {
  61. group = g;
  62. }
  63. });
  64. data.setCurrentGroup(group);
  65. },
  66. upCurrentGroup: function()
  67. {
  68. if (data.CurrentGroups.length > 1) {
  69. data.setCurrentGroup(data.CurrentGroups[data.CurrentGroups.length - 2]);
  70. }
  71. else if (data.CurrentGroups.length == 1) {
  72. data.setCurrentGroup(null);
  73. }
  74. }
  75. };
  76. return data;
  77. }]);
  78. })();