Diet1 - Nutrition To Go
Evidently I've created quite a sensation....
PR Newswire
ABC News Boston
Yahoo News
Restaurant News
Bio Medicine News
I appreciated the fact that the ABC news anchor woman gave the proper usage/syntax instructions... "restaurant name food item". Play with the web interface here: DIET.COM
Diet.com Nutrition Facts SMS Service
So I finally have something truly great to write about...
I'm pleased to announce the release of my pet project of late 2007: Diet1.
Diet1 is a short code, which means: you send it a restaurant name and menu item from that restaurant and it will send you back the nutrition information for that food.
The system is completely PHP/MySQL and lightning fast.... so fast, its almost eerie.
The system has 4 spell correction gates that are "secrets"... but i can tell you this: It knows that "stairbuks cnnamen dolc" means "Starbuck's Cinnamon Dolce Latte" (try it! text it to 34381)
I don't really know what to write about here, so I guess I'll leave it open for questions.
http://www.diet.com/dietblogs/read_blog.php?blid=5729&title=Diet.com+Dials+Up+A+Winner%21
Javascript Wheelmouse Controls : PHP Data Grid
The premise:
Assuming you've already set up some neat-o PHP/MySQL & AJAX (or AHAH) Data Grid with all nifty onmouseovers you can cram in there, I've got another one you might try...
Warning, this was a total hack. Feel free to clean up after me, just do me a favor and report your version.
Here we go. Somewhere in your neat data grid table interface you've got paging buttons, and I imagine those paging buttons have values that they send to some kind of AJAX call, which sends it to PHP which then tells MySQL which records we want to view next, ie. the next 10 records starting at record 20? or the last 10 records starting at record 20?
Does that button have an ID? The DOM owns you in this Web 2.0 era, so I suggest that it must have an ID, if not, please add one (hint: i just used id=n for the next button and id=p for the previous button ... cryptic, huh?).
Ok, now that you have an ID, we can access the button's value="" from document.getElementById('').value
So throw this in the <head> or in a *.js :
function handle(delta) {
if (delta <>
process(document.getElementById('n').value); // NEXT SET OF RECORDS
else
process(document.getElementById('p').value); // PREVIOUS SET OF RECORDS
}
function wheel(event){
var delta = 0;
if (!event) event = window.event;
if (event.wheelDelta) {
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) {
delta = -event.detail/3;
}
if (delta)
handle(delta);
}
/* Initialization code. */
if (window.addEventListener)
window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
Thats it. process(); is my AJAX call and I don't need to tell you want the values were, figure that part out. (hint: 10, 20, 30 , 40 , 50, 60 etc.). process(); will send back that value, which will then be processed by a PHP script that will then instruct MySQL to give it so many records from such and such table and so on, order by, desc, asc, limit *, * and what-have-you. Once MySQL coughs up the goods to PHP, PHP send back some lovely JSON-ese and AJAX takes it from there, putting it into a nice table and then shoving it into a <div> on the users end.
So what's the end product? Mousewheel controlled record perusing in your browser based data-grid.
Fancy.
EDIT! I've re-written this for use with Prototype... and its much better now.
I will take this seriously... I promise.
Disregard my last post. That's not the only thing I will be talking about.
development
This blog will be for tracking my projects.
That is all for now.