<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Javascript on Emad Alashi</title>
    <link>https://emadashi.com/tags/javascript/</link>
    <description>Recent content in Javascript on Emad Alashi</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 15 Jun 2010 14:42:23 +0000</lastBuildDate>
    <atom:link href="https://emadashi.com/tags/javascript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Happy Life with Intuitive API in Smart Controls</title>
      <link>https://emadashi.com/2010/06/happy-life-with-intuitive-api-in-smart-controls/</link>
      <pubDate>Tue, 15 Jun 2010 14:42:23 +0000</pubDate>
      <guid>https://emadashi.com/2010/06/happy-life-with-intuitive-api-in-smart-controls/</guid>
      <description>&lt;p&gt;In this post I will show you an example of how smartly built controls and API’s can make the developers programming life extremely enjoyable, hopefully this example will urge you in giving such a smart effort when you build your own control or API.&lt;/p&gt;
&lt;p&gt;Lately I have been playing around with a very nice tree control based on jQuery called &lt;a href=&#34;http://www.jstree.com/&#34;&gt;jsTree&lt;/a&gt;. One of the nice features is that it allows populating the tree through asynchronous calls with JSON data representation. In order to achieve that, you needed to provide the data by JSON special format suitable to the tree. This format, regrettably, is open to the JSON vulnerability &lt;a href=&#34;http://haacked.com/&#34;&gt;Phil Haack&lt;/a&gt; talked about in his two posts &lt;a href=&#34;http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;http://haacked.com/archive/2009/06/25/json-hijacking.aspx&#34;&gt;here&lt;/a&gt;.&lt;br&gt;
So to avoid this vulnerability I had to change this default data format of the tree, at least until the very end of the data flow just before the tree populates the data, only then I can change it back to the default format, like the following:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Clear jQuery Droppable List</title>
      <link>https://emadashi.com/2009/05/clear-jquery-droppable-list/</link>
      <pubDate>Tue, 19 May 2009 18:25:19 +0000</pubDate>
      <guid>https://emadashi.com/2009/05/clear-jquery-droppable-list/</guid>
      <description>&lt;p&gt;The other day at work I finally had the chance to get my hands on code (see &lt;a title=&#34;Technical Team Leader...Who Is Not&#34; href=&#34;http://www.emadashi.com/index.php/2009/04/technical-team-leaderwho-is-not/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt; why I&amp;rsquo;m so anxious about it 😛 ).&lt;/p&gt;
&lt;p&gt;We were using the jQuery&amp;rsquo;s Drag and Drop feature, where the droppable areas (DIV&amp;rsquo;s) are marked as droppable and registered for the events like the following:&lt;/p&gt;
&lt;div style=&#34;font-family: Courier New; font-size: 10pt; color: black; background: white;&#34;&gt;
  &lt;p style=&#34;margin: 0px;&#34;&gt;
    &lt;span style=&#34;color: #2b91af;&#34;&gt;  126&lt;/span&gt; &lt;span style=&#34;color: blue;&#34;&gt;function&lt;/span&gt; RegisterDroppable(DomID) {
  &lt;/p&gt;
  &lt;p style=&#34;margin: 0px;&#34;&gt;
    &lt;span style=&#34;color: #2b91af;&#34;&gt;  &lt;/span&gt;&lt;span style=&#34;color: #2b91af;&#34;&gt;128&lt;/span&gt;        $(&lt;span style=&#34;color: #a31515;&#34;&gt;‘#&#39;&lt;/span&gt; + DomID).droppable({
  &lt;/p&gt;</description>
    </item>
    <item>
      <title>JavaScript Date Object and Code Convention</title>
      <link>https://emadashi.com/2009/02/javascript-datetime-and-code-convention/</link>
      <pubDate>Thu, 26 Feb 2009 22:01:17 +0000</pubDate>
      <guid>https://emadashi.com/2009/02/javascript-datetime-and-code-convention/</guid>
      <description>&lt;p&gt;“is Code Convention important?”, I couldn&amp;rsquo;t find better time to answer this with a big, decorated, shiny, flashing “YES” more than now!&lt;/p&gt;
&lt;p&gt;I was doing some coding with JavaScript in which I needed to create a Date object and add to it 30 days, simple job! So I did the following:&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1256\uc1 \deff0{\fonttbl{\f0\fnil\fcharset178\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red242\green235\blue227;\red0\green0\blue0;\red0\green128\blue0;}??\fs20 \cf1\cb2\highlight2 var\cf0  x = \cf1 new\cf0  Date();\par ??    x.setFullYear(2009, 3, 12);\cf4 //Create date 12th of March, 2009\par ??\cf0     x.setDate(x.getDate() + 30);\par ??    document.writeln(x);}
--&gt;
&lt;div style=&#34;font-size: 10pt; background: #f2ebe3; color: black; font-family: courier new&#34;&gt;
  &lt;p style=&#34;margin: 0px&#34;&gt;
    &lt;span style=&#34;color: blue&#34;&gt;    var&lt;/span&gt; x = &lt;span style=&#34;color: blue&#34;&gt;new&lt;/span&gt; Date();
  &lt;/p&gt;</description>
    </item>
  </channel>
</rss>
