Advertisement
patrickc

Untitled

Nov 8th, 2011
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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: "Picker",
  25.   value: "name",
  26.   items: ["Top 5", "Top 25", "Top 250", "Top 500"],
  27.   onChange: "pickerPick"
  28. },
  29.                
  30.                
  31.             /*{name: "sound", kind: "Sound", src: "/media/internal/ringtones/Flurry.mp3", preload:true}*/
  32.     ],
  33.     create: function() {
  34.         this.inherited(arguments);
  35.     },
  36.     pickerPick: function(inSender) {
  37.         var ext = this.$.picker.getValue();
  38.         this.log(ext);
  39.         this.fieldType = this.$.picker.getValue();
  40.        
  41.     },
  42.     searcchPopup: function() {
  43.         this.$.newSearchPopup.openAtCenter();
  44.     },
  45.     search: function() {
  46.         var ext = this.$.searchParams.getValue();
  47.         this.log(ext);
  48.         this.$.newSearchPopup.close();
  49.         },
  50.     closePopup: function() {
  51.         this.$.newSearchPopup.close();
  52.         },
  53.     stop: function() {
  54.         this.$.urlSrc.audio.pause();
  55.     },
  56.     // Changes XML to JSON
  57.     xmlToJson function(xml) {
  58.    
  59.     // Create the return object
  60.     var obj = {};
  61.  
  62.     if (xml.nodeType == 1) { // element
  63.         // do attributes
  64.         if (xml.attributes.length > 0) {
  65.         obj["@attributes"] = {};
  66.             for (var j = 0; j < xml.attributes.length; j++) {
  67.                 var attribute = xml.attributes.item(j);
  68.                 obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
  69.             }
  70.         }
  71.     } else if (xml.nodeType == 3) { // text
  72.         obj = xml.nodeValue;
  73.     }
  74.  
  75.     // do children
  76.     if (xml.hasChildNodes()) {
  77.         for(var i = 0; i < xml.childNodes.length; i++) {
  78.             var item = xml.childNodes.item(i);
  79.             var nodeName = item.nodeName;
  80.             if (typeof(obj[nodeName]) == "undefined") {
  81.                 obj[nodeName] = xmlToJson(item);
  82.             } else {
  83.                 if (typeof(obj[nodeName].length) == "undefined") {
  84.                     var old = obj[nodeName];
  85.                     obj[nodeName] = [];
  86.                     obj[nodeName].push(old);
  87.                 }
  88.                 obj[nodeName].push(xmlToJson(item));
  89.             }
  90.         }
  91.     }
  92.     return obj;
  93. },
  94.     backHandler: function(inSender, e) {
  95.             this.doBack();
  96.     }
  97. });
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement