Klipfolio Dashboard 5 API

Object Items.Deleted

Object
   |
   +--Klip
         |
         +--Items
               |
               +--Items.Deleted

The Items.Deleted object provides an API to query and remove items that have been deleted from the Klip.

An item can be deleted by one of the following actions:

The Items.Deleted[] Array

When an item is deleted from an Items[] array, it is added to the Items.Deleted[] array.

For example, let's say there are three items in your Klip as illustrated below:

If the user right-clicks on the second item ("Second Item") and chooses 'Remove' from the pop-up menu, it is removed from the Items[] array and moved to the Items.Deleted[] array:

Example

The following Klip adds two items to the Klip, then calls Items.remove() to remove the second item.
<klip>
   <identity>
      <title>
	 API: Items.Deleted
      </title>
   </identity>
   <locations>
      <contentsource>
	 http://support.klipfolio.com/files/demo/demo.xml
      </contentsource>
      <icon>
         http://www.klipfolio.com/static/klips/klipfolio/sample_icon.png
      </icon>
      <banner>
         http://www.klipfolio.com/static/klips/klipfolio/sample_banner.png   
      </banner>
   </locations>
   <style>
      alert {
	 type: item;
      }

      sender {
	 itemcol: 2;
	 noterow: 1;

	 label: 'Sender';

	 emphasis: strong;
      }


      summary {
	 itemcol: 3;
	 noterow: 4;

	 wrap: false;

	 notelabel: false;
      }

      date {
	 itemcol: 4;
	 noterow: 2;

	 label: 'Date';
      }

      category {
	 noterow: 3;

	 label: 'Category';
      }


      level {
	 itemcol: 1;
	 noterow: 5;
	 notelabel: false;
	 
	 type: image;
      }

      url {
	 type: link;
      }
	    
      id {
	 key: override;
      }
   </style>
   <klipscript>
   <![CDATA[

function onRefresh()
{
	_t( "onRefresh () -- " + Prefs.contentsource );
	var result = Engines.Data.process ( Prefs.contentsource );
	
	Items.remove( 1 );
	
	show_state();
	
	return result;
}


//
// Support functions -----------------------------------------------
//

//
// Useful Debug Code -----------------------------------------------
//
var button;
function show_state() 
{
   	show_items ();
  	show_itemsDeleted ();
	show_all_prefs ();
}

function show_items() 
{
	if (Items.length == 0) 
	{
		trace ("There are no items in the Items[] array\r\n");
		return;
	}

	for( i = 0; i < Items.length; i++ ) 
	{
		trace ("Items[" + i + "]: \r\n");    	
		queryItem (Items[i]);
	}
}

function show_itemsDeleted() 
{
	if (Items.Deleted.length == 0) 
	{
		trace ("There are no items in the Items.Deleted[] array\r\n");
		return;
	}
    
	for (i = 0; i < Items.Deleted.length; i++) 
	{
		trace ("Items.Deleted[" + i + "]: \r\n");    	
		queryItem ( Items.Deleted[i]);
	}
}

function queryItem( item ) 
{
    trace( "-----------------\r\n" );
    trace( "    .hidden       = " + item.hidden + " (boolean)\r\n" );
    trace( "    .visited      = " + item.visited + " (boolean)\r\n" );
    trace( "    .canpurge     = " + item.canpurge + "  (boolean)\r\n" );
    trace( "    .alerting     = " + item.alerting + " (boolean)\r\n" );
    trace( "    .creation     = " + item.creation + " (double)\r\n" );
    trace( "    .pubdate      = " + item.pubdate + "  (double)\r\n" );
    trace( "    .lastmodified = " + item.lastmodified + "  (double)\r\n" );

    // Output the current value of each defined element in an item

    	trace( "      .getData (\"level\") = \"" + item.getData( "level" ) + "\" (string)\r\n" );
    	trace( "      .getData (\"sender\") = \"" + item.getData( "sender" ) + "\" (string)\r\n" );
    	trace( "      .getData (\"summary\") = \"" + item.getData( "summary" ) + "\" (string)\r\n" );
    	trace( "      .getData (\"date\") = \"" + item.getData( "date" ) + "\" (string)\r\n" );
    	trace( "      .getData (\"category\") = \"" + item.getData( "category" ) + "\" (string)\r\n" );
    	trace( "      .getData (\"url\") = \"" + item.getData( "url" ) + "\" (string)\r\n" );
    	trace( "      .getData (\"id\") = \"" + item.getData( "id" ) + "\" (string)\r\n" );
    
    trace( "\r\n" );
}

function show_all_prefs() 
{
   if (Prefs.length == 0) 
   {
      trace ("There are no Prefs defined\r\n");
      return;
   }
   
   trace( "------------------------\r\n" );

   for (var i = 0; i < Prefs.length; i++) 
   { 
      trace("Prefs.getPref( \""+Prefs[i].name+"\" ) == \""+Prefs[i].value+"\"\r\n"); 
   }
   
   trace( "------------------------\r\n" );
}

function _t( s ) 
{
   trace( s + "\r\n" );
}

]]>
   </klipscript>
</klip>

     	
Upon loading, Klipfolio Dashboard will display the following contents of the Items[] and Items.Deleted[] array to the Debug Window.

 onRefresh () -- http://www.serence.com/support/samples/demo/demo-
 static.xml
 Items[0]: 
 -----------------
     .hidden       = false (boolean)
     .visited      = false (boolean)
     .canpurge     = true  (boolean)
     .alerting     = false (boolean)
     .creation     = 1217601846 (double)
     .pubdate      = 0  (double)
     .lastmodified = 1217601846  (double)
       .getData ("level") = 
 "http://www.serence.com/support/samples/images/high.png" (string)
       .getData ("sender") = "Server Monitor" (string)
       .getData ("summary") = "Server BU172 is down." (string)
       .getData ("date") = "06/09/2008 20:29" (string)
       .getData ("category") = "Category 1" (string)
       .getData ("url") = "http://www.serence.com/" (string)
       .getData ("id") = "1133054944" (string)
 
 Items.Deleted[0]: 
 -----------------
     .hidden       = false (boolean)
     .visited      = false (boolean)
     .canpurge     = true  (boolean)
     .alerting     = false (boolean)
     .creation     = 1217601846 (double)
     .pubdate      = 0  (double)
     .lastmodified = 1217601846  (double)
       .getData ("level") = "false" (string)
       .getData ("sender") = "false" (string)
       .getData ("summary") = "false" (string)
       .getData ("date") = "false" (string)
       .getData ("category") = "false" (string)
       .getData ("url") = "false" (string)
       .getData ("id") = "1133055050" (string)
 
 There are no Prefs defined
 
Note: Changes to the Items.deleted[] array will be saved across Klipfolio Dashboard sessions unless otherwise noted.


Properties Summary
 integer expiry
          Returns the number of days an unmodified item will remain in Items.Deleted[] before it is permanently removed.
 integer length
          Returns the number of Item objects in the Items.Deleted array.
   
Function Summary
 function clear()
           Clears all items from the Items.Deleted[] array.
 function expiredeleteditems( index | object )
           Removes any items in Items.Deleted array that have not been modified within expiry days.
 boolean remove( <integer> index )
           Removes the specified item from the Items.Deleted[] array.
 boolean restore( <integer> index | <Item> object )
           Restores the specified item from the Items.Deleted array to the Items array, thus making it visible again to the user.

Properties Detail

expiry

integer expiry

length

integer length

Function Detail

clear

function clear()

expiredeleteditems

function expiredeleteditems( index | object )

remove

boolean remove( <integer> index )

restore

boolean restore( <integer> index | <Item> object )

Klipfolio Dashboard 5 API

© 2009 Klipfolio Inc. All Rights Reserved.