This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sample_code:volume_box [2016/03/27 00:43] 196.101.253.72 created |
sample_code:volume_box [2017/06/12 21:03] titus |
||
---|---|---|---|
Line 1: | Line 1: | ||
**Volume Box** | **Volume Box** | ||
- | < | + | [[ http://mycode.coolpage.biz/ |
- | //Global variables | + | . |
- | var music = app.GetVolume(" | + | <code JavaScript Volume box.js> |
- | var alarm = app.GetVolume(" | + | //Called when application is started. |
- | var notification = app.GetVolume(" | + | function OnStart() |
- | var system = app.GetVolume(" | + | { |
- | var ring = app.GetVolume(" | + | app.SetOrientation(" |
- | var dtmf = app.GetVolume(" | + | //Create a layout with objects vertically centered. |
- | var voicecall = app.GetVolume(" | + | |
- | var other = app.GetVolume(" | + | lay.SetBackColor("# |
- | //Called when application is started. | + | //Create Top Layout |
- | function OnStart() | + | |
- | { | + | lay1.SetSize(1, |
- | app.SetOrientation(" | + | lay1.SetBackColor("# |
- | //Create a layout with objects vertically centered. | + | //Create a text label and add it to layout. |
- | lay = app.CreateLayout( " | + | |
- | lay.SetBackColor("# | + | txt.SetTextColor("# |
- | //Create Top Layout | + | txt.SetTextSize(30); |
- | lay1 =app.CreateLayout(" | + | lay1.AddChild(txt); |
- | lay1.SetSize(1, | + | //Set the menu items |
- | lay1.SetBackColor("# | + | |
- | //Create a text label and add it to layout. | + | lay.AddChild(lay1); |
- | txt = app.CreateText( " | + | //Create a text label and add it to layout. |
- | txt.SetTextColor("# | + | |
- | txt.SetTextSize( 30 ); | + | txt1.SetTextColor("# |
- | lay1.AddChild( txt ); | + | txt1.SetTextSize(32); |
- | + | lay.AddChild(txt1); | |
- | //Set the menu items | + | //Create volume bar and add to layout. |
- | menu = app.SetMenu(" | + | |
- | + | | |
- | lay.AddChild(lay1) | + | |
- | + | lay.AddChild(skbVol1); | |
- | //Create a text label and add it to layout. | + | //Create a text label and add it to layout. |
- | txt1 = app.CreateText( " | + | |
- | txt1.SetTextColor("# | + | txt2.SetTextColor("# |
- | txt1.SetTextSize( 32 ); | + | txt2.SetTextSize(20); |
- | lay.AddChild( txt1); | + | lay.AddChild(txt2); |
- | //Create volume bar and add to layout. | + | //Create volume bar and add to layout. |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch ); | + | |
- | skbVol.SetRange( 1.0 ); | + | lay.AddChild(skbVol2); |
- | + | //Create a text label and add it to layout. | |
- | lay.AddChild( skbVol ) | + | |
- | skbVol.SetValue(music) | + | txt3.SetTextColor("# |
- | //Create a text label and add it to layout. | + | txt3.SetTextSize(20); |
- | txt2 = app.CreateText( " | + | lay.AddChild(txt3); |
- | txt2.SetTextColor("# | + | |
- | txt2.SetTextSize( 20 ); | + | |
- | lay.AddChild( txt2 ) | + | |
- | //Create volume bar and add to layout. | + | |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch1 ); | + | |
- | skbVol.SetRange( 1.0 ); | + | |
- | skbVol.SetValue( alarm ); | + | |
- | lay.AddChild( skbVol ) | + | |
- | //Create a text label and add it to layout. | + | |
- | txt3 = app.CreateText( " | + | |
- | txt3.SetTextColor("# | + | |
- | txt3.SetTextSize( 20 ); | + | |
- | lay.AddChild( txt3 ); | + | |
- | + | ||
- | // | + | |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch2 ); | + | |
- | skbVol.SetRange( 1.0 ); | + | |
- | skbVol.SetValue( notification ); | + | |
- | lay.AddChild( skbVol ) | + | |
- | // | + | |
- | txt4 = app.CreateText( " | + | |
- | txt4.SetTextColor("# | + | |
- | txt4.SetTextSize( 20 ); | + | |
- | lay.AddChild( txt4 ); | + | |
- | // | + | |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch3 ); | + | |
- | skbVol.SetRange( 1.0 ); | + | |
- | skbVol.SetValue( system ); | + | |
- | lay.AddChild( skbVol ) | + | |
- | // | + | |
- | txt5 = app.CreateText( " | + | |
- | txt5.SetTextColor("# | + | |
- | txt5.SetTextSize( 20 ); | + | |
- | lay.AddChild( txt5 ); | + | |
- | // | + | |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch4 ); | + | |
- | skbVol.SetRange( 1.0 ); | + | |
- | skbVol.SetValue( ring ); | + | |
- | lay.AddChild( skbVol ) | + | |
- | // | + | |
- | txt6 = app.CreateText( " | + | |
- | txt6.SetTextColor("# | + | |
- | txt6.SetTextSize( 20 ); | + | |
- | lay.AddChild( txt6 ); | + | |
- | // | + | |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch5 ); | + | |
- | skbVol.SetRange( 1.0 ); | + | |
- | skbVol.SetValue( dtmf ); | + | |
- | lay.AddChild( skbVol ) | + | |
- | // | + | |
- | txt7 = app.CreateText( " | + | |
- | txt7.SetTextColor("# | + | |
- | txt7.SetTextSize( 20 ); | + | |
- | lay.AddChild( txt7 ); | + | |
- | // | + | |
- | skbVol = app.CreateSeekBar( 0.8, | + | |
- | // | + | |
- | skbVol.SetOnTouch( skbVol_OnTouch6 ); | + | |
- | skbVol.SetRange( 1.0 ); | + | |
- | skbVol.SetValue( voicecall ); | + | |
- | lay.AddChild( skbVol ) | + | |
- | //Create a text label and add it to layout. | + | |
- | txt8 = app.CreateText( " | + | |
- | txt8.SetTextColor("# | + | skbVol3.SetOnTouch(skbVol_OnTouch2); |
- | txt8.SetTextSize( 20 ); | + | skbVol3.SetRange(1.0); |
- | lay.AddChild( txt8 ) | + | lay.AddChild(skbVol3); |
- | //Add layout to app. | + | //Create a text label and add it to layout. |
- | app.AddLayout( lay ); | + | txt4 = app.CreateText(" |
- | setInterval("update()") | + | txt4.SetTextColor("# |
+ | txt4.SetTextSize(20); | ||
+ | lay.AddChild(txt4); | ||
+ | //Create volume bar and add to layout. | ||
+ | skbVol4 = app.CreateSeekBar(0.8, | ||
+ | skbVol4.SetOnTouch(skbVol_OnTouch3); | ||
+ | skbVol4.SetRange(1.0); | ||
+ | lay.AddChild(skbVol4); | ||
+ | //Create a text label and add it to layout. | ||
+ | txt5 = app.CreateText(" | ||
+ | txt5.SetTextColor("# | ||
+ | txt5.SetTextSize(20); | ||
+ | lay.AddChild(txt5); | ||
+ | //Create volume bar and add to layout. | ||
+ | skbVol5 = app.CreateSeekBar(0.8, | ||
+ | skbVol5.SetOnTouch(skbVol_OnTouch4); | ||
+ | skbVol5.SetRange(1.0); | ||
+ | lay.AddChild(skbVol5); | ||
+ | //Create a text label and add it to layout. | ||
+ | txt6 = app.CreateText(" | ||
+ | txt6.SetTextColor("# | ||
+ | txt6.SetTextSize(20); | ||
+ | lay.AddChild(txt6); | ||
+ | //Create volume bar and add to layout. | ||
+ | skbVol6 = app.CreateSeekBar(0.8, | ||
+ | skbVol6.SetOnTouch(skbVol_OnTouch5); | ||
+ | skbVol6.SetRange(1.0); | ||
+ | lay.AddChild(skbVol6); | ||
+ | //Create a text label and add it to layout. | ||
+ | txt7 = app.CreateText(" | ||
+ | txt7.SetTextColor("# | ||
+ | txt7.SetTextSize(20); | ||
+ | lay.AddChild(txt7); | ||
+ | //Create volume bar and add to layout. | ||
+ | skbVol7 = app.CreateSeekBar(0.8, | ||
+ | skbVol7.SetOnTouch(skbVol_OnTouch6); | ||
+ | skbVol7.SetRange(1.0); | ||
+ | lay.AddChild(skbVol7); | ||
+ | |||
+ | //Create a text label and add it to layout. | ||
+ | txt8 = app.CreateText(" | ||
+ | txt8.SetTextColor("# | ||
+ | txt8.SetTextSize(20); | ||
+ | lay.AddChild(txt8); | ||
+ | //Add layout to app. | ||
+ | app.AddLayout(lay); | ||
+ | setInterval(update, 1000); | ||
} | } | ||
- | //Called when user touches volume bar. | + | //Called when user touches volume bar. |
- | function skbVol_OnTouch( value ) | + | function skbVol_OnTouch(value) |
- | { | + | { |
- | app.SetVolume( " | + | app.SetVolume(" |
- | } | + | |
- | // | ||
- | function skbVol_OnTouch1( value ) | ||
- | { | ||
- | app.SetVolume( " | ||
} | } | ||
- | //Called when user touches volume bar. | + | //Called when user touches volume bar. |
- | function skbVol_OnTouch2( value ) | + | function skbVol_OnTouch1(value) |
- | { | + | { |
- | app.SetVolume( " | + | app.SetVolume(" |
- | } | + | } |
+ | //Called when user touches volume bar. | ||
+ | function skbVol_OnTouch2(value) | ||
+ | { | ||
+ | app.SetVolume(" | ||
+ | } | ||
- | // | ||
- | function skbVol_OnTouch3( value ) | ||
- | { | ||
- | app.SetVolume( " | ||
- | } | ||
- | //Called when user touches volume bar. | + | //Called when user touches volume bar. |
- | function skbVol_OnTouch4( value ) | + | function skbVol_OnTouch3(value) |
- | { | + | { |
- | app.SetVolume( " | + | app.SetVolume(" |
- | } | + | } |
- | //Called when user touches volume bar. | + | //Called when user touches volume bar. |
- | function skbVol_OnTouch5( value ) | + | function skbVol_OnTouch4(value) |
- | { | + | { |
- | app.SetVolume( " | + | app.SetVolume(" |
- | } | + | } |
+ | //Called when user touches volume bar. | ||
+ | function skbVol_OnTouch5(value) | ||
+ | { | ||
+ | app.SetVolume(" | ||
+ | } | ||
- | //Called when user touches volume bar. | + | |
- | function skbVol_OnTouch6( value ) | + | //Called when user touches volume bar. |
- | { | + | function skbVol_OnTouch6(value) |
- | app.SetVolume( " | + | { |
- | } | + | app.SetVolume(" |
- | //About | + | |
- | function About() { | + | |
- | app.Alert(" | + | |
- | } | + | |
- | // | + | |
- | function update() { | + | |
- | var music = app.GetVolume(" | + | |
- | var alarm = app.GetVolume(" | + | |
- | var notification = app.GetVolume(" | + | |
- | var system = app.GetVolume(" | + | |
- | var ring = app.GetVolume(" | + | |
- | var dtmf = app.GetVolume(" | + | |
- | var voicecall = app.GetVolume(" | + | |
- | txt2.SetText(" | + | |
- | txt3.SetText(" | + | |
- | txt4.SetText(" | + | |
- | txt5.SetText(" | + | |
- | txt6.SetText(" | + | |
- | txt7.SetText(" | + | |
- | txt8.SetText(" | + | |
} | } | ||
- | // | ||
- | function OnMenu(item) { | ||
- | var item; | ||
- | switch(item) { | ||
- | case " | ||
- | break; | ||
- | case " | ||
- | break; | ||
- | default : | ||
- | }} | ||
+ | //Update values of volume | ||
+ | function update() | ||
+ | { | ||
+ | var music = (app.GetVolume(" | ||
+ | var alarm = (app.GetVolume(" | ||
+ | var notification = (app.GetVolume(" | ||
+ | var system = (app.GetVolume(" | ||
+ | var ring = (app.GetVolume(" | ||
+ | var dtmf = (app.GetVolume(" | ||
+ | var voicecall = (app.GetVolume(" | ||
+ | txt2.SetText(" | ||
+ | txt3.SetText(" | ||
+ | txt4.SetText(" | ||
+ | txt5.SetText(" | ||
+ | txt6.SetText(" | ||
+ | txt7.SetText(" | ||
+ | txt8.SetText(" | ||
+ | skbVol1.SetValue(music / 100); | ||
+ | skbVol2.SetValue(alarm / 100); | ||
+ | skbVol3.SetValue(notification / 100); | ||
+ | skbVol4.SetValue(system / 100); | ||
+ | skbVol5.SetValue(ring / 100); | ||
+ | skbVol6.SetValue(dtmf / 100); | ||
+ | skbVol7.SetValue(voicecall / 100); | ||
+ | } | ||
+ | //Called when the menu key is pressed | ||
+ | function OnMenu(item) | ||
+ | { | ||
+ | var item; | ||
+ | switch (item) | ||
+ | { | ||
+ | case " | ||
+ | About(); | ||
+ | break; | ||
+ | case " | ||
+ | app.Exit(); | ||
+ | break; | ||
+ | default: | ||
+ | } | ||
+ | } | ||
+ | //About | ||
+ | function About() | ||
+ | { | ||
+ | var dlg = app.CreateDialog(" | ||
+ | var lay = app.CreateLayout(" | ||
+ | var text = app.CreateText("", | ||
+ | text.SetTextSize(25); | ||
+ | var txt = '< | ||
+ | text.SetHtml(txt); | ||
+ | lay.AddChild(text); | ||
+ | dlg.AddLayout(lay); | ||
+ | dlg.Show(); | ||
+ | } | ||
/* | /* | ||
- | Note that values of notification, | + | Note that values of notification, system, |
*/ | */ | ||
</ | </ | ||
- | + | [[: | |
- | + |