<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ropox.net &#187; Snippets</title>
	<atom:link href="http://ropox.net/archives/category/programming/snippets/feed" rel="self" type="application/rss+xml" />
	<link>http://ropox.net</link>
	<description>thoughts from a web engineer</description>
	<lastBuildDate>Wed, 21 Jul 2010 05:33:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting the page and viewport dimensions using jQuery</title>
		<link>http://ropox.net/archives/20449</link>
		<comments>http://ropox.net/archives/20449#comments</comments>
		<pubDate>Tue, 08 Jun 2010 14:22:22 +0000</pubDate>
		<dc:creator>ropox</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://ropox.net/?p=20449</guid>
		<description><![CDATA[Getting the page and viewport dimensions using jQuery is as easy as 1 2 3


Related posts:<ol><li><a href='http://ropox.net/archives/1081' rel='bookmark' title='Permanent Link: JQuery wildcard selectors'>JQuery wildcard selectors</a> <small>JQuery wildcard selectors on select boxes, how to reset all...</small></li>
<li><a href='http://feedproxy.google.com/~r/ajaxian/~3/8XlkyLk5Yc8/custom-info-windows-with-jquery-and-google-maps' rel='bookmark' title='Permanent Link: Custom info windows with jQuery and Google Maps'>Custom info windows with jQuery and Google Maps</a> <small>Ben Nolan has a writeup on a new feature in...</small></li>
<li><a href='http://feedproxy.google.com/~r/ajaxian/~3/ZhCs9AtdZOA/html-5-section-is-not-just-a-semantic-div' rel='bookmark' title='Permanent Link: HTML 5 section is not just a “semantic div”'>HTML 5 section is not just a “semantic div”</a> <small>James Graham of Opera has a post about how section...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brown" style="float: right;margin-left: 0.75em;"><script type="text/javascript" src="http://button.topsy.com/widget/retweet-big?url=http://ropox.net/archives/20449&amp;shorturl=http://bit.ly/crkOnG&amp;title=Getting+the+page+and+viewport+dimensions+using+jQuery&amp;theme=brown&amp;nick=ropox&amp;order=count,retweet,badge&amp;txt_tweet=tweet&amp;txt_retweet=retweet"></script></div><p>thats why i Love jquery, cause everything is so simple&#8230;</p>
<p>To get the width and height of the whole page (document), use:</p>
<pre class="brush: javascript">
var pageWidth = $(document).width();
var pageHeight = $(document).height();
</pre>
<p>To get the width and height of the viewport (window), use:</p>
<pre class="brush: javascript">
var viewportWidth = $(window).width();
var viewportHeight = $(window).height();
</pre>
<p>
Opera though has a different approach. with Opera 9.5 $(window).height() returns the document height (more info here)<br />
you can get around this by using</p>
<pre class="brush: javascript">
var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
</pre>
<!-- AdSense Now! V1.83 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="text-align:center;margin: 12px;"><br /><br />
<script type="text/javascript"><!--
google_ad_client = "pub-9479225664088173";
/* 300x250, ropox content */
google_ad_slot = "4563927795";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fropox.net%2Farchives%2F20449&amp;linkname=Getting%20the%20page%20and%20viewport%20dimensions%20using%20jQuery"><img src="http://ropox.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></p>

<p>Related posts:<ol><li><a href='http://ropox.net/archives/1081' rel='bookmark' title='Permanent Link: JQuery wildcard selectors'>JQuery wildcard selectors</a> <small>JQuery wildcard selectors on select boxes, how to reset all...</small></li>
<li><a href='http://feedproxy.google.com/~r/ajaxian/~3/8XlkyLk5Yc8/custom-info-windows-with-jquery-and-google-maps' rel='bookmark' title='Permanent Link: Custom info windows with jQuery and Google Maps'>Custom info windows with jQuery and Google Maps</a> <small>Ben Nolan has a writeup on a new feature in...</small></li>
<li><a href='http://feedproxy.google.com/~r/ajaxian/~3/ZhCs9AtdZOA/html-5-section-is-not-just-a-semantic-div' rel='bookmark' title='Permanent Link: HTML 5 section is not just a “semantic div”'>HTML 5 section is not just a “semantic div”</a> <small>James Graham of Opera has a post about how section...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://ropox.net/archives/20449/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image upload with AS3 mac problem fix</title>
		<link>http://ropox.net/archives/16145</link>
		<comments>http://ropox.net/archives/16145#comments</comments>
		<pubDate>Tue, 27 Apr 2010 06:33:02 +0000</pubDate>
		<dc:creator>ropox</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://ropox.net/?p=16145</guid>
		<description><![CDATA[I hit my head several times on the wall before I found out why browsers on MAC dont work exactly as browsers on windows, after uploading a file via Flash.


Related posts:<ol><li><a href='http://ropox.net/archives/17137' rel='bookmark' title='Permanent Link: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs'>Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs</a> <small>It was nice enough in AS2 when you did a...</small></li>
<li><a href='http://feedproxy.google.com/~r/PHPMagazineNetwork/~3/8AWqslHXjUA/dhtmlx_released_version_21.html' rel='bookmark' title='Permanent Link: [AJAX Magazine] DHTMLX Released Version 2.1'>[AJAX Magazine] DHTMLX Released Version 2.1</a> <small>DHTMLX announced the update of their Ajax UI Toolkit, a...</small></li>
<li><a href='http://ropox.net/archives/1081' rel='bookmark' title='Permanent Link: JQuery wildcard selectors'>JQuery wildcard selectors</a> <small>JQuery wildcard selectors on select boxes, how to reset all...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brown" style="float: right;margin-left: 0.75em;"><script type="text/javascript" src="http://button.topsy.com/widget/retweet-big?url=http://ropox.net/archives/16145&amp;shorturl=http://bit.ly/91k5Wg&amp;title=Image+upload+with+AS3+mac+problem+fix&amp;theme=brown&amp;nick=ropox&amp;order=count,retweet,badge&amp;txt_tweet=tweet&amp;txt_retweet=retweet"></script></div><p>I hit my head several times on the wall before I found out why browsers on MAC dont work exactly as browsers on windows, after uploading a file via Flash.</p>
<p>the reason is simple : on MAC the browsers never calls onComplete = function(fileRef:FileReference) {}. Which means that the image is uploaded alright, but the flash app never gets a response back that the file has finished uploading.</p>
<p>All you have to do is , on your php/aspx/apsx/py or whatever server side file is handling your file upload from flash, you need to print something at the end of uploading.</p>
<p>for example in php, you could print the word : completed.</p>
<pre class="brush: php">
print &quot;completed&quot;;
</pre>
<p>you can print whatever word you want, it doesnt matter, all that matters is that the server side file is printing something (After the upload has finished) and browsers on mac platforms, will pick up on that , and your file upload will work!</p>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fropox.net%2Farchives%2F16145&amp;linkname=Image%20upload%20with%20AS3%20mac%20problem%20fix"><img src="http://ropox.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></p>

<p>Related posts:<ol><li><a href='http://ropox.net/archives/17137' rel='bookmark' title='Permanent Link: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs'>Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs</a> <small>It was nice enough in AS2 when you did a...</small></li>
<li><a href='http://feedproxy.google.com/~r/PHPMagazineNetwork/~3/8AWqslHXjUA/dhtmlx_released_version_21.html' rel='bookmark' title='Permanent Link: [AJAX Magazine] DHTMLX Released Version 2.1'>[AJAX Magazine] DHTMLX Released Version 2.1</a> <small>DHTMLX announced the update of their Ajax UI Toolkit, a...</small></li>
<li><a href='http://ropox.net/archives/1081' rel='bookmark' title='Permanent Link: JQuery wildcard selectors'>JQuery wildcard selectors</a> <small>JQuery wildcard selectors on select boxes, how to reset all...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://ropox.net/archives/16145/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JQuery wildcard selectors</title>
		<link>http://ropox.net/archives/1081</link>
		<comments>http://ropox.net/archives/1081#comments</comments>
		<pubDate>Mon, 19 Jan 2009 13:44:01 +0000</pubDate>
		<dc:creator>ropox</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[selectors]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[wildcard]]></category>

		<guid isPermaLink="false">http://ropox.net/?p=1081</guid>
		<description><![CDATA[JQuery wildcard selectors on select boxes, how to reset all select boxes using wildcards


Related posts:<ol><li><a href='http://ropox.net/archives/16145' rel='bookmark' title='Permanent Link: Image upload with AS3 mac problem fix'>Image upload with AS3 mac problem fix</a> <small>I hit my head several times on the wall before...</small></li>
<li><a href='http://ropox.net/archives/20449' rel='bookmark' title='Permanent Link: Getting the page and viewport dimensions using jQuery'>Getting the page and viewport dimensions using jQuery</a> <small>Getting the page and viewport dimensions using jQuery is as...</small></li>
<li><a href='http://feedproxy.google.com/~r/ajaxian/~3/8XlkyLk5Yc8/custom-info-windows-with-jquery-and-google-maps' rel='bookmark' title='Permanent Link: Custom info windows with jQuery and Google Maps'>Custom info windows with jQuery and Google Maps</a> <small>Ben Nolan has a writeup on a new feature in...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brown" style="float: right;margin-left: 0.75em;"><script type="text/javascript" src="http://button.topsy.com/widget/retweet-big?url=http://ropox.net/archives/1081&amp;title=JQuery+wildcard+selectors&amp;theme=brown&amp;nick=ropox&amp;order=count,retweet,badge&amp;txt_tweet=tweet&amp;txt_retweet=retweet"></script></div><p>Ok i spend a lot of time on finding how to work this around using JQuery, but i finally found a solution.</p>
<p>Say we have some elements in our page that we don&#8217;t know their ID&#8217;s. For example in my case I was printing dynamically select elements but did not know their ID cause each id had an integer to distinguish it from the others. What i wanted to do was to reset all select boxes with a certain word in their ID&#8217;s to their first element as soon as one of them changed.</p>
<p>For example all the elements that i wanted to change had the word &#8220;upgrade&#8221; in them plus some other numbers. What I did was on the onChange function that would trigger the event:</p>
<pre class="brush: javascript">
$(&quot;select[id^=upgrade]&quot;).each(function() {
$(this).val(&quot;-&quot;);
});
</pre>
<p>which would return to me all elements that started with the word upgrade.  <a href="http://docs.jquery.com/Selectors" target="_blank">JQuery selectors</a> are great. Using the each function you can go around all selectors and set the value of each select box to &#8220;-&#8221; which in my case the &#8220;-&#8221; was the first element of each select box. Usually you will have as the first element something like &#8220;0&#8243; or &#8220;&#8221; (empty).</p>
<p>Also searching <a href="http://colourgray.wordpress.com/2008/08/05/jquery-wildcard-selectors/" target="_blank">I found this interesting snippet </a>which didnt work for me, but i assume i did something wrong.</p>
<pre class="brush: javascript"> $(&#039;#myElement&#039;).html();</pre>
<p>You can use \\S* to make wildcard selections, I.E.:</p>
<pre class="brush: javascript"> $(&#039;#myEle\\S*&#039;).each();</pre>
<p>Dont know why it didnt work on my case&#8230;.</p>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fropox.net%2Farchives%2F1081&amp;linkname=JQuery%20wildcard%20selectors"><img src="http://ropox.net/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></p>

<p>Related posts:<ol><li><a href='http://ropox.net/archives/16145' rel='bookmark' title='Permanent Link: Image upload with AS3 mac problem fix'>Image upload with AS3 mac problem fix</a> <small>I hit my head several times on the wall before...</small></li>
<li><a href='http://ropox.net/archives/20449' rel='bookmark' title='Permanent Link: Getting the page and viewport dimensions using jQuery'>Getting the page and viewport dimensions using jQuery</a> <small>Getting the page and viewport dimensions using jQuery is as...</small></li>
<li><a href='http://feedproxy.google.com/~r/ajaxian/~3/8XlkyLk5Yc8/custom-info-windows-with-jquery-and-google-maps' rel='bookmark' title='Permanent Link: Custom info windows with jQuery and Google Maps'>Custom info windows with jQuery and Google Maps</a> <small>Ben Nolan has a writeup on a new feature in...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://ropox.net/archives/1081/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
