Skip to content

Instantly share code, notes, and snippets.

@teaualune
Forked from anonymous/taiyen's stupid ideal
Last active December 20, 2015 04:29
Show Gist options
  • Save teaualune/6071513 to your computer and use it in GitHub Desktop.
Save teaualune/6071513 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>T.T. in GT Lab</title>
<meta http-equiv=content-type content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.10.2/build/cssreset/cssreset-min.css">
<style type="text/css">
#query {
margin: 10px 0;
}
#controls {
margin: 10px 0;
}
.rpp {
padding-left: 1.5em;
}
.yui3-skin-sam .yui3-datatable caption {
padding: 0 !important;
}
.yui3-skin-sam .yui3-paginator-rpp-options {
margin-left: 0;
}
</style>
</head>
<body class="yui3-skin-sam">
Good morning Georgia!
<h1><a href="https://www.facebook.com/bjeremyl">T.T FB</a> ~~~~~~</h1>
<hr>
<form id="query-form" name="query_form">
<div id="query"></div>
</form>
<div>
<div id="simple"></div>
<button id="button1">I Love</button>
<button id="button2">YuZu</button>
<button id="button3">(~"~)</button>
</div>
<input type="text" placeholder="search name..." />
<script src="http://yui.yahooapis.com/3.10.2/build/yui/yui-min.js"></script>
<script>
YUI({
gallery: 'gallery-2013.06.26-23-09'
}).use(
'datatable-datasource',
'datasource-arrayschema',
'gallery-querybuilder',
'gallery-formmgr',
'gallery-paginator',
'array-extras',
function (Y) {
var data = [
{id: 'n1', name: "Brian", years: 23, price: "$16.88 (On-Sale)"},
{id: 'n2', name: "Emily", years: 24, price: "$29.99"},
{id: 'n3', name: "TaiYen", years: "forever 19", price: "Priceless"},
],
// A table from data with keys that work fine as column names
simple = new Y.DataTable({
columns: ["name", "years", "price"],
data: data,
summary: "Price sheet for inventory parts QQ",
caption: "Example table with simple columns"
});
//上面是我的想法但doesn't work
//下面是我的問題,如果這樣寫
//var i,
// k,
// dataObject = {},
// match = false;
//
//for (i = 0; i < data.length; i=i+1) {
// for (k in data[i])
// if (data[i][k] === searchText) {
// matched = true;}
// }
//...
//最後
//Y.on("click", function (e) {
// if (match = true){
// alert(data[i].price)
// }
// if (!matched) {
// alert("Are you kidding!?");
// }
Y.on("click", function (e) {
simple.render("#simple");
Y.one("#simple").show();
}, '#button1');
Y.on("click", function (e) {
Y.one("#simple").hide();
}, '#button2') ;
Y.on("click", function (e) {
var searchText = Y.one('input').get('value'),
i,
k;
for (i = 0; i < data.length; i=i+1) {
for (k in data[i]) {
if (data[i][k] === searchText) {
matched = true;
}
}
}
alert(matched ? searchText : 'Are you kidding?');
}, '#button3');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment