Permalink
Browse files

finish 0.1.0

  • Loading branch information...
1 parent e32428c commit 65d95964d94e108152c26304a13b15f1d47e4377 U-IE361-PC\Administrator committed Jul 4, 2011
Showing with 2,254 additions and 72 deletions.
  1. +1 −1 ant/build.properties
  2. +0 −12 ant/java.exe.stackdump
  3. +75 −0 examples/weather.html
  4. +1,432 −47 src/jsxml.js
  5. +746 −12 tests/jsxml-test.js
View
@@ -2,7 +2,7 @@
### Build settings
######################################################################
-build.version = 1.0.0
+build.version = 0.1.0
build.name = jsxml-${build.version}
build.files = jsxml.js
View
@@ -1,12 +0,0 @@
-Exception: STATUS_ACCESS_VIOLATION at eip=610C7B39
-eax=00000000 ebx=00000001 ecx=00000000 edx=0000068C esi=00000000 edi=0112CCC8
-ebp=0112CB04 esp=0112CADC program=\\?\C:\Program Files\Java\jre6\bin\java.exe, pid 27748, thread unknown (0x7920)
-cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
-Stack trace:
-Frame Function Args
-0112CB04 610C7B39 (00000000, 00000000, 00000000, 00000000)
-0112CC14 610C84D5 (00000000, 00000000, 00000000, 00000000)
-0112CCD4 610C923A (FFFFFFFF, FFFFFFFF, 00000000, 00000000)
-0112CD24 61028142 (00000002, 0112CE64, 00000002, 0112CDF4)
-0112CDB8 7C87655C (00000002, 0112CDF4, 7C8763C0, 00000002)
-End of stack trace
View
@@ -0,0 +1,75 @@
+<!doctype>
+<html>
+<head>
+<meta charset="utf-8">
+<title>jsxml example - Yahoo weather</title>
+</head>
+<style>
+html{
+ background:#f2f2f2;
+}
+body{
+ padding-top:20px;
+ width:960px;
+ margin:0 auto;
+ text-align:center;
+ color:#404040;
+ font-family: 'Microsoft Yahei', Verdana, Arial;
+ text-shadow:#fff 1px 0px 1px;
+}
+
+ol{
+ list-style:none;
+}
+
+#container{
+ text-align:left;
+}
+</style>
+<body>
+<h1>jsxml example - Yahoo weather</h1>
+<button id="btn">fetch weather data</button>
+<div id="container">
+</div>
+<script src="http://cdnjs.cloudflare.com/ajax/libs/yui/3.3.0/yui-min.js"></script>
+<script src="../src/jsxml.js"></script>
+<script>
+YUI().use('node-base', 'yql', 'substitute', function(Y){
+ //http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D'CHXX0044'
+ var query = "select * from weather.forecast where location='CHXX0044'";
+ var XML = jsxml.XML;
+ var init = function(){
+ var list = xml.descendants('forecast'),
+ template = "{date},{day},天气{weather},最高气温{high},最低气温{low}。",
+ innerHTML = '<h2>'+xml.child('item').child('title').getValue()+'</h1>';
+
+ innerHTML += '<h3>天气预报</h3><ol>';
+ list.each(function(item, index){
+ var html = Y.substitute(template, {
+ date: item.attribute('date').getValue(),
+ day: item.attribute('day').getValue(),
+ high: item.attribute('high').getValue(),
+ low: item.attribute('low').getValue(),
+ weather: item.attribute('text').getValue()
+ });
+ innerHTML += '<li>'+html +'</li>';
+ });
+ innerHTML += '</ol>';
+ innerHTML += "<h3>详情</h3>";
+ innerHTML += "<div>"+xml.child('item').child('description').getValue() + "</div>";
+ Y.one('#container').setContent(innerHTML);
+ };
+ var getWeather = function(){
+ Y.one('#container').setContent('start fetching weather data...');
+ Y.YQL(query, function(r){
+ xml = new XML(r.results[0]);
+ init();
+ }, {format:'xml'});
+ }
+ Y.one('#btn').on('click', function(e){
+ getWeather();
+ });
+});
+</script>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit 65d9596

Please sign in to comment.