Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

file hierachy reordering

darcs-hash:20070619140720-6e07b-2001276d635b4578c12c90724ce6b2cd7f41e785.gz
  • Loading branch information...
commit 64fca63a29fb2a863d159734627795acfb17c853 1 parent cb2adba
@splitbrain splitbrain authored
Showing with 315 additions and 6,051 deletions.
  1. +2 −9 ajax.php
  2. 0  { → doc}/COPYING
  3. 0  { → doc}/README
  4. 0  { → doc}/TODO
  5. 0  ldapab.schema → doc/docs
  6. 0  { → doc}/slapd.example
  7. +0 −20 entries.conf
  8. +176 −181 entry.php
  9. +8 −8 help.php
  10. +12 −12 img.php
  11. +102 −138 import.php
  12. 0  { → inc}/Contact_Vcard_Parse.php
  13. 0  { → inc}/config.php
  14. 0  { → inc}/fields.php
  15. 0  { → inc}/functions.php
  16. 0  { → inc}/importVCF.php
  17. +8 −8 { → inc}/init.php
  18. 0  { → inc}/lang/ca.php
  19. 0  { → inc}/lang/de.php
  20. 0  { → inc}/lang/en.php
  21. 0  { → inc}/lang/fr.php
  22. 0  { → inc}/lang/it.php
  23. 0  { → inc}/lang/nl.php
  24. 0  { → inc}/smarty/Config_File.class.php
  25. 0  { → inc}/smarty/Smarty.class.php
  26. 0  { → inc}/smarty/Smarty_Compiler.class.php
  27. 0  { → inc}/smarty/debug.tpl
  28. 0  { → inc}/smarty/internals/core.assemble_plugin_filepath.php
  29. 0  { → inc}/smarty/internals/core.assign_smarty_interface.php
  30. 0  { → inc}/smarty/internals/core.create_dir_structure.php
  31. 0  { → inc}/smarty/internals/core.display_debug_console.php
  32. 0  { → inc}/smarty/internals/core.get_include_path.php
  33. 0  { → inc}/smarty/internals/core.get_microtime.php
  34. 0  { → inc}/smarty/internals/core.get_php_resource.php
  35. 0  { → inc}/smarty/internals/core.is_secure.php
  36. 0  { → inc}/smarty/internals/core.is_trusted.php
  37. 0  { → inc}/smarty/internals/core.load_plugins.php
  38. 0  { → inc}/smarty/internals/core.load_resource_plugin.php
  39. 0  { → inc}/smarty/internals/core.process_cached_inserts.php
  40. 0  { → inc}/smarty/internals/core.process_compiled_include.php
  41. 0  { → inc}/smarty/internals/core.read_cache_file.php
  42. 0  { → inc}/smarty/internals/core.rm_auto.php
  43. 0  { → inc}/smarty/internals/core.rmdir.php
  44. 0  { → inc}/smarty/internals/core.run_insert_handler.php
  45. 0  { → inc}/smarty/internals/core.smarty_include_php.php
  46. 0  { → inc}/smarty/internals/core.write_cache_file.php
  47. 0  { → inc}/smarty/internals/core.write_compiled_include.php
  48. 0  { → inc}/smarty/internals/core.write_compiled_resource.php
  49. 0  { → inc}/smarty/internals/core.write_file.php
  50. 0  { → inc}/smarty/plugins/block.textformat.php
  51. 0  { → inc}/smarty/plugins/compiler.assign.php
  52. 0  { → inc}/smarty/plugins/function.assign.php
  53. 0  { → inc}/smarty/plugins/function.assign_debug_info.php
  54. 0  { → inc}/smarty/plugins/function.config_load.php
  55. 0  { → inc}/smarty/plugins/function.counter.php
  56. 0  { → inc}/smarty/plugins/function.cycle.php
  57. 0  { → inc}/smarty/plugins/function.debug.php
  58. 0  { → inc}/smarty/plugins/function.eval.php
  59. 0  { → inc}/smarty/plugins/function.fetch.php
  60. 0  { → inc}/smarty/plugins/function.html_checkboxes.php
  61. 0  { → inc}/smarty/plugins/function.html_image.php
  62. 0  { → inc}/smarty/plugins/function.html_options.php
  63. 0  { → inc}/smarty/plugins/function.html_radios.php
  64. 0  { → inc}/smarty/plugins/function.html_select_date.php
  65. 0  { → inc}/smarty/plugins/function.html_select_time.php
  66. 0  { → inc}/smarty/plugins/function.html_table.php
  67. 0  { → inc}/smarty/plugins/function.mailto.php
  68. 0  { → inc}/smarty/plugins/function.math.php
  69. 0  { → inc}/smarty/plugins/function.popup.php
  70. 0  { → inc}/smarty/plugins/function.popup_init.php
  71. 0  { → inc}/smarty/plugins/modifier.capitalize.php
  72. 0  { → inc}/smarty/plugins/modifier.cat.php
  73. 0  { → inc}/smarty/plugins/modifier.count_characters.php
  74. 0  { → inc}/smarty/plugins/modifier.count_paragraphs.php
  75. 0  { → inc}/smarty/plugins/modifier.count_sentences.php
  76. 0  { → inc}/smarty/plugins/modifier.count_words.php
  77. 0  { → inc}/smarty/plugins/modifier.csv.php
  78. 0  { → inc}/smarty/plugins/modifier.date_format.php
  79. 0  { → inc}/smarty/plugins/modifier.debug_print_var.php
  80. 0  { → inc}/smarty/plugins/modifier.default.php
  81. 0  { → inc}/smarty/plugins/modifier.escape.php
  82. 0  { → inc}/smarty/plugins/modifier.indent.php
  83. 0  { → inc}/smarty/plugins/modifier.lower.php
  84. 0  { → inc}/smarty/plugins/modifier.nl2br.php
  85. 0  { → inc}/smarty/plugins/modifier.noteparser.php
  86. 0  { → inc}/smarty/plugins/modifier.regex_replace.php
  87. 0  { → inc}/smarty/plugins/modifier.replace.php
  88. 0  { → inc}/smarty/plugins/modifier.spacify.php
  89. 0  { → inc}/smarty/plugins/modifier.string_format.php
  90. 0  { → inc}/smarty/plugins/modifier.strip.php
  91. 0  { → inc}/smarty/plugins/modifier.strip_tags.php
  92. 0  { → inc}/smarty/plugins/modifier.truncate.php
  93. 0  { → inc}/smarty/plugins/modifier.upper.php
  94. 0  { → inc}/smarty/plugins/modifier.wordwrap.php
  95. 0  { → inc}/smarty/plugins/outputfilter.trimwhitespace.php
  96. 0  { → inc}/smarty/plugins/shared.escape_special_chars.php
  97. 0  { → inc}/smarty/plugins/shared.make_timestamp.php
  98. 0  { → inc}/template.php
  99. +3 −6 index.php
  100. +0 −101 js/builder.js
  101. +0 −770 js/controls.js
  102. +0 −253 js/date-formatting.js
  103. +0 −585 js/dragdrop.js
  104. +0 −903 js/effects.js
  105. +0 −290 js/formatDate.js
  106. +0 −148 js/gui.js
  107. +0 −1,785 js/prototype.js
  108. +0 −45 js/scriptaculous.js
  109. +0 −283 js/slider.js
  110. +0 −363 js/unittest.js
  111. +1 −1  login.php
  112. +1 −1  orgs.php
  113. +2 −2 tags.php
  114. +0 −139 xml.php
View
11 ajax.php
@@ -1,14 +1,7 @@
<?
-require_once('init.php');
+require_once('inc/init.php');
ldap_login();
-
-/*
-echo '<bla><[!CDATA[';
-print_r($_REQUEST);
-echo ']]></bla>';
-*/
-
$FIELD = preg_replace('/entry\[/','',$_REQUEST['field']);
$FIELD = preg_replace('/\W+/','',$FIELD);
@@ -46,7 +39,7 @@ function ajax_addnote($dn,$note){
ldap_modify($LDAP_CON,$dn,$entry);
- require_once(dirname(__FILE__).'/smarty/plugins/modifier.noteparser.php');
+ require_once(dirname(__FILE__).'/inc/smarty/plugins/modifier.noteparser.php');
print smarty_modifier_noteparser($note);
}
View
0  COPYING → doc/COPYING
File renamed without changes
View
0  README → doc/README
File renamed without changes
View
0  TODO → doc/TODO
File renamed without changes
View
0  ldapab.schema → doc/docs
File renamed without changes
View
0  slapd.example → doc/slapd.example
File renamed without changes
View
20 entries.conf
@@ -1,20 +0,0 @@
-dn dn
-sn name
-givenName givenname
-title title
-o organization
-physicalDeliveryOfficeName office
-postalAddress street
-postalCode zip
-l location
-telephoneNumber phone
-facsimileTelephoneNumber fax
-mobile mobile
-pager pager
-homePhone homephone
-homePostalAddress homestreet
-photo photo
-jpegPhoto photo
-labeledURI url
-description note
-manager manager
View
357 entry.php
@@ -1,141 +1,136 @@
-<?
- require_once('init.php');
- ldap_login();
-
- $users = get_users();
-
- //select template to use
- if (empty($_REQUEST['mode'])) { $_REQUEST['mode']='show'; }
- if( $_SESSION['ldapab']['username'] &&
- ($_REQUEST['mode']=='edit' || $_REQUEST['mode']=='copy')){
- $template='entry_edit.tpl';
- }elseif($_REQUEST['mode']=='vcf'){
- $template='entry_vcf.tpl';
- }else{
- $template='entry_show.tpl';
- }
-
- if (empty($_REQUEST['dn'])) {
- $dn = "";
- }else{
- $dn = $_REQUEST['dn'];
- #$dn = 'cn=bar foo, ou=contacts, o=cosmocode, c=de';
- }
-
- //save data if asked for
- if($_SESSION['ldapab']['username'] && !empty($_REQUEST['save']) && $_REQUEST['save']){
- // prepare special data
- $_REQUEST['entry']['photo'] = _getUploadData();
- $_REQUEST['entry']['marker'] = explode(',',$_REQUEST['entry']['markers']);
- unset($_REQUEST['entry']['markers']);
-
- foreach(array_keys($_REQUEST['entry']) as $field){
- if($FIELDS['_'.$field]){
- // entry has to be handled as array -> clean it up (trim, unique, sort)
- $_REQUEST['entry'][$field] = array_map('trim',$_REQUEST['entry'][$field]);
- $_REQUEST['entry'][$field] = array_unique($_REQUEST['entry'][$field]);
- $_REQUEST['entry'][$field] = array_filter($_REQUEST['entry'][$field]);
- natcasesort($_REQUEST['entry'][$field]);
- }
- }
- $dn = _saveData();
+<?php
+require_once('inc/init.php');
+ldap_login();
+
+$users = get_users();
+
+//select template to use
+if (empty($_REQUEST['mode'])) { $_REQUEST['mode']='show'; }
+if( $_SESSION['ldapab']['username'] &&
+ ($_REQUEST['mode']=='edit' || $_REQUEST['mode']=='copy')){
+ $template='entry_edit.tpl';
+}elseif($_REQUEST['mode']=='vcf'){
+ $template='entry_vcf.tpl';
+}else{
+ $template='entry_show.tpl';
+}
+
+if (empty($_REQUEST['dn'])) {
+ $dn = "";
+}else{
+ $dn = $_REQUEST['dn'];
+ #$dn = 'cn=bar foo, ou=contacts, o=cosmocode, c=de';
+}
+
+//save data if asked for
+if($_SESSION['ldapab']['username'] && !empty($_REQUEST['save']) && $_REQUEST['save']){
+ // prepare special data
+ $_REQUEST['entry']['photo'] = _getUploadData();
+ $_REQUEST['entry']['marker'] = explode(',',$_REQUEST['entry']['markers']);
+ unset($_REQUEST['entry']['markers']);
+
+ foreach(array_keys($_REQUEST['entry']) as $field){
+ if($FIELDS['_'.$field]){
+ // entry has to be handled as array -> clean it up (trim, unique, sort)
+ $_REQUEST['entry'][$field] = array_map('trim',$_REQUEST['entry'][$field]);
+ $_REQUEST['entry'][$field] = array_unique($_REQUEST['entry'][$field]);
+ $_REQUEST['entry'][$field] = array_filter($_REQUEST['entry'][$field]);
+ natcasesort($_REQUEST['entry'][$field]);
+ }
}
+ $dn = _saveData();
+}
- if(empty($dn)){
- if(!$_REQUEST['mode']=='edit'){
- $smarty->assign('error','No dn was given');
- $template = 'error.tpl';
- }
- }elseif(!empty($_REQUEST['del']) && $_REQUEST['del']){
- _delEntry($dn);
- }elseif(!_fetchData($dn)){
- $smarty->assign('error',"The requested entry '$dn' was not found");
+if(empty($dn)){
+ if(!$_REQUEST['mode']=='edit'){
+ $smarty->assign('error','No dn was given');
$template = 'error.tpl';
}
-
- //prepare templates
- $smarty->assign('dn',$dn);
- $smarty->assign('managers',$users);
- tpl_std();
- tpl_orgs();
- tpl_markers();
- tpl_categories();
- tpl_timezone();
- tpl_country();
- //display templates
- if($_REQUEST['mode']=='vcf'){
- $entry = $smarty->get_template_vars('entry');
- $filename = $entry['givenname'].'_'.$entry['name'].'.vcf';
- header("Content-Disposition: attachment; filename=\"$filename\"");
- header("Content-type: text/x-vcard; name=\"$filename\"; charset=utf-8");
- $smarty->display($template);
- }else{
- header('Content-Type: text/html; charset=utf-8');
- $smarty->display($template);
+}elseif(!empty($_REQUEST['del']) && $_REQUEST['del']){
+ _delEntry($dn);
+}elseif(!_fetchData($dn)){
+ $smarty->assign('error',"The requested entry '$dn' was not found");
+ $template = 'error.tpl';
+}
+
+//prepare templates
+$smarty->assign('dn',$dn);
+$smarty->assign('managers',$users);
+tpl_std();
+//display templates
+if($_REQUEST['mode']=='vcf'){
+ $entry = $smarty->get_template_vars('entry');
+ $filename = $entry['givenname'].'_'.$entry['name'].'.vcf';
+ header("Content-Disposition: attachment; filename=\"$filename\"");
+ header("Content-type: text/x-vcard; name=\"$filename\"; charset=utf-8");
+ $smarty->display($template);
+}else{
+ header('Content-Type: text/html; charset=utf-8');
+ $smarty->display($template);
+}
+
+//--------------------------------------------------------------
+
+/**
+ * fetches the Data from the LDAP directory and assigns it to
+ * the global smarty object using tpl_entry()
+ */
+function _fetchData($dn){
+ global $LDAP_CON;
+ global $conf;
+ global $smarty;
+ global $users; //contains the users for manager role
+
+ $sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)');
+ if(!ldap_count_entries($LDAP_CON,$sr)){
+ return false;
}
+ $result = ldap_get_binentries($LDAP_CON, $sr);
+ $entry = $result[0];
- //--------------------------------------------------------------
-
- /**
- * fetches the Data from the LDAP directory and assigns it to
- * the global smarty object using tpl_entry()
- */
- function _fetchData($dn){
- global $LDAP_CON;
- global $conf;
- global $smarty;
- global $users; //contains the users for manager role
-
- $sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)');
- if(!ldap_count_entries($LDAP_CON,$sr)){
- return false;
- }
- $result = ldap_get_binentries($LDAP_CON, $sr);
- $entry = $result[0];
-
- //remove dn from entry when copy
- if(!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'copy'){
- $entry['dn']='';
- }
+ //remove dn from entry when copy
+ if(!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'copy'){
+ $entry['dn']='';
+ }
- //assign entry to template:
- tpl_entry($entry);
+ //assign entry to template:
+ tpl_entry($entry);
/*print '<pre>';
print_r($entry);
print '</pre>';*/
- // make username from dn for manager:
- if (empty($entry['manager'])) { $entry['manager']=array(""); }
- if (empty($users[$entry['manager'][0]])) { $users[$entry['manager'][0]]=''; }
- $smarty->assign('managername',$users[$entry['manager'][0]]);
- return true;
+ // make username from dn for manager:
+ if (empty($entry['manager'])) { $entry['manager']=array(""); }
+ if (empty($users[$entry['manager'][0]])) { $users[$entry['manager'][0]]=''; }
+ $smarty->assign('managername',$users[$entry['manager'][0]]);
+ return true;
+}
+
+/**
+ * saves the data from $_REQUEST['entry'] to the LDAP directory
+ *
+ * returns given or constructed dn
+ */
+function _saveData(){
+ global $LDAP_CON;
+ global $conf;
+ global $FIELDS;
+ global $OCLASSES;
+
+ $entry = $_REQUEST['entry'];
+ $dn = $_REQUEST['dn'];
+ //construct new dn
+ $now = time();
+ $newdn = 'uid='.$now;
+ if (empty($_REQUEST['type'])) { $_REQUEST['type']='public'; }
+ if($_REQUEST['type'] == 'private'){
+ $newdn .= ', '.$conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
+ }else{
+ $newdn .= ', '.$conf['publicbook'];
}
-
- /**
- * saves the data from $_REQUEST['entry'] to the LDAP directory
- *
- * returns given or constructed dn
- */
- function _saveData(){
- global $LDAP_CON;
- global $conf;
- global $FIELDS;
- global $OCLASSES;
-
- $entry = $_REQUEST['entry'];
- $dn = $_REQUEST['dn'];
- //construct new dn
- $now = time();
- $newdn = 'uid='.$now;
- if (empty($_REQUEST['type'])) { $_REQUEST['type']='public'; }
- if($_REQUEST['type'] == 'private'){
- $newdn .= ', '.$conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
- }else{
- $newdn .= ', '.$conf['publicbook'];
- }
- $entry['displayname'] = $entry['givenname'].' '.$entry['name'];;
- $entry = prepare_ldap_entry($entry);
+ $entry['displayname'] = $entry['givenname'].' '.$entry['name'];;
+ $entry = prepare_ldap_entry($entry);
/*
print '<pre>';
@@ -143,68 +138,68 @@ function _saveData(){
print '</pre>';
*/
- if(empty($dn)){
- //new entry
- $entry['uid'][] = $now;
- $r = ldap_add($LDAP_CON,$newdn,$entry);
- tpl_ldaperror();
- return $newdn;
- }else{
- // update the objectClasses
- ldap_store_objectclasses($dn,$OCLASSES);
- unset($entry['objectclass']);
-
- //modify entry attribute by attribute - this ensure we don't delete unknown stuff
- foreach (array_values($FIELDS) as $key){
- if($key == 'dn'){
+ if(empty($dn)){
+ //new entry
+ $entry['uid'][] = $now;
+ $r = ldap_add($LDAP_CON,$newdn,$entry);
+ tpl_ldaperror();
+ return $newdn;
+ }else{
+ // update the objectClasses
+ ldap_store_objectclasses($dn,$OCLASSES);
+ unset($entry['objectclass']);
+
+ //modify entry attribute by attribute - this ensure we don't delete unknown stuff
+ foreach (array_values($FIELDS) as $key){
+ if($key == 'dn'){
+ continue;
+ }elseif(empty($entry[$key])){
+ // field is empty -> handle deletion (except for photo unless deletion triggered)
+ if (empty($_REQUEST['delphoto'])) { $_REQUEST['delphoto']=0; }
+ if($key == 'jpegPhoto' && !$_REQUEST['delphoto']){
continue;
- }elseif(empty($entry[$key])){
- // field is empty -> handle deletion (except for photo unless deletion triggered)
- if (empty($_REQUEST['delphoto'])) { $_REQUEST['delphoto']=0; }
- if($key == 'jpegPhoto' && !$_REQUEST['delphoto']){
- continue;
- }
- unset($del);
- $del[$key]=array();
- $r = @ldap_mod_replace($LDAP_CON,$dn,$del);
- tpl_ldaperror("del $key");
- }else{
- unset($add);
- $add[$key]=$entry[$key];
- $r = @ldap_mod_replace($LDAP_CON,$dn,$add);
- tpl_ldaperror("mod $key");
}
+ unset($del);
+ $del[$key]=array();
+ $r = @ldap_mod_replace($LDAP_CON,$dn,$del);
+ tpl_ldaperror("del $key");
+ }else{
+ unset($add);
+ $add[$key]=$entry[$key];
+ $r = @ldap_mod_replace($LDAP_CON,$dn,$add);
+ tpl_ldaperror("mod $key");
}
- return $dn;
}
+ return $dn;
}
-
- /**
- * does as the name says - delete the whole entry
- */
- function _delEntry($dn){
- global $LDAP_CON;
- if(ldap_full_delete($LDAP_CON,$dn,true)){
- header("Location: index.php");
- exit;
- }
+}
+
+/**
+ * does as the name says - delete the whole entry
+ */
+function _delEntry($dn){
+ global $LDAP_CON;
+ if(ldap_full_delete($LDAP_CON,$dn,true)){
+ header("Location: index.php");
+ exit;
}
-
- /**
- * gets the binary data from an uploaded file
- */
- function _getUploadData(){
- $file = $_FILES['photoupload'];
-
- if (is_uploaded_file($file['tmp_name'])) {
- if(preg_match('=image/p?jpe?g=',$file['type'])){
- $fh = fopen($file['tmp_name'],'r');
- $data = fread($fh,$file['size']);
- fclose($fh);
- unlink($file['tmp_name']);
- return $data;
- }
+}
+
+/**
+ * gets the binary data from an uploaded file
+ */
+function _getUploadData(){
+ $file = $_FILES['photoupload'];
+
+ if (is_uploaded_file($file['tmp_name'])) {
+ if(preg_match('=image/p?jpe?g=',$file['type'])){
+ $fh = fopen($file['tmp_name'],'r');
+ $data = fread($fh,$file['size']);
+ fclose($fh);
+ unlink($file['tmp_name']);
+ return $data;
}
- return '';
}
+ return '';
+}
View
16 help.php
@@ -1,11 +1,11 @@
-<?
- require_once('init.php');
- ldap_login();
+<?php
+require_once('inc/init.php');
+ldap_login();
- //prepare templates
- tpl_std();
- //display templates
- header('Content-Type: text/html; charset=utf-8');
- $smarty->display('help.tpl');
+//prepare templates
+tpl_std();
+//display templates
+header('Content-Type: text/html; charset=utf-8');
+$smarty->display('help.tpl');
?>
View
24 img.php
@@ -1,16 +1,16 @@
-<?
- require_once('init.php');
- ldap_login();
+<?php
+require_once('inc/init.php');
+ldap_login();
- $dn = $_REQUEST['dn'];
+$dn = $_REQUEST['dn'];
- $sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array('jpegPhoto'));
- if(!ldap_count_entries($LDAP_CON,$sr)){
- exit;
- }
- $result = ldap_get_binentries($LDAP_CON, $sr);
- $entry = $result[0];
+$sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array('jpegPhoto'));
+if(!ldap_count_entries($LDAP_CON,$sr)){
+ exit;
+}
+$result = ldap_get_binentries($LDAP_CON, $sr);
+$entry = $result[0];
- header("Content-type: image/jpeg");
- print $entry['jpegPhoto'][0];
+header("Content-type: image/jpeg");
+print $entry['jpegPhoto'][0];
?>
View
240 import.php
@@ -1,162 +1,126 @@
<?
- require_once('init.php');
- require_once('Contact_Vcard_Parse.php');
- require_once('xml.php');
- ldap_login();
+require_once('inc/init.php');
+require_once('inc/Contact_Vcard_Parse.php');
+ldap_login();
- if(! $_SESSION['ldapab']['username'] ){
- header("Location: login.php");
- exit;
- }
+if(! $_SESSION['ldapab']['username'] ){
+ header("Location: login.php");
+ exit;
+}
- $error = '';
- if(isset($_FILES['userfile'])){
- if (is_uploaded_file($_FILES['userfile']['tmp_name'])){
- if(preg_match('/\.vcf$/i', $_FILES['userfile']['name'])){
- //parse VCF
- $vcfparser = new Contact_Vcard_Parse();
- $vcards = $vcfparser->fromFile($_FILES['userfile']['tmp_name']);
- }elseif(preg_match('/^addressbook\.xml$/i', $_FILES['userfile']['name'])){
- //parse Zaurus Addressbook
- $contacts = XML_unserialize(@join('',@file($_FILES['userfile']['tmp_name'])));
- }else{
- $error = "Only *.vcf or addressbook.xml are accepted";
- }
+$error = '';
+if(isset($_FILES['userfile'])){
+ if (is_uploaded_file($_FILES['userfile']['tmp_name'])){
+ if(preg_match('/\.vcf$/i', $_FILES['userfile']['name'])){
+ //parse VCF
+ $vcfparser = new Contact_Vcard_Parse();
+ $vcards = $vcfparser->fromFile($_FILES['userfile']['tmp_name']);
}else{
- switch($_FILES['userfile']['error']){
- case 0: //no error; possible file attack!
- $error = "There was a problem with your upload.";
- break;
- case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
- $error = "The file you are trying to upload is too big.";
- break;
- case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
- $error = "The file you are trying to upload is too big.";
- break;
- case 3: //uploaded file was only partially uploaded
- $error = "The file you are trying upload was only partially uploaded.";
- break;
- case 4: //no file was uploaded
- $error = "You must select a VCF file for upload.";
- break;
- default: //a default error, just in case! :)
- $error = "There was a problem with your upload.";
- break;
- }
- }
- }
-
- //prepare templates for all found entries
- $list = '';
- if(count($vcards)){
- foreach ($vcards as $vcard){
- $entry = vcard_entry($vcard);
- $smarty->clear_all_assign();
- tpl_std();
- $smarty->assign('entry',$entry);
- $list .= $smarty->fetch('import_entry.tpl');
+ $error = "Only *.vcf accepted";
}
- }elseif(count($contacts)){
- foreach ($contacts['AddressBook']['Contacts']['Contact'] as $contact){
- if (!is_array($contact)) continue;
- $entry = zaurus_entry($contact);
- $smarty->clear_all_assign();
- tpl_std();
- $smarty->assign('entry',$entry);
- $list .= $smarty->fetch('import_entry.tpl');
+ }else{
+ switch($_FILES['userfile']['error']){
+ case 0: //no error; possible file attack!
+ $error = "There was a problem with your upload.";
+ break;
+ case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
+ $error = "The file you are trying to upload is too big.";
+ break;
+ case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
+ $error = "The file you are trying to upload is too big.";
+ break;
+ case 3: //uploaded file was only partially uploaded
+ $error = "The file you are trying upload was only partially uploaded.";
+ break;
+ case 4: //no file was uploaded
+ $error = "You must select a VCF file for upload.";
+ break;
+ default: //a default error, just in case! :)
+ $error = "There was a problem with your upload.";
+ break;
}
}
+}
- //prepare templates
- tpl_std();
- tpl_orgs();
- tpl_markers();
- $smarty->assign('error',$error);
- $smarty->assign('list',$list);
- //display templates
- $smarty->display('header.tpl');
- $smarty->display('import.tpl');
- $smarty->display('footer.tpl');
-
+//prepare templates for all found entries
+$list = '';
+if(count($vcards)){
+ foreach ($vcards as $vcard){
+ $entry = vcard_entry($vcard);
+ $smarty->clear_all_assign();
+ tpl_std();
+ $smarty->assign('entry',$entry);
+ $list .= $smarty->fetch('import_entry.tpl');
+ }
+}
-function zaurus_entry($cnct){
- $entry['name'] = $cnct['LastName'];
- $entry['givenname'] = trim($cnct['FirstName'].' '.$cnct['MiddleName']);
- $entry['title'] = $cnct['JobTitle'];
- $entry['organization'] = $cnct['Company'];
- $entry['office'] = $cnct['Office'];
- $entry['note'] = $cnct['Notes'];
- $entry['mail'] = split(' ',$cnct['Emails']);
- $entry['street'] = $cnct['BusinessStreet'];
- $entry['location'] = $cnct['BusinessCity'];
- $entry['zip'] = $cnct['BusinessZip'];
- $entry['homestreet'] = $cnct['HomeStreet']."\n". //str
- $cnct['HomeZip']." ". //plz
- $cnct['HomeCity']; //ort
- $entry['homephone'] = $cnct['HomePhone'];
- $entry['phone'] = $cnct['BusinessPhone'];
- $entry['fax'] = empty($cnct['BusinessFax']) ? $cnct['HomeFax'] : $cnct['BusinessFax'];
- $entry['mobile'] = empty($cnct['HomeMobile']) ? $cnct['BusinessMobile'] : $cnct['HomeMobile'];
- $entry['fax'] = empty($cnct['BusinessFax']) ? $cnct['HomeFax'] : $cnct['BusinessFax'];
+//prepare templates
+tpl_std();
+tpl_orgs();
+tpl_markers();
+$smarty->assign('error',$error);
+$smarty->assign('list',$list);
+//display templates
+$smarty->display('header.tpl');
+$smarty->display('import.tpl');
+$smarty->display('footer.tpl');
- return $entry;
-}
function vcard_entry($vcf){
- $entry['name'] = $vcf['N'][0]['value'][0][0];
- $entry['givenname'] = trim($vcf['N'][0]['value'][1][0].' '.$vcf['N'][0]['value'][2][0]);
- $entry['title'] = $vcf['N'][0]['value'][3][0];
- $entry['organization'] = $vcf['ORG'][0]['value'][0][0];
- $entry['office'] = $vcf['ORG'][0]['value'][1][0];
- $entry['note'] = $vcf['NOTE'][0]['value'][0][0];
- $entry['url'] = $vcf['URL'][0]['value'][0][0];
- $bday = $vcf['BDAY'][0]['value'][0][0];
- $entry['anniversary'] = substr($bday,0,4).'-'.substr($bday,4,2).'-'.substr($bday,6,2);
+$entry['name'] = $vcf['N'][0]['value'][0][0];
+$entry['givenname'] = trim($vcf['N'][0]['value'][1][0].' '.$vcf['N'][0]['value'][2][0]);
+$entry['title'] = $vcf['N'][0]['value'][3][0];
+$entry['organization'] = $vcf['ORG'][0]['value'][0][0];
+$entry['office'] = $vcf['ORG'][0]['value'][1][0];
+$entry['note'] = $vcf['NOTE'][0]['value'][0][0];
+$entry['url'] = $vcf['URL'][0]['value'][0][0];
+$bday = $vcf['BDAY'][0]['value'][0][0];
+$entry['anniversary'] = substr($bday,0,4).'-'.substr($bday,4,2).'-'.substr($bday,6,2);
- foreach($vcf['TEL'] as $tel){
- if( empty($entry['phone']) &&
- array_search('WORK',$tel['param']['TYPE']) !== FALSE &&
+foreach($vcf['TEL'] as $tel){
+ if( empty($entry['phone']) &&
+ array_search('WORK',$tel['param']['TYPE']) !== FALSE &&
+ array_search('VOICE',$tel['param']['TYPE']) !== FALSE){
+ // Work phone
+ $entry['phone'] = $tel['value'][0][0];
+ }elseif(empty($entry['fax']) &&
+ array_search('FAX',$tel['param']['TYPE']) !== FALSE){
+ $entry['fax'] = $tel['value'][0][0];
+ }elseif(empty($entry['mobile']) &&
+ array_search('CELL',$tel['param']['TYPE']) !== FALSE){
+ $entry['mobile'] = $tel['value'][0][0];
+ }elseif(empty($entry['pager']) &&
+ array_search('PAGER',$tel['param']['TYPE']) !== FALSE){
+ $entry['pager'] = $tel['value'][0][0];
+ }elseif(empty($entry['homephone']) &&
+ array_search('HOME',$tel['param']['TYPE']) !== FALSE &&
array_search('VOICE',$tel['param']['TYPE']) !== FALSE){
- // Work phone
- $entry['phone'] = $tel['value'][0][0];
- }elseif(empty($entry['fax']) &&
- array_search('FAX',$tel['param']['TYPE']) !== FALSE){
- $entry['fax'] = $tel['value'][0][0];
- }elseif(empty($entry['mobile']) &&
- array_search('CELL',$tel['param']['TYPE']) !== FALSE){
- $entry['mobile'] = $tel['value'][0][0];
- }elseif(empty($entry['pager']) &&
- array_search('PAGER',$tel['param']['TYPE']) !== FALSE){
- $entry['pager'] = $tel['value'][0][0];
- }elseif(empty($entry['homephone']) &&
- array_search('HOME',$tel['param']['TYPE']) !== FALSE &&
- array_search('VOICE',$tel['param']['TYPE']) !== FALSE){
- $entry['homephone'] = $tel['value'][0][0];
- }
- }
- foreach($vcf['EMAIL'] as $mail){
- $entry['mail'][] = $mail['value'][0][0];
+ $entry['homephone'] = $tel['value'][0][0];
}
- foreach($vcf['ADR'] as $adr){
- if(array_search('HOME',$adr['param']['TYPE']) !== FALSE){
- $entry['homestreet'] = $adr['value'][2][0]."\n". //str
- $adr['value'][5][0]." ". //plz
- $adr['value'][3][0]; //ort
+}
+foreach($vcf['EMAIL'] as $mail){
+ $entry['mail'][] = $mail['value'][0][0];
+}
+foreach($vcf['ADR'] as $adr){
+ if(array_search('HOME',$adr['param']['TYPE']) !== FALSE){
+ $entry['homestreet'] = $adr['value'][2][0]."\n". //str
+ $adr['value'][5][0]." ". //plz
+ $adr['value'][3][0]; //ort
- }elseif(array_search('WORK',$adr['param']['TYPE']) !== FALSE){
- $entry['street'] = $adr['value'][2][0];
- $entry['location'] = $adr['value'][3][0];
- $entry['zip'] = $adr['value'][5][0];
- }
+ }elseif(array_search('WORK',$adr['param']['TYPE']) !== FALSE){
+ $entry['street'] = $adr['value'][2][0];
+ $entry['location'] = $adr['value'][3][0];
+ $entry['zip'] = $adr['value'][5][0];
}
+}
/*
- print '<pre>';
- print_r($entry);
- print '</pre>';
+print '<pre>';
+print_r($entry);
+print '</pre>';
*/
- return $entry;
+return $entry;
}
View
0  Contact_Vcard_Parse.php → inc/Contact_Vcard_Parse.php
File renamed without changes
View
0  config.php → inc/config.php
File renamed without changes
View
0  fields.php → inc/fields.php
File renamed without changes
View
0  functions.php → inc/functions.php
File renamed without changes
View
0  importVCF.php → inc/importVCF.php
File renamed without changes
View
16 init.php → inc/init.php
@@ -1,10 +1,10 @@
<?
- require_once('config.php');
- require_once('fields.php');
- require_once('lang/'.$conf['lang'].'.php');
- require_once('functions.php');
- require_once('template.php');
- require_once('smarty/Smarty.class.php');
+ require_once(dirname(__FILE__).'/config.php');
+ require_once(dirname(__FILE__).'/fields.php');
+ require_once(dirname(__FILE__).'/lang/'.$conf['lang'].'.php');
+ require_once(dirname(__FILE__).'/functions.php');
+ require_once(dirname(__FILE__).'/template.php');
+ require_once(dirname(__FILE__).'/smarty/Smarty.class.php');
define('NL',"\n");
@@ -35,8 +35,8 @@ function remove_magic_quotes(&$array) {
//prepare SMARTY object
$smarty = new Smarty;
- $smarty->compile_dir = './cache';
+ $smarty->compile_dir = dirname(__FILE__).'/../cache';
$smarty->use_sub_dirs = 0;
- $smarty->template_dir = './templates';
+ $smarty->template_dir = dirname(__FILE__).'/../templates';
$smarty->force_compile = $conf['smartycompile'];
?>
View
0  lang/ca.php → inc/lang/ca.php
File renamed without changes
View
0  lang/de.php → inc/lang/de.php
File renamed without changes
View
0  lang/en.php → inc/lang/en.php
File renamed without changes
View
0  lang/fr.php → inc/lang/fr.php
File renamed without changes
View
0  lang/it.php → inc/lang/it.php
File renamed without changes
View
0  lang/nl.php → inc/lang/nl.php
File renamed without changes
View
0  smarty/Config_File.class.php → inc/smarty/Config_File.class.php
File renamed without changes
View
0  smarty/Smarty.class.php → inc/smarty/Smarty.class.php
File renamed without changes
View
0  smarty/Smarty_Compiler.class.php → inc/smarty/Smarty_Compiler.class.php
File renamed without changes
View
0  smarty/debug.tpl → inc/smarty/debug.tpl
File renamed without changes
View
0  smarty/internals/core.assemble_plugin_filepath.php → ...marty/internals/core.assemble_plugin_filepath.php
File renamed without changes
View
0  smarty/internals/core.assign_smarty_interface.php → ...smarty/internals/core.assign_smarty_interface.php
File renamed without changes
View
0  smarty/internals/core.create_dir_structure.php → inc/smarty/internals/core.create_dir_structure.php
File renamed without changes
View
0  smarty/internals/core.display_debug_console.php → inc/smarty/internals/core.display_debug_console.php
File renamed without changes
View
0  smarty/internals/core.get_include_path.php → inc/smarty/internals/core.get_include_path.php
File renamed without changes
View
0  smarty/internals/core.get_microtime.php → inc/smarty/internals/core.get_microtime.php
File renamed without changes
View
0  smarty/internals/core.get_php_resource.php → inc/smarty/internals/core.get_php_resource.php
File renamed without changes
View
0  smarty/internals/core.is_secure.php → inc/smarty/internals/core.is_secure.php
File renamed without changes
View
0  smarty/internals/core.is_trusted.php → inc/smarty/internals/core.is_trusted.php
File renamed without changes
View
0  smarty/internals/core.load_plugins.php → inc/smarty/internals/core.load_plugins.php
File renamed without changes
View
0  smarty/internals/core.load_resource_plugin.php → inc/smarty/internals/core.load_resource_plugin.php
File renamed without changes
View
0  smarty/internals/core.process_cached_inserts.php → inc/smarty/internals/core.process_cached_inserts.php
File renamed without changes
View
0  smarty/internals/core.process_compiled_include.php → ...marty/internals/core.process_compiled_include.php
File renamed without changes
View
0  smarty/internals/core.read_cache_file.php → inc/smarty/internals/core.read_cache_file.php
File renamed without changes
View
0  smarty/internals/core.rm_auto.php → inc/smarty/internals/core.rm_auto.php
File renamed without changes
View
0  smarty/internals/core.rmdir.php → inc/smarty/internals/core.rmdir.php
File renamed without changes
View
0  smarty/internals/core.run_insert_handler.php → inc/smarty/internals/core.run_insert_handler.php
File renamed without changes
View
0  smarty/internals/core.smarty_include_php.php → inc/smarty/internals/core.smarty_include_php.php
File renamed without changes
View
0  smarty/internals/core.write_cache_file.php → inc/smarty/internals/core.write_cache_file.php
File renamed without changes
View
0  smarty/internals/core.write_compiled_include.php → inc/smarty/internals/core.write_compiled_include.php
File renamed without changes
View
0  smarty/internals/core.write_compiled_resource.php → ...smarty/internals/core.write_compiled_resource.php
File renamed without changes
View
0  smarty/internals/core.write_file.php → inc/smarty/internals/core.write_file.php
File renamed without changes
View
0  smarty/plugins/block.textformat.php → inc/smarty/plugins/block.textformat.php
File renamed without changes
View
0  smarty/plugins/compiler.assign.php → inc/smarty/plugins/compiler.assign.php
File renamed without changes
View
0  smarty/plugins/function.assign.php → inc/smarty/plugins/function.assign.php
File renamed without changes
View
0  smarty/plugins/function.assign_debug_info.php → inc/smarty/plugins/function.assign_debug_info.php
File renamed without changes
View
0  smarty/plugins/function.config_load.php → inc/smarty/plugins/function.config_load.php
File renamed without changes
View
0  smarty/plugins/function.counter.php → inc/smarty/plugins/function.counter.php
File renamed without changes
View
0  smarty/plugins/function.cycle.php → inc/smarty/plugins/function.cycle.php
File renamed without changes
View
0  smarty/plugins/function.debug.php → inc/smarty/plugins/function.debug.php
File renamed without changes
View
0  smarty/plugins/function.eval.php → inc/smarty/plugins/function.eval.php
File renamed without changes
View
0  smarty/plugins/function.fetch.php → inc/smarty/plugins/function.fetch.php
File renamed without changes
View
0  smarty/plugins/function.html_checkboxes.php → inc/smarty/plugins/function.html_checkboxes.php
File renamed without changes
View
0  smarty/plugins/function.html_image.php → inc/smarty/plugins/function.html_image.php
File renamed without changes
View
0  smarty/plugins/function.html_options.php → inc/smarty/plugins/function.html_options.php
File renamed without changes
View
0  smarty/plugins/function.html_radios.php → inc/smarty/plugins/function.html_radios.php
File renamed without changes
View
0  smarty/plugins/function.html_select_date.php → inc/smarty/plugins/function.html_select_date.php
File renamed without changes
View
0  smarty/plugins/function.html_select_time.php → inc/smarty/plugins/function.html_select_time.php
File renamed without changes
View
0  smarty/plugins/function.html_table.php → inc/smarty/plugins/function.html_table.php
File renamed without changes
View
0  smarty/plugins/function.mailto.php → inc/smarty/plugins/function.mailto.php
File renamed without changes
View
0  smarty/plugins/function.math.php → inc/smarty/plugins/function.math.php
File renamed without changes
View
0  smarty/plugins/function.popup.php → inc/smarty/plugins/function.popup.php
File renamed without changes
View
0  smarty/plugins/function.popup_init.php → inc/smarty/plugins/function.popup_init.php
File renamed without changes
View
0  smarty/plugins/modifier.capitalize.php → inc/smarty/plugins/modifier.capitalize.php
File renamed without changes
View
0  smarty/plugins/modifier.cat.php → inc/smarty/plugins/modifier.cat.php
File renamed without changes
View
0  smarty/plugins/modifier.count_characters.php → inc/smarty/plugins/modifier.count_characters.php
File renamed without changes
View
0  smarty/plugins/modifier.count_paragraphs.php → inc/smarty/plugins/modifier.count_paragraphs.php
File renamed without changes
View
0  smarty/plugins/modifier.count_sentences.php → inc/smarty/plugins/modifier.count_sentences.php
File renamed without changes
View
0  smarty/plugins/modifier.count_words.php → inc/smarty/plugins/modifier.count_words.php
File renamed without changes
View
0  smarty/plugins/modifier.csv.php → inc/smarty/plugins/modifier.csv.php
File renamed without changes
View
0  smarty/plugins/modifier.date_format.php → inc/smarty/plugins/modifier.date_format.php
File renamed without changes
View
0  smarty/plugins/modifier.debug_print_var.php → inc/smarty/plugins/modifier.debug_print_var.php
File renamed without changes
View
0  smarty/plugins/modifier.default.php → inc/smarty/plugins/modifier.default.php
File renamed without changes
View
0  smarty/plugins/modifier.escape.php → inc/smarty/plugins/modifier.escape.php
File renamed without changes
View
0  smarty/plugins/modifier.indent.php → inc/smarty/plugins/modifier.indent.php
File renamed without changes
View
0  smarty/plugins/modifier.lower.php → inc/smarty/plugins/modifier.lower.php
File renamed without changes
View
0  smarty/plugins/modifier.nl2br.php → inc/smarty/plugins/modifier.nl2br.php
File renamed without changes
View
0  smarty/plugins/modifier.noteparser.php → inc/smarty/plugins/modifier.noteparser.php
File renamed without changes
View
0  smarty/plugins/modifier.regex_replace.php → inc/smarty/plugins/modifier.regex_replace.php
File renamed without changes
View
0  smarty/plugins/modifier.replace.php → inc/smarty/plugins/modifier.replace.php
File renamed without changes
View
0  smarty/plugins/modifier.spacify.php → inc/smarty/plugins/modifier.spacify.php
File renamed without changes
View
0  smarty/plugins/modifier.string_format.php → inc/smarty/plugins/modifier.string_format.php
File renamed without changes
View
0  smarty/plugins/modifier.strip.php → inc/smarty/plugins/modifier.strip.php
File renamed without changes
View
0  smarty/plugins/modifier.strip_tags.php → inc/smarty/plugins/modifier.strip_tags.php
File renamed without changes
View
0  smarty/plugins/modifier.truncate.php → inc/smarty/plugins/modifier.truncate.php
File renamed without changes
View
0  smarty/plugins/modifier.upper.php → inc/smarty/plugins/modifier.upper.php
File renamed without changes
View
0  smarty/plugins/modifier.wordwrap.php → inc/smarty/plugins/modifier.wordwrap.php
File renamed without changes
View
0  smarty/plugins/outputfilter.trimwhitespace.php → inc/smarty/plugins/outputfilter.trimwhitespace.php
File renamed without changes
View
0  smarty/plugins/shared.escape_special_chars.php → inc/smarty/plugins/shared.escape_special_chars.php
File renamed without changes
View
0  smarty/plugins/shared.make_timestamp.php → inc/smarty/plugins/shared.make_timestamp.php
File renamed without changes
View
0  template.php → inc/template.php
File renamed without changes
View
9 index.php
@@ -1,5 +1,6 @@
-<?
- require_once('init.php');
+<?php
+
+ require_once('inc/init.php');
ldap_login();
//prepare filter
@@ -43,10 +44,6 @@
//prepare templates
tpl_std();
- tpl_markers(); //FIXME not needed anymore!?
- tpl_categories();
- tpl_timezone();
- tpl_country();
if (empty($_REQUEST['filter'])) $_REQUEST['filter']='';
if (empty($_REQUEST['marker'])) $_REQUEST['marker']='';
if (empty($_REQUEST['search'])) $_REQUEST['search']='';
View
101 js/builder.js
@@ -1,101 +0,0 @@
-// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-//
-// See scriptaculous.js for full license.
-
-var Builder = {
- NODEMAP: {
- AREA: 'map',
- CAPTION: 'table',
- COL: 'table',
- COLGROUP: 'table',
- LEGEND: 'fieldset',
- OPTGROUP: 'select',
- OPTION: 'select',
- PARAM: 'object',
- TBODY: 'table',
- TD: 'table',
- TFOOT: 'table',
- TH: 'table',
- THEAD: 'table',
- TR: 'table'
- },
- // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
- // due to a Firefox bug
- node: function(elementName) {
- elementName = elementName.toUpperCase();
-
- // try innerHTML approach
- var parentTag = this.NODEMAP[elementName] || 'div';
- var parentElement = document.createElement(parentTag);
- try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
- parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
- } catch(e) {}
- var element = parentElement.firstChild || null;
-
- // see if browser added wrapping tags
- if(element && (element.tagName != elementName))
- element = element.getElementsByTagName(elementName)[0];
-
- // fallback to createElement approach
- if(!element) element = document.createElement(elementName);
-
- // abort if nothing could be created
- if(!element) return;
-
- // attributes (or text)
- if(arguments[1])
- if(this._isStringOrNumber(arguments[1]) ||
- (arguments[1] instanceof Array)) {
- this._children(element, arguments[1]);
- } else {
- var attrs = this._attributes(arguments[1]);
- if(attrs.length) {
- try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
- parentElement.innerHTML = "<" +elementName + " " +
- attrs + "></" + elementName + ">";
- } catch(e) {}
- element = parentElement.firstChild || null;
- // workaround firefox 1.0.X bug
- if(!element) {
- element = document.createElement(elementName);
- for(attr in arguments[1])
- element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
- }
- if(element.tagName != elementName)
- element = parentElement.getElementsByTagName(elementName)[0];
- }
- }
-
- // text, or array of children
- if(arguments[2])
- this._children(element, arguments[2]);
-
- return element;
- },
- _text: function(text) {
- return document.createTextNode(text);
- },
- _attributes: function(attributes) {
- var attrs = [];
- for(attribute in attributes)
- attrs.push((attribute=='className' ? 'class' : attribute) +
- '="' + attributes[attribute].toString().escapeHTML() + '"');
- return attrs.join(" ");
- },
- _children: function(element, children) {
- if(typeof children=='object') { // array can hold nodes and text
- children.flatten().each( function(e) {
- if(typeof e=='object')
- element.appendChild(e)
- else
- if(Builder._isStringOrNumber(e))
- element.appendChild(Builder._text(e));
- });
- } else
- if(Builder._isStringOrNumber(children))
- element.appendChild(Builder._text(children));
- },
- _isStringOrNumber: function(param) {
- return(typeof param=='string' || typeof param=='number');
- }
-}
View
770 js/controls.js
@@ -1,770 +0,0 @@
-// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005 Jon Tirsen (http://www.tirsen.com)
-// Contributors:
-// Richard Livsey
-// Rahul Bhargava
-// Rob Wills
-//
-// See scriptaculous.js for full license.
-
-// Autocompleter.Base handles all the autocompletion functionality
-// that's independent of the data source for autocompletion. This
-// includes drawing the autocompletion menu, observing keyboard
-// and mouse events, and similar.
-//
-// Specific autocompleters need to provide, at the very least,
-// a getUpdatedChoices function that will be invoked every time
-// the text inside the monitored textbox changes. This method
-// should get the text for which to provide autocompletion by
-// invoking this.getToken(), NOT by directly accessing
-// this.element.value. This is to allow incremental tokenized
-// autocompletion. Specific auto-completion logic (AJAX, etc)
-// belongs in getUpdatedChoices.
-//
-// Tokenized incremental autocompletion is enabled automatically
-// when an autocompleter is instantiated with the 'tokens' option
-// in the options parameter, e.g.:
-// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
-// will incrementally autocomplete with a comma as the token.
-// Additionally, ',' in the above example can be replaced with
-// a token array, e.g. { tokens: [',', '\n'] } which
-// enables autocompletion on multiple tokens. This is most
-// useful when one of the tokens is \n (a newline), as it
-// allows smart autocompletion after linebreaks.
-
-var Autocompleter = {}
-Autocompleter.Base = function() {};
-Autocompleter.Base.prototype = {
- baseInitialize: function(element, update, options) {
- this.element = $(element);
- this.update = $(update);
- this.hasFocus = false;
- this.changed = false;
- this.active = false;
- this.index = 0;
- this.entryCount = 0;
-
- if (this.setOptions)
- this.setOptions(options);
- else
- this.options = options || {};
-
- this.options.paramName = this.options.paramName || this.element.name;
- this.options.tokens = this.options.tokens || [];
- this.options.frequency = this.options.frequency || 0.4;
- this.options.minChars = this.options.minChars || 1;
- this.options.onShow = this.options.onShow ||
- function(element, update){
- if(!update.style.position || update.style.position=='absolute') {
- update.style.position = 'absolute';
- Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
- }
- Effect.Appear(update,{duration:0.15});
- };
- this.options.onHide = this.options.onHide ||
- function(element, update){ new Effect.Fade(update,{duration:0.15}) };
-
- if (typeof(this.options.tokens) == 'string')
- this.options.tokens = new Array(this.options.tokens);
-
- this.observer = null;
-
- this.element.setAttribute('autocomplete','off');
-
- Element.hide(this.update);
-
- Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
- Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
- },
-
- show: function() {
- if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
- if(!this.iefix &&
- (navigator.appVersion.indexOf('MSIE')>0) &&
- (navigator.userAgent.indexOf('Opera')<0) &&
- (Element.getStyle(this.update, 'position')=='absolute')) {
- new Insertion.After(this.update,
- '<iframe id="' + this.update.id + '_iefix" '+
- 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
- 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
- this.iefix = $(this.update.id+'_iefix');
- }
- if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
- },
-
- fixIEOverlapping: function() {
- Position.clone(this.update, this.iefix);
- this.iefix.style.zIndex = 1;
- this.update.style.zIndex = 2;
- Element.show(this.iefix);
- },
-
- hide: function() {
- this.stopIndicator();
- if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
- if(this.iefix) Element.hide(this.iefix);
- },
-
- startIndicator: function() {
- if(this.options.indicator) Element.show(this.options.indicator);
- },
-
- stopIndicator: function() {
- if(this.options.indicator) Element.hide(this.options.indicator);
- },
-
- onKeyPress: function(event) {
- if(this.active)
- switch(event.keyCode) {
- case Event.KEY_TAB:
- case Event.KEY_RETURN:
- this.selectEntry();
- Event.stop(event);
- case Event.KEY_ESC:
- this.hide();
- this.active = false;
- Event.stop(event);
- return;
- case Event.KEY_LEFT:
- case Event.KEY_RIGHT:
- return;
- case Event.KEY_UP:
- this.markPrevious();
- this.render();
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
- return;
- case Event.KEY_DOWN:
- this.markNext();
- this.render();
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
- return;
- }
- else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN)
- return;
-
- this.changed = true;
- this.hasFocus = true;
-
- if(this.observer) clearTimeout(this.observer);
- this.observer =
- setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
- },
-
- onHover: function(event) {
- var element = Event.findElement(event, 'LI');
- if(this.index != element.autocompleteIndex)
- {
- this.index = element.autocompleteIndex;
- this.render();
- }
- Event.stop(event);
- },
-
- onClick: function(event) {
- var element = Event.findElement(event, 'LI');
- this.index = element.autocompleteIndex;
- this.selectEntry();
- this.hide();
- },
-
- onBlur: function(event) {
- // needed to make click events working
- setTimeout(this.hide.bind(this), 250);
- this.hasFocus = false;
- this.active = false;
- },
-
- render: function() {
- if(this.entryCount > 0) {
- for (var i = 0; i < this.entryCount; i++)
- this.index==i ?
- Element.addClassName(this.getEntry(i),"selected") :
- Element.removeClassName(this.getEntry(i),"selected");
-
- if(this.hasFocus) {
- this.show();
- this.active = true;
- }
- } else {
- this.active = false;
- this.hide();
- }
- },
-
- markPrevious: function() {
- if(this.index > 0) this.index--
- else this.index = this.entryCount-1;
- },
-
- markNext: function() {
- if(this.index < this.entryCount-1) this.index++
- else this.index = 0;
- },
-
- getEntry: function(index) {
- return this.update.firstChild.childNodes[index];
- },
-
- getCurrentEntry: function() {
- return this.getEntry(this.index);
- },
-
- selectEntry: function() {
- this.active = false;
- this.updateElement(this.getCurrentEntry());
- },
-
- updateElement: function(selectedElement) {
- if (this.options.updateElement) {
- this.options.updateElement(selectedElement);
- return;
- }
- var value = '';
- if (this.options.select) {
- var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];
- if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
- } else
- value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
-
- var lastTokenPos = this.findLastToken();
- if (lastTokenPos != -1) {
- var newValue = this.element.value.substr(0, lastTokenPos + 1);
- var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
- if (whitespace)
- newValue += whitespace[0];
- this.element.value = newValue + value;
- } else {
- this.element.value = value;
- }
- this.element.focus();
-
- if (this.options.afterUpdateElement)
- this.options.afterUpdateElement(this.element, selectedElement);
- },
-
- updateChoices: function(choices) {
- if(!this.changed && this.hasFocus) {
- this.update.innerHTML = choices;
- Element.cleanWhitespace(this.update);
- Element.cleanWhitespace(this.update.firstChild);
-
- if(this.update.firstChild && this.update.firstChild.childNodes) {
- this.entryCount =
- this.update.firstChild.childNodes.length;
- for (var i = 0; i < this.entryCount; i++) {
- var entry = this.getEntry(i);
- entry.autocompleteIndex = i;
- this.addObservers(entry);
- }
- } else {
- this.entryCount = 0;
- }
-
- this.stopIndicator();
-
- this.index = 0;
- this.render();
- }
- },
-
- addObservers: function(element) {
- Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
- Event.observe(element, "click", this.onClick.bindAsEventListener(this));
- },
-
- onObserverEvent: function() {
- this.changed = false;
- if(this.getToken().length>=this.options.minChars) {
- this.startIndicator();
- this.getUpdatedChoices();
- } else {
- this.active = false;
- this.hide();
- }
- },
-
- getToken: function() {
- var tokenPos = this.findLastToken();
- if (tokenPos != -1)
- var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
- else
- var ret = this.element.value;
-
- return /\n/.test(ret) ? '' : ret;
- },
-
- findLastToken: function() {
- var lastTokenPos = -1;
-
- for (var i=0; i<this.options.tokens.length; i++) {
- var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
- if (thisTokenPos > lastTokenPos)
- lastTokenPos = thisTokenPos;
- }
- return lastTokenPos;
- }
-}
-
-Ajax.Autocompleter = Class.create();
-Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
- initialize: function(element, update, url, options) {
- this.baseInitialize(element, update, options);
- this.options.asynchronous = true;
- this.options.onComplete = this.onComplete.bind(this);
- this.options.defaultParams = this.options.parameters || null;
- this.url = url;
- },
-
- getUpdatedChoices: function() {
- entry = encodeURIComponent(this.options.paramName) + '=' +
- encodeURIComponent(this.getToken());
-
- this.options.parameters = this.options.callback ?
- this.options.callback(this.element, entry) : entry;
-
- if(this.options.defaultParams)
- this.options.parameters += '&' + this.options.defaultParams;
-
- new Ajax.Request(this.url, this.options);
- },
-
- onComplete: function(request) {
- this.updateChoices(request.responseText);
- }
-
-});
-
-// The local array autocompleter. Used when you'd prefer to
-// inject an array of autocompletion options into the page, rather
-// than sending out Ajax queries, which can be quite slow sometimes.
-//
-// The constructor takes four parameters. The first two are, as usual,
-// the id of the monitored textbox, and id of the autocompletion menu.
-// The third is the array you want to autocomplete from, and the fourth
-// is the options block.
-//
-// Extra local autocompletion options:
-// - choices - How many autocompletion choices to offer
-//
-// - partialSearch - If false, the autocompleter will match entered
-// text only at the beginning of strings in the
-// autocomplete array. Defaults to true, which will
-// match text at the beginning of any *word* in the
-// strings in the autocomplete array. If you want to
-// search anywhere in the string, additionally set
-// the option fullSearch to true (default: off).
-//
-// - fullSsearch - Search anywhere in autocomplete array strings.
-//
-// - partialChars - How many characters to enter before triggering
-// a partial match (unlike minChars, which defines
-// how many characters are required to do any match
-// at all). Defaults to 2.
-//
-// - ignoreCase - Whether to ignore case when autocompleting.
-// Defaults to true.
-//
-// It's possible to pass in a custom function as the 'selector'
-// option, if you prefer to write your own autocompletion logic.
-// In that case, the other options above will not apply unless
-// you support them.
-
-Autocompleter.Local = Class.create();
-Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
- initialize: function(element, update, array, options) {
- this.baseInitialize(element, update, options);
- this.options.array = array;
- },
-
- getUpdatedChoices: function() {
- this.updateChoices(this.options.selector(this));
- },
-
- setOptions: function(options) {
- this.options = Object.extend({
- choices: 10,
- partialSearch: true,
- partialChars: 2,
- ignoreCase: true,
- fullSearch: false,
- selector: function(instance) {
- var ret = []; // Beginning matches
- var partial = []; // Inside matches
- var entry = instance.getToken();
- var count = 0;
-
- for (var i = 0; i < instance.options.array.length &&
- ret.length < instance.options.choices ; i++) {
-
- var elem = instance.options.array[i];
- var foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
- elem.indexOf(entry);
-
- while (foundPos != -1) {
- if (foundPos == 0 && elem.length != entry.length) {
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
- elem.substr(entry.length) + "</li>");
- break;
- } else if (entry.length >= instance.options.partialChars &&
- instance.options.partialSearch && foundPos != -1) {
- if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
- partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
- elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
- foundPos + entry.length) + "</li>");
- break;
- }
- }
-
- foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
- elem.indexOf(entry, foundPos + 1);
-
- }
- }
- if (partial.length)
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
- return "<ul>" + ret.join('') + "</ul>";
- }
- }, options || {});
- }
-});
-
-// AJAX in-place editor
-//
-// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
-
-// Use this if you notice weird scrolling problems on some browsers,
-// the DOM might be a bit confused when this gets called so do this
-// waits 1 ms (with setTimeout) until it does the activation
-Field.scrollFreeActivate = function(field) {
- setTimeout(function() {
- Field.activate(field);
- }, 1);
-}
-
-Ajax.InPlaceEditor = Class.create();
-Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
-Ajax.InPlaceEditor.prototype = {
- initialize: function(element, url, options) {
- this.url = url;
- this.element = $(element);
-
- this.options = Object.extend({
- okButton: true,
- okText: "ok",
- cancelLink: true,
- cancelText: "cancel",
- savingText: "Saving...",
- clickToEditText: "Click to edit",
- okText: "ok",
- rows: 1,
- onComplete: function(transport, element) {
- new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
- },
- onFailure: function(transport) {
- alert("Error communicating with the server: " + transport.responseText.stripTags());
- },
- callback: function(form) {
- return Form.serialize(form);
- },
- handleLineBreaks: true,
- loadingText: 'Loading...',
- savingClassName: 'inplaceeditor-saving',
- loadingClassName: 'inplaceeditor-loading',
- formClassName: 'inplaceeditor-form',
- highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
- highlightendcolor: "#FFFFFF",
- externalControl: null,
- submitOnBlur: false,
- ajaxOptions: {}
- }, options || {});
-
- if(!this.options.formId && this.element.id) {
- this.options.formId = this.element.id + "-inplaceeditor";
- if ($(this.options.formId)) {
- // there's already a form with that name, don't specify an id
- this.options.formId = null;
- }
- }
-
- if (this.options.externalControl) {
- this.options.externalControl = $(this.options.externalControl);
- }
-
- this.originalBackground = Element.getStyle(this.element, 'background-color');
- if (!this.originalBackground) {
- this.originalBackground = "transparent";
- }
-
- this.element.title = this.options.clickToEditText;
-
- this.onclickListener = this.enterEditMode.bindAsEventListener(this);
- this.mouseoverListener = this.enterHover.bindAsEventListener(this);
- this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
- Event.observe(this.element, 'click', this.onclickListener);
- Event.observe(this.element, 'mouseover', this.mouseoverListener);
- Event.observe(this.element, 'mouseout', this.mouseoutListener);
- if (this.options.externalControl) {
- Event.observe(this.options.externalControl, 'click', this.onclickListener);
- Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
- Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
- }
- },
- enterEditMode: function(evt) {
- if (this.saving) return;
- if (this.editing) return;
- this.editing = true;
- this.onEnterEditMode();
- if (this.options.externalControl) {
- Element.hide(this.options.externalControl);
- }
- Element.hide(this.element);
- this.createForm();
- this.element.parentNode.insertBefore(this.form, this.element);
- Field.scrollFreeActivate(this.editField);
- // stop the event to avoid a page refresh in Safari
- if (evt) {
- Event.stop(evt);
- }
- return false;
- },
- createForm: function() {
- this.form = document.createElement("form");
- this.form.id = this.options.formId;
- Element.addClassName(this.form, this.options.formClassName)
- this.form.onsubmit = this.onSubmit.bind(this);
-
- this.createEditField();
-
- if (this.options.textarea) {
- var br = document.createElement("br");
- this.form.appendChild(br);
- }
-
- if (this.options.okButton) {
- okButton = document.createElement("input");
- okButton.type = "submit";
- okButton.value = this.options.okText;
- this.form.appendChild(okButton);
- }
-
- if (this.options.cancelLink) {
- cancelLink = document.createElement("a");
- cancelLink.href = "#";
- cancelLink.appendChild(document.createTextNode(this.options.cancelText));
- cancelLink.onclick = this.onclickCancel.bind(this);
- this.form.appendChild(cancelLink);
- }
- },
- hasHTMLLineBreaks: function(string) {
- if (!this.options.handleLineBreaks) return false;
- return string.match(/<br/i) || string.match(/<p>/i);
- },
- convertHTMLLineBreaks: function(string) {
- return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
- },
- createEditField: function() {
- var text;
- if(this.options.loadTextURL) {
- text = this.options.loadingText;
- } else {
- text = this.getText();
- }
-
- var obj = this;
-
- if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
- this.options.textarea = false;
- var textField = document.createElement("input");
- textField.obj = this;
- textField.type = "text";
- textField.name = "value";
- textField.value = text;
- textField.style.backgroundColor = this.options.highlightcolor;
- var size = this.options.size || this.options.cols || 0;
- if (size != 0) textField.size = size;
- if (this.options.submitOnBlur)
- textField.onblur = this.onSubmit.bind(this);
- this.editField = textField;
- } else {
- this.options.textarea = true;
- var textArea = document.createElement("textarea");
- textArea.obj = this;
- textArea.name = "value";
- textArea.value = this.convertHTMLLineBreaks(text);
- textArea.rows = this.options.rows;
- textArea.cols = this.options.cols || 40;
- if (this.options.submitOnBlur)
- textArea.onblur = this.onSubmit.bind(this);
- this.editField = textArea;
- }
-
- if(this.options.loadTextURL) {
- this.loadExternalText();
- }
- this.form.appendChild(this.editField);
- },
- getText: function() {
- return this.element.innerHTML;
- },
- loadExternalText: function() {
- Element.addClassName(this.form, this.options.loadingClassName);
- this.editField.disabled = true;
- new Ajax.Request(
- this.options.loadTextURL,
- Object.extend({
- asynchronous: true,
- onComplete: this.onLoadedExternalText.bind(this)
- }, this.options.ajaxOptions)
- );
- },
- onLoadedExternalText: function(transport) {
- Element.removeClassName(this.form, this.options.loadingClassName);
- this.editField.disabled = false;
- this.editField.value = transport.responseText.stripTags();
- },
- onclickCancel: function() {
- this.onComplete();
- this.leaveEditMode();
- return false;
- },
- onFailure: function(transport) {
- this.options.onFailure(transport);
- if (this.oldInnerHTML) {
- this.element.innerHTML = this.oldInnerHTML;
- this.oldInnerHTML = null;
- }
- return false;
- },
- onSubmit: function() {
- // onLoading resets these so we need to save them away for the Ajax call
- var form = this.form;
- var value = this.editField.value;
-
- // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
- // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
- // to be displayed indefinitely
- this.onLoading();
-
- new Ajax.Updater(
- {
- success: this.element,
- // don't update on failure (this could be an option)
- failure: null
- },
- this.url,
- Object.extend({
- parameters: this.options.callback(form, value),
- onComplete: this.onComplete.bind(this),
- onFailure: this.onFailure.bind(this)
- }, this.options.ajaxOptions)
- );
- // stop the event to avoid a page refresh in Safari
- if (arguments.length > 1) {
- Event.stop(arguments[0]);
- }
- return false;
- },
- onLoading: function() {
- this.saving = true;
- this.removeForm();
- this.leaveHover();
- this.showSaving();
- },
- showSaving: function() {
- this.oldInnerHTML = this.element.innerHTML;
- this.element.innerHTML = this.options.savingText;
- Element.addClassName(this.element, this.options.savingClassName);
- this.element.style.backgroundColor = this.originalBackground;
- Element.show(this.element);
- },
- removeForm: function() {
- if(this.form) {
- if (this.form.parentNode) Element.remove(this.form);
- this.form = null;
- }
- },
- enterHover: function() {
- if (this.saving) return;
- this.element.style.backgroundColor = this.options.highlightcolor;
- if (this.effect) {
- this.effect.cancel();
- }
- Element.addClassName(this.element, this.options.hoverClassName)
- },
- leaveHover: function() {
- if (this.options.backgroundColor) {
- this.element.style.backgroundColor = this.oldBackground;
- }
- Element.removeClassName(this.element, this.options.hoverClassName)
- if (this.saving) return;
- this.effect = new Effect.Highlight(this.element, {
- startcolor: this.options.highlightcolor,
- endcolor: this.options.highlightendcolor,
- restorecolor: this.originalBackground
- });
- },
- leaveEditMode: function() {
- Element.removeClassName(this.element, this.options.savingClassName);
- this.removeForm();
- this.leaveHover();
- this.element.style.backgroundColor = this.originalBackground;
- Element.show(this.element);
- if (this.options.externalControl) {
- Element.show(this.options.externalControl);
- }
- this.editing = false;
- this.saving = false;
- this.oldInnerHTML = null;
- this.onLeaveEditMode();
- },
- onComplete: function(transport) {
- this.leaveEditMode();
- this.options.onComplete.bind(this)(transport, this.element);
- },
- onEnterEditMode: function() {},
- onLeaveEditMode: function() {},
- dispose: function() {
- if (this.oldInnerHTML) {
- this.element.innerHTML = this.oldInnerHTML;
- }
- this.leaveEditMode();
- Event.stopObserving(this.element, 'click', this.onclickListener);
- Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
- Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
- if (this.options.externalControl) {
- Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
- Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
- Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
- }
- }
-};
-
-// Delayed observer, like Form.Element.Observer,
-// but waits for delay after last key input
-// Ideal for live-search fields
-
-Form.Element.DelayedObserver = Class.create();
-Form.Element.DelayedObserver.prototype = {
- initialize: function(element, delay, callback) {
- this.delay = delay || 0.5;
- this.element = $(element);
- this.callback = callback;
- this.timer = null;
- this.lastValue = $F(this.element);
- Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
- },
- delayedListener: function(event) {
- if(this.lastValue == $F(this.element)) return;
- if(this.timer) clearTimeout(this.timer);
- this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
- this.lastValue = $F(this.element);
- },
- onTimerEvent: function() {
- this.timer = null;
- this.callback(this.element, $F(this.element));
- }
-};
View
253 js/date-formatting.js
@@ -1,253 +0,0 @@
-/*