-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
345 lines (281 loc) · 15 KB
/
app.php
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?php
/* Simple query parser
This will take a url of the form
<baseurl>/compare?car1=xxx&car2=xxx&car3=xxx&car4=xxx
and define variables $car1 thru $car4 with values that are the parameter values.
[parse_str() does all that work.]
sample url: http://localhost/dynamic-url-exp/app.php?car1=Accord&car2=Camry
*/
$run_php_flag = true; // can disable php if there's a db problem, will just lose that functionality.
// Declare vars to prevent breakage if php is "turned off":
// "VS" string that will be used to customize tags.
$vs_string = "";
$list_string = "";
// array of ids:
$ids_array = "";
if ( $run_php_flag ) {
$dbhost = 'localhost';
$dbname = 'wesrowen_carids';
$dbtable = 'styles';
$dbuser = 'wesrowen_noodler';
$dbpassword = 'w9y^s@bIk)&g';
// table columns are model_name and style_id
mysql_connect( $dbhost, $dbuser, $dbpassword ) or die(/* mysql_error() */);
mysql_select_db( $dbname ) or die(mysql_error());
$url_current = "http://" . $_SERVER['SERVER_NAME'] . "/dynamic-url-exp/app.html?" . $_SERVER['QUERY_STRING'];
// &'s are entity-escaped in sitemap
parse_str( str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) );
// query var names have to be unique, & have to exist or it will SCREAM
function lookup_style_id( $table, $car_name ) {
// if lookup succeeds
$query = "SELECT * FROM " . $table . " WHERE model_name='" . $car_name . "'";
//echo $query;
$resource = mysql_query($query); // returning false. hmmmmm.
if ( !$resource ) { echo "<br/>query resource is false<br/>"; }
// puts the resource into the $info array
$info = mysql_fetch_array( $resource );
return( $info['style_id'] );
}
if ( isset( $car1 ) ) { // param exists
$id1 = lookup_style_id( $dbtable, $car1 );
$url_current .= "&id1=" . $id1;
$vs_string .= $car1;
$list_string .= $car1;
}
if ( isset( $car2 ) ) { // param exists
$id2 = lookup_style_id( $dbtable, $car2 );
$url_current .= "&id2=" . $id2;
$vs_string .= " <span class='vs_txt'>vs.</span> " . $car2;
$list_string .= ", " . $car2;
}
if ( isset( $car3 ) ) { // param exists
$id3 = lookup_style_id( $dbtable, $car3 );
$url_current .= "&id3=" . $id3;
$vs_string .= " <span class='vs_txt'>vs.</span><br/>" . $car3;
$list_string .= ", " . $car3;
}
if ( isset( $car4 ) ) { // param exists
$id4 = lookup_style_id( $dbtable, $car4 );
$url_current .= "&id4=" . $id4;
$vs_string .= " <span class='vs_txt'>vs.</span> " . $car4;
$list_string .= ", " . $car4;
}
if ( isset( $car1 ) ) {
if ( $id1 !== '' ) { $ids_array .= $id1; }
}
if ( isset( $car2 ) ) {
if ( $id2 !== '' ) { $ids_array .= ", " . $id2; }
}
if ( isset( $car3 ) ) {
if ( $id3 !== '' ) { $ids_array .= ", " . $id3; }
}
if ( isset( $car4 ) ) {
if ( $id4 !== '' ) { $ids_array .= ", " . $id4; }
}
// replace '-' with spaces for display of model_names
$vs_string_pretty = str_replace ( "-", " ", $vs_string ); // using hyphens for spaces in url params
$list_string_pretty = str_replace ( "-", " ", $list_string );
} // end of $run_php_flag conditional
// replace '-' with spaces for display of model_names
$vs_string_pretty = str_replace ( "-", " ", $vs_string ); // using hyphens for spaces in url params
$list_string_pretty = str_replace ( "-", " ", $list_string );
//echo $url_current; // original url plus params holding style_ids.
//header("Location: " . $url_current ); // changes (redirects) the address bar url
/* Okay, now output the markup */
?>
<!doctype html>
<html lang="en">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#
website: http://ogp.me/ns/website#">
<title><?php
$s = ( $vs_string_pretty !== "" ) ? $vs_string_pretty : "Compare Cars Visually";
echo $s .= "– Noodler" ;
?></title>
<meta property="fb:admins" content="1034261419" />
<meta property="og:title" content="Compare Cars with Noodler"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://www.noodlercompare.com"/>
<meta property="og:image" content="http://www.noodlercompare.com/images/NoodlerClose-up_sq.png"/>
<meta property="og:site_name" content="Noodler Car Compare"/>
<meta property="og:description"
content="Noodler makes car comparison easy! See similarities and differences at a glance. Data from Edmunds.com."/>
<meta charset="utf-8">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta name="description" content="Noodler Compare lets you see the key differences YOU care about, between the <?php
if ( $list_string_pretty != "" ) {
echo $list_string_pretty;
} else {
echo "cars you care about";
}
?>. Specs and pricing data by Edmunds.com.">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!--[if !IE]><!--><script>if(/*@cc_on!@*/false){$('html').addClass('ie_user');}</script><!--<![endif]-->
<!--[if IE]><script>$('html').addClass('ie_user');</script><!--<![endif]-->
<script src="common-js/raphael-min.js" type="text/javascript" charset="utf-8"></script>
<!-- <script type="text/javascript" src="chooser_objects/easyload_menu_object.js"></script> -->
<script type="text/javascript" src="common-js/fastclick.js"></script>
<script type="text/javascript" src="chooser_objects/makeQuery_newandusedmakes_noYearOption.js"></script>
<script type="text/javascript" src="common-js/interaction.js"></script>
<script src="common-js/carviz.js"></script>
<link rel="stylesheet" href="css/style_app.css">
<script>
var dynamic_ids = [ <?php echo $ids_array ?> ];
</script>
</head>
<body>
<!-- GA -->
<script type="text/javascript">
var _gaq = _gaq || [];
var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
_gaq.push(['_setAccount', 'UA-38228914-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<section id="header">
<h1 id="versus_title"><?php
$vs_string_pretty .= " ...<span class='vs_txt'>vs.</span> <span id='anything'>Anything</span>";
echo $vs_string_pretty
?></h1>
<a href="http://www.noodlercompare.com/index.html" alt="Noodler Compare Home" title="Noodler Compare logo"><img id="main_logo" src="images/NoodlerLogo_wNoodles_209x100blk.png" alt="Noodler Compares Cars" Title="Noodler Compare Home"></a>
<ul id="tabs">
<li id="discover_btn" onclick="_gaq.push(['_trackEvent', 'Interaction', 'DiscoverTab', 'Clicked', 0, false]); ">POPULAR</li>
<li id="hints_btn" onclick="_gaq.push(['_trackEvent', 'Interaction', 'KeyTiles', 'Clicked', 0, false]); ">HINTS</li>
</ul>
<div id="demo_announcement">
<h1>A Demo has loaded for you.</h1>
<h2>Customize your comparison at left by <span class="add_car_color">adding new cars</span> and deleting ones you don't want.</h2>
</div>
<div class="clear"></div>
</section>
<div id="fb_share">
<div id="sharer">
<p>
<img id="fb_icon" src="images/facebook.png" alt="Share on Facebook" width="30"/>
</p>
<p>
<a href="https://twitter.com/share" class="twitter-share-button" data-size="large" data-via="noodlerviz" data-hashtags="noodlercarcompare">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</p>
<p><a href="mailto:?body=Check out this car comparison site: Noodler Compare. Add a car or two you like and send it back to me!%0A%0AThe cars you pick will load automatically!%0A%0A%0Ac/o www.noodlercompare.com" target="_blank" id="emailer"><img id="email_icon" src="images/email_icon.png" alt="Email your comparison to yourself or a friend." title="Save or send your work."/> Email your work</a></p>
</div>
</div>
<div id="outside_left_mask"></div>
<section id="left_bar">
<div id="demo_x_flasher">X</div>
<div id="dynamic_picker">
<!-- <p class="close_handle">< < < CLOSE < < <</p> -->
<div class="picker_title" onclick="_gaq.push(['_trackEvent', 'Interaction', 'SliderMenuTitle', 'AddCar', 0, true]); ">
<span class="picker_close_arrows"></span>
<span class="title_span">Add a Vehicle</span>
<!-- <span class="picker_x">X</span> -->
</div>
<div id="options_list">
<select id="make_select" name="make">
<option value>Select Make</option> <!-- empty "value" required for one-choice select lists -->
</select>
<select disabled="disabled" id="model_select" name="model" disabled="disabled">
<option value>Select Model</option>
</select>
<select disabled="disabled" id="year_select" name="year" disabled="disabled">
<option value>Select Year</option>
</select>
<select disabled="disabled" id="trim_select" name="trim" disabled="disabled">
<option value>Select Trim</option>
</select>
<button id="add_car_btn" disabled="disabled">Add Vehicle</button>
<div class="loading_mask"></div>
</div>
</div>
<div id="remembered_cars_container">
<div class="picker_title" onclick="_gaq.push(['_trackEvent', 'Interaction', 'SliderMenuTitle', 'RememberedCars', 0, true]);">
<span class="picker_close_arrows"></span>
<span class="title_span">My Rides</span>
</div>
<ul id="remembered_cars_list">
<li class="template remembered_car" style="display:none">
<button class="add_remembered_car_btn" onclick="_gaq.push(['_trackEvent', 'Interaction', 'Remembered car', 'Added', 1, false]);">Add to Compare</button>
<span class="car_name_rem"></span><br/><span class="trim_level_rem"></span>
</li>
</ul>
<div class="clear"></div>
<div class="loading_mask"></div>
</div>
<div id="low_left_mask"></div>
<div id="lower_left_bar">
<ul id="dynamic_car_display">
<li class="template car_info_box" style="display:none" onclick="_gaq.push(['_trackEvent', 'Interaction', 'KeyTiles', 'Clicked', 0, false]); console.log('clicked key tile');">
<h3 class="car_name key_clickable"></h3>
<p class="trim_level key_clickable trim_text" >
</p>
<p class="tile_button_row">
<!--<img class="add_trims_btn" src="images/plus_btn_32.png"/>-->
<a class="edmunds_link" target="_blank" onclick="_gaq.push(['_trackEvent', 'OutBound', 'Edm_referral', 'more_info', 1, false]);"><img class="edmunds_btn" title="View car at Edmunds.com" src="images/Edmunds_link_logo_74x24.png"/></a>
</p>
<div class="delete_btn">X</div>
</li>
</ul>
<!-- <a href="http://www.jdoqocy.com/click-7024258-10364260" target="_blank" onmouseover="window.status='http://www.edmunds.com';return true;" onmouseout="window.status=' ';return true;">
<img src="http://www.tqlkg.com/image-7024258-10364260" width="125" height="125" alt="Search for your next car or truck at Edmunds.com" border="0"/>
</a> -->
<!-- <a href="http://www.edmunds.com/" target="_new"><img id="edmunds_credit" src="images/edmunds_api150x30vb.png" title="Data provided by Edmunds.com" alt="Data via the Edmunds API"></a>
<p class="copyright">Code and design <br/>©2013 Wesley Rowe</p> -->
<!-- <p>Lots of products can be Noodled. Have an idea? Get in touch!<br/>wes [at] wesrowe [dot] net</p> -->
</div>
</section>
<div id="content_area">
<div id="helpful_hints_container">
<div id="hints">
<p class="close_x">CLOSE X</p>
<h3>Helpful hints:</h3>
<ol>
<li>You can <span class="blue">compare any car or truck, new or used</span>, that can be found at Edmunds.com. Compare minivans, pickups, SUVs, hybrids, luxury cars. Just click "Add a Vehicle" at left. Pro tip: Pick a vehicle you know well as a baseline, to compare others against.</li>
<li><span class="blue">Demos</span> will help you see how easy it is to compare the vehicle specs you care about with Noodler. Pick one from the list in the Discover menu.</li>
<li><span class="blue">You <em>can</em> take it with you</span> – Noodler is the only vehicle comparison that's useful on a mobile screen.</li>
<li><span class="blue">Your device will remember</span> cars you've noodled before, look for them under "My Rides" next time. <span id="want_more_devices"><i>Do you want to send your custom vehicle comparison to another device?</i></span> <br/>
<span id="working_on_it">Email it to yourself! (top of screen)</span></li>
<li>Click or tap the brightly colored stuff. You'll be glad you did!</li>
</ol>
</div>
</div>
<div style="display: none;" id="discover_area">
<h1>Popular...</h1>
<p class="close_x">CLOSE X</p>
<select id="load_demo_btn">
<option value>Choose a demo</option>
<option value="minivans">Minivans</option>
<option value="crossovers">Crossovers</option>
<option value="hatchbacks">Hatchbacks</option>
</select>
</div> <!-- /discover -->
<div id="main_paper_container">
<section class="template section_container" style="display:none">
<div class="paper" ></div>
<div class="button_area">
<p class="expander" onclick="_gaq.push(['_trackEvent', 'Interaction', 'Expander', 'Clicked', 0, false]);"><span class="expand_indicator">+</span> <span class="section_title"></span></p>
</div>
<div class="spread_adjust_container">
<img class="smaller" src="images/arrow-up.png" alt="Increase spread" title="Increase space between expanded axes">
<span class="spreader_text">axis spacing</span>
<img class="bigger" src="images/arrow-up.png" alt="Decrease spread" title="Decrease space between expanded axes">
</div>
<div class="clear"></div>
<!-- <div class="spread_handle">spread handle</div> -->
</section>
<div class="clear"></div>
</div> <!-- /main_paper_container -->
<a href="http://www.edmunds.com/" target="_new"><img id="edmunds_credit" src="images/edmunds_api150x30vb.png" title="Data provided by Edmunds.com" alt="Data via the Edmunds API" onclick="_gaq.push(['_trackEvent', 'OutboundLink', 'EdmundsCredit', 'Clicked', 0, false]);"></a>
<p class="copyright">Code and design <br/>©2013 Wesley Rowe</p>
<div id="privacy_policy">
<div><span id="pp_bright_text">Privacy Policy:</span> This website's server does not store information of any kind regarding you or your vehicle interests. Noodler does utilize your computer's hard drive, if your browser allows it, to remember a few facts about cars you've compared so that you can find them again easily. Your use of this web application confirms that you are okay with that.</div>
</div>
</div> <!-- content_area -->
<div class="clear"></div>
</body>
</html>