Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. {
  2. "ChangeCollectionList": [
  3. {
  4. "AssetID": "Server123",
  5. "ChangeDateTime": "2014-07-25T16:14:32.6575954-07:00",
  6. "TriggerID": "Deployement_07_25_2014"
  7. },
  8. {
  9. "AssetID": "Server123",
  10. "ChangeDateTime": "2014-07-25T16:14:32.6575954-07:00",
  11. "TriggerID": "Patch_07_26_2014"
  12. },
  13. {
  14. "AssetID": "ServerABC",
  15. "ChangeDateTime": "2014-07-25T16:14:32.6575954-07:00",
  16. "TriggerID": "Deployement_07_25_2014"
  17. }
  18. ],
  19. "TriggerList": [
  20. {
  21. "TriggerID": "Deployement_07_25_2014",
  22. "PropertyChangeList": [
  23. {
  24. "PropertyID": "16.00.12.2345",
  25. "PropertyType": "Build",
  26. "ChangeType": "Modified",
  27. "ChangedDateTime": "2014-07-25T00:00:00",
  28. "HasNestedChanges": true
  29. },
  30. {
  31. "PropertyID": "\exc\cafe\cafeproxy.cs",
  32. "PropertyType": "SourceCode",
  33. "ChangeType": "Modified",
  34. "ChangedDateTime": "2014-07-25T00:00:00",
  35. "HasNestedChanges": false
  36. },
  37. {
  38. "PropertyID": "\exc\momt\rpcproxy.cs",
  39. "PropertyType": "SourceCode",
  40. "ChangeType": "Modified",
  41. "ChangedDateTime": "2014-07-25T00:00:00",
  42. "HasNestedChanges": false
  43. }
  44. ]
  45. },....
  46.  
  47. $.getJSON("jsonSample.json", function (obj) {
  48. var dictionary = {};
  49. var local_cell_ids = [];
  50. $.each(obj.ChangeCollectionList, function (key, value) {
  51. if (local_cell_ids.length == 0) {
  52. local_cell_ids.push(value.AssetID);
  53. insertIntoDic(value.AssetID, value.TriggerID);
  54. }
  55. else {
  56. for (var i = 0; i < local_cell_ids.length; i++) {
  57. if (local_cell_ids[i] == value.AssetID) {
  58. insertIntoDic(value.AssetID, value.TriggerID);
  59. break;
  60. }
  61. if (i = local_cell_ids.length) {
  62. local_cell_ids.push(value.AssetID);
  63. insertIntoDic(value.AssetID, value.TriggerID);
  64. }
  65. }
  66.  
  67. }
  68. });
  69. function insertIntoDic(key, value) {
  70. // If key is not initialized or some bad structure
  71. if (!dictionary[key] || !(dictionary[key] instanceof Array)) {
  72. dictionary[key] = [];
  73. }
  74. // All arguments, exept first push as valuses to the dictonary
  75. dictionary[key] = dictionary[key].concat(Array.prototype.slice.call(arguments, 1));
  76. //alert(dictionary[key]);
  77.  
  78. }
  79.  
  80. for (var key in dictionary) {enter code here
  81. $("#accordion").accordion();
  82. $("<h3>" + key + "</h3>").appendTo("#accordion");
  83. $("<div> <p> " + dictionary[key] + "<p></div><").appendTo("#accordion");
  84. // $("<div> <p> " + dictionary[key] + "<p></div><").appendTo("#accordion");
  85. $("#accordion").accordion("refresh");
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement