Professional Documents
Culture Documents
VIEW EXAMPLE
td.pane {
padding:8px;
background:#1e252e url(../images/page-contents-bg.gif) repeat-x left
top;
border-left:1px solid #555;
border-right:1px solid #222;
border-bottom:1px solid #000;
}
td.paneSpacer {
width:10px;
}
<body>
<script type="text/javascript">
var
segmentThickness = 26,
displayWidth = 164,
displayHeight = 246,
segmentGap = 1,
segmentThicknessDiv2 = segmentThickness / 2,
segmentThicknessPlusSegmentGap = segmentThickness + segmentGap,
styleTag =
'<style type="text/css">\n' +
' .sevenSeg {\n' +
' width:' + displayWidth + 'px;\n' +
' height:' + displayHeight + 'px;\n' +
' }\n' +
' .sevenSegSegmentEnd {\n' +
' border-width:' + segmentThicknessDiv2 + 'px;\n' +
' }\n' +
' .sevenSegHorzSegment {\n' +
' height:' + segmentThickness + 'px;\n' +
' }\n' +
' .sevenSegHorzSegmentMiddle {\n' +
' top:' + (displayHeight / 2 - segmentThicknessDiv2) + 'px;\n' +
' }\n' +
' .sevenSegSegmentLeftEnd {\n' +
' left:' + segmentGap + 'px;\n' +
' }\n' +
' .sevenSegHorzSegment .sevenSegSegmentBar {\n' +
' left:' + segmentThicknessPlusSegmentGap + 'px;\n' +
' right:' + segmentThicknessPlusSegmentGap + 'px;\n' +
' }\n' +
' .sevenSegSegmentRightEnd {\n' +
' right:' + segmentGap + 'px;\n' +
' }\n' +
' .sevenSegVertSegment {\n' +
' width:' + segmentThickness + 'px;\n' +
' }\n' +
' .sevenSegSegmentTopEnd {\n' +
' top:' + segmentGap + 'px;\n' +
' }\n' +
' .sevenSegVertSegment .sevenSegSegmentBar {\n' +
' top:' + segmentThicknessPlusSegmentGap + 'px;\n' +
' bottom:' + segmentThicknessPlusSegmentGap + 'px;\n' +
' }\n' +
' .sevenSegSegmentBottomEnd {\n' +
' bottom:' + segmentGap + 'px;\n' +
' }\n' +
' .sevenSegVertSegmentTop .sevenSegSegmentBottomEnd {\n' +
' bottom:' + (segmentGap - segmentThicknessDiv2) + 'px;\n' +
' }\n' +
' .sevenSegVertSegmentTop .sevenSegSegmentBar {\n' +
' bottom:' + (segmentGap + segmentThicknessDiv2) + 'px;\n' +
' }\n' +
' .sevenSegVertSegmentBottom .sevenSegSegmentTopEnd {\n' +
' top:' + (segmentGap - segmentThicknessDiv2) + 'px;\n' +
' }\n' +
' .sevenSegVertSegmentBottom .sevenSegSegmentBar {\n' +
' top:' + (segmentGap + segmentThicknessDiv2) + 'px;\n' +
' }\n' +
'</style>\n'
;
document.writeln (styleTag);
</script>
<h1 class="document-title">
<a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework
home"></a>
<a href="../javascript-examples.html" class="breadcrumb
breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
Seven Segment Display
<div id="page-actions" class="pageActions">
<a href="source-code/seven-segment-display.html"
class="buttonLink">SOURCE</a>
</div>
</h1>
<div class="main">
<!-- explanation copy -->
<div class="explanation">
<p>In this example, an instance of the <a
href="../reference/Uize.Widget.SegmentDisplay.Seven.html"><code>Uize.Widget.Se
gmentDisplay.Seven</code></a> widget class is being used to wire up a <a
href="http://en.wikipedia.org/wiki/Seven-segment_display"
class="externalSiteLink" target="_top">seven segment display</a> UI. The seven
segment display is an old style of display device for displaying decimal
numerals and a limited number of alphabetical characters (often utilizing LED
or LCD electonics), which is often found in displays in pocket calculators,
VHS and DVD players, digital watches, audio recording hardware, etc. The seven
segment display shown in this example is interactive. You can choose a value
to display by using the <b>"VALUE SELECTOR"</b> droplist. You can toggle the
lit state of individual segments of the display by clicking directly on the
segments of the display, or you can click on the binary digits in the ABCDEFG
and GFEDCBA segments state tables. Various buttons are also provided in the
<b>"SEGMENTS STATE"</b> pane to let you easily change the lit state of all
segments at once. To see animations of the display state, use the buttons in
the <b>"ANIMATE VALUE"</b> pane to the right.</p>
</div>
<!-- JavaScript code to make the static slider HTML "come alive" -->
<script type="text/javascript">
Uize.module ({
required:[
'UizeDotCom.Page.Example.library',
'UizeDotCom.Page.Example',
'Uize.Widget.SegmentDisplay.Seven',
'Uize.Templates.SevenSegmentDisplay',
'Uize.Node',
'Uize.Fade',
'Uize.Fade.xFactory',
'Uize.Curve'
],
builder:function () {
/*** create the example page widget ***/
var page = window.page = new UizeDotCom.Page.Example;
/*** build the values set for the value selector (before wiring the UI, so
there's no UI updating) ***/
var
alphaValues = [],
miscCharValues = [],
hexValues = []
;
for (var segmentsState = -1; ++segmentsState < 128;) {
var value = Uize.Widget.SegmentDisplay.Seven.getValueFromSegmentsState
(segmentsState);
(value.length > 1 ? hexValues : /^[0-9a-zA-Z]$/.test (value) ?
alphaValues : miscCharValues).push (value);
}
alphaValues.sort ();
var values = alphaValues.concat (miscCharValues,hexValues);
/*** wire seven segment display widget to sync value selector ***/
sevenSegmentDisplay.wire (
'Changed.value',
function () {
page.setNodeValue ('valueSelector',sevenSegmentDisplay + '');
updateSegmentTables ();
}
);
/*** wire up all on, all off, and invert links ***/
page.wireNode ('allSegmentsOn','click',function ()
{sevenSegmentDisplay.setAllSegmentsState (1)});
page.wireNode ('allSegmentsOff','click',function ()
{sevenSegmentDisplay.setAllSegmentsState (0)});
page.wireNode ('invertSegmentsState','click',function ()
{sevenSegmentDisplay.invertAllSegmentsState ()});
</script>
</body>
</html>
SHARE THIS USING...
Personal E-mail...Facebook...Twitter...StumbleUpon...del.icio.us...Digg...Reddit...FriendFeed...MySpace...Google
Bookmarks...LinkedIn...Mixx...Technorati...Posterous...Plurk...Ping.fm...Diigo...Faves...Mister
Wong...dzone...Connotea...
© 1997-2011 UIZE (UIZE JavaScript Framework) -- Available under MIT License or GNU General Public
License
INDISPENSABLE ONLINE
RESOURCES: w3c.org | w3schools.com | webmonkey.com | webreference.com | wikipedia.org
RELEVANT BLOG SITES: ajaxian.com | sixrevisions.com | alistapart.com | quirksmode.org
STANDARDS: ECMA-262 | ECMA-327 | ECMA-357 | XHTML 1.1 | CSS 2.1
B U Y U I Z E S W A G A T T H E O F F I C I A L M E R C H A N D I S E S T O R E