Skip to content

Instantly share code, notes, and snippets.

@kratskij
Last active April 26, 2024 08:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kratskij/92616d060250b92f03b6 to your computer and use it in GitHub Desktop.
Save kratskij/92616d060250b92f03b6 to your computer and use it in GitHub Desktop.
oel
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style type="text/css">
tr.had { color: #888; }
</style>
<script type="text/html" id="beer_row">
<% var d = new Date(obj.updated * 1000); now = new Date(); %>
<tr <%= (Beerradar.myRatings.indexOf(parseInt(obj.beer.ratings[0].id)) > -1) ? 'class="had"' : '' %>>
<td><%= Math.round((now.getTime() - d.getTime()) / 86400000) %> days</td>
<td><%= obj.beer.brewery %> - <%= obj.beer.name %></td>
<td><%= obj.beer.style %></td>
<td><%= obj.abv %></td>
<td><%= obj.price %></td>
<td><%= obj.beer.ratings[0].rating %></td>
</tr>
</script>
<script type="text/javascript">
(function(){
var cache = {};
this.tmpl = function tmpl(str, data, callback){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj",
"var p=[],print=function(){p.push.apply(p,arguments);};" +
// Introduce the data as local variables using with(){}
"with(obj){p.push('" +
// Convert the template into pure JavaScript
str
.replace(/[\r\t\n]/g, " ")
.split("<%").join("\t")
.replace(/((^|%>)[^\t]*)'/g, "$1\r")
.replace(/\t=(.*?)%>/g, "',$1,'")
.split("\t").join("');")
.split("%>").join("p.push('")
.split("\r").join("\\'")
+ "');}return p.join('');");
if (typeof callback == 'function' && data) {
return callback(fn(data));
}
return data
? fn( data )
: fn;
};
})();
jQuery(document).ready(function() {
Beerradar = {
get: function(venue) {
var json = jQuery.getJSON(
'http://br.morud.org/api/v1/vendors/' + venue + '/beers?orderBy=rating', {}, function(json) {
rows = '';
for (i in json) {
console.log(json[i]);
rows += tmpl(
'beer_row',
json[i]
)
}
jQuery('#beer').html(rows);
});
},
myRatings: [ 2,14,69,101,107,179,227,372,410,414,424,449,471,487,811,833,851,872,918,923,1013,1064,1221,1365,1456,1536,1705,1826,1830,1860,1861,2240,2241,2246,2554,3108,3354,3557,3558,3622,3775,3830,3898,3901,3917,4010,4168,4172,4178,4473,4482,4485,4486,4589,4680,4702,4705,4933,4997,5038,5048,5052,5101,5190,5261,5375,5385,5419,5476,5558,5571,5583,5646,5702,5703,5707,5708,5709,5712,5756,5860,5925,5932,5939,5940,5941,6004,6042,6201,6210,6284,6337,6347,6393,6469,6511,6745,6760,6766,6797,6860,6863,6872,6887,6976,7120,7427,7705,7710,7763,7768,7847,7978,7983,8021,8119,8121,8292,8391,8413,8518,8782,8821,8843,8906,9288,9320,9346,9368,9446,9540,9564,9601,9747,9775,9933,9994,10049,10137,10148,10316,10421,10460,10580,10589,10703,10747,10839,10891,10907,11112,11354,11357,11473,11489,11713,11726,12111,12327,12331,12534,12541,12734,12789,12983,13244,13390,13409,13559,13560,13660,13868,14071,14140,14338,14484,14535,14567,14814,14891,14945,15068,15078,15157,15188,15276,15360,15929,15990,16377,16551,16828,17113,17218,17653,17844,18410,18411,18598,19093,19223,19245,19282,19807,20064,20736,20785,20934,21296,22245,22288,23292,23580,24126,24262,24675,24807,25784,25988,26271,26405,27638,28493,29512,29684,29756,30057,30064,30672,30711,31656,31717,31823,32206,32370,32851,33087,33109,33151,33765,33994,34213,34831,35047,35135,35198,35803,36461,36474,36485,36534,36568,36834,37316,37462,37764,37936,38078,38223,38369,38700,39331,39365,39544,39546,39623,41289,42397,42729,42732,42744,42747,42871,43682,43705,44455,44678,44903,44953,45093,45894,45917,45942,46454,46968,47248,47597,47737,48103,48271,49146,49647,49655,49657,51282,51876,52492,52923,52947,53454,53589,53610,53642,53751,54209,54222,55913,55963,56106,56117,56157,56674,56969,57462,58686,59860,59916,60842,61061,61070,61682,61759,62574,63111,63113,64205,64209,64564,64631,64908,65205,65245,65761,65947,66146,66679,66696,66917,67299,67569,67987,68094,68265,68933,69064,69204,69327,69410,70959,70995,71307,71833,72307,72651,72668,73409,73766,73773,74967,75528,75685,76400,76824,77302,82286,83093,83409,84216,84508,85863,88216,88234,89336,91303,92188,92971,92993,93406,93773,93893,93942,94109,94919,95261,95315,96597,97367,97997,98930,99106,99138,99370,99929,99973,102376,103075,103119,103961,104140,105221,105307,106412,106460,107027,109306,111624,111664,113059,114743,115958,116019,116828,116903,117077,118453,119080,123022,123800,124424,124451,126477,126753,127727,127729,127837,127944,130017,130571,130880,131266,134354,134501,134860,135476,136240,136568,136656,136670,138864,138916,139359,139763,142353,142770,142808,143311,143420,143851,144297,144746,147735,150355,151039,155186,157081,158573,162215,162332,162599,163976,164769,164809,164859,166202,167933,169302,170352,171129,171205,171325,171336,171807,178348,183789,184362,186562,187076,189083,189455,194724,196338,196380,203250,203360,204447,205064,205068,208586,208851,210358,213636,218397,218637,219135,219458,222510,222867,222979,226384,227206,233058,234539,239666,239777,241059,245413,246017,247272,248133,253534,253708,254660,254667,255629,256365,257734,258437,259598,259662,260214,260240,260752,261258,262918,263341,263346,264024,264036,267943,268216,269262,270389,271145,271183,273455,273456,278253,278889,281775,284524,284663,285128,290412,293430,298490,300627,300849,300903,301243,301802,302484,302487,303346,304408,307109,313273,314635,316720,317597,318741,318958,319007,319028,319433,319606,322584,323445,324254,325272,329416,333794,334651,335057,335062,335180,338758,339819,340623,341646,344201,345075,347608,347877,348372,353315,353374,356281,356328,356896,358263,360986,365651,367026,370645,371158,372902,373821,374054,374055,374056,374954,375057,378898,385489,385490,385497,386689,388102,389377,389378,389381,390174,393917,396362,396363,396364,398232,398273,399159,399164,406947,419725,420344,420381,421548,421744,424316,427901,430597,440094,440933,440949,441124,444114,447260,448458,450795,450895,451270,451842,452385,455694,455971,457594,457903,458183,459831,460776,462660,462734,462746,462839,463947,468304,469531,473045,473047,473086,473224,474099,474268,475860,476863,477237,479434,480135,480136,480227,483449,484426,485592,485634,486813,489935,490072,490410,491728,492540,492552,492578,493930,496015,496063,497891,498535,498656,503048,503078,504156,505396,507889,508505,509364,511194,516958,518116,519005,519588,524519,524539,526287,528643,529039,529483,534685,534783,536663,536664,541045,541160,543089,547187,549105,551878,552346,556340,560808,562027,562100,562695,562734,562735,568177,568900,572961,573270,575164,575246,577043,578483,579813,579820,581895,586774,586793,587400,587627,588157,593636,594402,595430,600547,600645,601151,602101,606168,608369,609041,609043,609069,610064,610329,610388,610624,613111,613120,613121,613768,614026,614398,615118,616327,617422,618424,621189,622552,626717,628645,628918,629583,630831,630992,630994,640340,641402,641405,643071,643779,646273,648623,657029,663338,665521,665533,666873,668094,668557,669827,670187,671024,672005,672188,673151,673212,674058,674315,675542,678275,679763,681727,688551,688772,691967,693193,694970,695024,699392,701869,702364,702367,702388,702393,703060,703743,703835,708830,708838,712404,720497,724505,727011,727695,732903,733435,734639,734642,738777,741110,746360,750332,751341,754557,755478,755781,762966,764034,764159,768356,769420,770861,774505,776844,777123,777800,777922,780280,784351,784982,785010,786706,788038,789016,791749,793009,793059,794867,800015,800016,801742,801985,803611,803944,807278,810316,810376,810384,810434,810756,810859,816127,821316,824321,825443,830118,830235,835574,838523,844815,852749,852803,853584,854135,854457,854772,856055,856205,859793,859929,861205,861250,861306,862415,866966,867178,869699,869986,873925,874798,875279,877581,878912,879420,881683,881705,881736,882607,883319,888530,894215,894541,895639,897027,897865,900249,909138,913560,921309,933042,934684,936489,945241,946043,959293,959554,960870,960953,967653,976399,982782,996180,1001126,1002356,1008378,1051494 ]
};
});
</script>
</head>
<body onload="Beerradar.get('sot');">
<select onchange="Beerradar.get(this.value);">
<option value="sot">Sot</option>
<option value="antikvariatet">Antikvariatet</option>
<option value="naboen">Naboen</option>
<option value="brygghus9">Brygghus9</option>
<option value="bryggkjelleren">Bryggkjelleren</option>
<option value="moskus">Moskus</option>
<option value="diskoteket">Diskoteket</option>
<option value="taps">Taps</option>
<option value="crowbar">Crowbar</option>
<option value="sara">Café Sara</option>
<option value="schouskjelleren">Schouskjelleren</option>
</select>
<table><thead><th>Updated</th><th>name</th><th>style</th><th>abv</th><th>price</th><th>rating</th></thead><tbody id="beer"></tbody></table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment