<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: hidden code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 07 Sep 2008 08:59:48 GMT</pubDate>
    <description>DZone Snippets: hidden code</description>
    <item>
      <title>Toggle hidden files in Mac OS X Finder</title>
      <link>http://snippets.dzone.com/posts/show/5855</link>
      <description>Works in Leopard, should work in all versions of OS X.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;if [ `defaults read com.apple.finder AppleShowAllFiles` == 1 ]&lt;br /&gt;then &lt;br /&gt;  echo "Hiding hidden files."&lt;br /&gt;  defaults write com.apple.finder AppleShowAllFiles -bool false&lt;br /&gt;else &lt;br /&gt;  echo "Showing hidden files."&lt;br /&gt;  defaults write com.apple.finder AppleShowAllFiles -bool true&lt;br /&gt;fi   &lt;br /&gt;     &lt;br /&gt;KillAll Finder&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 31 Jul 2008 02:00:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5855</guid>
      <author>Aupajo (Pete)</author>
    </item>
    <item>
      <title>JavaScript Function checks for DOM Element visibility</title>
      <link>http://snippets.dzone.com/posts/show/5757</link>
      <description>Determines if a given element is visible, by checking a variety of things. Will work for CSS or inline style declarations of visible:hidden or display: none. Will check if it's inside of an invisible element, as well.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function isVisible(obj)&lt;br /&gt;{&lt;br /&gt;    if (obj == document) return true&lt;br /&gt;    &lt;br /&gt;    if (!obj) return false&lt;br /&gt;    if (!obj.parentNode) return false&lt;br /&gt;    if (obj.style) {&lt;br /&gt;        if (obj.style.display == 'none') return false&lt;br /&gt;        if (obj.style.visibility == 'hidden') return false&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    //Try the computed style in a standard way&lt;br /&gt;    if (window.getComputedStyle) {&lt;br /&gt;        var style = window.getComputedStyle(obj, "")&lt;br /&gt;        if (style.display == 'none') return false&lt;br /&gt;        if (style.visibility == 'hidden') return false&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    //Or get the computed style using IE's silly proprietary way&lt;br /&gt;    var style = obj.currentStyle&lt;br /&gt;    if (style) {&lt;br /&gt;        if (style['display'] == 'none') return false&lt;br /&gt;        if (style['visibility'] == 'hidden') return false&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    return isVisible(obj.parentNode)&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 10 Jul 2008 17:48:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5757</guid>
      <author>TALlama (Seth A. Roby)</author>
    </item>
    <item>
      <title>'Delete a Twitter entry' dissected</title>
      <link>http://snippets.dzone.com/posts/show/5145</link>
      <description>The following code was copied from my Twitter home page, it shows how to delete a twitter entry on the server.&lt;br /&gt;&lt;br /&gt;raw HTML code with embedded JavaScript code.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="/status/destroy/719423092" onclick="if (confirm('Sure you want to delete this update? There is NO undo!')) &lt;br /&gt;{var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = &lt;br /&gt;'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); &lt;br /&gt;m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);var s = &lt;br /&gt;document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); &lt;br /&gt;s.setAttribute('value', 'd0057265c3784d2a6dc6cdb2c26083f638152151'); f.appendChild(s);f.submit(); };return false;" &lt;br /&gt;title="Delete this update?"&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;same code as above but with comments.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;a href="/status/destroy/719423092" onclick="&lt;br /&gt;&lt;br /&gt;                     // if the user clicks the 'OK' button the confirm function will return true&lt;br /&gt;if (confirm('Sure you want to delete this update? There is NO undo!')) { &lt;br /&gt;&lt;br /&gt;  // -- dhtml: creating html elements on-the-fly -------------------------------&lt;br /&gt;  var f = document.createElement('form'); // create the dhtml 'form' (&lt;form/&gt;) element&lt;br /&gt;  f.style.display = 'none';               // hide the form&lt;br /&gt;  this.parentNode.appendChild(f);         // append the form element to the parent of the current node (&lt;a/&gt;)&lt;br /&gt;  f.method = 'POST';                      // add the method to the form&lt;br /&gt;  f.action = this.href;                   // add the action using the href of the current node (&lt;a/&gt;)&lt;br /&gt;    &lt;br /&gt;  var m = document.createElement('input');   // create the input (&lt;input/&gt;) 'element' &lt;br /&gt;  m.setAttribute('type', 'hidden');          // set the input type to 'hidden'&lt;br /&gt;  m.setAttribute('name', '_method');         // set the input name to '_method'&lt;br /&gt;  m.setAttribute('value', 'delete');         // set the input value to 'delete'&lt;br /&gt;  f.appendChild(m);                          // append the input element to the form element&lt;br /&gt;  &lt;br /&gt;  var s = document.createElement('input');   // create another input element&lt;br /&gt;  s.setAttribute('type', 'hidden');          // set the type to 'hidden'&lt;br /&gt;  s.setAttribute('name', 'authenticity_token'); // set the name to 'authenticity_token'&lt;br /&gt;  &lt;br /&gt;                                     // set the input element's value using a unique id.&lt;br /&gt;  s.setAttribute('value', 'd0057265c3784d2a6dc6cdb2c26083f638152151'); &lt;br /&gt;  &lt;br /&gt;  f.appendChild(s);                  // apend the input element to the form element&lt;br /&gt;  // -- end of dhtml: creating html elements on-the-fly -------------------------------&lt;br /&gt;  &lt;br /&gt;  f.submit(); // post the form data back to the server to delete the record, &lt;br /&gt;              // just as if the user had pressed the submit button.&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;  return false; // returning false cancels the default &lt;a href="..."&gt; request. &lt;br /&gt;                 // However if JavaScript had been disabled for some reason the &lt;br /&gt;                 // &lt;a href="..."&gt; would have acted normally, meaning the record &lt;br /&gt;                 // would have been deleted from following the URL request directly.&lt;br /&gt; "&lt;br /&gt;&lt;/code&gt; &lt;br /&gt;Note: Twitter needs JavaScript for the web page to work properly, I've tried and it is not possible to delete a record without JavaScript.  The authenticity_token has been altered by me to prevent any malicious activity on my Twitter account.&lt;br /&gt;</description>
      <pubDate>Sat, 16 Feb 2008 13:17:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5145</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
  </channel>
</rss>
