Skip to content

Instantly share code, notes, and snippets.

Created July 23, 2013 13:31
Show Gist options
  • Save anonymous/6062357 to your computer and use it in GitHub Desktop.
Save anonymous/6062357 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"},
{id: 'n4', name: "TaiYen", years: "forever 18", price: "Great worth"}
];
// A table from data with keys that work fine as column names
simple = new Y.DataTable({
//可以不要
columns: ["name", "years", "price"],
//data:不可改成→data=
data: data,
summary: "Price sheet for inventory parts QQ",
caption: "Example table with simple columns"
});
Y.on("click", function (e) {
simple.render("#simple");
Y.one("#simple").show();
}, '#button1');
Y.on("click", function (e) {
Y.one("#simple").hide();
}, '#button2') ;
//
var searchText = Y.one('input').get('value'),
i = 0,
nameString={},
matched = false;
buttonshow;
for (i; i < data.length; i = i + 1) {
nameString[data[i].name]=data[i].price;
if (searchText === data[i].name) {
nameString[data[i].name]=data[i].price;
matched = true;
buttonshow = nameString[data[i].name];
}
}
if (!matched) {
buttonshow = "Are you kidding!?";
};
var functionbutton3 = function (e){alert(buttonshow);
if (searchText === data[i].name) {
nameString[data[i].name]=data[i].price;
matched = true;
buttonshow = nameString[data[i].name];
}
if (!matched) {
buttonshow = "Are you kidding!?";
};
};
Y.on("click", function (e){functionbutton3(e)}, '#button3');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment