Advertisement
patrickc

Untitled

Nov 10th, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. enyo.kind({
  2. name: "showShoutcast",
  3. kind: "VFlexBox",
  4. events: {
  5. onBack: ""
  6. },
  7. components: [
  8. {kind: "Header", content:"Shoutcast"},
  9.  
  10. /* {kind: "Button", caption: "Search", onclick: "searcchPopup"},
  11. {kind: "Popup", name: "newSearchPopup", components: [
  12. {style: "font-size: 1.1em; text-align: center", className: "enyo-item enyo-first", components: [
  13. {content: "Search SHOUTCast", style: "align: center"}
  14. ]},
  15. {className: "enyo-item enyo-last", components: [
  16. {kind: enyo.Input, name: "searchParams", hint: "Search...", autoCapitalize: "lowercase"}
  17. ]},
  18. {flex: 1, components: [
  19. {kind: enyo.Button, onclick: "search", caption: "Search", className: "enyo-button-affirmative"},
  20. {kind: enyo.Button, onclick: "closePopup", caption: "Cancel", className: "enyo-button-negative"}
  21. ]},
  22. ]}, */
  23.  
  24. {kind: "PickerGroup", label: "Search Top", onChange: "pickerPick",
  25. components: [
  26. {name: "topSearch", value: "5", items: ["5", "250", "500"]},
  27. ]
  28. },
  29. {kind: "VirtualList", style: "width: 100%; height: 100%;",
  30. onSetupRow: "setupRow", components: [
  31. {kind: "Item", layoutKind: "HFlexLayout", components: [
  32. {name: "caption", flex: 1},
  33. {kind: "Button", onclick: "buttonClick"}
  34. ]}
  35. ]
  36. }
  37.  
  38.  
  39. /*{name: "sound", kind: "Sound", src: "/media/internal/ringtones/Flurry.mp3", preload:true}*/
  40. ],
  41. create: function() {
  42. this.inherited(arguments);
  43. },
  44.  
  45. setupRow: function(inSender, inIndex) {
  46. if (this.$.topSearch.getValue() == 5) {
  47. this.$.caption.setContent("Top 5");
  48. this.$.button.setCaption("Play Song" + inIndex);
  49. return true;
  50. }
  51. else if (this.$.topSearch.getValue() == 250) {
  52. this.$.caption.setContent("Top 250");
  53. this.$.button.setCaption("Play Song" + inIndex);
  54. return true;
  55. }
  56. else {
  57. this.$.caption.setContent("Top 500");
  58. this.$.button.setCaption("Play Song" + inIndex);
  59. return true;
  60. }
  61. },
  62. pickerPick: function(inSender, inEvent) {
  63. var ext = this.$.topSearch.getValue();
  64. this.log(ext);
  65. this.fieldType = this.$.topSearch.getValue();
  66. //var jsonText = JSON.stringify(xmlToJson(xmlDoc));
  67.  
  68.  
  69. },
  70. searcchPopup: function() {
  71. this.$.newSearchPopup.openAtCenter();
  72. },
  73. search: function() {
  74. var ext = this.$.searchParams.getValue();
  75. this.log(ext);
  76. this.$.newSearchPopup.close();
  77. },
  78. closePopup: function() {
  79. this.$.newSearchPopup.close();
  80. },
  81. stop: function() {
  82. this.$.urlSrc.audio.pause();
  83. },
  84. // Changes XML to JSON
  85. xmlToJson: function(xml) {
  86.  
  87. // Create the return object
  88. var obj = {};
  89.  
  90. if (xml.nodeType == 1) { // element
  91. // do attributes
  92. if (xml.attributes.length > 0) {
  93. obj["@attributes"] = {};
  94. for (var j = 0; j < xml.attributes.length; j++) {
  95. var attribute = xml.attributes.item(j);
  96. obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
  97. }
  98. }
  99. } else if (xml.nodeType == 3) { // text
  100. obj = xml.nodeValue;
  101. }
  102.  
  103. // do children
  104. if (xml.hasChildNodes()) {
  105. for(var i = 0; i < xml.childNodes.length; i++) {
  106. var item = xml.childNodes.item(i);
  107. var nodeName = item.nodeName;
  108. if (typeof(obj[nodeName]) == "undefined") {
  109. obj[nodeName] = xmlToJson(item);
  110. } else {
  111. if (typeof(obj[nodeName].length) == "undefined") {
  112. var old = obj[nodeName];
  113. obj[nodeName] = [];
  114. obj[nodeName].push(old);
  115. }
  116. obj[nodeName].push(xmlToJson(item));
  117. }
  118. }
  119. }
  120. return obj;
  121. },
  122. backHandler: function(inSender, e) {
  123. this.doBack();
  124. }
  125. });
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement