<?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>naden.de/blog</title>
	<atom:link href="http://www.naden.de/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.naden.de/blog</link>
	<description>/* no comment */</description>
	<lastBuildDate>Wed, 21 Mar 2012 11:22:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Vorsicht: PHP json_encode und numerische Arrays</title>
		<link>http://www.naden.de/blog/vorsicht-php-json_encode-und-numerische-arrays</link>
		<comments>http://www.naden.de/blog/vorsicht-php-json_encode-und-numerische-arrays#comments</comments>
		<pubDate>Fri, 23 Dec 2011 19:51:26 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=482</guid>
		<description><![CDATA[Auf den ersten Blick liefert die PHP-Funktion json_encode ein unerwartetes Ergebnis, wenn man ein Array mit numerischen Indizes umwandelt. #1 fortlaufenden, numerische Indizes 0, 1 und 2 $a = array&#40;5, 6, 7&#41;; echo json_encode($a); #1 Ausgabe: Array sieht wie erwartet aus &#91;5,6,7&#93; #2 Index beginnt bei 2 $b = array&#40;2 =&#62; 'a', 'b', 'c'&#41;; echo [...]]]></description>
			<content:encoded><![CDATA[<p>Auf den ersten Blick liefert die PHP-Funktion json_encode ein unerwartetes Ergebnis, wenn man ein Array mit numerischen Indizes umwandelt.</p>
<p><span id="more-482"></span></p>
<p><strong>#1 fortlaufenden, numerische Indizes 0, 1 und 2</strong></p>

<div class="wp_codebox"><table><tr id="p4827"><td class="code" id="p482code7"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>echo json_encode($a);</p>
<p><strong>#1 Ausgabe: Array sieht wie erwartet aus</strong></p>

<div class="wp_codebox"><table><tr id="p4828"><td class="code" id="p482code8"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span><span style="color: #CC0000;">7</span><span style="color: #009900;">&#93;</span></pre></td></tr></table></div>

<p><strong>#2 Index beginnt bei 2</strong></p>

<div class="wp_codebox"><table><tr id="p4829"><td class="code" id="p482code9"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'c'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>echo json_encode($b);</p>
<p><strong>#2 Ausgabe ist kein Array, sondern ein Objekt</strong></p>

<div class="wp_codebox"><table><tr id="p48210"><td class="code" id="p482code10"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;3&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;b&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;4&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;c&quot;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>#3 Index beginnt bei 0 und macht dann einen Sprung auf 20</strong></p>

<div class="wp_codebox"><table><tr id="p48211"><td class="code" id="p482code11"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>echo json_encode($c);</p>
<p><strong>#3 Ausgabe ist kein Array, sondern ein Objekt</strong></p>

<div class="wp_codebox"><table><tr id="p48212"><td class="code" id="p482code12"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;20&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">6</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Unerwartet aber es macht nat&#252;rlich Sinn. Javascript kennt kein associativen Arrays, sondern nur fortlaufend nummerierte.</p>
<p>&#8220;Associative Arrays&#8221; werden in Javascript als Objekte abgebildet, da ist ist es von json_encode nat&#252;rlich richtig, in diesem Fall so zu verfahren.</p>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=482&amp;md5=a2a3374a3ba21ba8be7b740bc110f71b" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/vorsicht-php-json_encode-und-numerische-arrays/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>onNodeInserted jQuery Plugin</title>
		<link>http://www.naden.de/blog/onnodeinserted-jquery-plugin</link>
		<comments>http://www.naden.de/blog/onnodeinserted-jquery-plugin#comments</comments>
		<pubDate>Thu, 22 Dec 2011 17:20:36 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=458</guid>
		<description><![CDATA[Bei stark ajax-lastigen Oberfl&#228;chen habe ich immer eine M&#246;glichkeit gesucht, auf neu eingef&#252;gte DomNodes meist zu Formatierungszwecken Javascript-Funktionen anzuwenden global, ohne die immer wiederkehrenden Aufrufe in jedem onSuccess-Handler. Das ist nicht immer &#252;ber simple CSS-Angaben m&#246;glich, besonders dann nicht, wenn man HTML ohne Klassenangaben geliefert bekommt oder einen clientseitigen Tablesorter nutzen m&#246;chte etc. jQuery bietet [...]]]></description>
			<content:encoded><![CDATA[<p>Bei stark ajax-lastigen Oberfl&#228;chen habe ich immer eine M&#246;glichkeit gesucht, auf neu eingef&#252;gte DomNodes meist zu Formatierungszwecken Javascript-Funktionen anzuwenden global, ohne die immer wiederkehrenden Aufrufe in jedem onSuccess-Handler.</p>
<p><span id="more-458"></span></p>
<p>Das ist nicht immer &#252;ber simple CSS-Angaben m&#246;glich, besonders dann nicht, wenn man HTML ohne Klassenangaben geliefert bekommt oder einen clientseitigen Tablesorter nutzen m&#246;chte etc.</p>
<p>jQuery bietet seit einiger Zeit mit <em>live();</em> eine M&#246;glich um Events auch an zuk&#252;nftige Elemente zu binden. Das l&#228;sst sich zwar auch f&#252;r Custome-Events nutzen, diese muss man aber explizit triggern.</p>
<p>Die M&#246;glichkeit, die ich gebaut habe ist sehr experimentell und nicht f&#252;r Produktivsysteme geeignet.</p>
<p>Dazu habe ich ein jQuery-Plugin geschrieben, was das Event <em>DOMNodeInserted</em> &#252;berwacht und, wenn einer der definierten Selektoren greift den dazu passenden Callback-Handler aufruft.</p>
<p>Als Selektor kann jedes Konstrukt benutzt werden, dass <em>jQuery.is()</em> versteht, was uns eine enorme Flexibilit&#228;t gibt. Diese ist auch wichtig, den Selektoren sollten so genau wie m&#246;glich definiert sein, sonst k&#246;nnen leicht 10.000 von Aufrufen zustande kommen, wenn ein etwas allgemeineres Element eingef&#252;gt wird. Das w&#228;re dann ein echtes Performanceproblem.</p>
<p><strong>Die Nutzung ist sehr einfach, hier ein Beispiel</strong></p>
<p>Als Test Html nehmen wir eine unsortierte Liste, die bereits zwei Elemente enth&#228;lt.</p>

<div class="wp_codebox"><table><tr id="p45817"><td class="code" id="p458code17"><pre class="html" style="font-family:monospace;">&nbsp;</pre></td></tr></table></div>

<ul></ul>
<ul>
<li>one</li>
<p>
</ul>
<ul>
<li>two</li>
<p>
</ul>
<p>Nun initialisieren wir unseren Event-Listener mit einem <em>selectorMap</em> genannten Objekt, was als Schl&#252;ssel unsere jeweiligen Selektoren und als Werte die dazu passenden Callback-Handler enth&#228;lt. Hier &#252;berwachen wir alle Listen darauf, ob ein neues Listenelement oder ein neues Listenelement mit einem enthaltenen Link eingef&#252;gt wird.</p>

<div class="wp_codebox"><table><tr id="p45818"><td class="code" id="p458code18"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">onnodeinserted</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

<p>selectorMap: {</p>
<p>&#8216;ul li&#8217;: function(el, selector) {</p>
<p>$(el).css({color: &#8216;red&#8217;});</p>
<p>},</p>
<p>&#8216;ul li a&#8217;: function(el, selector) {</p>
<p>$(el).css({fontWeight: &#8216;bold&#8217;});</p>
<p>$.data(el, &#8216;nonce&#8217;, Math.random());</p>
<p>}</p>
<p>}</p>
<p>});</p>
<p>Zu Testzwecken f&#252;gen wir nun einige Elemente hinzu.</p>

<div class="wp_codebox"><table><tr id="p45819"><td class="code" id="p458code19"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'</span></pre></td></tr></table></div>

<ul>
<li>&#8216;, {text: &#8216;and a young tree&#8217;}).appendTo(&#8216;ul&#8217;);$(&#8216;ul li:nth(1)&#8217;).html($(&#8216;<a shape="rect">&#8216;, {href:&#8217;#', text: &#8216;two&#8217;}));</a><br />
<br clear="none"></br></p>
<p><br clear="none"></br><br />
Nun entfernen wir den Even-Listener wieder, der folgende Aufruf wird nun nicht mehr abgefangen.<br />
<br />
<br clear="none"></br></p>
<p><br clear="none"></br></p>

<div class="wp_codebox"><table><tr id="p45820"><td class="code" id="p458code20"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">onnodeinserted</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'destroy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
<br clear="none"></br><br />
$(&#8216;<br />
<br />
<br clear="none"></br>
</li>
<p>
</ul>
<ul>
<li>&#8216;, {text: &#8216;one more&#8217;}).appendTo(&#8216;ul&#8217;);<strong>Demos mit allen Optionen</strong><br />
<br clear="none"></br></p>
<p><br clear="none"></br></p>
<p><br clear="none"></br></p>
<ul></ul>
<li><a shape="rect" href="/blog/wp-content/download/onnodeinserted-demo.html" target="_blank" rel="nofollow">Demo</a><br />
<br clear="none"></br>
</li>
<p><strong>Download</strong></p>
<ul></ul>
<ul>
<li><a shape="rect" href="/blog/wp-content/download/jquery.onnodeinserted.min.js" target="_blank" rel="nofollow">Download</a><br />
<br clear="none"></br>
</li>
<p>
</ul>
<p><strong>Einschr&#228;nkungen:</strong></p>
<ul></ul>
<ul>
<li>ich nutze das Event DOMNodeInserted, was als <a shape="rect" href="http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted" rel="nofollow" target="_blank">deprecated</a><br />
<br clear="none"></br><br />
gekennzeichnet ist</li>
<p>
</ul>
<ul>
<li>im Internet-Explorer funktioniert es erst ab Version 9</li>
<p>
</ul>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=458&amp;md5=0db75ff32ae367b997bb89ee7b8b7dad" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/onnodeinserted-jquery-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.htaccess-Redirect &#8211; ohne Query-String</title>
		<link>http://www.naden.de/blog/htaccess-redirect-ohne-query-string</link>
		<comments>http://www.naden.de/blog/htaccess-redirect-ohne-query-string#comments</comments>
		<pubDate>Fri, 16 Dec 2011 14:14:05 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Webserver]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=418</guid>
		<description><![CDATA[Um alle Url&#8217;s mittels mod_rewrite und .htaccess von Domain A auf die Index von Domain B umzuschreiben und dabei auch den vorhandenen Query-String zu entfernen bedarf eines kleinen Tricks. Falsch Die Ziel-Url enth&#228;lt noch immer den Query-String. Quell-Url http://www.domain-a.tld/topic.php?id=2839 mod_rewrite RewriteRule ^(.*)$ http://www.domain-b.tld [R=301, L] Ziel-Url http://www.domain-b.tld/?id=2839 Richtig Wir m&#252;ssen ein ? an die Ziel-Url [...]]]></description>
			<content:encoded><![CDATA[<p>Um alle Url&#8217;s mittels mod_rewrite und .htaccess von Domain A auf die Index von Domain B umzuschreiben und dabei auch den vorhandenen Query-String zu entfernen bedarf eines kleinen Tricks.<br />
<span id="more-418"></span></p>
<h2>Falsch</h2>
<p>Die Ziel-Url enth&#228;lt noch immer den Query-String.</p>
<p><strong>Quell-Url</strong><br />
<code>http://www.domain-a.tld/topic.php?id=2839</code></p>
<p><strong>mod_rewrite</strong><br />
<code><br />
RewriteRule ^(.*)$ http://www.domain-b.tld [R=301, L]<br />
</code></p>
<p><strong>Ziel-Url</strong><br />
<code>http://www.domain-b.tld/?id=2839</code></p>
<h2>Richtig</h2>
<p>Wir m&#252;ssen ein <strong>?</strong> an die Ziel-Url ranh&#228;ngen, damit mod_rewrite den Query-String nicht mit &#252;bergibt.</p>
<p><strong>Quell-Url</strong><br />
<code>http://www.domain-a.tld/topic.php?id=2839</code></p>
<p><strong>mod_rewrite</strong><br />
<code><br />
RewriteRule ^(.*)$ http://www.domain-b.tld? [R=301, L]<br />
</code></p>
<p><strong>Ziel-Url</strong><br />
<code>http://www.domain-b.tld</code></p>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=418&amp;md5=addd1fde9c2092fe81f85019ae488c03" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/htaccess-redirect-ohne-query-string/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 Wege um Parameter an Javascripts zu &#252;bergeben</title>
		<link>http://www.naden.de/blog/wege-um-paramater-an-javascriptdateien-zu-uebergeben</link>
		<comments>http://www.naden.de/blog/wege-um-paramater-an-javascriptdateien-zu-uebergeben#comments</comments>
		<pubDate>Tue, 29 Nov 2011 12:24:50 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[paramater]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=375</guid>
		<description><![CDATA[&#220;ber die Jahre habe ich so einige Methoden ausprobiert, um an externe Javascript-Dateien GET-Parameter zu &#252;bergeben. Diese habe ich nun in einem Post zusammengefasst. Die Scripte sind simpel gehalten. F&#252;r den Einsatz in der Wildnis w&#252;rde sich noch die eine oder andere Fehler&#252;berpr&#252;fung anbieten. Enjoy! #1 Die simpelste Methode &#252;bergibt GET-Parameter an das eingebundene Script, [...]]]></description>
			<content:encoded><![CDATA[<p>&#220;ber die Jahre habe ich so einige Methoden ausprobiert, um an externe Javascript-Dateien GET-Parameter zu &#252;bergeben. Diese habe ich nun in einem Post zusammengefasst. Die Scripte sind simpel gehalten. F&#252;r den Einsatz in der Wildnis w&#252;rde sich noch die eine oder andere Fehler&#252;berpr&#252;fung anbieten.  Enjoy!<span id="more-375"></span></p>
<h2>#1</h2>
<p>Die simpelste Methode &#252;bergibt GET-Parameter an das eingebundene Script, so wie man es mit jeder Url machen w&#252;rde.</p>
<p><strong>Einbindung</strong></p>

<div class="wp_codebox"><table><tr id="p37541"><td class="code" id="p375code41"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript-params-1.js?id=1&amp;language=de&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Script</strong></p>

<div class="wp_codebox"><table><tr id="p37542"><td class="code" id="p375code42"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getParams1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> scripts <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      tokens <span style="color: #339933;">=</span> scripts<span style="color: #009900;">&#91;</span>scripts.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">src</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'?'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      params <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> k<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> k<span style="color: #339933;">&lt;</span>tokens .<span style="color: #660066;">length</span><span style="color: #339933;">;</span> k<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> tokens<span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    params<span style="color: #009900;">&#91;</span>tmp<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> tmp<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> params<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Aufruf und Ausgabe</strong></p>

<div class="wp_codebox"><table><tr id="p37543"><td class="code" id="p375code43"><pre class="javascript" style="font-family:monospace;">console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>getParams1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p37544"><td class="code" id="p375code44"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
 id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span>
 language<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;de&quot;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>#2</h2>
<p>In den eigenen Script-Tag werden beliebig viele zus&#228;tzliche <em>data-</em>Attribute eingebaut.</p>
<p><strong>Einbindung</strong></p>

<div class="wp_codebox"><table><tr id="p37545"><td class="code" id="p375code45"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript-params-2.js&quot;</span> data<span style="color: #339933;">-</span>id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;2&quot;</span> data<span style="color: #339933;">-</span>language<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;en&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Script</strong></p>

<div class="wp_codebox"><table><tr id="p37546"><td class="code" id="p375code46"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getParams2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> scripts <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      script <span style="color: #339933;">=</span> scripts<span style="color: #009900;">&#91;</span>scripts.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
      params <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> k<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> k<span style="color: #339933;">&lt;</span>script .<span style="color: #660066;">attributes</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> k<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/data\-/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>script.<span style="color: #660066;">attributes</span><span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nodeName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>    
      params<span style="color: #009900;">&#91;</span>script.<span style="color: #660066;">attributes</span><span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nodeName</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> script.<span style="color: #660066;">attributes</span><span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nodeValue</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> params<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Aufruf und Ausgabe</strong></p>

<div class="wp_codebox"><table><tr id="p37547"><td class="code" id="p375code47"><pre class="javascript" style="font-family:monospace;">console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>getParams2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p37548"><td class="code" id="p375code48"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
 id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">,</span>
 language<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;en&quot;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>#3</h2>
<p>In den eigenen Script-Tag wird ein data-Attribute eingebaut, in dem ein anonymes Javascript-Object im JSON-Format eingebettet ist.</p>
<p><strong>Einbindung</strong></p>

<div class="wp_codebox"><table><tr id="p37549"><td class="code" id="p375code49"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript-params-3.js&quot;</span> data<span style="color: #339933;">-</span>params<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;{id:3, language:'fr'}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Script</strong></p>

<div class="wp_codebox"><table><tr id="p37550"><td class="code" id="p375code50"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getParams3<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> scripts <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'('</span> <span style="color: #339933;">+</span> scripts<span style="color: #009900;">&#91;</span>scripts.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data-params'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">')'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Aufruf und Ausgabe</strong></p>

<div class="wp_codebox"><table><tr id="p37551"><td class="code" id="p375code51"><pre class="javascript" style="font-family:monospace;">console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>getParams3<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p37552"><td class="code" id="p375code52"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
 id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;3&quot;</span><span style="color: #339933;">,</span>
 language<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;fr&quot;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>#4</h2>
<p>In den eigenen Script-Tag wird ein anonymes Javascript-Object im JSON-Format eingebettet.</p>
<p><strong>Einbindung</strong></p>

<div class="wp_codebox"><table><tr id="p37553"><td class="code" id="p375code53"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript-params-4.js&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> language<span style="color: #339933;">:</span> <span style="color: #3366CC;">'it'</span><span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Script</strong></p>

<div class="wp_codebox"><table><tr id="p37554"><td class="code" id="p375code54"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getParams4<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> scripts <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> text <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// webkit kennt innerText nicht</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerText</span> <span style="color: #339933;">!=</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		text <span style="color: #339933;">=</span> scripts<span style="color: #009900;">&#91;</span>scripts.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerText</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		text <span style="color: #339933;">=</span> scripts<span style="color: #009900;">&#91;</span>scripts.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">textContent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'('</span> <span style="color: #339933;">+</span> text <span style="color: #339933;">+</span> <span style="color: #3366CC;">')'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Aufruf und Ausgabe</strong></p>

<div class="wp_codebox"><table><tr id="p37555"><td class="code" id="p375code55"><pre class="javascript" style="font-family:monospace;">console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>getParams4<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p37556"><td class="code" id="p375code56"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
 id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4&quot;</span><span style="color: #339933;">,</span>
 language<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;it&quot;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>#5</h2>
<p>In einem extra Script-Tag werden globale Javascript-Variablen definiert, die im Script ausgelesen werden k&#246;nnen.</p>
<p><strong>Einbindung</strong></p>

<div class="wp_codebox"><table><tr id="p37557"><td class="code" id="p375code57"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
param_id <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
param_language <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;es&quot;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;javascript-params-5.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>Script</strong></p>

<div class="wp_codebox"><table><tr id="p37558"><td class="code" id="p375code58"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getParams5<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span> window.<span style="color: #660066;">param_id</span><span style="color: #339933;">,</span> language<span style="color: #339933;">:</span> window.<span style="color: #660066;">param_language</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Aufruf und Ausgabe</strong></p>

<div class="wp_codebox"><table><tr id="p37559"><td class="code" id="p375code59"><pre class="javascript" style="font-family:monospace;">console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>getParams5<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p37560"><td class="code" id="p375code60"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
 id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;5&quot;</span><span style="color: #339933;">,</span>
 language<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;es&quot;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<ul>
<li><a href="http://www.naden.de/blog/wp-content/download/javascript-paramater-demo.html">Demo</a></li>
</ul>
<p></script></pre>
<p></tokens></pre>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=375&amp;md5=22265dd2d3cae0aa7a626b91cbf00d88" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/wege-um-paramater-an-javascriptdateien-zu-uebergeben/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Domain Ajax Proxy</title>
		<link>http://www.naden.de/blog/cross-domain-ajax-proxy</link>
		<comments>http://www.naden.de/blog/cross-domain-ajax-proxy#comments</comments>
		<pubDate>Fri, 26 Aug 2011 11:18:54 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=353</guid>
		<description><![CDATA[Durch die sicherheitsbedingte &#8220;same domain policy&#8221; kann man per Ajax nur Daten von der eigenen Domain laden. Das st&#246;rt oft, l&#228;sst sich aber mit einem 10-zeiligen serverseitigen PHP-Proxy leicht l&#246;sen. Wenn man diesen zus&#228;tzlichen Traffic aber auf die Clientseite verlagern m&#246;chte, muss man auf Drittdiente ausweichen. Dazu gibt es einige kostenlose Dienste, die aber mehr [...]]]></description>
			<content:encoded><![CDATA[<p>Durch die sicherheitsbedingte &#8220;same domain policy&#8221; kann man per Ajax nur Daten von der eigenen Domain laden. Das st&#246;rt oft, l&#228;sst sich aber mit einem 10-zeiligen serverseitigen PHP-Proxy leicht l&#246;sen.<span id="more-353"></span> Wenn man diesen zus&#228;tzlichen Traffic aber auf die Clientseite verlagern m&#246;chte, muss man auf Drittdiente ausweichen.</p>
<p>Dazu gibt es einige kostenlose Dienste, die aber mehr offline als online sind. Einzig Google biete &#252;ber ihre Feed-Api eine L&#246;sung, auf deren Verf&#252;gbarkeit man sich verlassen kann. Google verlangt allerdings einen API-Key, den man erst nach einer Registrierung bekommt. Zudem l&#228;d Google einen ganzen Shitload an Javascript-Dateien nach, die man eigentlich gar nicht haben m&#246;chte.</p>
<p>Eine gute Alternative ist die von Yahoo! angebotene <a href="http://developer.yahoo.com/yql/console/" rel="nofollow" target="_blank">Yahoo! Query Language</a> zu nutzen, die den Zugriff auf externe Datenfeeds in zahllosen Formaten erlaubt und ihre eigene Syntax an SQL anlehnt.</p>
<p>Um z.B. den JSON-Feed einer Facebook-Seite anzuzeigen reichen wenige Zeilen jQuery:</p>

<div class="wp_codebox"><table><tr id="p35362"><td class="code" id="p353code62"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> query <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;SELECT * FROM json WHERE url = 'http://www.facebook.com/feeds/page.php?id=106760056048493&amp;format=json'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://query.yahooapis.com/v1/public/yql?q='</span> <span style="color: #339933;">+</span> encodeURIComponent<span style="color: #009900;">&#40;</span>query.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;format=json&amp;callback=?'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
$.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>result.<span style="color: #660066;">query</span>.<span style="color: #660066;">results</span>.<span style="color: #660066;">json</span>.<span style="color: #660066;">entries</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>k<span style="color: #339933;">,</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>      
&nbsp;
<span style="color: #006600; font-style: italic;">// ...</span>
&nbsp;
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Die Daten werden dabei &#252;ber <em>http://query.yahooapis.com/v1/public/yql?q=</em> getunnelt.</p>
<p>Eine komplett funktionierendes Demo gibt es hier: <a href="http://www.naden.de/blog/wp-content/download/json-ajax-proxy-demo.html" rel="nofollow" target="_blank">Cross Domain Ajax Proxy Demo</a></p>
<p>YQL kann sehr viel mehr Datenquellen anzapfen, ein genaueres Angucken lohnt!</p>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=353&amp;md5=3b87ed6ae4f413292d4965ae23c9e600" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/cross-domain-ajax-proxy/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript lernen</title>
		<link>http://www.naden.de/blog/javascript-lernen</link>
		<comments>http://www.naden.de/blog/javascript-lernen#comments</comments>
		<pubDate>Tue, 23 Aug 2011 14:06:52 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Linkperlen]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[lernen]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=349</guid>
		<description><![CDATA[Ein nettes, interaktives Lernprogramm f&#252;r Javascript-Neulinge haben die Jungs und M&#228;dels von Codecademy.com ins Netz gestellt. Die Webseite wendet sich wirklich nur an absolute Programmierneulinge, die noch keine Ahnung von Variablen haben und denken, dass ein Array die neueste Pastasorte ist. In acht, aufeinander aufbauenden Tutorials werden Kontrollstrukturen und Variablentypen gut erkl&#228;rt. Abgesehen von alert [...]]]></description>
			<content:encoded><![CDATA[<p>Ein nettes, interaktives Lernprogramm f&#252;r Javascript-Neulinge haben die Jungs und M&#228;dels von Codecademy.com ins Netz gestellt.<span id="more-349"></span></p>
<p>Die Webseite wendet sich wirklich nur an absolute Programmierneulinge, die noch keine Ahnung von Variablen haben und denken, dass ein Array die neueste Pastasorte ist.</p>
<p>In acht, aufeinander aufbauenden Tutorials werden Kontrollstrukturen und Variablentypen gut erkl&#228;rt. Abgesehen von alert und confirm ist es eine allgemeine Einf&#252;hrung in eine Programmiersprache.</p>
<p>Das ist auch der einzige Kritikpunkt, da eine Interaktion mit dem DOM nicht stattfindet. Ansonsten eine gelungene Webseite f&#252;r Lernwillige, die etwas den Spiele-Karma-Character von Stackoverflow.com aufgreift.</p>
<p><a href="http://www.codecademy.com/programming-intro" rel="nofollow" target="_blank">zur Webseite</a></p>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=349&amp;md5=693fad6024d901ec5871dfbd133b350d" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/javascript-lernen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.1 Update mit Problemen</title>
		<link>http://www.naden.de/blog/wordpress-update-mit-problemen</link>
		<comments>http://www.naden.de/blog/wordpress-update-mit-problemen#comments</comments>
		<pubDate>Mon, 22 Aug 2011 10:03:35 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[fehler]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=346</guid>
		<description><![CDATA[Wer WordPress auf die Version 3.1 oder neuer upgedatet hat, der sollte sich mal seine Kategorie- und Tag-Seiten angucken. Die liefern n&#228;mlich alle stillschweigend den Fehler 404 &#8211; Not funny found! Das Update-Problem besteht schon seit Januar 2011 und von Seiten der WordPress-Entwickler gibt es keinen Fix. Was im Netz alles als L&#246;sung kursiert schwankt [...]]]></description>
			<content:encoded><![CDATA[<p>Wer WordPress auf die Version 3.1 oder neuer upgedatet hat, der sollte sich mal seine Kategorie- und Tag-Seiten angucken. Die liefern n&#228;mlich alle stillschweigend den Fehler 404 &#8211; Not <s>funny</s>  found!<span id="more-346"></span></p>
<p>Das Update-Problem besteht schon seit Januar 2011 und von Seiten der WordPress-Entwickler gibt es keinen Fix. Was im Netz alles als L&#246;sung kursiert schwankt zwischen kurios und sch&#228;dlich. Ich habe alles an L&#246;sungsversuchen inklusive einem sogenannten &#8220;HotfiX&#8221; ausprobiert, der dann per 302-Redirect auf einem Link wie /category/drupal ?cat=ID gemacht hat. Nichts davon funktioniert.</p>
<p>Die einzige funktionierende L&#246;sung ist ein Downgrade auf WordPress v3.0.5 und das geht so:</p>
<ol>
<li>Download von WordPress 3.05</li>
<li>Alle Dateien au&#223;er dem Verzeichnis wp-content und der Datei wp-config.php hochladen und vorhandene Dateien &#252;berschreiben.</li>
<li>/wp-admin aufrufen und dem Datenbankupdate zustimmen.</li>
</ol>
<p>Fertig. F&#252;r mich ein weiterer Grund, endlich die Migration auf Drupal voranzutreiben. Ein WordPress-Import Modul gibt es bereits.</p>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=346&amp;md5=e3b0583eb42f4ae6d8c51f3622a25020" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/wordpress-update-mit-problemen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql Substring Count</title>
		<link>http://www.naden.de/blog/mysql-substring-count</link>
		<comments>http://www.naden.de/blog/mysql-substring-count#comments</comments>
		<pubDate>Mon, 20 Jun 2011 15:30:47 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=335</guid>
		<description><![CDATA[Ein n&#252;tzlichen MySql-Schnipsel, was den Befehl substr_count simuliert. SELECT &#40;LENGTH&#40;field&#41;-LENGTH&#40;REPLACE&#40;field, 'string', ''&#41;&#41;&#41;/LENGTH&#40;'string'&#41; FROM table string zu z&#228;hlender String field Datenbankfeld, in dem gesucht werden soll table Datenbaktabelle]]></description>
			<content:encoded><![CDATA[<p>Ein n&#252;tzlichen MySql-Schnipsel, was den Befehl substr_count simuliert.<span id="more-335"></span></p>

<div class="wp_codebox"><table><tr id="p33564"><td class="code" id="p335code64"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">LENGTH</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">field</span><span style="color: #FF00FF;">&#41;</span><span style="color: #CC0099;">-</span><span style="color: #000099;">LENGTH</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">REPLACE</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">field</span><span style="color: #000033;">,</span> <span style="color: #008000;">'string'</span><span style="color: #000033;">,</span> <span style="color: #008000;">''</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #CC0099;">/</span><span style="color: #000099;">LENGTH</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'string'</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #990099; font-weight: bold;">table</span></pre></td></tr></table></div>

<dl>
<dt>string</dt>
<dd>zu z&#228;hlender String</dd>
<dt>field</dt>
<dd>Datenbankfeld, in dem gesucht werden soll</dd>
<dt>table</dt>
<dd>Datenbaktabelle</dd>
</dl>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=335&amp;md5=4f9de52b182060fa575a0f79847773e0" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/mysql-substring-count/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fb_xd_fragment</title>
		<link>http://www.naden.de/blog/fb_xd_fragment</link>
		<comments>http://www.naden.de/blog/fb_xd_fragment#comments</comments>
		<pubDate>Wed, 25 May 2011 11:01:54 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[allgemeines]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=329</guid>
		<description><![CDATA[Wer einen Facebook-Like-Button via Javascript API eingebunden hat, der wird sich wundern, warum Urls, die den ?fb_xd_fragment= Paramater enthalten nur eine leere Seite liefern. So auch ich. Alarmiert von einer Bouncerate von 98%. Ich habe mich quer durch das Facebook Developer Forum, Gitbub und Stackoverlow gelesen. Das Problem ist schon seit &#252;ber einem Jahr bekannt. [...]]]></description>
			<content:encoded><![CDATA[<p>Wer einen Facebook-Like-Button via Javascript API eingebunden hat, der wird sich wundern, warum Urls, die den <em>?fb_xd_fragment=</em> Paramater enthalten nur eine leere Seite liefern. So auch ich. Alarmiert von einer Bouncerate von 98%.<span id="more-329"></span></p>
<p>Ich habe mich quer durch das Facebook Developer Forum, Gitbub und Stackoverlow gelesen. Das Problem ist schon seit &#252;ber einem Jahr bekannt. Leider funktionierten alle L&#246;sungen die irgendwo gelistet waren f&#252;r mich nicht. Egal ob channelUrl oder nicht. Besonders gef&#228;hrlich die sehr hei&#223; gestrickten L&#246;sungen in PHP.</p>
<p>Das folgende Code-Snippet l&#246;st das Problem, wenn man die M&#246;glichkeit hat, PHP zu nutzen.</p>

<div class="wp_codebox"><table><tr id="p32966"><td class="code" id="p329code66"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fb_xd_fragment_fix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fb_xd_fragment'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$tokens</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tokens</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span><span style="color: #339933;">,</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'='</span><span style="color: #339933;">,</span> <span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'fb_xd_fragment'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>    
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$target</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tokens</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$target</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'?'</span><span style="color: #339933;">.</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 301 Moved permanently.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$target</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Die Funktion <em>fb_xd_fragment_fix();</em> sollte m&#246;glichst vor allem anderen Code aufgerufen werden. Es wird nur der st&#246;rende Parameter aus der Url herausgetrennt und auf die so entstandene, saubere Url weitergeleitet.</p>
 <p><a href="http://www.naden.de/blog/?flattrss_redirect&amp;id=329&amp;md5=91e37e13d2ceddb4ee4cc17f049dbfab" title="Flattr" target="_blank"><img src="http://www.naden.de/blog/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/fb_xd_fragment/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Shortcodes f&#252;r Kommentare</title>
		<link>http://www.naden.de/blog/wordpress-shortcodes-fuer-kommentare</link>
		<comments>http://www.naden.de/blog/wordpress-shortcodes-fuer-kommentare#comments</comments>
		<pubDate>Tue, 26 Apr 2011 17:59:51 +0000</pubDate>
		<dc:creator>naden</dc:creator>
				<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[Kommentare]]></category>
		<category><![CDATA[Shortcodes]]></category>

		<guid isPermaLink="false">http://www.naden.de/blog/?p=319</guid>
		<description><![CDATA[Seit WordPress 2.5 gibt es eine sogenannte Shortcode-Api, mit der man BB-Code-artige Tags im Blogpost mit Content-Parsern verdrahten kann. Obwohl das mitunter n&#252;tzlich sein kann, haben die Machen diese bis heute nicht f&#252;r Kommentare aktiviert. Das folgende Miniplugin r&#252;stet diese Funktion nach: /* Plugin Name: CommentShortcodes Plugin URI: http://www.naden.de/blog/wordpress-shortcodes-fuer-kommentare Description: Enables all available shortcodes for [...]]]></description>
			<content:encoded><![CDATA[<p>Seit WordPress 2.5 gibt es eine sogenannte Shortcode-Api, mit der man BB-Code-artige Tags im Blogpost mit Content-Parsern verdrahten kann.<span id="more-319"></span></p>
<p>Obwohl das mitunter n&#252;tzlich sein kann, haben die Machen diese bis heute nicht f&#252;r Kommentare aktiviert.</p>
<p>Das folgende Miniplugin r&#252;stet diese Funktion nach:</p>

<div class="wp_codebox"><table><tr id="p31968"><td class="code" id="p319code68"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Plugin Name: CommentShortcodes
Plugin URI: http://www.naden.de/blog/wordpress-shortcodes-fuer-kommentare
Description: Enables all available shortcodes for use in wordpress comments. 
Version: 0.1
Author: Naden Badalgogtapeh
Author URI: http://www.naden.de
*/</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'do_shortcode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="/blog/shorturl/49" target="_blank" rel="nofollow" class="download">Download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.naden.de/blog/wordpress-shortcodes-fuer-kommentare/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

