<?xml version="1.0" encoding="utf-8"?>
<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" cornerRadius="7" title="Channel Manager" width="800" height="620" creationComplete="doInit()" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable]
public var tvMaster:Master;
[Bindable]
private var chanList:ArrayCollection;
[Bindable]
private var chanInfo:ArrayCollection;
[Bindable]
private var tvUsers:ArrayCollection;
private function doInit():void {
var uArgs:Object = new Object;
uArgs.gid = tvMaster.userInfo[0].gid;
uArgs.uid = tvMaster.userInfo[0].uid;
tvMaster.gateway.call("tuve.getUsers",new Responder(gotUsers,tvMaster.onFault),uArgs);
uArgs = null;
findChan();
}
private function gotUsers(result:Array):void {
if (result != null)
tvUsers = new ArrayCollection(result);
}
public function findChan():void {
var uArgs:Object = new Object;
uArgs.gid = tvMaster.userInfo[0].gid;
uArgs.uid = tvMaster.userInfo[0].uid;
uArgs.skey = chanSearch.text;
tvMaster.gateway.call("tuve.getChans",new Responder(gotChans,tvMaster.onFault),uArgs);
uArgs = null;
}
private function gotChans(result:Array):void {
if (result != null) {
if (chanList != null)
chanList = null;
chanList = new ArrayCollection(result);
chanGrid.selectedIndex = 0;
getChanData();
}
}
private function getChanData():void {
tvMaster.gateway.call("tuve.getChannel",new Responder(gotChannel,tvMaster.onFault),chanGrid.selectedItem.channel);
}
private function gotChannel(result:Array):void {
var i:Number;
if (result != null) {
vidStatus.text = "Data Retrieved";
chanInfo = new ArrayCollection(result);
chanName.text = chanInfo[0].channel;
chanTopic.text = chanInfo[0].topic;
if (chanInfo[0].random == 1)
chanRandom.selected = true;
else
chanRandom.selected = false;
if (chanInfo[0].queue == 1)
chanQueue.selected = true;
else
chanQueue.selected = false;
if (chanInfo[0].exclusive == 1)
chanExclusive.selected = true;
else
chanExclusive.selected = false;
if (chanInfo[0].time == 0)
chanTime.selected = false;
else
chanTime.selected = true;
chanTimeLimit.text = chanInfo[0].time;
chanDesc.htmlText = " ";
chanDesc.htmlText = chanInfo[0].description;
for (i = 0;i < tvUsers.length;i++) {
if (chanInfo[0].oid == tvUsers[i].uid) {
chanOwner.selectedIndex = i;
break;
}
}
for (i = 0;i< tvMaster.tvRating.length();i++) {
if (tvMaster.tvRating[i].@data == chanInfo[0].rating) {
chanRating.selectedIndex = i;
break;
}
}
for (i = 0;i< tvMaster.tvClass.length();i++) {
if (tvMaster.tvClass[i].@data == chanInfo[0].classification) {
chanClass.selectedIndex = i;
break;
}
}
}
}
private function doUpdate():void {
var newInfo:Object = new Object();
newInfo.channel = chanName.text;
newInfo.oid = chanOwner.selectedItem.uid;
newInfo.rating = chanRating.selectedItem.@data.toString();
newInfo.classification = chanClass.selectedItem.@data.toString();
newInfo.topic = chanTopic.text;
newInfo.random = Number(chanRandom.selected);
newInfo.queue = Number(chanQueue.selected);
newInfo.exclusive = Number(chanExclusive.selected);
if (chanTime.selected == true)
newInfo.time = chanTimeLimit.text;
else
newInfo.time = 0;
newInfo.description = chanDesc.htmlText;
tvMaster.gateway.call("tuve.updateChannel",new Responder(updateRes,tvMaster.onFault),newInfo);
}
private function updateRes(result:String):void {
if (result == "0")
vidStatus.text = "Updated";
else
vidStatus.text = "Error Updating";
}
private function doPrev():void {
if (upOnChange.selected == true)
doUpdate();
chanGrid.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN,true,false,0.0,38));
}
private function doNext():void {
if (upOnChange.selected == true)
doUpdate();
chanGrid.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN,true,false,0.0,40))
}
]]>
</mx:Script>
<mx:HBox width="100%" horizontalGap="0" height="100%">
<mx:Canvas width="100%" height="100%">
<mx:Label text="Status:" />
<mx:Label id="vidStatus" x="44" width="400"/>
<mx:TabNavigator y="20" height="480" creationPolicy="all">
<mx:Canvas label="Channel Info" height="100%">
<mx:Form width="100%" height="445">
<mx:FormItem label="Channel:">
<mx:TextInput width="350" id="chanName" editable="false" />
</mx:FormItem>
<mx:FormItem label="Topic:">
<mx:TextInput width="350" id="chanTopic" />
</mx:FormItem>
<mx:FormItem label="Random">
<mx:CheckBox id="chanRandom" label="Enabled" />
</mx:FormItem>
<mx:FormItem label="User Queues">
<mx:CheckBox id="chanQueue" label="Enabled" />
</mx:FormItem>
<mx:FormItem label="Exclusive">
<mx:CheckBox id="chanExclusive" label="Enabled" />
</mx:FormItem>
<mx:FormItem label="Time Limit">
<mx:CheckBox id="chanTime" label="Enabled" />
<mx:TextInput id="chanTimeLimit" />
</mx:FormItem>
<mx:FormItem label="Rating:">
<mx:ComboBox dataProvider="{tvMaster.tvRating}" labelField="@label" width="200" id="chanRating" />
</mx:FormItem>
<mx:FormItem label="Classification:">
<mx:ComboBox dataProvider="{tvMaster.tvClass}" labelField="@label" width="200" id="chanClass" />
</mx:FormItem>
<mx:FormItem label="Owner">
<mx:ComboBox dataProvider="{tvUsers}" labelField="username" width="200" id="chanOwner" />
</mx:FormItem>
</mx:Form>
</mx:Canvas>
<mx:Canvas label="Channel Description">
<mx:RichTextEditor id="chanDesc" width="100%" height="100%"/>
</mx:Canvas>
</mx:TabNavigator>
<mx:Button label="Update" click="doUpdate()" y="508" x="10"/>
<mx:Button label="Prev" click="doPrev()" x="10" y="533"/>
<mx:Button label="Next" click="doNext()" x="71" y="533"/>
<mx:CheckBox label="Update On Record Change" x="10" y="558" selected="false" id="upOnChange"/>
</mx:Canvas>
<mx:Canvas width="300" height="100%">
<mx:TextInput id="chanSearch" width="227" enter="findChan()" y="5"/>
<mx:Button label="Search" x="235" click="findChan()" y="5"/>
<mx:DataGrid y="30" id="chanGrid" dataProvider="{chanList}" width="300" height="100%" change="getChanData()" verticalScrollPolicy="on">
<mx:columns>
<mx:DataGridColumn headerText="Channel" dataField="channel" />
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:HBox>
</tvWindow>