summaryrefslogtreecommitdiff
path: root/demo.html
blob: c107c572732bcedd07411d4c71d0c8cc7cd6adba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<style type="text/css">
	/*
	Copyright (c) 2010, Yahoo! Inc. All rights reserved.
	Code licensed under the BSD License:
	http://developer.yahoo.com/yui/license.html
	version: 3.2.0
	build: 2676
	*/
	html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
	
	/*
	 * Custom styles
	 */
	body {
		width: 100%;
		overflow: hidden;
	}
	</style>
	
	<!-- standalone yaml.js library -->
	<script type="text/javascript" src="yaml.js"></script>
	
	<!-- encode json with mootools -->
	<script type="text/javascript" src="libs/demo/mootools.js"></script>
	
	<title>yaml.js demo</title>
	
	<script type="text/javascript">
	window.addEvent('domready', function()
	{
		$('parse').setStyles({
			border: 'none',
			backgroundColor: 'white',
			color: 'black',
			zIndex: '3',
			position: 'absolute',
			right: '50%',
			top: '0%',
			width: '100px'
		});
		
		$('yaml').setStyles({
			color: 'white',
			backgroundColor: 'black',
			fontFamily: 'Courier New',
			fontSize: '14px',
			width: '50%',
			height: parseInt($(document.body).getSize().y)+'px',
			border: 'none',
			position: 'absolute',
			top: '0%',
			left: '0%',
			zIndex: '1'
		});
		
		$('result').setStyles({
			color: 'black',
			backgroundColor: 'white',
			fontFamily: 'Courier New',
			fontSize: '15px',
			width: '50%',
			height: parseInt($(document.body).getSize().y)+'px',
			border: 'none',
			position: 'absolute',
			top: '0%',
			left: '50%',
			overflow: 'auto',
			zIndex: '2'
		});
	});
	</script>
</head>

<body>
<form action="" onsubmit="return false;">
	<textarea name="yaml" id="yaml" cols="70" rows="20">--- !clarkevans.com/^invoice
invoice: 34843
date   : 2001-01-23
bill-to: &amp;id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : &quot;BL394D&quot;
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments: &gt;
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.
</textarea>
<input type="button" id="parse" name="parse" value="Parse &raquo;" onclick="try{$('result').innerHTML=JSON.encode(YAML.decode($('yaml').value))}catch(e){alert(e);}" />
<div id="result"></div>

</form>
</body>
</html>