Advertisement
patrickc

Untitled

Nov 10th, 2011
73
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: "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. },
  52.     pickerPick: function(inSender) {
  53.         var ext = this.$.topSearch.getValue();
  54.         this.log(ext);
  55.         this.fieldType = this.$.topSearch.getValue();
  56.         //var jsonText = JSON.stringify(xmlToJson(xmlDoc));
  57.  
  58.        
  59.     },
  60.     searcchPopup: function() {
  61.         this.$.newSearchPopup.openAtCenter();
  62.     },
  63.     search: function() {
  64.         var ext = this.$.searchParams.getValue();
  65.         this.log(ext);
  66.         this.$.newSearchPopup.close();
  67.         },
  68.     closePopup: function() {
  69.         this.$.newSearchPopup.close();
  70.         },
  71.     stop: function() {
  72.         this.$.urlSrc.audio.pause();
  73.     },
  74.     // Changes XML to JSON
  75.     xmlToJson: function(xml) {
  76.    
  77.     // Create the return object
  78.     var obj = {};
  79.  
  80.     if (xml.nodeType == 1) { // element
  81.         // do attributes
  82.         if (xml.attributes.length > 0) {
  83.         obj["@attributes"] = {};
  84.             for (var j = 0; j < xml.attributes.length; j++) {
  85.                 var attribute = xml.attributes.item(j);
  86.                 obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
  87.             }
  88.         }
  89.     } else if (xml.nodeType == 3) { // text
  90.         obj = xml.nodeValue;
  91.     }
  92.  
  93.     // do children
  94.     if (xml.hasChildNodes()) {
  95.         for(var i = 0; i < xml.childNodes.length; i++) {
  96.             var item = xml.childNodes.item(i);
  97.             var nodeName = item.nodeName;
  98.             if (typeof(obj[nodeName]) == "undefined") {
  99.                 obj[nodeName] = xmlToJson(item);
  100.             } else {
  101.                 if (typeof(obj[nodeName].length) == "undefined") {
  102.                     var old = obj[nodeName];
  103.                     obj[nodeName] = [];
  104.                     obj[nodeName].push(old);
  105.                 }
  106.                 obj[nodeName].push(xmlToJson(item));
  107.             }
  108.         }
  109.     }
  110.     return obj;
  111. },
  112.     backHandler: function(inSender, e) {
  113.             this.doBack();
  114.     }
  115. });
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement