<?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>GeneralThreat.com &#187; javascript</title>
	<atom:link href="http://www.generalthreat.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.generalthreat.com</link>
	<description>Dangerously different projects and code</description>
	<lastBuildDate>Sun, 19 Jan 2014 20:00:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Highlighting Features with WordPress Admin Pointers &#8211; A Quick Guide for Plugin Authors</title>
		<link>http://www.generalthreat.com/2012/01/highlighting-features-with-wordpress-admin-pointers/</link>
		<comments>http://www.generalthreat.com/2012/01/highlighting-features-with-wordpress-admin-pointers/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 05:24:12 +0000</pubDate>
		<dc:creator><![CDATA[David]]></dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.generalthreat.com/?p=80</guid>
		<description><![CDATA[Here&#8217;s a quick intro to admin pointers for plugins to WordPress 3.3+, based on some work I recently put into making the help system in Networks more intuitive: Step One &#8212; Add the admin&#46;&#46;&#46;]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a quick intro to admin pointers for plugins to WordPress 3.3+, based on some work I recently put into making the help system in <a href="http://wordpress.org/extend/plugins/networks-for-wordpress/" title="Networks for WordPress">Networks</a> more intuitive:</p>
<h3>Step One &mdash; Add the admin pointer style and script to your page</h3>
<p>This is a fairly standard chain of <code>admin_menu</code> action functions, which should look familiar if you&#8217;re using a class for your plugin. If they don&#8217;t, some <a href="http://codex.wordpress.org/Administration_Menus">light background reading</a> may be in order.</p>
<p>You&#8217;ll need to create a script file for your admin page to follow this guide, although you could also dump the required JavaScript into the admin page itself.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> admin_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">admin_page</span> <span style="color: #339933;">=</span> add_menu_page<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'manage_options'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my-page'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">FUNCTION</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	wp_register_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_admin_js'</span><span style="color: #339933;">,</span> plugins_url<span style="color: #009900;">&#40;</span>SCRIPT <span style="color: #990000;">FILE</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_scripts-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">admin_page</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_admin_scripts'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_print_styles-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">admin_page</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_admin_styles'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_admin_styles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pointer'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_admin_scripts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp-pointer'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_admin_js'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	wp_localize_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_admin_js'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'strings'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">localize_admin_js</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: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In addition to enqueueing the admin pointer CSS and script files, we&#8217;ve set up a localization function.  Beside being good coding practice, generating the strings for the admin pointer here, instead of in the script file, is going to allow us to use a nice shortcut.</p>
<h3>Step Two &mdash; Build the pointer text and check for dismissal</h3>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> localize_admin_js<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$pointer_text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;h3&gt;'</span> <span style="color: #339933;">.</span> esc_js<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'My Pointer Header'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/h3&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$pointer_text</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;p&gt;'</span> <span style="color: #339933;">.</span> esc_js<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'This is the text of my pointer.'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Get the list of dismissed pointers for the user</span>
	<span style="color: #000088;">$dismissed</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: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> get_user_meta<span style="color: #009900;">&#40;</span> get_current_user_id<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dismissed_wp_pointers'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Check whether our pointer has been dismissed</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span> POINTER HANDLE<span style="color: #339933;">,</span> <span style="color: #000088;">$dismissed</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$pointer_text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'pointerText'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$pointer_text</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In testing, setting the pointer text to <code>''</code> was sufficient to hide the pointer from the screen. However, we can add another layer of protection in the script, which you&#8217;ll see below.</p>
<h3>Step Three &#8211; Script the pointer object gracefully</h3>
<p>If you don&#8217;t already have an admin script file, you&#8217;ll need to create one for this step.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">/** Check that pointer support exists AND that text is not empty */</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pointer</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">&amp;&amp;</span> strings.<span style="color: #660066;">pointerText</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#OBJECT_YOU_WANT_TO_POINT_AT'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pointer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			content    <span style="color: #339933;">:</span> strings.<span style="color: #660066;">pointerText</span><span style="color: #339933;">,</span>
			close  <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span> ajaxurl<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
					pointer<span style="color: #339933;">:</span> POINTER HANDLE<span style="color: #339933;">,</span>
					action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'dismiss-wp-pointer'</span>
				<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pointer</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'open'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Note the <code>close</code> property of the pointer object: calling this action hooks us right into WordPress&#8217;s pointer management, so that when the user clicks the <code>Dismiss</code> button, our pointer is added to his list of dismissed pointers.  The <code>wp-pointer</code> stylesheet takes care of making the pointer look right so long as there&#8217;s an <code>&lt;h3&gt;</code> and one or more paragraphs, and the close button is added and wired up automatically.</p>
<p>Hope this helps anyone wishing to use this neat, new feature!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.generalthreat.com/2012/01/highlighting-features-with-wordpress-admin-pointers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>bbPress Topics for Posts</title>
		<link>http://www.generalthreat.com/projects/bbpress-post-topics/</link>
		<comments>http://www.generalthreat.com/projects/bbpress-post-topics/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 19:33:00 +0000</pubDate>
		<dc:creator><![CDATA[David]]></dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[bbpress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.generalthreat.com/?page_id=55</guid>
		<description><![CDATA[Automate use of an integrated bbPress forum install for handling comments on your WordPress posts and pages. About About This plugin adds an option to the Discussion meta box allowing an author to create&#46;&#46;&#46;]]></description>
				<content:encoded><![CDATA[<p>Automate use of an integrated bbPress forum install for handling comments on your WordPress posts and pages.</p>
<p><div class='postTabs_divs postTabs_curr_div' id='postTabs_0_55'>
<span class='postTabs_titles'><b>About</b></span></p>
<h3>About</h3>
<p>This plugin adds an option to the Discussion meta box allowing an author to create a new bbPress forum topic, or select an existing one, to attach to his post or page.  A site admin can also set a default forum for all new posts and pages.</p>
<p>Now authors can select from a wealth of display options, from the full topic to a simple link, and the display system has hooks for extension by developers or integrators.  The topic itself is built according to a rich template system to accommodate any site.</p>
<p></div>

<div class='postTabs_divs' id='postTabs_1_55'>
<span class='postTabs_titles'><b>Filters</b></span></p>
<h3>Some of the filters you can use to customize bbPress Topics for Posts to fit your needs:</h3>
<dl>
<dt><code>bbppt_eligible_post_status ( array( 'publish' ) )</code></dt>
<dd>Return an array of post statuses that you want to trigger new topic creation (when selected). By default, this is only publish.</dd>
<dt><code>bbppt_eligible_post_types ( array( 'post', 'page' ) )</code></dt>
<dd>Return an array of post types that you want to be able to associate with topics. By default, posts and pages are included.</dd>
<dt><code>bbppt_topic_content ( $topic_content, $post_ID )</code></dt>
<dd>Filter the content of the topic to be created. The first parameter is the topic content generated according to your template.  The second is the ID of the current post or page.</dd>
</dl>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.generalthreat.com/projects/bbpress-post-topics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BuddyPress Group Organizer</title>
		<link>http://www.generalthreat.com/projects/buddypress-group-organizer/</link>
		<comments>http://www.generalthreat.com/projects/buddypress-group-organizer/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 02:05:43 +0000</pubDate>
		<dc:creator><![CDATA[David]]></dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.generalthreat.com/?page_id=50</guid>
		<description><![CDATA[About Easily organize your BuddyPress groups with drag and drop simplicity. Also known as the BP Group Organizer, this plugin adds a page to your BuddyPress admin menu letting you easily drag and drop&#46;&#46;&#46;]]></description>
				<content:encoded><![CDATA[<p><div class='postTabs_divs postTabs_curr_div' id='postTabs_0_50'>
<span class='postTabs_titles'><b>About</b></span></p>
<p>Easily organize your <a href="http://buddypress.org">BuddyPress</a> groups with drag and drop simplicity. </p>
<p>Also known as the BP Group Organizer, this plugin adds a page to your BuddyPress admin menu letting you easily drag and drop your groups around, or create new groups just by filling out a single form.  No more paging through the group creation screen over and over again when setting up a new BuddyPress site!</p>
<p></div>

<div class='postTabs_divs' id='postTabs_1_50'>
<span class='postTabs_titles'><b>API for Developers</b></span></p>
<h3>Actions for extending the Organizer</h3>
<h5>bp_group_organizer_display_new_group_options</h5>
<p>Hook this action to display custom options when creating new groups in the Organizer.</p>
<h5>bp_group_organizer_display_group_options</h5>
<p>Hook this action to display custom options when creating new groups in the Organizer.</p>
<p>Parameters:</p>
<ul>
<li><code>$group</code> &#8211; object of group being edited in the Organizer</li>
</ul>
<h5>bp_group_organizer_save_new_group_options</h5>
<p>Hook this action to save custom options when users create new groups in the Organizer.</p>
<p>Parameters:</p>
<ul>
<li><code>$group_id</code> &#8211; ID of newly-created group</li>
</ul>
<h5>bp_group_organizer_save_group_options</h5>
<p>Hook this action to save custom options when users save changes in the Organizer.</p>
<p>Parameters:</p>
<ul>
<li><code>$group</code> &#8211; array of POSTed group options</li>
<li><code>$group_reference</code> &#8211; BP_Groups_Group object of the group being saved</li>
</ul>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.generalthreat.com/projects/buddypress-group-organizer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lists Improved for DokuWiki</title>
		<link>http://www.generalthreat.com/projects/lists-improved-for-dokuwiki/</link>
		<comments>http://www.generalthreat.com/projects/lists-improved-for-dokuwiki/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 23:41:13 +0000</pubDate>
		<dc:creator><![CDATA[David]]></dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[dokuwiki]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.generalthreat.com/?page_id=12</guid>
		<description><![CDATA[Background DokuWiki is a fantastic tool for collaborative documentation, but the included editor is a little rough around the edges in list management. WYSIWYG editors not only go against the spirit of the wiki,&#46;&#46;&#46;]]></description>
				<content:encoded><![CDATA[<h3>Background</h3>
<p><a href="http://www.dokuwiki.org">DokuWiki</a> is a fantastic tool for collaborative documentation, but the included editor is a little rough around the edges in list management. <abbr title="What You See is What You Get">WYSIWYG</abbr> editors not only go against the spirit of the wiki, but also paint with broad strokes, eliminating the fine detail and tweaks that are a developer&#8217;s joy.</p>
<p>Lists Improved enhances list management by changing some key behaviors and creating intuitive actions. For the time being, it does <strong>NOT</strong> work in Internet Explorer.</p>
<ul>
<li>Press <strong>Enter</strong> on a list item to create another of the same type and level.</li>
<li>Use <strong>Tab</strong> and <strong>Shift + Tab</strong> to indent and outdent list items.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.generalthreat.com/projects/lists-improved-for-dokuwiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>email me</title>
		<link>http://www.generalthreat.com/projects/email-me/</link>
		<comments>http://www.generalthreat.com/projects/email-me/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 05:05:48 +0000</pubDate>
		<dc:creator><![CDATA[David]]></dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.generalthreat.com/?page_id=9</guid>
		<description><![CDATA[A rudimentary copy-and-paste bookmarklet for iPhone]]></description>
				<content:encoded><![CDATA[<p><div class='postTabs_divs postTabs_curr_div' id='postTabs_0_9'>
<span class='postTabs_titles'><b>About</b></span></p>
<h3>What is it?</h3>
<p>A bookmarklet for the iPhone that delivers rudimentary copy and paste functionality. Data is stored in <a href="http://ajaxian.com/archives/whats-in-a-windowname">window.name</a>, so the usual security caveats apply.</p>
<p>This is primarily a proof of concept for working with <a href="http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/">iPhone-specific event handlers</a>, and is presented with that goal in mind. A few liberties have been taken with JavaScript syntax since there is a single platform in play and every character counts.</p>
<p>The necessary style sheet is included via a data URI. This turned out to be a nice way to avoid any server-side dependencies.</p>
<h3>How is it used?</h3>
<p>Hold down with one finger on the screen to pop up the context menu, which will vary depending on the status of the window.name variable. An additional option is exposed if you hold down over a paragraph (must be a real paragraph with a &lt;P&gt; tag). See line 55 of the source.</p>
<p></div>

<div class='postTabs_divs' id='postTabs_1_9'>
<span class='postTabs_titles'><b>Source</b></span></p>
<p>Here is an uncondensed version for your perusal.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span>
mD<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
d<span style="color: #339933;">=</span>document<span style="color: #339933;">;</span>
cT<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  clearTimeout<span style="color: #009900;">&#40;</span>mD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">;</span>
data<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>
  url<span style="color: #339933;">:</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;">&#125;</span>
<span style="color: #339933;">;</span>
d.<span style="color: #660066;">ontouchstart</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  t<span style="color: #339933;">=</span>ev.<span style="color: #660066;">touches</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">target</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">id</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">'contextMenu'</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">nodeName</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">'A'</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span>t.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">nodeName</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">'A'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    rCM<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mD<span style="color: #339933;">=</span>setTimeout<span style="color: #009900;">&#40;</span>sCM<span style="color: #339933;">,</span><span style="color: #CC0000;">500</span><span style="color: #339933;">,</span>ev<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    d.<span style="color: #660066;">ontouchmove</span><span style="color: #339933;">=</span>cT<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">;</span>
d.<span style="color: #660066;">ontouchend</span><span style="color: #339933;">=</span>cT<span style="color: #339933;">;</span>
rCM<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><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;">if</span><span style="color: #009900;">&#40;</span>cM<span style="color: #339933;">=</span>d.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'contextMenu'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    cM.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>cM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">;</span>
rP<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ev<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  ps<span style="color: #339933;">=</span>d.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'textarea'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i
<span style="color: #CC0000;">150</span><span style="color: #339933;">?</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">pageY</span><span style="color: #339933;">-</span><span style="color: #CC0000;">150</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span><span style="color: #339933;">;</span>
  cM.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">pageX</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #CC0000;">150</span><span style="color: #339933;">?</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">pageX</span><span style="color: #339933;">-</span><span style="color: #CC0000;">150</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span><span style="color: #339933;">;</span>
  cM.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'none'</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">name</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    html<span style="color: #339933;">=</span>unescape<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'%3Cli%3E%3Ca href=%22#paste%22 onclick=%22rP();rCM();return false;%22%3EP%3C/a%3E%3C/li%3E%3Cli%3E%3Ca href=%22mailto:friend?subject=Web Link&amp;amp;body='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>window.<span style="color: #660066;">name</span><span style="color: #339933;">+</span>unescape<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'%22%3EE%3C/a%3E%3C/li%3E%3Cli%3E%3Ca href=%22#clear%22 onclick=%22window.name=<span style="color: #000099; font-weight: bold;">\'</span><span style="color: #000099; font-weight: bold;">\'</span>;rCM();return false;%22%3EC%3C/a%3E%3C/li%3E'</span><span style="color: #009900;">&#41;</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>
    html<span style="color: #339933;">=</span>unescape<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'%3Cli%3E%3Ca onclick=%22window.name=data.url;%22%3EURI%3C/a%3E%3C/li%3E'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    data.<span style="color: #660066;">url</span><span style="color: #339933;">=</span>escape<span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tt.<span style="color: #660066;">nodeName</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'#text'</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span>tt.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">nodeName</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'P'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      html<span style="color: #339933;">+=</span>unescape<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'%3Cli%3E%3Ca onclick=%22window.name=data.text;%22%3E¶%3C/a%3E%3C/li%3E'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      data.<span style="color: #660066;">text</span><span style="color: #339933;">=</span>escape<span style="color: #009900;">&#40;</span>tt.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">innerHTML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">' from: '</span><span style="color: #339933;">+</span>location.<span style="color: #660066;">href</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  cM.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span>html<span style="color: #339933;">;</span>
  d.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>cM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  cM.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'block'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">;</span>
init<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  css<span style="color: #339933;">=</span>d.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  css.<span style="color: #660066;">type</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'text/css'</span><span style="color: #339933;">;</span>
  css.<span style="color: #660066;">rel</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'stylesheet'</span><span style="color: #339933;">;</span>
  css.<span style="color: #660066;">href</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'data:text/css;base64,I2NvbnRleHRNZW51IHtsaXN0LXN0eWxlLXR5cGU6IG5vbmU7cG9zaXRpb246IGFic29sdXRlO29wYWNpdHk6IDAuODttYXJnaW46IDA7cGFkZGluZzogMTBweDtiYWNrZ3JvdW5kLWNvbG9yOiAjNmY4NmEzO3dpZHRoOiAyNSU7aGVpZ2h0OiAyNSU7Zm9udC1mYW1pbHk6IFwiTHVjaWRhIEdyYW5kZVwiLHNhbnMtc2VyaWY7fQ0KI2NvbnRleHRNZW51IGxpIHtmbG9hdDogbGVmdDt9DQojY29udGV4dE1lbnUgYSB7ZGlzcGxheTogYmxvY2s7dGV4dC1hbGlnbjogY2VudGVyO3RleHQtZGVjb3JhdGlvbjogbm9uZTtmb250LXNpemU6IDNlbTttaW4td2lkdGg6IDFlbTtwYWRkaW5nOiAxMHB4O2JvcmRlcjogMXB4IHNvbGlkICNjY2M7Y29sb3I6ICNmZmY7fQ0KI2NvbnRleHRNZW51IGE6aG92ZXIge2JvcmRlci1jb2xvcjogI2ZmZjt9'</span><span style="color: #339933;">;</span>
  d.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</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;">appendChild</span><span style="color: #009900;">&#40;</span>css<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">;</span>
init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p></div>

</p>
]]></content:encoded>
			<wfw:commentRss>http://www.generalthreat.com/projects/email-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scansion</title>
		<link>http://www.generalthreat.com/projects/scansion/</link>
		<comments>http://www.generalthreat.com/projects/scansion/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 05:15:01 +0000</pubDate>
		<dc:creator><![CDATA[David]]></dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[ahah]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[poetry]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.generalthreat.com/?page_id=5</guid>
		<description><![CDATA[Interactive poetry analysis ]]></description>
				<content:encoded><![CDATA[<h3>What:</h3>
<p>A way to explore poems visually. Apply and remove stress from syllables and see the effect on meter immediately. Also, alter syllabic construction of words with ease. Great for working with poems from different time periods.</p>
<h3>Features:</h3>
<ul>
<li>Javascript interface for quick modifications with no interruptions</li>
<li>Automatic syllable detection enhanced by memory of previous modifications</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.generalthreat.com/projects/scansion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

 Served from: www.generalthreat.com @ 2026-07-27 12:46:06 by W3 Total Cache -->