code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php
//============================================================+
// File name : ger.php
// Begin : 2004-03-03
// Last Update : 2010-11-16
//
// Description : Language module for TCPDF
// (contains translated texts)
// German
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: German
* @author Nicola Asuni
* @since 2004-03-03
*/
// German
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'de';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'Seite';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/ger.php | PHP | gpl2 | 1,198 |
<?php
//============================================================+
// File name : aze.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Azerbaijani
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Azerbaijani
* @author Nicola Asuni
* @since 2010-10-26
*/
// Azerbaijani
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'az';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'səhifə';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/aze.php | PHP | gpl2 | 1,216 |
<?php
//============================================================+
// File name : est.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Estonian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Estonian
* @author Nicola Asuni
* @since 2010-10-26
*/
// Estonian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'et';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'lehekülg';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/est.php | PHP | gpl2 | 1,208 |
<?php
//============================================================+
// File name : eng.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// English
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: English
* @author Nicola Asuni
* @since 2004-03-03
*/
// English
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'en';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'page';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/eng.php | PHP | gpl2 | 1,200 |
<?php
//============================================================+
// File name : afr.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Afrikaans
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Afrikaans
* @author Nicola Asuni
* @since 2010-10-26
*/
// Afrikaans
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'af';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'bladsy';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/afr.php | PHP | gpl2 | 1,208 |
<?php
//============================================================+
// File name : hun.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Hungarian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Hungarian
* @author Nicola Asuni
* @since 2004-03-03
*/
// Hungarian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'hu';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'oldal';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/hun.php | PHP | gpl2 | 1,207 |
<?php
//============================================================+
// File name : bel.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Basque
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Basque
* @author Nicola Asuni
* @since 2010-10-26
*/
// Basque
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'be';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'старонкі';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/bel.php | PHP | gpl2 | 1,209 |
<?php
//============================================================+
// File name : ind.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Indonesian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Indonesian
* @author Nicola Asuni
* @since 2004-03-03
*/
// Indonesian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'id';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'halaman';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/ind.php | PHP | gpl2 | 1,212 |
<?php
//============================================================+
// File name : ces.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Czech
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Czech
* @author Nicola Asuni
* @since 2010-10-26
*/
// Czech
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'cs';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'stránky';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/ces.php | PHP | gpl2 | 1,198 |
<?php
//============================================================+
// File name : sqi.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Albanian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Albanian
* @author Nicola Asuni
* @since 2010-10-26
*/
// Albanian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'sq';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'faqe';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/sqi.php | PHP | gpl2 | 1,203 |
<?php
//============================================================+
// File name : cat.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Catalan
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Catalan
* @author Nicola Asuni
* @since 2010-10-26
*/
// Catalan
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ca';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'pàgina';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/cat.php | PHP | gpl2 | 1,203 |
<?php
//============================================================+
// File name : zho.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Chinese
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Chinese
* @author Nicola Asuni
* @since 2010-10-26
*/
// Chinese
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'zh';
// TRANSLATIONS --------------------------------------
$l['w_page'] = '頁面';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/zho.php | PHP | gpl2 | 1,202 |
<?php
//============================================================+
// File name : urd.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Welsh
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Welsh
* @author Nicola Asuni
* @since 2004-03-03
*/
// Welsh
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'cy';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'tudalen';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/cym.php | PHP | gpl2 | 1,197 |
<?php
//============================================================+
// File name : ind.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Irish
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Irish
* @author Nicola Asuni
* @since 2004-03-03
*/
// Irish
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ga';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'leathanach';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/gle.php | PHP | gpl2 | 1,200 |
<?php
//============================================================+
// File name : ara.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Arabic
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Arabic
* @author Nicola Asuni
* @since 2010-10-26
*/
// Arabic
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = 'ar';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'صفحة';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/ara.php | PHP | gpl2 | 1,201 |
<?php
//============================================================+
// File name : fra.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// French
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: French
* @author Nicola Asuni
* @since 2010-10-26
*/
// French
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'fr';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'page';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/fra.php | PHP | gpl2 | 1,197 |
<?php
//============================================================+
// File name : glg.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Galician
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Galician
* @author Nicola Asuni
* @since 2010-10-26
*/
// Galician
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'gl';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'Páxina';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/glg.php | PHP | gpl2 | 1,206 |
<?php
//============================================================+
// File name : far.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Farsi
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Farsi
* @author Sina Saeedi
* @since 2011-04-12
*/
// Farsi
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = 'fa';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'صفحه';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/far.php | PHP | gpl2 | 1,197 |
<?php
//============================================================+
// File name : ron.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Romanian, Moldavian, Moldovan
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Romanian, Moldavian, Moldovan
* @author Nicola Asuni
* @since 2004-03-03
*/
// Romanian, Moldavian, Moldovan
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ro';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'pagina';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/ron.php | PHP | gpl2 | 1,268 |
<?php
//============================================================+
// File name : rus.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Russian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Russian
* @author Nicola Asuni
* @since 2004-03-03
*/
// Russian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ru';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'страницы';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/rus.php | PHP | gpl2 | 1,212 |
<?php
//============================================================+
// File name : eng.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Brazilian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Brazilian
* @author Nicola Asuni
* @since 2004-03-03
*/
// Brazilian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'pt';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'página';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/bra.php | PHP | gpl2 | 1,209 |
<?php
//============================================================+
// File name : heb.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Hebrew
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Hebrew
* @author Nicola Asuni
* @since 2004-03-03
*/
// Hebrew
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = 'he';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'מקור:';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/heb.php | PHP | gpl2 | 1,202 |
<?php
//============================================================+
// File name : pol.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Polish
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Polish
* @author Nicola Asuni
* @since 2010-10-26
*/
// Polish
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'pl';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'strona';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/pol.php | PHP | gpl2 | 1,199 |
<?php
//============================================================+
// File name : kat.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Georgian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Georgian
* @author Nicola Asuni
* @since 2010-10-26
*/
// Georgian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'ka';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'გვერდი';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/kat.php | PHP | gpl2 | 1,217 |
<?php
//============================================================+
// File name : chi.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Chinese (Simplified)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Chinese (Simplified)
* @author Nicola Asuni
* @since 2010-10-26
*/
// Chinese (Simplified)
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'cn';
// TRANSLATIONS --------------------------------------
$l['w_page'] = '页面';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/chi.php | PHP | gpl2 | 1,241 |
<?php
//============================================================+
// File name : eus.php
// Begin : 2010-10-26
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Basque
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Basque
* @author Nicola Asuni
* @since 2010-10-26
*/
// Basque
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'eu';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'Orrialdearen';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/eus.php | PHP | gpl2 | 1,205 |
<?php
//============================================================+
// File name : srp.php
// Begin : 2004-03-03
// Last Update : 2010-10-26
//
// Description : Language module for TCPDF
// (contains translated texts)
// Serbian
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @brief TCPDF language file: Serbian
* @author Nicola Asuni
* @since 2004-03-03
*/
// Serbian
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'sr';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'страна';
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/config/lang/srp.php | PHP | gpl2 | 1,208 |
<?php
//============================================================+
// File name : barcodes.php
// Version : 1.0.021
// Begin : 2008-06-09
// Last Update : 2011-09-15
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2008-2011 Nicola Asuni - Tecnick.com S.r.l.
//
// This file is part of TCPDF software library.
//
// TCPDF is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : PHP class to creates array representations for
// common 1D barcodes to be used with TCPDF.
//
//============================================================+
/**
* @file
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF.
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.021
*/
/**
* @class TCPDFBarcode
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
* @package com.tecnick.tcpdf
* @version 1.0.021
* @author Nicola Asuni
*/
class TCPDFBarcode {
/**
* Array representation of barcode.
* @protected
*/
protected $barcode_array;
/**
* This is the class constructor.
* Return an array representations for common 1D barcodes:<ul>
* <li>$arrcode['code'] code to be printed on text label</li>
* <li>$arrcode['maxh'] max barcode height</li>
* <li>$arrcode['maxw'] max barcode width</li>
* <li>$arrcode['bcode'][$k] single bar or space in $k position</li>
* <li>$arrcode['bcode'][$k]['t'] bar type: true = bar, false = space.</li>
* <li>$arrcode['bcode'][$k]['w'] bar width in units.</li>
* <li>$arrcode['bcode'][$k]['h'] bar height in units.</li>
* <li>$arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)</li></ul>
* @param $code (string) code to print
* @param $type (string) type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128 : CODE 128</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
* @public
*/
public function __construct($code, $type) {
$this->setBarcode($code, $type);
}
/**
* Return an array representations of barcode.
* @return array
* @public
*/
public function getBarcodeArray() {
return $this->barcode_array;
}
/**
* Send barcode as SVG image object to the standard output.
* @param $w (int) Minimum width of a single bar in user units.
* @param $h (int) Height of barcode in user units.
* @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent).
* @public
*/
public function getBarcodeSVG($w=2, $h=30, $color='black') {
// send headers
$code = $this->getBarcodeSVGcode($w, $h, $color);
header('Content-Type: application/svg+xml');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Content-Disposition: inline; filename="'.md5($code).'.svg";');
//header('Content-Length: '.strlen($code));
echo $code;
}
/**
* Return a SVG string representation of barcode.
* @param $w (int) Minimum width of a single bar in user units.
* @param $h (int) Height of barcode in user units.
* @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent).
* @return string SVG code.
* @public
*/
public function getBarcodeSVGcode($w=2, $h=30, $color='black') {
// replace table for special characters
$repstr = array("\0" => '', '&' => '&', '<' => '<', '>' => '>');
$svg = '<'.'?'.'xml version="1.0" standalone="no"'.'?'.'>'."\n";
$svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n";
$svg .= '<svg width="'.round(($this->barcode_array['maxw'] * $w), 3).'" height="'.$h.'" version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n";
$svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n";
$svg .= "\t".'<g id="bars" fill="'.$color.'" stroke="none">'."\n";
// print bars
$x = 0;
foreach ($this->barcode_array['bcode'] as $k => $v) {
$bw = round(($v['w'] * $w), 3);
$bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3);
if ($v['t']) {
$y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3);
// draw a vertical bar
$svg .= "\t\t".'<rect x="'.$x.'" y="'.$y.'" width="'.$bw.'" height="'.$bh.'" />'."\n";
}
$x += $bw;
}
$svg .= "\t".'</g>'."\n";
$svg .= '</svg>'."\n";
return $svg;
}
/**
* Return an HTML representation of barcode.
* @param $w (int) Width of a single bar element in pixels.
* @param $h (int) Height of a single bar element in pixels.
* @param $color (string) Foreground color for bar elements (background is transparent).
* @return string HTML code.
* @public
*/
public function getBarcodeHTML($w=2, $h=30, $color='black') {
// replace table for special characters
$html = '<div style="font-size:0;position:relative;">'."\n";
// print bars
$x = 0;
foreach ($this->barcode_array['bcode'] as $k => $v) {
$bw = round(($v['w'] * $w), 3);
$bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3);
if ($v['t']) {
$y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3);
// draw a vertical bar
$html .= '<div style="background-color:'.$color.';width:'.$bw.'px;height:'.$bh.'px;position:absolute;left:'.$x.'px;top:'.$y.'px;"> </div>'."\n";
}
$x += $bw;
}
$html .= '</div>'."\n";
return $html;
}
/**
* Return a PNG image representation of barcode (requires GD or Imagick library).
* @param $w (int) Width of a single bar element in pixels.
* @param $h (int) Height of a single bar element in pixels.
* @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
* @return image or false in case of error.
* @public
*/
public function getBarcodePNG($w=2, $h=30, $color=array(0,0,0)) {
// calculate image size
$width = ($this->barcode_array['maxw'] * $w);
$height = $h;
if (function_exists('imagecreate')) {
// GD library
$imagick = false;
$png = imagecreate($width, $height);
$bgcol = imagecolorallocate($png, 255, 255, 255);
imagecolortransparent($png, $bgcol);
$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
} elseif (extension_loaded('imagick')) {
$imagick = true;
$bgcol = new imagickpixel('rgb(255,255,255');
$fgcol = new imagickpixel('rgb('.$color[0].','.$color[1].','.$color[2].')');
$png = new Imagick();
$png->newImage($width, $height, 'none', 'png');
$bar = new imagickdraw();
$bar->setfillcolor($fgcol);
} else {
return false;
}
// print bars
$x = 0;
foreach ($this->barcode_array['bcode'] as $k => $v) {
$bw = round(($v['w'] * $w), 3);
$bh = round(($v['h'] * $h / $this->barcode_array['maxh']), 3);
if ($v['t']) {
$y = round(($v['p'] * $h / $this->barcode_array['maxh']), 3);
// draw a vertical bar
if ($imagick) {
$bar->rectangle($x, $y, ($x + $bw), ($y + $bh));
} else {
imagefilledrectangle($png, $x, $y, ($x + $bw), ($y + $bh), $fgcol);
}
}
$x += $bw;
}
// send headers
header('Content-Type: image/png');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
if ($imagick) {
$png->drawimage($bar);
echo $png;
} else {
imagepng($png);
imagedestroy($png);
}
}
/**
* Set the barcode.
* @param $code (string) code to print
* @param $type (string) type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128 : CODE 128</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
* @return array barcode array
* @public
*/
public function setBarcode($code, $type) {
switch (strtoupper($type)) {
case 'C39': { // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
$arrcode = $this->barcode_code39($code, false, false);
break;
}
case 'C39+': { // CODE 39 with checksum
$arrcode = $this->barcode_code39($code, false, true);
break;
}
case 'C39E': { // CODE 39 EXTENDED
$arrcode = $this->barcode_code39($code, true, false);
break;
}
case 'C39E+': { // CODE 39 EXTENDED + CHECKSUM
$arrcode = $this->barcode_code39($code, true, true);
break;
}
case 'C93': { // CODE 93 - USS-93
$arrcode = $this->barcode_code93($code);
break;
}
case 'S25': { // Standard 2 of 5
$arrcode = $this->barcode_s25($code, false);
break;
}
case 'S25+': { // Standard 2 of 5 + CHECKSUM
$arrcode = $this->barcode_s25($code, true);
break;
}
case 'I25': { // Interleaved 2 of 5
$arrcode = $this->barcode_i25($code, false);
break;
}
case 'I25+': { // Interleaved 2 of 5 + CHECKSUM
$arrcode = $this->barcode_i25($code, true);
break;
}
case 'C128': { // CODE 128
$arrcode = $this->barcode_c128($code, '');
break;
}
case 'C128A': { // CODE 128 A
$arrcode = $this->barcode_c128($code, 'A');
break;
}
case 'C128B': { // CODE 128 B
$arrcode = $this->barcode_c128($code, 'B');
break;
}
case 'C128C': { // CODE 128 C
$arrcode = $this->barcode_c128($code, 'C');
break;
}
case 'EAN2': { // 2-Digits UPC-Based Extention
$arrcode = $this->barcode_eanext($code, 2);
break;
}
case 'EAN5': { // 5-Digits UPC-Based Extention
$arrcode = $this->barcode_eanext($code, 5);
break;
}
case 'EAN8': { // EAN 8
$arrcode = $this->barcode_eanupc($code, 8);
break;
}
case 'EAN13': { // EAN 13
$arrcode = $this->barcode_eanupc($code, 13);
break;
}
case 'UPCA': { // UPC-A
$arrcode = $this->barcode_eanupc($code, 12);
break;
}
case 'UPCE': { // UPC-E
$arrcode = $this->barcode_eanupc($code, 6);
break;
}
case 'MSI': { // MSI (Variation of Plessey code)
$arrcode = $this->barcode_msi($code, false);
break;
}
case 'MSI+': { // MSI + CHECKSUM (modulo 11)
$arrcode = $this->barcode_msi($code, true);
break;
}
case 'POSTNET': { // POSTNET
$arrcode = $this->barcode_postnet($code, false);
break;
}
case 'PLANET': { // PLANET
$arrcode = $this->barcode_postnet($code, true);
break;
}
case 'RMS4CC': { // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
$arrcode = $this->barcode_rms4cc($code, false);
break;
}
case 'KIX': { // KIX (Klant index - Customer index)
$arrcode = $this->barcode_rms4cc($code, true);
break;
}
case 'IMB': { // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
$arrcode = $this->barcode_imb($code);
break;
}
case 'CODABAR': { // CODABAR
$arrcode = $this->barcode_codabar($code);
break;
}
case 'CODE11': { // CODE 11
$arrcode = $this->barcode_code11($code);
break;
}
case 'PHARMA': { // PHARMACODE
$arrcode = $this->barcode_pharmacode($code);
break;
}
case 'PHARMA2T': { // PHARMACODE TWO-TRACKS
$arrcode = $this->barcode_pharmacode2t($code);
break;
}
default: {
$this->barcode_array = false;
$arrcode = false;
break;
}
}
$this->barcode_array = $arrcode;
}
/**
* CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
* General-purpose code in very wide use world-wide
* @param $code (string) code to represent.
* @param $extended (boolean) if true uses the extended mode.
* @param $checksum (boolean) if true add a checksum to the code.
* @return array barcode representation.
* @protected
*/
protected function barcode_code39($code, $extended=false, $checksum=false) {
$chr['0'] = '111331311';
$chr['1'] = '311311113';
$chr['2'] = '113311113';
$chr['3'] = '313311111';
$chr['4'] = '111331113';
$chr['5'] = '311331111';
$chr['6'] = '113331111';
$chr['7'] = '111311313';
$chr['8'] = '311311311';
$chr['9'] = '113311311';
$chr['A'] = '311113113';
$chr['B'] = '113113113';
$chr['C'] = '313113111';
$chr['D'] = '111133113';
$chr['E'] = '311133111';
$chr['F'] = '113133111';
$chr['G'] = '111113313';
$chr['H'] = '311113311';
$chr['I'] = '113113311';
$chr['J'] = '111133311';
$chr['K'] = '311111133';
$chr['L'] = '113111133';
$chr['M'] = '313111131';
$chr['N'] = '111131133';
$chr['O'] = '311131131';
$chr['P'] = '113131131';
$chr['Q'] = '111111333';
$chr['R'] = '311111331';
$chr['S'] = '113111331';
$chr['T'] = '111131331';
$chr['U'] = '331111113';
$chr['V'] = '133111113';
$chr['W'] = '333111111';
$chr['X'] = '131131113';
$chr['Y'] = '331131111';
$chr['Z'] = '133131111';
$chr['-'] = '131111313';
$chr['.'] = '331111311';
$chr[' '] = '133111311';
$chr['$'] = '131313111';
$chr['/'] = '131311131';
$chr['+'] = '131113131';
$chr['%'] = '111313131';
$chr['*'] = '131131311';
$code = strtoupper($code);
if ($extended) {
// extended mode
$code = $this->encode_code39_ext($code);
}
if ($code === false) {
return false;
}
if ($checksum) {
// checksum
$code .= $this->checksum_code39($code);
}
// add start and stop codes
$code = '*'.$code.'*';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$char = $code{$i};
if(!isset($chr[$char])) {
// invalid character
return false;
}
for ($j = 0; $j < 9; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $chr[$char]{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
// intercharacter gap
$bararray['bcode'][$k] = array('t' => false, 'w' => 1, 'h' => 1, 'p' => 0);
$bararray['maxw'] += 1;
++$k;
}
return $bararray;
}
/**
* Encode a string to be used for CODE 39 Extended mode.
* @param $code (string) code to represent.
* @return encoded string.
* @protected
*/
protected function encode_code39_ext($code) {
$encode = array(
chr(0) => '%U', chr(1) => '$A', chr(2) => '$B', chr(3) => '$C',
chr(4) => '$D', chr(5) => '$E', chr(6) => '$F', chr(7) => '$G',
chr(8) => '$H', chr(9) => '$I', chr(10) => '$J', chr(11) => '£K',
chr(12) => '$L', chr(13) => '$M', chr(14) => '$N', chr(15) => '$O',
chr(16) => '$P', chr(17) => '$Q', chr(18) => '$R', chr(19) => '$S',
chr(20) => '$T', chr(21) => '$U', chr(22) => '$V', chr(23) => '$W',
chr(24) => '$X', chr(25) => '$Y', chr(26) => '$Z', chr(27) => '%A',
chr(28) => '%B', chr(29) => '%C', chr(30) => '%D', chr(31) => '%E',
chr(32) => ' ', chr(33) => '/A', chr(34) => '/B', chr(35) => '/C',
chr(36) => '/D', chr(37) => '/E', chr(38) => '/F', chr(39) => '/G',
chr(40) => '/H', chr(41) => '/I', chr(42) => '/J', chr(43) => '/K',
chr(44) => '/L', chr(45) => '-', chr(46) => '.', chr(47) => '/O',
chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3',
chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7',
chr(56) => '8', chr(57) => '9', chr(58) => '/Z', chr(59) => '%F',
chr(60) => '%G', chr(61) => '%H', chr(62) => '%I', chr(63) => '%J',
chr(64) => '%V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G',
chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K',
chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O',
chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S',
chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W',
chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => '%K',
chr(92) => '%L', chr(93) => '%M', chr(94) => '%N', chr(95) => '%O',
chr(96) => '%W', chr(97) => '+A', chr(98) => '+B', chr(99) => '+C',
chr(100) => '+D', chr(101) => '+E', chr(102) => '+F', chr(103) => '+G',
chr(104) => '+H', chr(105) => '+I', chr(106) => '+J', chr(107) => '+K',
chr(108) => '+L', chr(109) => '+M', chr(110) => '+N', chr(111) => '+O',
chr(112) => '+P', chr(113) => '+Q', chr(114) => '+R', chr(115) => '+S',
chr(116) => '+T', chr(117) => '+U', chr(118) => '+V', chr(119) => '+W',
chr(120) => '+X', chr(121) => '+Y', chr(122) => '+Z', chr(123) => '%P',
chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T');
$code_ext = '';
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
if (ord($code{$i}) > 127) {
return false;
}
$code_ext .= $encode[$code{$i}];
}
return $code_ext;
}
/**
* Calculate CODE 39 checksum (modulo 43).
* @param $code (string) code to represent.
* @return char checksum.
* @protected
*/
protected function checksum_code39($code) {
$chars = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
$sum = 0;
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
$k = array_keys($chars, $code{$i});
$sum += $k[0];
}
$j = ($sum % 43);
return $chars[$j];
}
/**
* CODE 93 - USS-93
* Compact code similar to Code 39
* @param $code (string) code to represent.
* @return array barcode representation.
* @protected
*/
protected function barcode_code93($code) {
$chr[48] = '131112'; // 0
$chr[49] = '111213'; // 1
$chr[50] = '111312'; // 2
$chr[51] = '111411'; // 3
$chr[52] = '121113'; // 4
$chr[53] = '121212'; // 5
$chr[54] = '121311'; // 6
$chr[55] = '111114'; // 7
$chr[56] = '131211'; // 8
$chr[57] = '141111'; // 9
$chr[65] = '211113'; // A
$chr[66] = '211212'; // B
$chr[67] = '211311'; // C
$chr[68] = '221112'; // D
$chr[69] = '221211'; // E
$chr[70] = '231111'; // F
$chr[71] = '112113'; // G
$chr[72] = '112212'; // H
$chr[73] = '112311'; // I
$chr[74] = '122112'; // J
$chr[75] = '132111'; // K
$chr[76] = '111123'; // L
$chr[77] = '111222'; // M
$chr[78] = '111321'; // N
$chr[79] = '121122'; // O
$chr[80] = '131121'; // P
$chr[81] = '212112'; // Q
$chr[82] = '212211'; // R
$chr[83] = '211122'; // S
$chr[84] = '211221'; // T
$chr[85] = '221121'; // U
$chr[86] = '222111'; // V
$chr[87] = '112122'; // W
$chr[88] = '112221'; // X
$chr[89] = '122121'; // Y
$chr[90] = '123111'; // Z
$chr[45] = '121131'; // -
$chr[46] = '311112'; // .
$chr[32] = '311211'; //
$chr[36] = '321111'; // $
$chr[47] = '112131'; // /
$chr[43] = '113121'; // +
$chr[37] = '211131'; // %
$chr[128] = '121221'; // ($)
$chr[129] = '311121'; // (/)
$chr[130] = '122211'; // (+)
$chr[131] = '312111'; // (%)
$chr[42] = '111141'; // start-stop
$code = strtoupper($code);
$encode = array(
chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C',
chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G',
chr(8) => chr(128).'H', chr(9) => chr(128).'I', chr(10) => chr(128).'J', chr(11) => '£K',
chr(12) => chr(128).'L', chr(13) => chr(128).'M', chr(14) => chr(128).'N', chr(15) => chr(128).'O',
chr(16) => chr(128).'P', chr(17) => chr(128).'Q', chr(18) => chr(128).'R', chr(19) => chr(128).'S',
chr(20) => chr(128).'T', chr(21) => chr(128).'U', chr(22) => chr(128).'V', chr(23) => chr(128).'W',
chr(24) => chr(128).'X', chr(25) => chr(128).'Y', chr(26) => chr(128).'Z', chr(27) => chr(131).'A',
chr(28) => chr(131).'B', chr(29) => chr(131).'C', chr(30) => chr(131).'D', chr(31) => chr(131).'E',
chr(32) => ' ', chr(33) => chr(129).'A', chr(34) => chr(129).'B', chr(35) => chr(129).'C',
chr(36) => chr(129).'D', chr(37) => chr(129).'E', chr(38) => chr(129).'F', chr(39) => chr(129).'G',
chr(40) => chr(129).'H', chr(41) => chr(129).'I', chr(42) => chr(129).'J', chr(43) => chr(129).'K',
chr(44) => chr(129).'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129).'O',
chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3',
chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7',
chr(56) => '8', chr(57) => '9', chr(58) => chr(129).'Z', chr(59) => chr(131).'F',
chr(60) => chr(131).'G', chr(61) => chr(131).'H', chr(62) => chr(131).'I', chr(63) => chr(131).'J',
chr(64) => chr(131).'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G',
chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K',
chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O',
chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S',
chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W',
chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131).'K',
chr(92) => chr(131).'L', chr(93) => chr(131).'M', chr(94) => chr(131).'N', chr(95) => chr(131).'O',
chr(96) => chr(131).'W', chr(97) => chr(130).'A', chr(98) => chr(130).'B', chr(99) => chr(130).'C',
chr(100) => chr(130).'D', chr(101) => chr(130).'E', chr(102) => chr(130).'F', chr(103) => chr(130).'G',
chr(104) => chr(130).'H', chr(105) => chr(130).'I', chr(106) => chr(130).'J', chr(107) => chr(130).'K',
chr(108) => chr(130).'L', chr(109) => chr(130).'M', chr(110) => chr(130).'N', chr(111) => chr(130).'O',
chr(112) => chr(130).'P', chr(113) => chr(130).'Q', chr(114) => chr(130).'R', chr(115) => chr(130).'S',
chr(116) => chr(130).'T', chr(117) => chr(130).'U', chr(118) => chr(130).'V', chr(119) => chr(130).'W',
chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P',
chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T');
$code_ext = '';
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
if (ord($code{$i}) > 127) {
return false;
}
$code_ext .= $encode[$code{$i}];
}
// checksum
$code_ext .= $this->checksum_code93($code_ext);
// add start and stop codes
$code = '*'.$code_ext.'*';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$char = ord($code{$i});
if(!isset($chr[$char])) {
// invalid character
return false;
}
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $chr[$char]{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
$bararray['bcode'][$k] = array('t' => true, 'w' => 1, 'h' => 1, 'p' => 0);
$bararray['maxw'] += 1;
++$k;
return $bararray;
}
/**
* Calculate CODE 93 checksum (modulo 47).
* @param $code (string) code to represent.
* @return string checksum code.
* @protected
*/
protected function checksum_code93($code) {
$chars = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%',
'<', '=', '>', '?');
// translate special characters
$code = strtr($code, chr(128).chr(131).chr(129).chr(130), '<=>?');
$len = strlen($code);
// calculate check digit C
$p = 1;
$check = 0;
for ($i = ($len - 1); $i >= 0; --$i) {
$k = array_keys($chars, $code{$i});
$check += ($k[0] * $p);
++$p;
if ($p > 20) {
$p = 1;
}
}
$check %= 47;
$c = $chars[$check];
$code .= $c;
// calculate check digit K
$p = 1;
$check = 0;
for ($i = $len; $i >= 0; --$i) {
$k = array_keys($chars, $code{$i});
$check += ($k[0] * $p);
++$p;
if ($p > 15) {
$p = 1;
}
}
$check %= 47;
$k = $chars[$check];
$checksum = $c.$k;
// resto respecial characters
$checksum = strtr($checksum, '<=>?', chr(128).chr(131).chr(129).chr(130));
return $checksum;
}
/**
* Checksum for standard 2 of 5 barcodes.
* @param $code (string) code to process.
* @return int checksum.
* @protected
*/
protected function checksum_s25($code) {
$len = strlen($code);
$sum = 0;
for ($i = 0; $i < $len; $i+=2) {
$sum += $code{$i};
}
$sum *= 3;
for ($i = 1; $i < $len; $i+=2) {
$sum += ($code{$i});
}
$r = $sum % 10;
if($r > 0) {
$r = (10 - $r);
}
return $r;
}
/**
* MSI.
* Variation of Plessey code, with similar applications
* Contains digits (0 to 9) and encodes the data only in the width of bars.
* @param $code (string) code to represent.
* @param $checksum (boolean) if true add a checksum to the code (modulo 11)
* @return array barcode representation.
* @protected
*/
protected function barcode_msi($code, $checksum=false) {
$chr['0'] = '100100100100';
$chr['1'] = '100100100110';
$chr['2'] = '100100110100';
$chr['3'] = '100100110110';
$chr['4'] = '100110100100';
$chr['5'] = '100110100110';
$chr['6'] = '100110110100';
$chr['7'] = '100110110110';
$chr['8'] = '110100100100';
$chr['9'] = '110100100110';
$chr['A'] = '110100110100';
$chr['B'] = '110100110110';
$chr['C'] = '110110100100';
$chr['D'] = '110110100110';
$chr['E'] = '110110110100';
$chr['F'] = '110110110110';
if ($checksum) {
// add checksum
$clen = strlen($code);
$p = 2;
$check = 0;
for ($i = ($clen - 1); $i >= 0; --$i) {
$check += (hexdec($code{$i}) * $p);
++$p;
if ($p > 7) {
$p = 2;
}
}
$check %= 11;
if ($check > 0) {
$check = 11 - $check;
}
$code .= $check;
}
$seq = '110'; // left guard
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$digit = $code{$i};
if (!isset($chr[$digit])) {
// invalid character
return false;
}
$seq .= $chr[$digit];
}
$seq .= '1001'; // right guard
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* Standard 2 of 5 barcodes.
* Used in airline ticket marking, photofinishing
* Contains digits (0 to 9) and encodes the data only in the width of bars.
* @param $code (string) code to represent.
* @param $checksum (boolean) if true add a checksum to the code
* @return array barcode representation.
* @protected
*/
protected function barcode_s25($code, $checksum=false) {
$chr['0'] = '10101110111010';
$chr['1'] = '11101010101110';
$chr['2'] = '10111010101110';
$chr['3'] = '11101110101010';
$chr['4'] = '10101110101110';
$chr['5'] = '11101011101010';
$chr['6'] = '10111011101010';
$chr['7'] = '10101011101110';
$chr['8'] = '10101110111010';
$chr['9'] = '10111010111010';
if ($checksum) {
// add checksum
$code .= $this->checksum_s25($code);
}
if((strlen($code) % 2) != 0) {
// add leading zero if code-length is odd
$code = '0'.$code;
}
$seq = '11011010';
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$digit = $code{$i};
if (!isset($chr[$digit])) {
// invalid character
return false;
}
$seq .= $chr[$digit];
}
$seq .= '1101011';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* Convert binary barcode sequence to TCPDF barcode array.
* @param $seq (string) barcode as binary sequence.
* @param $bararray (array) barcode array.
* òparam array $bararray TCPDF barcode array to fill up
* @return array barcode representation.
* @protected
*/
protected function binseq_to_array($seq, $bararray) {
$len = strlen($seq);
$w = 0;
$k = 0;
for ($i = 0; $i < $len; ++$i) {
$w += 1;
if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
if ($seq{$i} == '1') {
$t = true; // bar
} else {
$t = false; // space
}
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
$w = 0;
}
}
return $bararray;
}
/**
* Interleaved 2 of 5 barcodes.
* Compact numeric code, widely used in industry, air cargo
* Contains digits (0 to 9) and encodes the data in the width of both bars and spaces.
* @param $code (string) code to represent.
* @param $checksum (boolean) if true add a checksum to the code
* @return array barcode representation.
* @protected
*/
protected function barcode_i25($code, $checksum=false) {
$chr['0'] = '11221';
$chr['1'] = '21112';
$chr['2'] = '12112';
$chr['3'] = '22111';
$chr['4'] = '11212';
$chr['5'] = '21211';
$chr['6'] = '12211';
$chr['7'] = '11122';
$chr['8'] = '21121';
$chr['9'] = '12121';
$chr['A'] = '11';
$chr['Z'] = '21';
if ($checksum) {
// add checksum
$code .= $this->checksum_s25($code);
}
if((strlen($code) % 2) != 0) {
// add leading zero if code-length is odd
$code = '0'.$code;
}
// add start and stop codes
$code = 'AA'.strtolower($code).'ZA';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; $i = ($i + 2)) {
$char_bar = $code{$i};
$char_space = $code{$i+1};
if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
// invalid character
return false;
}
// create a bar-space sequence
$seq = '';
$chrlen = strlen($chr[$char_bar]);
for ($s = 0; $s < $chrlen; $s++){
$seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s};
}
$seqlen = strlen($seq);
for ($j = 0; $j < $seqlen; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* C128 barcodes.
* Very capable code, excellent density, high reliability; in very wide use world-wide
* @param $code (string) code to represent.
* @param $type (string) barcode type: A, B, C or empty for automatic switch (AUTO mode)
* @return array barcode representation.
* @protected
*/
protected function barcode_c128($code, $type='') {
$chr = array(
'212222', /* 00 */
'222122', /* 01 */
'222221', /* 02 */
'121223', /* 03 */
'121322', /* 04 */
'131222', /* 05 */
'122213', /* 06 */
'122312', /* 07 */
'132212', /* 08 */
'221213', /* 09 */
'221312', /* 10 */
'231212', /* 11 */
'112232', /* 12 */
'122132', /* 13 */
'122231', /* 14 */
'113222', /* 15 */
'123122', /* 16 */
'123221', /* 17 */
'223211', /* 18 */
'221132', /* 19 */
'221231', /* 20 */
'213212', /* 21 */
'223112', /* 22 */
'312131', /* 23 */
'311222', /* 24 */
'321122', /* 25 */
'321221', /* 26 */
'312212', /* 27 */
'322112', /* 28 */
'322211', /* 29 */
'212123', /* 30 */
'212321', /* 31 */
'232121', /* 32 */
'111323', /* 33 */
'131123', /* 34 */
'131321', /* 35 */
'112313', /* 36 */
'132113', /* 37 */
'132311', /* 38 */
'211313', /* 39 */
'231113', /* 40 */
'231311', /* 41 */
'112133', /* 42 */
'112331', /* 43 */
'132131', /* 44 */
'113123', /* 45 */
'113321', /* 46 */
'133121', /* 47 */
'313121', /* 48 */
'211331', /* 49 */
'231131', /* 50 */
'213113', /* 51 */
'213311', /* 52 */
'213131', /* 53 */
'311123', /* 54 */
'311321', /* 55 */
'331121', /* 56 */
'312113', /* 57 */
'312311', /* 58 */
'332111', /* 59 */
'314111', /* 60 */
'221411', /* 61 */
'431111', /* 62 */
'111224', /* 63 */
'111422', /* 64 */
'121124', /* 65 */
'121421', /* 66 */
'141122', /* 67 */
'141221', /* 68 */
'112214', /* 69 */
'112412', /* 70 */
'122114', /* 71 */
'122411', /* 72 */
'142112', /* 73 */
'142211', /* 74 */
'241211', /* 75 */
'221114', /* 76 */
'413111', /* 77 */
'241112', /* 78 */
'134111', /* 79 */
'111242', /* 80 */
'121142', /* 81 */
'121241', /* 82 */
'114212', /* 83 */
'124112', /* 84 */
'124211', /* 85 */
'411212', /* 86 */
'421112', /* 87 */
'421211', /* 88 */
'212141', /* 89 */
'214121', /* 90 */
'412121', /* 91 */
'111143', /* 92 */
'111341', /* 93 */
'131141', /* 94 */
'114113', /* 95 */
'114311', /* 96 */
'411113', /* 97 */
'411311', /* 98 */
'113141', /* 99 */
'114131', /* 100 */
'311141', /* 101 */
'411131', /* 102 */
'211412', /* 103 START A */
'211214', /* 104 START B */
'211232', /* 105 START C */
'233111', /* STOP */
'200000' /* END */
);
// ASCII characters for code A (ASCII 00 - 95)
$keys_a = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
$keys_a .= chr(0).chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8).chr(9);
$keys_a .= chr(10).chr(11).chr(12).chr(13).chr(14).chr(15).chr(16).chr(17).chr(18).chr(19);
$keys_a .= chr(20).chr(21).chr(22).chr(23).chr(24).chr(25).chr(26).chr(27).chr(28).chr(29);
$keys_a .= chr(30).chr(31);
// ASCII characters for code B (ASCII 32 - 127)
$keys_b = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127);
// special codes
$fnc_a = array(241 => 102, 242 => 97, 243 => 96, 244 => 101);
$fnc_b = array(241 => 102, 242 => 97, 243 => 96, 244 => 100);
// array of symbols
$code_data = array();
// lenght of the code
$len = strlen($code);
switch(strtoupper($type)) {
case 'A': { // MODE A
$startid = 103;
for ($i = 0; $i < $len; ++$i) {
$char = $code{$i};
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_a[$char_id];
} elseif (($char_id >= 0) AND ($char_id <= 95)) {
$code_data[] = strpos($keys_a, $char);
} else {
return false;
}
}
break;
}
case 'B': { // MODE B
$startid = 104;
for ($i = 0; $i < $len; ++$i) {
$char = $code{$i};
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_b[$char_id];
} elseif (($char_id >= 32) AND ($char_id <= 127)) {
$code_data[] = strpos($keys_b, $char);
} else {
return false;
}
}
break;
}
case 'C': { // MODE C
$startid = 105;
if (ord($code{0}) == 241) {
$code_data[] = 102;
$code = substr($code, 1);
--$len;
}
if (($len % 2) != 0) {
// the length must be even
return false;
}
for ($i = 0; $i < $len; $i+=2) {
$chrnum = $code{$i}.$code{$i+1};
if (preg_match('/([0-9]{2})/', $chrnum) > 0) {
$code_data[] = intval($chrnum);
} else {
return false;
}
}
break;
}
default: { // MODE AUTO
// split code into sequences
$sequence = array();
// get numeric sequences (if any)
$numseq = array();
preg_match_all('/([0-9]{4,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
if (isset($numseq[1]) AND !empty($numseq[1])) {
$end_offset = 0;
foreach ($numseq[1] as $val) {
$offset = $val[1];
if ($offset > $end_offset) {
// non numeric sequence
$sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset, ($offset - $end_offset))));
}
// numeric sequence
$slen = strlen($val[0]);
if (($slen % 2) != 0) {
// the length must be even
--$slen;
}
$sequence[] = array('C', substr($code, $offset, $slen), $slen);
$end_offset = $offset + $slen;
}
if ($end_offset < $len) {
$sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset)));
}
} else {
// text code (non C mode)
$sequence = array_merge($sequence, $this->get128ABsequence($code));
}
// process the sequence
foreach ($sequence as $key => $seq) {
switch($seq[0]) {
case 'A': {
if ($key == 0) {
$startid = 103;
} elseif ($sequence[($key - 1)][0] != 'A') {
if (($seq[2] == 1) AND ($key > 0) AND ($sequence[($key - 1)][0] == 'B') AND (!isset($sequence[($key - 1)][3]))) {
// single character shift
$code_data[] = 98;
// mark shift
$sequence[$key][3] = true;
} elseif (!isset($sequence[($key - 1)][3])) {
$code_data[] = 101;
}
}
for ($i = 0; $i < $seq[2]; ++$i) {
$char = $seq[1]{$i};
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_a[$char_id];
} else {
$code_data[] = strpos($keys_a, $char);
}
}
break;
}
case 'B': {
if ($key == 0) {
$tmpchr = ord($seq[1]{0});
if (($seq[2] == 1) AND ($tmpchr >= 241) AND ($tmpchr <= 244) AND isset($sequence[($key + 1)]) AND ($sequence[($key + 1)][0] != 'B')) {
switch ($sequence[($key + 1)][0]) {
case 'A': {
$startid = 103;
$sequence[$key][0] = 'A';
$code_data[] = $fnc_a[$tmpchr];
break;
}
case 'C': {
$startid = 105;
$sequence[$key][0] = 'C';
$code_data[] = $fnc_a[$tmpchr];
break;
}
}
break;
} else {
$startid = 104;
}
} elseif ($sequence[($key - 1)][0] != 'B') {
if (($seq[2] == 1) AND ($key > 0) AND ($sequence[($key - 1)][0] == 'A') AND (!isset($sequence[($key - 1)][3]))) {
// single character shift
$code_data[] = 98;
// mark shift
$sequence[$key][3] = true;
} elseif (!isset($sequence[($key - 1)][3])) {
$code_data[] = 100;
}
}
for ($i = 0; $i < $seq[2]; ++$i) {
$char = $seq[1]{$i};
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_b[$char_id];
} else {
$code_data[] = strpos($keys_b, $char);
}
}
break;
}
case 'C': {
if ($key == 0) {
$startid = 105;
} elseif ($sequence[($key - 1)][0] != 'C') {
$code_data[] = 99;
}
for ($i = 0; $i < $seq[2]; $i+=2) {
$chrnum = $seq[1]{$i}.$seq[1]{$i+1};
$code_data[] = intval($chrnum);
}
break;
}
}
}
}
}
// calculate check character
$sum = $startid;
foreach ($code_data as $key => $val) {
$sum += ($val * ($key + 1));
}
// add check character
$code_data[] = ($sum % 103);
// add stop sequence
$code_data[] = 106;
$code_data[] = 107;
// add start code at the beginning
array_unshift($code_data, $startid);
// build barcode array
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
foreach ($code_data as $val) {
$seq = $chr[$val];
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
}
}
return $bararray;
}
/**
* Split text code in A/B sequence for 128 code
* @param $code (string) code to split.
* @return array sequence
* @protected
*/
protected function get128ABsequence($code) {
$len = strlen($code);
$sequence = array();
// get A sequences (if any)
$numseq = array();
preg_match_all('/([\0-\31])/', $code, $numseq, PREG_OFFSET_CAPTURE);
if (isset($numseq[1]) AND !empty($numseq[1])) {
$end_offset = 0;
foreach ($numseq[1] as $val) {
$offset = $val[1];
if ($offset > $end_offset) {
// B sequence
$sequence[] = array('B', substr($code, $end_offset, ($offset - $end_offset)), ($offset - $end_offset));
}
// A sequence
$slen = strlen($val[0]);
$sequence[] = array('A', substr($code, $offset, $slen), $slen);
$end_offset = $offset + $slen;
}
if ($end_offset < $len) {
$sequence[] = array('B', substr($code, $end_offset), ($len - $end_offset));
}
} else {
// only B sequence
$sequence[] = array('B', $code, $len);
}
return $sequence;
}
/**
* EAN13 and UPC-A barcodes.
* EAN13: European Article Numbering international retail product code
* UPC-A: Universal product code seen on almost all retail products in the USA and Canada
* UPC-E: Short version of UPC symbol
* @param $code (string) code to represent.
* @param $len (string) barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
* @return array barcode representation.
* @protected
*/
protected function barcode_eanupc($code, $len=13) {
$upce = false;
if ($len == 6) {
$len = 12; // UPC-A
$upce = true; // UPC-E mode
}
$data_len = $len - 1;
//Padding
$code = str_pad($code, $data_len, '0', STR_PAD_LEFT);
$code_len = strlen($code);
// calculate check digit
$sum_a = 0;
for ($i = 1; $i < $data_len; $i+=2) {
$sum_a += $code{$i};
}
if ($len > 12) {
$sum_a *= 3;
}
$sum_b = 0;
for ($i = 0; $i < $data_len; $i+=2) {
$sum_b += ($code{$i});
}
if ($len < 13) {
$sum_b *= 3;
}
$r = ($sum_a + $sum_b) % 10;
if($r > 0) {
$r = (10 - $r);
}
if ($code_len == $data_len) {
// add check digit
$code .= $r;
} elseif ($r !== intval($code{$data_len})) {
// wrong checkdigit
return false;
}
if ($len == 12) {
// UPC-A
$code = '0'.$code;
++$len;
}
if ($upce) {
// convert UPC-A to UPC-E
$tmp = substr($code, 4, 3);
if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) {
// manufacturer code ends in 000, 100, or 200
$upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
} else {
$tmp = substr($code, 5, 2);
if ($tmp == '00') {
// manufacturer code ends in 00
$upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
} else {
$tmp = substr($code, 6, 1);
if ($tmp == '0') {
// manufacturer code ends in 0
$upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
} else {
// manufacturer code does not end in zero
$upce_code = substr($code, 2, 5).substr($code, 11, 1);
}
}
}
}
//Convert digits to bars
$codes = array(
'A'=>array( // left odd parity
'0'=>'0001101',
'1'=>'0011001',
'2'=>'0010011',
'3'=>'0111101',
'4'=>'0100011',
'5'=>'0110001',
'6'=>'0101111',
'7'=>'0111011',
'8'=>'0110111',
'9'=>'0001011'),
'B'=>array( // left even parity
'0'=>'0100111',
'1'=>'0110011',
'2'=>'0011011',
'3'=>'0100001',
'4'=>'0011101',
'5'=>'0111001',
'6'=>'0000101',
'7'=>'0010001',
'8'=>'0001001',
'9'=>'0010111'),
'C'=>array( // right
'0'=>'1110010',
'1'=>'1100110',
'2'=>'1101100',
'3'=>'1000010',
'4'=>'1011100',
'5'=>'1001110',
'6'=>'1010000',
'7'=>'1000100',
'8'=>'1001000',
'9'=>'1110100')
);
$parities = array(
'0'=>array('A','A','A','A','A','A'),
'1'=>array('A','A','B','A','B','B'),
'2'=>array('A','A','B','B','A','B'),
'3'=>array('A','A','B','B','B','A'),
'4'=>array('A','B','A','A','B','B'),
'5'=>array('A','B','B','A','A','B'),
'6'=>array('A','B','B','B','A','A'),
'7'=>array('A','B','A','B','A','B'),
'8'=>array('A','B','A','B','B','A'),
'9'=>array('A','B','B','A','B','A')
);
$upce_parities = array();
$upce_parities[0] = array(
'0'=>array('B','B','B','A','A','A'),
'1'=>array('B','B','A','B','A','A'),
'2'=>array('B','B','A','A','B','A'),
'3'=>array('B','B','A','A','A','B'),
'4'=>array('B','A','B','B','A','A'),
'5'=>array('B','A','A','B','B','A'),
'6'=>array('B','A','A','A','B','B'),
'7'=>array('B','A','B','A','B','A'),
'8'=>array('B','A','B','A','A','B'),
'9'=>array('B','A','A','B','A','B')
);
$upce_parities[1] = array(
'0'=>array('A','A','A','B','B','B'),
'1'=>array('A','A','B','A','B','B'),
'2'=>array('A','A','B','B','A','B'),
'3'=>array('A','A','B','B','B','A'),
'4'=>array('A','B','A','A','B','B'),
'5'=>array('A','B','B','A','A','B'),
'6'=>array('A','B','B','B','A','A'),
'7'=>array('A','B','A','B','A','B'),
'8'=>array('A','B','A','B','B','A'),
'9'=>array('A','B','B','A','B','A')
);
$k = 0;
$seq = '101'; // left guard bar
if ($upce) {
$bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$p = $upce_parities[$code{1}][$r];
for ($i = 0; $i < 6; ++$i) {
$seq .= $codes[$p[$i]][$upce_code{$i}];
}
$seq .= '010101'; // right guard bar
} else {
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$half_len = ceil($len / 2);
if ($len == 8) {
for ($i = 0; $i < $half_len; ++$i) {
$seq .= $codes['A'][$code{$i}];
}
} else {
$p = $parities[$code{0}];
for ($i = 1; $i < $half_len; ++$i) {
$seq .= $codes[$p[$i-1]][$code{$i}];
}
}
$seq .= '01010'; // center guard bar
for ($i = $half_len; $i < $len; ++$i) {
$seq .= $codes['C'][$code{$i}];
}
$seq .= '101'; // right guard bar
}
$clen = strlen($seq);
$w = 0;
for ($i = 0; $i < $clen; ++$i) {
$w += 1;
if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
if ($seq{$i} == '1') {
$t = true; // bar
} else {
$t = false; // space
}
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
$w = 0;
}
}
return $bararray;
}
/**
* UPC-Based Extentions
* 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers
* 5-Digit Ext.: Used to mark suggested retail price of books
* @param $code (string) code to represent.
* @param $len (string) barcode type: 2 = 2-Digit, 5 = 5-Digit
* @return array barcode representation.
* @protected
*/
protected function barcode_eanext($code, $len=5) {
//Padding
$code = str_pad($code, $len, '0', STR_PAD_LEFT);
// calculate check digit
if ($len == 2) {
$r = $code % 4;
} elseif ($len == 5) {
$r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3}));
$r %= 10;
} else {
return false;
}
//Convert digits to bars
$codes = array(
'A'=>array( // left odd parity
'0'=>'0001101',
'1'=>'0011001',
'2'=>'0010011',
'3'=>'0111101',
'4'=>'0100011',
'5'=>'0110001',
'6'=>'0101111',
'7'=>'0111011',
'8'=>'0110111',
'9'=>'0001011'),
'B'=>array( // left even parity
'0'=>'0100111',
'1'=>'0110011',
'2'=>'0011011',
'3'=>'0100001',
'4'=>'0011101',
'5'=>'0111001',
'6'=>'0000101',
'7'=>'0010001',
'8'=>'0001001',
'9'=>'0010111')
);
$parities = array();
$parities[2] = array(
'0'=>array('A','A'),
'1'=>array('A','B'),
'2'=>array('B','A'),
'3'=>array('B','B')
);
$parities[5] = array(
'0'=>array('B','B','A','A','A'),
'1'=>array('B','A','B','A','A'),
'2'=>array('B','A','A','B','A'),
'3'=>array('B','A','A','A','B'),
'4'=>array('A','B','B','A','A'),
'5'=>array('A','A','B','B','A'),
'6'=>array('A','A','A','B','B'),
'7'=>array('A','B','A','B','A'),
'8'=>array('A','B','A','A','B'),
'9'=>array('A','A','B','A','B')
);
$p = $parities[$len][$r];
$seq = '1011'; // left guard bar
$seq .= $codes[$p[0]][$code{0}];
for ($i = 1; $i < $len; ++$i) {
$seq .= '01'; // separator
$seq .= $codes[$p[$i]][$code{$i}];
}
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* POSTNET and PLANET barcodes.
* Used by U.S. Postal Service for automated mail sorting
* @param $code (string) zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD.
* @param $planet (boolean) if true print the PLANET barcode, otherwise print POSTNET
* @return array barcode representation.
* @protected
*/
protected function barcode_postnet($code, $planet=false) {
// bar lenght
if ($planet) {
$barlen = Array(
0 => Array(1,1,2,2,2),
1 => Array(2,2,2,1,1),
2 => Array(2,2,1,2,1),
3 => Array(2,2,1,1,2),
4 => Array(2,1,2,2,1),
5 => Array(2,1,2,1,2),
6 => Array(2,1,1,2,2),
7 => Array(1,2,2,2,1),
8 => Array(1,2,2,1,2),
9 => Array(1,2,1,2,2)
);
} else {
$barlen = Array(
0 => Array(2,2,1,1,1),
1 => Array(1,1,1,2,2),
2 => Array(1,1,2,1,2),
3 => Array(1,1,2,2,1),
4 => Array(1,2,1,1,2),
5 => Array(1,2,1,2,1),
6 => Array(1,2,2,1,1),
7 => Array(2,1,1,1,2),
8 => Array(2,1,1,2,1),
9 => Array(2,1,2,1,1)
);
}
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
$k = 0;
$code = str_replace('-', '', $code);
$code = str_replace(' ', '', $code);
$len = strlen($code);
// calculate checksum
$sum = 0;
for ($i = 0; $i < $len; ++$i) {
$sum += intval($code{$i});
}
$chkd = ($sum % 10);
if($chkd > 0) {
$chkd = (10 - $chkd);
}
$code .= $chkd;
$len = strlen($code);
// start bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
for ($i = 0; $i < $len; ++$i) {
for ($j = 0; $j < 5; ++$j) {
$h = $barlen[$code{$i}][$j];
$p = floor(1 / $h);
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
}
// end bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 1;
return $bararray;
}
/**
* RMS4CC - CBC - KIX
* RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index)
* RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.
* @param $code (string) code to print
* @param $kix (boolean) if true prints the KIX variation (doesn't use the start and end symbols, and the checksum) - in this case the house number must be sufficed with an X and placed at the end of the code.
* @return array barcode representation.
* @protected
*/
protected function barcode_rms4cc($code, $kix=false) {
$notkix = !$kix;
// bar mode
// 1 = pos 1, length 2
// 2 = pos 1, length 3
// 3 = pos 2, length 1
// 4 = pos 2, length 2
$barmode = array(
'0' => array(3,3,2,2),
'1' => array(3,4,1,2),
'2' => array(3,4,2,1),
'3' => array(4,3,1,2),
'4' => array(4,3,2,1),
'5' => array(4,4,1,1),
'6' => array(3,1,4,2),
'7' => array(3,2,3,2),
'8' => array(3,2,4,1),
'9' => array(4,1,3,2),
'A' => array(4,1,4,1),
'B' => array(4,2,3,1),
'C' => array(3,1,2,4),
'D' => array(3,2,1,4),
'E' => array(3,2,2,3),
'F' => array(4,1,1,4),
'G' => array(4,1,2,3),
'H' => array(4,2,1,3),
'I' => array(1,3,4,2),
'J' => array(1,4,3,2),
'K' => array(1,4,4,1),
'L' => array(2,3,3,2),
'M' => array(2,3,4,1),
'N' => array(2,4,3,1),
'O' => array(1,3,2,4),
'P' => array(1,4,1,4),
'Q' => array(1,4,2,3),
'R' => array(2,3,1,4),
'S' => array(2,3,2,3),
'T' => array(2,4,1,3),
'U' => array(1,1,4,4),
'V' => array(1,2,3,4),
'W' => array(1,2,4,3),
'X' => array(2,1,3,4),
'Y' => array(2,1,4,3),
'Z' => array(2,2,3,3)
);
$code = strtoupper($code);
$len = strlen($code);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
if ($notkix) {
// table for checksum calculation (row,col)
$checktable = array(
'0' => array(1,1),
'1' => array(1,2),
'2' => array(1,3),
'3' => array(1,4),
'4' => array(1,5),
'5' => array(1,0),
'6' => array(2,1),
'7' => array(2,2),
'8' => array(2,3),
'9' => array(2,4),
'A' => array(2,5),
'B' => array(2,0),
'C' => array(3,1),
'D' => array(3,2),
'E' => array(3,3),
'F' => array(3,4),
'G' => array(3,5),
'H' => array(3,0),
'I' => array(4,1),
'J' => array(4,2),
'K' => array(4,3),
'L' => array(4,4),
'M' => array(4,5),
'N' => array(4,0),
'O' => array(5,1),
'P' => array(5,2),
'Q' => array(5,3),
'R' => array(5,4),
'S' => array(5,5),
'T' => array(5,0),
'U' => array(0,1),
'V' => array(0,2),
'W' => array(0,3),
'X' => array(0,4),
'Y' => array(0,5),
'Z' => array(0,0)
);
$row = 0;
$col = 0;
for ($i = 0; $i < $len; ++$i) {
$row += $checktable[$code{$i}][0];
$col += $checktable[$code{$i}][1];
}
$row %= 6;
$col %= 6;
$chk = array_keys($checktable, array($row,$col));
$code .= $chk[0];
++$len;
}
$k = 0;
if ($notkix) {
// start bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
for ($i = 0; $i < $len; ++$i) {
for ($j = 0; $j < 4; ++$j) {
switch ($barmode[$code{$i}][$j]) {
case 1: {
$p = 0;
$h = 2;
break;
}
case 2: {
$p = 0;
$h = 3;
break;
}
case 3: {
$p = 1;
$h = 1;
break;
}
case 4: {
$p = 1;
$h = 2;
break;
}
}
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
}
if ($notkix) {
// stop bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 3, 'p' => 0);
$bararray['maxw'] += 1;
}
return $bararray;
}
/**
* CODABAR barcodes.
* Older code often used in library systems, sometimes in blood banks
* @param $code (string) code to represent.
* @return array barcode representation.
* @protected
*/
protected function barcode_codabar($code) {
$chr = array(
'0' => '11111221',
'1' => '11112211',
'2' => '11121121',
'3' => '22111111',
'4' => '11211211',
'5' => '21111211',
'6' => '12111121',
'7' => '12112111',
'8' => '12211111',
'9' => '21121111',
'-' => '11122111',
'$' => '11221111',
':' => '21112121',
'/' => '21211121',
'.' => '21212111',
'+' => '11222221',
'A' => '11221211',
'B' => '12121121',
'C' => '11121221',
'D' => '11122211'
);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$w = 0;
$seq = '';
$code = 'A'.strtoupper($code).'A';
$len = strlen($code);
for ($i = 0; $i < $len; ++$i) {
if (!isset($chr[$code{$i}])) {
return false;
}
$seq = $chr[$code{$i}];
for ($j = 0; $j < 8; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* CODE11 barcodes.
* Used primarily for labeling telecommunications equipment
* @param $code (string) code to represent.
* @return array barcode representation.
* @protected
*/
protected function barcode_code11($code) {
$chr = array(
'0' => '111121',
'1' => '211121',
'2' => '121121',
'3' => '221111',
'4' => '112121',
'5' => '212111',
'6' => '122111',
'7' => '111221',
'8' => '211211',
'9' => '211111',
'-' => '112111',
'S' => '112211'
);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$w = 0;
$seq = '';
$len = strlen($code);
// calculate check digit C
$p = 1;
$check = 0;
for ($i = ($len - 1); $i >= 0; --$i) {
$digit = $code{$i};
if ($digit == '-') {
$dval = 10;
} else {
$dval = intval($digit);
}
$check += ($dval * $p);
++$p;
if ($p > 10) {
$p = 1;
}
}
$check %= 11;
if ($check == 10) {
$check = '-';
}
$code .= $check;
if ($len > 10) {
// calculate check digit K
$p = 1;
$check = 0;
for ($i = $len; $i >= 0; --$i) {
$digit = $code{$i};
if ($digit == '-') {
$dval = 10;
} else {
$dval = intval($digit);
}
$check += ($dval * $p);
++$p;
if ($p > 9) {
$p = 1;
}
}
$check %= 11;
$code .= $check;
++$len;
}
$code = 'S'.$code.'S';
$len += 3;
for ($i = 0; $i < $len; ++$i) {
if (!isset($chr[$code{$i}])) {
return false;
}
$seq = $chr[$code{$i}];
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* Pharmacode
* Contains digits (0 to 9)
* @param $code (string) code to represent.
* @return array barcode representation.
* @protected
*/
protected function barcode_pharmacode($code) {
$seq = '';
$code = intval($code);
while ($code > 0) {
if (($code % 2) == 0) {
$seq .= '11100';
$code -= 2;
} else {
$seq .= '100';
$code -= 1;
}
$code /= 2;
}
$seq = substr($seq, 0, -2);
$seq = strrev($seq);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* Pharmacode two-track
* Contains digits (0 to 9)
* @param $code (string) code to represent.
* @return array barcode representation.
* @protected
*/
protected function barcode_pharmacode2t($code) {
$seq = '';
$code = intval($code);
do {
switch ($code % 3) {
case 0: {
$seq .= '3';
$code = ($code - 3) / 3;
break;
}
case 1: {
$seq .= '1';
$code = ($code - 1) / 3;
break;
}
case 2: {
$seq .= '2';
$code = ($code - 2) / 3;
break;
}
}
} while($code != 0);
$seq = strrev($seq);
$k = 0;
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
$len = strlen($seq);
for ($i = 0; $i < $len; ++$i) {
switch ($seq{$i}) {
case '1': {
$p = 1;
$h = 1;
break;
}
case '2': {
$p = 0;
$h = 1;
break;
}
case '3': {
$p = 0;
$h = 2;
break;
}
}
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
unset($bararray['bcode'][($k - 1)]);
--$bararray['maxw'];
return $bararray;
}
/**
* IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
* (requires PHP bcmath extension)
* Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
* The fields are described as follows:<ul><li>The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This shall be two digits, with the second digit in the range of 0–4. The allowable encoding ranges shall be 00–04, 10–14, 20–24, 30–34, 40–44, 50–54, 60–64, 70–74, 80–84, and 90–94.</li><li>The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. The allowable encoding range shall be 000http://it2.php.net/manual/en/function.dechex.php–999. Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier values.</li><li>The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999.</li><li>The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. The allowable encoding range shall be 000000000–999999999 when used with a 6 digit Mailer ID and 000000-999999 when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000–99999, 000000000–999999999, and 00000000000–99999999999.</li></ul>
* @param $code (string) code to print, separate the ZIP (routing code) from the rest using a minus char '-' (BarcodeID_ServiceTypeID_MailerID_SerialNumber-RoutingCode)
* @return array barcode representation.
* @protected
*/
protected function barcode_imb($code) {
$asc_chr = array(4,0,2,6,3,5,1,9,8,7,1,2,0,6,4,8,2,9,5,3,0,1,3,7,4,6,8,9,2,0,5,1,9,4,3,8,6,7,1,2,4,3,9,5,7,8,3,0,2,1,4,0,9,1,7,0,2,4,6,3,7,1,9,5,8);
$dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
$asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
$dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
$code_arr = explode('-', $code);
$tracking_number = $code_arr[0];
if (isset($code_arr[1])) {
$routing_code = $code_arr[1];
} else {
$routing_code = '';
}
// Conversion of Routing Code
switch (strlen($routing_code)) {
case 0: {
$binary_code = 0;
break;
}
case 5: {
$binary_code = bcadd($routing_code, '1');
break;
}
case 9: {
$binary_code = bcadd($routing_code, '100001');
break;
}
case 11: {
$binary_code = bcadd($routing_code, '1000100001');
break;
}
default: {
return false;
break;
}
}
$binary_code = bcmul($binary_code, 10);
$binary_code = bcadd($binary_code, $tracking_number{0});
$binary_code = bcmul($binary_code, 5);
$binary_code = bcadd($binary_code, $tracking_number{1});
$binary_code .= substr($tracking_number, 2, 18);
// convert to hexadecimal
$binary_code = $this->dec_to_hex($binary_code);
// pad to get 13 bytes
$binary_code = str_pad($binary_code, 26, '0', STR_PAD_LEFT);
// convert string to array of bytes
$binary_code_arr = chunk_split($binary_code, 2, "\r");
$binary_code_arr = substr($binary_code_arr, 0, -1);
$binary_code_arr = explode("\r", $binary_code_arr);
// calculate frame check sequence
$fcs = $this->imb_crc11fcs($binary_code_arr);
// exclude first 2 bits from first byte
$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
$binary_code_102bit = $first_byte.substr($binary_code, 2);
// convert binary data to codewords
$codewords = array();
$data = $this->hex_to_dec($binary_code_102bit);
$codewords[0] = bcmod($data, 636) * 2;
$data = bcdiv($data, 636);
for ($i = 1; $i < 9; ++$i) {
$codewords[$i] = bcmod($data, 1365);
$data = bcdiv($data, 1365);
}
$codewords[9] = $data;
if (($fcs >> 10) == 1) {
$codewords[9] += 659;
}
// generate lookup tables
$table2of13 = $this->imb_tables(2, 78);
$table5of13 = $this->imb_tables(5, 1287);
// convert codewords to characters
$characters = array();
$bitmask = 512;
foreach($codewords as $k => $val) {
if ($val <= 1286) {
$chrcode = $table5of13[$val];
} else {
$chrcode = $table2of13[($val - 1287)];
}
if (($fcs & $bitmask) > 0) {
// bitwise invert
$chrcode = ((~$chrcode) & 8191);
}
$characters[] = $chrcode;
$bitmask /= 2;
}
$characters = array_reverse($characters);
// build bars
$k = 0;
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
for ($i = 0; $i < 65; ++$i) {
$asc = (($characters[$asc_chr[$i]] & pow(2, $asc_pos[$i])) > 0);
$dsc = (($characters[$dsc_chr[$i]] & pow(2, $dsc_pos[$i])) > 0);
if ($asc AND $dsc) {
// full bar (F)
$p = 0;
$h = 3;
} elseif ($asc) {
// ascender (A)
$p = 0;
$h = 2;
} elseif ($dsc) {
// descender (D)
$p = 1;
$h = 2;
} else {
// tracker (T)
$p = 1;
$h = 1;
}
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
unset($bararray['bcode'][($k - 1)]);
--$bararray['maxw'];
return $bararray;
}
/**
* Convert large integer number to hexadecimal representation.
* (requires PHP bcmath extension)
* @param $number (string) number to convert specified as a string
* @return string hexadecimal representation
*/
public function dec_to_hex($number) {
$i = 0;
$hex = array();
if($number == 0) {
return '00';
}
while($number > 0) {
if($number == 0) {
array_push($hex, '0');
} else {
array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
$number = bcdiv($number, '16', 0);
}
}
$hex = array_reverse($hex);
return implode($hex);
}
/**
* Convert large hexadecimal number to decimal representation (string).
* (requires PHP bcmath extension)
* @param $hex (string) hexadecimal number to convert specified as a string
* @return string hexadecimal representation
*/
public function hex_to_dec($hex) {
$dec = 0;
$bitval = 1;
$len = strlen($hex);
for($pos = ($len - 1); $pos >= 0; --$pos) {
$dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
$bitval = bcmul($bitval, 16);
}
return $dec;
}
/**
* Intelligent Mail Barcode calculation of Frame Check Sequence
* @param $code_arr (string) array of hexadecimal values (13 bytes holding 102 bits right justified).
* @return int 11 bit Frame Check Sequence as integer (decimal base)
* @protected
*/
protected function imb_crc11fcs($code_arr) {
$genpoly = 0x0F35; // generator polynomial
$fcs = 0x07FF; // Frame Check Sequence
// do most significant byte skipping the 2 most significant bits
$data = hexdec($code_arr[0]) << 5;
for ($bit = 2; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = ($fcs << 1) ^ $genpoly;
} else {
$fcs = ($fcs << 1);
}
$fcs &= 0x7FF;
$data <<= 1;
}
// do rest of bytes
for ($byte = 1; $byte < 13; ++$byte) {
$data = hexdec($code_arr[$byte]) << 3;
for ($bit = 0; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = ($fcs << 1) ^ $genpoly;
} else {
$fcs = ($fcs << 1);
}
$fcs &= 0x7FF;
$data <<= 1;
}
}
return $fcs;
}
/**
* Reverse unsigned short value
* @param $num (int) value to reversr
* @return int reversed value
* @protected
*/
protected function imb_reverse_us($num) {
$rev = 0;
for ($i = 0; $i < 16; ++$i) {
$rev <<= 1;
$rev |= ($num & 1);
$num >>= 1;
}
return $rev;
}
/**
* generate Nof13 tables used for Intelligent Mail Barcode
* @param $n (int) is the type of table: 2 for 2of13 table, 5 for 5of13table
* @param $size (int) size of table (78 for n=2 and 1287 for n=5)
* @return array requested table
* @protected
*/
protected function imb_tables($n, $size) {
$table = array();
$lli = 0; // LUT lower index
$lui = $size - 1; // LUT upper index
for ($count = 0; $count < 8192; ++$count) {
$bit_count = 0;
for ($bit_index = 0; $bit_index < 13; ++$bit_index) {
$bit_count += intval(($count & (1 << $bit_index)) != 0);
}
// if we don't have the right number of bits on, go on to the next value
if ($bit_count == $n) {
$reverse = ($this->imb_reverse_us($count) >> 3);
// if the reverse is less than count, we have already visited this pair before
if ($reverse >= $count) {
// If count is symmetric, place it at the first free slot from the end of the list.
// Otherwise, place it at the first free slot from the beginning of the list AND place $reverse ath the next free slot from the beginning of the list
if ($reverse == $count) {
$table[$lui] = $count;
--$lui;
} else {
$table[$lli] = $count;
++$lli;
$table[$lli] = $reverse;
++$lli;
}
}
}
}
return $table;
}
} // end of class
//============================================================+
// END OF FILE
//============================================================+
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/tcpdf/barcodes.php | PHP | gpl2 | 71,427 |
<?php
/**
* This file is part of the exporting module for Highcharts JS.
* www.highcharts.com/license
*
*
* Available POST variables:
*
* $filename string The desired filename without extension
* $type string The MIME type for export.
* $width int The pixel width of the exported raster image. The height is calculated.
* $svg string The SVG source code to convert.
*/
// Options
define ('BATIK_PATH', 'batik-rasterizer.jar');
///////////////////////////////////////////////////////////////////////////////
$type = $_POST['type'];
$svg = (string) $_POST['svg'];
$filename = (string) $_POST['filename'];
// prepare variables
if (!$filename) $filename = 'chart';
if (get_magic_quotes_gpc()) {
$svg = stripslashes($svg);
}
$tempName = md5(rand());
// allow no other than predefined types
if ($type == 'image/png') {
$typeString = '-m image/png';
$ext = 'png';
} elseif ($type == 'image/jpeg') {
$typeString = '-m image/jpeg';
$ext = 'jpg';
} elseif ($type == 'application/pdf') {
$typeString = '-m application/pdf';
$ext = 'pdf';
} elseif ($type == 'image/svg+xml') {
$ext = 'svg';
}
$outfile = "temp/$tempName.$ext";
if (isset($typeString)) {
// size
if ($_POST['width']) {
$width = (int)$_POST['width'];
if ($width) $width = "-w $width";
}
// generate the temporary file
if (!file_put_contents("temp/$tempName.svg", $svg)) {
die("Couldn't create temporary file. Check that the directory permissions for
the /temp directory are set to 777.");
}
// do the conversion
$output = shell_exec("java -jar ". BATIK_PATH ." $typeString -d $outfile $width temp/$tempName.svg");
// catch error
if (!is_file($outfile) || filesize($outfile) < 10) {
echo "<pre>$output</pre>";
echo "Error while converting SVG";
}
// stream it
else {
header("Content-Disposition: attachment; filename=$filename.$ext");
header("Content-Type: $type");
echo file_get_contents($outfile);
}
// delete it
unlink("temp/$tempName.svg");
unlink($outfile);
// SVG can be streamed directly back
} else if ($ext == 'svg') {
header("Content-Disposition: attachment; filename=$filename.$ext");
header("Content-Type: $type");
echo $svg;
} else {
echo "Invalid type";
}
?>
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/jqchart-export/index.php | PHP | gpl2 | 2,317 |
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class jqEventLocalization {
//fullcalender translations
// these locale setting use javascript convensions for date forrmating
/*
* !!!!!!!!! NOTE dateFormat in fullcalender differ from datepicker
* Configure both in appropriate way
*/
// do not change this - it is changed at runtime automatically
public $dateFormat = "dd/MM/yyyy";
public $fullcalendar = array(
'isRTL'=> false,
'firstDay' => 1,
'monthNames'=>array('Януари','Февруари','Март','Април','Май','Юни','Юли','Август','Септември','Октомври','Ноември','Декември'),
'monthNamesShort'=>array('Яну','Фев','Мар','Апр','Май','Юни','Юли','Авг','Сеп','Окт','Ное','Дек'),
'dayNames'=> array('Неделя','Понеделник','Вторник','Сряда','Четвъртък','Петък','Събота'),
'dayNamesShort'=>array('Нед','Пон','Вто','Сря','Чет','Пет','Съб'),
'buttonText'=>array (
'prev'=> ' ◄ ',
'next'=> ' ► ',
'prevYear'=> ' << ',
'nextYear'=> ' >> ',
'today' =>'днес',
'month' =>'месец',
'week' =>'седмица',
'day'=> 'ден',
'search'=>'търси'
),
'allDayText'=> 'цял ден',
'axisFormat'=> 'hh(:mm)',
'timeFormat'=>array(
'agenda'=> 'h:mm{ - h:mm}'
)
);
//Time picker
// slotMinutes: 30 - this is get from calender options
// the corresponding options is timeInterval
public $timepicker = array(
"minutes"=>"мин.",
"onehour"=>"1 час",
"hours"=>"часа"
);
// Timepicker search dialog
public $timepicker_lang = array(
'timeOnlyTitle' =>'Избор Време',
'timeText'=>'Време',
'hourText'=> 'Час',
'minuteText'=> 'Минути',
'secondText'=> 'Секунди',
'currentText'=> 'Сега',
'closeText'=> 'Готово',
'ampm'=> false
);
function __construct() {
if($this->use_datepicker_lang === false)
{
$this->setDatepickerLang();
}
}
// Datepicker translations.
// We do this here since we can not determine the current datepicker pranslation
public $use_datepicker_lang = false;
public $datepicker_lang = array();
public function setDatepickerLang( )
{
$this->datepicker_lang= array(
'closeText'=>'Готово',
'prevText'=>'Пред.',
'nextText'=>'Следв.',
'currentText'=>'Днес',
'showMonthAfterYear'=> false,
'yearSuffix'=> '',
'dayNamesMin' => array('Нд','По','Вт','Ср','Че','Пе','Съ'),
'weekHeader'=> 'Wk',
'dateFormat'=> 'dd/mm/yy', // THE MOST IMPORTANT DIFFERENCE FROM full calender.
// Do not translate these - do it in fullcalender
'monthNames' => $this->fullcalendar['monthNames'],
'monthNamesShort'=> $this->fullcalendar['monthNamesShort'],
'dayNames'=> $this->fullcalendar['dayNames'],
'dayNamesShort'=> $this->fullcalendar['dayNamesShort'],
'firstDay'=> $this->fullcalendar['firstDay'],
'isRTL'=> $this->fullcalendar['isRTL']
);
}
// buttons left
public $button_search = "Търси";
public $button_user = "Календар";
public $button_export = "Експорт";
public $button_print = "Печат";
public $captionchangeusr = "Смяна Календар";
public $currentcalendar ="Текущ(и) Календар(и)";
// Search
public $find = 'Намери';
public $close = 'Затвори';
public $captionsearch = "Разширено Търсене";
public $found_events = "Намерени";
public $header_search = "Търсене на Събития";
// do not tuch the order
public $searchopers = array(
'равно',
'различно',
'по-малко',
'по-малко или равно',
'по-голямо',
'по-голямо или равно',
'зпочва с',
'не започва с',
'е в',
'не е в',
'звършва',
'не завършва',
'съдържа',
'не съдържа',
'е null',
'не е null'
);
// Form Fields
public $form_title = "Заглавие";
public $form_description = "Описание";
public $form_start = "Начало";
public $form_end = "Край";
public $form_location = "Къде";
public $form_categories= "Категория";
public $form_access = "Достъп";
public $form_all_day = "Целодневно Събитие";
public $form_user_id = "Календар";
// Form Buttons
public $add = "Добави";
public $save = "Съхрани";
public $remove = "Премахни";
public $change = "Промени";
public $cancel = "Отказ";
//Form Titles
public $captionedit = "Редакция Събитие";
public $captionadd = "Ново Събитие";
public $captionlist = "Списък Събития";
// options categories.
// translate the value and not the keys.
public $option_categories = array(
"personal"=>"Лично",
"work"=>"Работа",
"family"=>"Семейство",
"holiday"=>"Почивка"
);
// if you add or delete in option category change the array bellow accordandly
public $categories_css = array(
'personal' => '#c0c0c0',
'work' => '#ff0000',
'family' => '#00ff00',
'holiday' => '#ff6600'
);
public $option_access = array(
"public"=>"Обществен",
"private"=>"Личен"
);
//Swich user form
public $label_user = "Избор на Календар";
public $title_user = "Промяна Потребител Календар";
}
?>
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/localization/bg_BG.inc | PHP | gpl2 | 5,469 |
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class jqEventLocalization {
//fullcalender translations
// these locale setting use javascript convensions for date forrmating
/*
* !!!!!!!!! NOTE dateFormat in fullcalender differ from datepicker
* Configure both in appropriate way
*/
public $dateFormat = "dd/MM/yyyy";
public $fullcalendar = array(
'isRTL'=> false,
'firstDay' => 1,
'monthNames'=>array('January','February','March','April','May','June','July','August','September','October','November','December'),
'monthNamesShort'=>array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'),
'dayNames'=> array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'),
'dayNamesShort'=>array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'),
'buttonText'=>array (
'prev'=> ' ◄ ',
'next'=> ' ► ',
'prevYear'=> ' << ',
'nextYear'=> ' >> ',
'today' =>'today',
'month' =>'month',
'week' =>'week',
'day'=> 'day',
'year'=> 'year',
'search'=>'search'
),
'allDayText'=> 'all-day',
'axisFormat'=> 'h(:mm)tt',
'timeFormat'=>array(
'agenda'=> 'h:mm{ - h:mm}'
)
);
//Time picker
// slotMinutes: 30 - this is get from calender options
// the corresponding options is timeInterval
public $timepicker = array(
"minutes"=>"mins",
"onehour"=>"1 hr",
"hours"=>"hrs"
);
// Timepicker search dialog
public $timepicker_lang = array(
'timeOnlyTitle' =>'Choose Time',
'timeText'=>'Time',
'hourText'=> 'Hour',
'minuteText'=> 'Minute',
'secondText'=> 'Second',
'currentText'=> 'Now',
'closeText'=> 'Done',
'ampm'=> false
);
function __construct() {
if($this->use_datepicker_lang === false)
{
$this->setDatepickerLang();
}
}
// Datepicker translations.
// We do this here since we can not determine the current datepicker pranslation
public $use_datepicker_lang = false;
public $datepicker_lang = array();
public function setDatepickerLang( )
{
$this->datepicker_lang= array(
'closeText'=>'Done',
'prevText'=>'Prev',
'nextText'=>'Next',
'currentText'=>'Today',
'showMonthAfterYear'=> false,
'yearSuffix'=> '',
'dayNamesMin' => array('Su','Mo','Tu','We','Th','Fr','Sa'),
'weekHeader'=> 'Wk',
'dateFormat'=> 'dd/mm/yy', // THE MOST IMPORTANT DIFFERENCE FROM full calender.
// Do not translate these - do it in fullcalender
'monthNames' => $this->fullcalendar['monthNames'],
'monthNamesShort'=> $this->fullcalendar['monthNamesShort'],
'dayNames'=> $this->fullcalendar['dayNames'],
'dayNamesShort'=> $this->fullcalendar['dayNamesShort'],
'firstDay'=> $this->fullcalendar['firstDay'],
'isRTL'=> $this->fullcalendar['isRTL']
);
}
// buttons left
public $button_search = "Search";
public $button_user = "Calendar";
public $button_export = "Export";
public $button_print = "Print";
public $captionchangeusr = "Change Calendar";
public $currentcalendar ="Current Calendar(s)";
// Search
public $find = 'Find';
public $close = 'Close';
public $captionsearch = "Advanced Search";
public $found_events = "Found";
public $header_search = "Search Events";
// do not tuch the order
public $searchopers = array(
'equal',
'not equal',
'less',
'less or equal',
'greater',
'greater or equal',
'begins with',
'does not begin with',
'in',
'not in',
'ends with',
'does not end with',
'contains',
'does not contain',
'is null',
'is not null'
);
// Form Fields
public $form_title = "Title";
public $form_description = "Description";
public $form_start = "Start";
public $form_end = "End";
public $form_location = "Location";
public $form_categories= "Category";
public $form_access = "Access";
public $form_all_day = "All Day Event";
public $form_user_id = "Calendar";
// Form Buttons
public $add = "Add";
public $save = "Save";
public $remove = "Remove";
public $change = "Change";
public $cancel = "Cancel";
//Form Titles
public $captionedit = "Edit Event";
public $captionadd = "New Event";
public $captionlist = "List Event(s)";
// options categories.
// translate the value and not the keys.
public $option_categories = array(
"personal"=>"Personal",
"work"=>"Work",
"family"=>"Family",
"holiday"=>"Holiday"
);
// if you add or delete in option category change the array bellow accordandly
public $categories_css = array(
'personal' => '#c0c0c0',
'work' => '#ff0000',
'family' => '#00ff00',
'holiday' => '#ff6600'
);
public $option_access = array(
"public"=>"Public",
"private"=>"Private"
);
//Swich user form
public $label_user = "Select Calendar";
public $title_user = "Change calendar user";
}
?>
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/php/localization/en_GB.inc | PHP | gpl2 | 4,653 |
/*Grid*/
.ui-jqgrid {position: relative; font-size:11px;}
.ui-jqgrid .ui-jqgrid-view {position: relative;left:0px; top: 0px; padding: .0em;}
/* caption*/
.ui-jqgrid .ui-jqgrid-titlebar {padding: .3em .2em .2em .3em; position: relative; border-left: 0px none;border-right: 0px none; border-top: 0px none;}
.ui-jqgrid .ui-jqgrid-title { float: left; margin: .1em 0 .2em; }
.ui-jqgrid .ui-jqgrid-titlebar-close { position: absolute;top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height:18px;}.ui-jqgrid .ui-jqgrid-titlebar-close span { display: block; margin: 1px; }
.ui-jqgrid .ui-jqgrid-titlebar-close:hover { padding: 0; }
/* header*/
.ui-jqgrid .ui-jqgrid-hdiv {position: relative; margin: 0em;padding: 0em; overflow-x: hidden; border-left: 0px none !important; border-top : 0px none !important; border-right : 0px none !important;}
.ui-jqgrid .ui-jqgrid-hbox {float: left; padding-right: 20px;}
.ui-jqgrid .ui-jqgrid-htable {table-layout:fixed;margin:0em;}
.ui-jqgrid .ui-jqgrid-htable th {height:22px;padding: 0 2px 0 2px;}
.ui-jqgrid .ui-jqgrid-htable th div {overflow: hidden; position:relative; height:17px;}
.ui-th-column, .ui-jqgrid .ui-jqgrid-htable th.ui-th-column {overflow: hidden;white-space: nowrap;text-align:center;border-top : 0px none;border-bottom : 0px none;}
.ui-th-ltr, .ui-jqgrid .ui-jqgrid-htable th.ui-th-ltr {border-left : 0px none;}
.ui-th-rtl, .ui-jqgrid .ui-jqgrid-htable th.ui-th-rtl {border-right : 0px none;}
.ui-first-th-ltr {border-right: 1px solid; }
.ui-first-th-rtl {border-left: 1px solid; }
.ui-jqgrid .ui-th-div-ie {white-space: nowrap; zoom :1; height:17px;}
.ui-jqgrid .ui-jqgrid-resize {height:20px !important;position: relative; cursor :e-resize;display: inline;overflow: hidden;}
.ui-jqgrid .ui-grid-ico-sort {overflow:hidden;position:absolute;display:inline; cursor: pointer !important;}
.ui-jqgrid .ui-icon-asc {margin-top:-3px; height:12px;}
.ui-jqgrid .ui-icon-desc {margin-top:3px;height:12px;}
.ui-jqgrid .ui-i-asc {margin-top:0px;height:16px;}
.ui-jqgrid .ui-i-desc {margin-top:0px;margin-left:13px;height:16px;}
.ui-jqgrid .ui-jqgrid-sortable {cursor:pointer;}
.ui-jqgrid tr.ui-search-toolbar th { border-top-width: 1px !important; border-top-color: inherit !important; border-top-style: ridge !important }
tr.ui-search-toolbar input {margin: 1px 0px 0px 0px}
tr.ui-search-toolbar select {margin: 1px 0px 0px 0px}
/* body */
.ui-jqgrid .ui-jqgrid-bdiv {position: relative; margin: 0em; padding:0; overflow: auto; text-align:left;}
.ui-jqgrid .ui-jqgrid-btable {table-layout:fixed; margin:0em; outline-style: none; }
.ui-jqgrid tr.jqgrow { outline-style: none; }
.ui-jqgrid tr.jqgroup { outline-style: none; }
.ui-jqgrid tr.jqgrow td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;}
.ui-jqgrid tr.jqgfirstrow td {padding: 0 2px 0 2px;border-right-width: 1px; border-right-style: solid;}
.ui-jqgrid tr.jqgroup td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;}
.ui-jqgrid tr.jqfoot td {font-weight: bold; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;}
.ui-jqgrid tr.ui-row-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;}
.ui-jqgrid tr.ui-row-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;}
.ui-jqgrid td.jqgrid-rownum { padding: 0 2px 0 2px; margin: 0px; border: 0px none;}
.ui-jqgrid .ui-jqgrid-resize-mark { width:2px; left:0; background-color:#777; cursor: e-resize; cursor: col-resize; position:absolute; top:0; height:100px; overflow:hidden; display:none; border:0 none; z-index: 99999;}
/* footer */
.ui-jqgrid .ui-jqgrid-sdiv {position: relative; margin: 0em;padding: 0em; overflow: hidden; border-left: 0px none !important; border-top : 0px none !important; border-right : 0px none !important;}
.ui-jqgrid .ui-jqgrid-ftable {table-layout:fixed; margin-bottom:0em;}
.ui-jqgrid tr.footrow td {font-weight: bold; overflow: hidden; white-space:nowrap; height: 21px;padding: 0 2px 0 2px;border-top-width: 1px; border-top-color: inherit; border-top-style: solid;}
.ui-jqgrid tr.footrow-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;}
.ui-jqgrid tr.footrow-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;}
/* Pager*/
.ui-jqgrid .ui-jqgrid-pager { border-left: 0px none !important;border-right: 0px none !important; border-bottom: 0px none !important; margin: 0px !important; padding: 0px !important; position: relative; height: 25px;white-space: nowrap;overflow: hidden;}
.ui-jqgrid .ui-pager-control {position: relative;}
.ui-jqgrid .ui-pg-table {position: relative; padding-bottom:2px; width:auto; margin: 0em;}
.ui-jqgrid .ui-pg-table td {font-weight:normal; vertical-align:middle; padding:1px;}
.ui-jqgrid .ui-pg-button { height:19px !important;}
.ui-jqgrid .ui-pg-button span { display: block; margin: 1px; float:left;}
.ui-jqgrid .ui-pg-button:hover { padding: 0px; }
.ui-jqgrid .ui-state-disabled:hover {padding:1px;}
.ui-jqgrid .ui-pg-input { height:13px;font-size:.8em; margin: 0em;}
.ui-jqgrid .ui-pg-selbox {font-size:.8em; line-height:18px; display:block; height:18px; margin: 0em;}
.ui-jqgrid .ui-separator {height: 18px; border-left: 1px solid #ccc ; border-right: 1px solid #ccc ; margin: 1px; float: right;}
.ui-jqgrid .ui-paging-info {font-weight: normal;height:19px; margin-top:3px;margin-right:4px;}
.ui-jqgrid .ui-jqgrid-pager .ui-pg-div {padding:1px 0;float:left;position:relative;}
.ui-jqgrid .ui-jqgrid-pager .ui-pg-button { cursor:pointer; }
.ui-jqgrid .ui-jqgrid-pager .ui-pg-div span.ui-icon {float:left;margin:0 2px;}
.ui-jqgrid td input, .ui-jqgrid td select .ui-jqgrid td textarea { margin: 0em;}
.ui-jqgrid td textarea {width:auto;height:auto;}
.ui-jqgrid .ui-jqgrid-toppager {border-left: 0px none !important;border-right: 0px none !important; border-top: 0px none !important; margin: 0px !important; padding: 0px !important; position: relative; height: 25px !important;white-space: nowrap;overflow: hidden;}
.ui-jqgrid .ui-jqgrid-toppager .ui-pg-div {padding:1px 0;float:left;position:relative;}
.ui-jqgrid .ui-jqgrid-toppager .ui-pg-button { cursor:pointer; }
.ui-jqgrid .ui-jqgrid-toppager .ui-pg-div span.ui-icon {float:left;margin:0 2px;}
/*subgrid*/
.ui-jqgrid .ui-jqgrid-btable .ui-sgcollapsed span {display: block;}
.ui-jqgrid .ui-subgrid {margin:0em;padding:0em; width:100%;}
.ui-jqgrid .ui-subgrid table {table-layout: fixed;}
.ui-jqgrid .ui-subgrid tr.ui-subtblcell td {height:18px;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;}
.ui-jqgrid .ui-subgrid td.subgrid-data {border-top: 0px none !important;}
.ui-jqgrid .ui-subgrid td.subgrid-cell {border-width: 0px 0px 1px 0px;}
.ui-jqgrid .ui-th-subgrid {height:20px;}
/* loading */
.ui-jqgrid .loading {position: absolute; top: 45%;left: 45%;width: auto;z-index:101;padding: 6px; margin: 5px;text-align: center;font-weight: bold;display: none;border-width: 2px !important;}
.ui-jqgrid .jqgrid-overlay {display:none;z-index:100;}
* html .jqgrid-overlay {width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}
* .jqgrid-overlay iframe {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}
/* end loading div */
/* toolbar */
.ui-jqgrid .ui-userdata {border-left: 0px none; border-right: 0px none; height : 21px;overflow: hidden; }
/*Modal Window */
.ui-jqdialog { display: none; width: 300px; position: absolute; padding: .2em; font-size:11px; overflow:visible;}
.ui-jqdialog .ui-jqdialog-titlebar { padding: .3em .2em; position: relative; }
.ui-jqdialog .ui-jqdialog-title { margin: .1em 0 .2em; }
.ui-jqdialog .ui-jqdialog-titlebar-close { position: absolute; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
.ui-jqdialog .ui-jqdialog-titlebar-close span { display: block; margin: 1px; }
.ui-jqdialog .ui-jqdialog-titlebar-close:hover, .ui-jqdialog .ui-jqdialog-titlebar-close:focus { padding: 0; }
.ui-jqdialog-content, .ui-jqdialog .ui-jqdialog-content { border: 0; padding: .3em .2em; background: none; height:auto;}
.ui-jqdialog .ui-jqconfirm {padding: .4em 1em; border-width:3px;position:absolute;bottom:10px;right:10px;overflow:visible;display:none;height:80px;width:220px;text-align:center;}
/* end Modal window*/
/* Form edit */
.ui-jqdialog-content .FormGrid {margin: 0px;}
.ui-jqdialog-content .EditTable { width: 100%; margin-bottom:0em;}
.ui-jqdialog-content .DelTable { width: 100%; margin-bottom:0em;}
.EditTable td input, .EditTable td select, .EditTable td textarea {margin: 0em;}
.EditTable td textarea { width:auto; height:auto;}
.ui-jqdialog-content td.EditButton {text-align: right;border-top: 0px none;border-left: 0px none;border-right: 0px none; padding-bottom:5px; padding-top:5px;}
.ui-jqdialog-content td.navButton {text-align: center; border-left: 0px none;border-top: 0px none;border-right: 0px none; padding-bottom:5px; padding-top:5px;}
.ui-jqdialog-content input.FormElement {padding:.3em}
.ui-jqdialog-content .data-line {padding-top:.1em;border: 0px none;}
.ui-jqdialog-content .CaptionTD {text-align: left; vertical-align: middle;border: 0px none; padding: 2px;white-space: nowrap;}
.ui-jqdialog-content .DataTD {padding: 2px; border: 0px none; vertical-align: top;}
.ui-jqdialog-content .form-view-data {white-space:pre}
.fm-button { display: inline-block; margin:0 4px 0 0; padding: .4em .5em; text-decoration:none !important; cursor:pointer; position: relative; text-align: center; zoom: 1; }
.fm-button-icon-left { padding-left: 1.9em; }
.fm-button-icon-right { padding-right: 1.9em; }
.fm-button-icon-left .ui-icon { right: auto; left: .2em; margin-left: 0; position: absolute; top: 50%; margin-top: -8px; }
.fm-button-icon-right .ui-icon { left: auto; right: .2em; margin-left: 0; position: absolute; top: 50%; margin-top: -8px;}
#nData, #pData { float: left; margin:3px;padding: 0; width: 15px; }
/* End Eorm edit */
/*.ui-jqgrid .edit-cell {}*/
.ui-jqgrid .selected-row, div.ui-jqgrid .selected-row td {font-style : normal;border-left: 0px none;}
/* inline edit actions button*/
.ui-inline-del.ui-state-hover span, .ui-inline-edit.ui-state-hover span,
.ui-inline-save.ui-state-hover span, .ui-inline-cancel.ui-state-hover span {
margin: -1px;
}
/* Tree Grid */
.ui-jqgrid .tree-wrap {float: left; position: relative;height: 18px;white-space: nowrap;overflow: hidden;}
.ui-jqgrid .tree-minus {position: absolute; height: 18px; width: 18px; overflow: hidden;}
.ui-jqgrid .tree-plus {position: absolute; height: 18px; width: 18px; overflow: hidden;}
.ui-jqgrid .tree-leaf {position: absolute; height: 18px; width: 18px;overflow: hidden;}
.ui-jqgrid .treeclick {cursor: pointer;}
/* moda dialog */
* iframe.jqm {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}
.ui-jqgrid-dnd tr td {border-right-width: 1px; border-right-color: inherit; border-right-style: solid; height:20px}
/* RTL Support */
.ui-jqgrid .ui-jqgrid-title-rtl {float:right;margin: .1em 0 .2em; }
.ui-jqgrid .ui-jqgrid-hbox-rtl {float: right; padding-left: 20px;}
.ui-jqgrid .ui-jqgrid-resize-ltr {float: right;margin: -2px -2px -2px 0px;}
.ui-jqgrid .ui-jqgrid-resize-rtl {float: left;margin: -2px 0px -1px -3px;}
.ui-jqgrid .ui-sort-rtl {left:0px;}
.ui-jqgrid .tree-wrap-ltr {float: left;}
.ui-jqgrid .tree-wrap-rtl {float: right;}
.ui-jqgrid .ui-ellipsis {text-overflow:ellipsis;}
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/ui.jqgrid.css | CSS | gpl2 | 12,185 |
/* Multiselect
----------------------------------*/
.ui-multiselect { border: solid 1px; font-size: 0.8em; }
.ui-multiselect ul { -moz-user-select: none; }
.ui-multiselect li { margin: 0; padding: 0; cursor: default; line-height: 20px; height: 20px; font-size: 11px; list-style: none; }
.ui-multiselect li a { color: #999; text-decoration: none; padding: 0; display: block; float: left; cursor: pointer;}
.ui-multiselect li.ui-draggable-dragging { padding-left: 10px; }
.ui-multiselect div.selected { position: relative; padding: 0; margin: 0; border: 0; float:left; }
.ui-multiselect ul.selected { position: relative; padding: 0; overflow: auto; overflow-x: hidden; background: #fff; margin: 0; list-style: none; border: 0; position: relative; width: 100%; }
.ui-multiselect ul.selected li { }
.ui-multiselect div.available { position: relative; padding: 0; margin: 0; border: 0; float:left; border-left: 1px solid; }
.ui-multiselect ul.available { position: relative; padding: 0; overflow: auto; overflow-x: hidden; background: #fff; margin: 0; list-style: none; border: 0; width: 100%; }
.ui-multiselect ul.available li { padding-left: 10px; }
.ui-multiselect .ui-state-default { border: none; margin-bottom: 1px; position: relative; padding-left: 20px;}
.ui-multiselect .ui-state-hover { border: none; }
.ui-multiselect .ui-widget-header {border: none; font-size: 11px; margin-bottom: 1px;}
.ui-multiselect .add-all { float: right; padding: 7px;}
.ui-multiselect .remove-all { float: right; padding: 7px;}
.ui-multiselect .search { float: left; padding: 4px;}
.ui-multiselect .count { float: left; padding: 7px;}
.ui-multiselect li span.ui-icon-arrowthick-2-n-s { position: absolute; left: 2px; }
.ui-multiselect li a.action { position: absolute; right: 2px; top: 2px; }
.ui-multiselect input.search { height: 14px; padding: 1px; opacity: 0.5; margin: 4px; width: 100px; } | zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/ui.multiselect.css | CSS | gpl2 | 1,886 |
/**
* Dark blue theme for Highcharts JS
* @author Torstein Hønsi
*/
Highcharts.theme = {
colors: ["#DDDF0D", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
"#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
chart: {
backgroundColor: {
linearGradient: [0, 0, 250, 500],
stops: [
[0, 'rgb(48, 96, 48)'],
[1, 'rgb(0, 0, 0)']
]
},
borderColor: '#000000',
borderWidth: 2,
className: 'dark-container',
plotBackgroundColor: 'rgba(255, 255, 255, .1)',
plotBorderColor: '#CCCCCC',
plotBorderWidth: 1
},
title: {
style: {
color: '#C0C0C0',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
}
},
subtitle: {
style: {
color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
}
},
xAxis: {
gridLineColor: '#333333',
gridLineWidth: 1,
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
tickColor: '#A0A0A0',
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
yAxis: {
gridLineColor: '#333333',
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
minorTickInterval: null,
tickColor: '#A0A0A0',
tickWidth: 1,
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: '#A0A0A0'
}
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.75)',
style: {
color: '#F0F0F0'
}
},
toolbar: {
itemStyle: {
color: 'silver'
}
},
plotOptions: {
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
},
scatter: {
marker: {
lineColor: '#333'
}
}
},
legend: {
itemStyle: {
color: '#CCC'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#444'
}
},
credits: {
style: {
color: '#666'
}
},
labels: {
style: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
backgroundColor: {
linearGradient: [0, 0, 0, 20],
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
borderColor: '#000000',
symbolStroke: '#C0C0C0',
hoverSymbolStroke: '#FFFFFF'
}
},
exporting: {
buttons: {
exportButton: {
symbolFill: '#55BE3B'
},
printButton: {
symbolFill: '#7797BE'
}
}
},
// special colors for some of the
legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
legendBackgroundColorSolid: 'rgb(35, 35, 70)',
dataLabelsColor: '#444',
textColor: '#C0C0C0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
var highchartsOptions = Highcharts.setOptions(Highcharts.theme); | zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/dark-green.js | JavaScript | gpl2 | 3,011 |
.ui-input {padding :4px; margin: 1px;}
.ui-select {padding : 3px;}
.ui-textarea {padding: 3px;}
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/ui.jqform.css | CSS | gpl2 | 98 |
/**
* Dark blue theme for Highcharts JS
* @author Torstein Hønsi
*/
Highcharts.theme = {
colors: ["#DDDF0D", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
"#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
chart: {
backgroundColor: {
linearGradient: [0, 0, 250, 500],
stops: [
[0, 'rgb(48, 48, 96)'],
[1, 'rgb(0, 0, 0)']
]
},
borderColor: '#000000',
borderWidth: 2,
className: 'dark-container',
plotBackgroundColor: 'rgba(255, 255, 255, .1)',
plotBorderColor: '#CCCCCC',
plotBorderWidth: 1
},
title: {
style: {
color: '#C0C0C0',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
}
},
subtitle: {
style: {
color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
}
},
xAxis: {
gridLineColor: '#333333',
gridLineWidth: 1,
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
tickColor: '#A0A0A0',
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
yAxis: {
gridLineColor: '#333333',
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
minorTickInterval: null,
tickColor: '#A0A0A0',
tickWidth: 1,
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: '#A0A0A0'
}
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.75)',
style: {
color: '#F0F0F0'
}
},
toolbar: {
itemStyle: {
color: 'silver'
}
},
plotOptions: {
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
},
scatter: {
marker: {
lineColor: '#333'
}
}
},
legend: {
itemStyle: {
color: '#CCC'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#444'
}
},
credits: {
style: {
color: '#666'
}
},
labels: {
style: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
backgroundColor: {
linearGradient: [0, 0, 0, 20],
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
borderColor: '#000000',
symbolStroke: '#C0C0C0',
hoverSymbolStroke: '#FFFFFF'
}
},
exporting: {
buttons: {
exportButton: {
symbolFill: '#55BE3B'
},
printButton: {
symbolFill: '#7797BE'
}
}
},
// special colors for some of the
legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
legendBackgroundColorSolid: 'rgb(35, 35, 70)',
dataLabelsColor: '#444',
textColor: '#C0C0C0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
var highchartsOptions = Highcharts.setOptions(Highcharts.theme); | zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/dark-blue.js | JavaScript | gpl2 | 3,011 |
/*
* FullCalendar v1.5.1 Stylesheet
*
* Copyright (c) 2011 Adam Shaw
* Dual licensed under the MIT and GPL licenses, located in
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
*
* Date: Sat Apr 9 14:09:51 2011 -0700
*
*/
.fc {
direction: ltr;
text-align: left;
}
.fc table {
border-collapse: collapse;
border-spacing: 0;
}
html .fc,
.fc table {
font-size: 1em;
}
.fc td,
.fc th {
padding: 0;
vertical-align: top;
}
/* Header
------------------------------------------------------------------------*/
.fc-header td {
white-space: nowrap;
}
.fc-header-left {
width: 25%;
text-align: left;
}
.fc-header-center {
text-align: center;
}
.fc-header-right {
width: 25%;
text-align: right;
}
.fc-header-title {
display: inline-block;
vertical-align: top;
}
.fc-header-title h2 {
margin-top: 0;
white-space: nowrap;
}
.fc .fc-header-space {
padding-left: 10px;
}
.fc-header .fc-button {
margin-bottom: 1em;
vertical-align: top;
}
/* buttons edges butting together */
.fc-header .fc-button {
margin-right: -1px;
}
.fc-header .fc-corner-right {
margin-right: 1px; /* back to normal */
}
.fc-header .ui-corner-right {
margin-right: 0; /* back to normal */
}
/* button layering (for border precedence) */
.fc-header .fc-state-hover,
.fc-header .ui-state-hover {
z-index: 2;
}
.fc-header .fc-state-down {
z-index: 3;
}
.fc-header .fc-state-active,
.fc-header .ui-state-active {
z-index: 4;
}
/* Content
------------------------------------------------------------------------*/
.fc-content {
clear: both;
}
.fc-view {
width: 100%; /* needed for view switching (when view is absolute) */
overflow: hidden;
}
/* Cell Styles
------------------------------------------------------------------------*/
.fc-widget-header, /* <th>, usually */
.fc-widget-content { /* <td>, usually */
border: 1px solid #ccc;
}
.fc-state-highlight { /* <td> today cell */ /* TODO: add .fc-today to <th> */
background: #ffc;
}
.fc-cell-overlay { /* semi-transparent rectangle while dragging */
background: #9cf;
opacity: .2;
filter: alpha(opacity=20); /* for IE */
}
/* Buttons
------------------------------------------------------------------------*/
.fc-button {
position: relative;
display: inline-block;
cursor: pointer;
}
.fc-state-default { /* non-theme */
border-style: solid;
border-width: 1px 0;
}
.fc-button-inner {
position: relative;
float: left;
overflow: hidden;
}
.fc-state-default .fc-button-inner { /* non-theme */
border-style: solid;
border-width: 0 1px;
}
.fc-button-content {
position: relative;
float: left;
height: 1.9em;
line-height: 1.9em;
padding: 0 .6em;
white-space: nowrap;
}
/* icon (for jquery ui) */
.fc-button-content .fc-icon-wrap {
position: relative;
float: left;
top: 50%;
}
.fc-button-content .ui-icon {
position: relative;
float: left;
margin-top: -50%;
*margin-top: 0;
*top: -50%;
}
/* gloss effect */
.fc-state-default .fc-button-effect {
position: absolute;
top: 50%;
left: 0;
}
.fc-state-default .fc-button-effect span {
position: absolute;
top: -100px;
left: 0;
width: 500px;
height: 100px;
border-width: 100px 0 0 1px;
border-style: solid;
border-color: #fff;
background: #444;
opacity: .09;
filter: alpha(opacity=9);
}
/* button states (determines colors) */
.fc-state-default,
.fc-state-default .fc-button-inner {
border-style: solid;
border-color: #ccc #bbb #aaa;
background: #F3F3F3;
color: #000;
}
.fc-state-hover,
.fc-state-hover .fc-button-inner {
border-color: #999;
}
.fc-state-down,
.fc-state-down .fc-button-inner {
border-color: #555;
background: #777;
}
.fc-state-active,
.fc-state-active .fc-button-inner {
border-color: #555;
background: #777;
color: #fff;
}
.fc-state-disabled,
.fc-state-disabled .fc-button-inner {
color: #999;
border-color: #ddd;
}
.fc-state-disabled {
cursor: default;
}
.fc-state-disabled .fc-button-effect {
display: none;
}
/* Global Event Styles
------------------------------------------------------------------------*/
.fc-event {
border-style: solid;
border-width: 0;
font-size: .85em;
cursor: default;
}
a.fc-event,
.fc-event-draggable {
cursor: pointer;
}
a.fc-event {
text-decoration: none;
}
.fc-rtl .fc-event {
text-align: right;
}
.fc-event-skin {
border-color: #36c; /* default BORDER color */
background-color: #36c; /* default BACKGROUND color */
color: #fff; /* default TEXT color */
}
.fc-event-inner {
position: relative;
width: 100%;
height: 100%;
border-style: solid;
border-width: 0;
overflow: hidden;
}
.fc-event-time,
.fc-event-title {
padding: 0 1px;
}
.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/
display: block;
position: absolute;
z-index: 99999;
overflow: hidden; /* hacky spaces (IE6/7) */
font-size: 300%; /* */
line-height: 50%; /* */
}
/* Horizontal Events
------------------------------------------------------------------------*/
.fc-event-hori {
border-width: 1px 0;
margin-bottom: 1px;
}
/* resizable */
.fc-event-hori .ui-resizable-e {
top: 0 !important; /* importants override pre jquery ui 1.7 styles */
right: -3px !important;
width: 7px !important;
height: 100% !important;
cursor: e-resize;
}
.fc-event-hori .ui-resizable-w {
top: 0 !important;
left: -3px !important;
width: 7px !important;
height: 100% !important;
cursor: w-resize;
}
.fc-event-hori .ui-resizable-handle {
_padding-bottom: 14px; /* IE6 had 0 height */
}
/* Fake Rounded Corners (for buttons and events)
------------------------------------------------------------*/
.fc-corner-left {
margin-left: 1px;
}
.fc-corner-left .fc-button-inner,
.fc-corner-left .fc-event-inner {
margin-left: -1px;
}
.fc-corner-right {
margin-right: 1px;
}
.fc-corner-right .fc-button-inner,
.fc-corner-right .fc-event-inner {
margin-right: -1px;
}
.fc-corner-top {
margin-top: 1px;
}
.fc-corner-top .fc-event-inner {
margin-top: -1px;
}
.fc-corner-bottom {
margin-bottom: 1px;
}
.fc-corner-bottom .fc-event-inner {
margin-bottom: -1px;
}
/* Fake Rounded Corners SPECIFICALLY FOR EVENTS
-----------------------------------------------------------------*/
.fc-corner-left .fc-event-inner {
border-left-width: 1px;
}
.fc-corner-right .fc-event-inner {
border-right-width: 1px;
}
.fc-corner-top .fc-event-inner {
border-top-width: 1px;
}
.fc-corner-bottom .fc-event-inner {
border-bottom-width: 1px;
}
/* Reusable Separate-border Table
------------------------------------------------------------*/
table.fc-border-separate {
border-collapse: separate;
}
.fc-border-separate th,
.fc-border-separate td {
border-width: 1px 0 0 1px;
}
.fc-border-separate th.fc-last,
.fc-border-separate td.fc-last {
border-right-width: 1px;
}
.fc-border-separate tr.fc-last th,
.fc-border-separate tr.fc-last td {
border-bottom-width: 1px;
}
.fc-border-separate tbody tr.fc-first td,
.fc-border-separate tbody tr.fc-first th {
border-top-width: 0;
}
/* Month View, Basic Week View, Basic Day View
------------------------------------------------------------------------*/
.fc-grid th {
text-align: center;
}
.fc-grid .fc-day-number {
float: right;
padding: 0 2px;
}
.fc-grid .fc-other-month .fc-day-number {
opacity: 0.3;
filter: alpha(opacity=30); /* for IE */
/* opacity with small font can sometimes look too faded
might want to set the 'color' property instead
making day-numbers bold also fixes the problem */
}
.fc-grid .fc-day-content {
clear: both;
padding: 2px 2px 1px; /* distance between events and day edges */
}
/* event styles */
.fc-grid .fc-event-time {
font-weight: bold;
}
/* right-to-left */
.fc-rtl .fc-grid .fc-day-number {
float: left;
}
.fc-rtl .fc-grid .fc-event-time {
float: right;
}
/* Agenda Week View, Agenda Day View
------------------------------------------------------------------------*/
.fc-agenda table {
border-collapse: separate;
}
.fc-agenda-days th {
text-align: center;
}
.fc-agenda .fc-agenda-axis {
width: 50px;
padding: 0 4px;
vertical-align: middle;
text-align: right;
white-space: nowrap;
font-weight: normal;
}
.fc-agenda .fc-day-content {
padding: 2px 2px 1px;
}
/* make axis border take precedence */
.fc-agenda-days .fc-agenda-axis {
border-right-width: 1px;
}
.fc-agenda-days .fc-col0 {
border-left-width: 0;
}
/* all-day area */
.fc-agenda-allday th {
border-width: 0 1px;
}
.fc-agenda-allday .fc-day-content {
min-height: 34px; /* TODO: doesnt work well in quirksmode */
_height: 34px;
}
/* divider (between all-day and slots) */
.fc-agenda-divider-inner {
height: 2px;
overflow: hidden;
}
.fc-widget-header .fc-agenda-divider-inner {
background: #eee;
}
/* slot rows */
.fc-agenda-slots th {
border-width: 1px 1px 0;
}
.fc-agenda-slots td {
border-width: 1px 0 0;
background: none;
}
.fc-agenda-slots td div {
height: 20px;
}
.fc-agenda-slots tr.fc-slot0 th,
.fc-agenda-slots tr.fc-slot0 td {
border-top-width: 0;
}
.fc-agenda-slots tr.fc-minor th,
.fc-agenda-slots tr.fc-minor td {
border-top-style: dotted;
}
.fc-agenda-slots tr.fc-minor th.ui-widget-header {
*border-top-style: solid; /* doesn't work with background in IE6/7 */
}
/* Vertical Events
------------------------------------------------------------------------*/
.fc-event-vert {
border-width: 0 1px;
}
.fc-event-vert .fc-event-head,
.fc-event-vert .fc-event-content {
position: relative;
z-index: 2;
width: 100%;
overflow: hidden;
}
.fc-event-vert .fc-event-time {
white-space: nowrap;
font-size: 10px;
}
.fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #fff;
opacity: .3;
filter: alpha(opacity=30);
}
.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
.fc-select-helper .fc-event-bg {
display: none\9; /* for IE6/7/8. nested opacity filters while dragging don't work */
}
/* resizable */
.fc-event-vert .ui-resizable-s {
bottom: 0 !important; /* importants override pre jquery ui 1.7 styles */
width: 100% !important;
height: 8px !important;
overflow: hidden !important;
line-height: 8px !important;
font-size: 11px !important;
font-family: monospace;
text-align: center;
cursor: s-resize;
}
.fc-agenda .ui-resizable-resizing { /* TODO: better selector */
_overflow: hidden;
}
/*year view*/
.fc-year-main-table{
border-spacing: 5px !important;
}
.fc-year-monthly-td
{
/*border-bottom: 1px solid !important;*/
}
.fc-year-monthly-header{
border: thin #f0f0f0 solid !important;
}
.fc-year-have-event{
/*background: #9cf;*/
}
.calwrapper {
}
#progressbar {
background: url("ui-anim_basic_16x16_2.gif") left center no-repeat;
text-align: center;
} | zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/ui.jqscheduler.css | CSS | gpl2 | 11,070 |
/**
* Grid theme for Highcharts JS
* @author Torstein Hønsi
*/
Highcharts.theme = {
colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
chart: {
backgroundColor: {
linearGradient: [0, 0, 500, 500],
stops: [
[0, 'rgb(255, 255, 255)'],
[1, 'rgb(240, 240, 255)']
]
}
,
borderWidth: 2,
plotBackgroundColor: 'rgba(255, 255, 255, .9)',
plotShadow: true,
plotBorderWidth: 1
},
title: {
style: {
color: '#000',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
}
},
subtitle: {
style: {
color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
}
},
xAxis: {
gridLineWidth: 1,
lineColor: '#000',
tickColor: '#000',
labels: {
style: {
color: '#000',
font: '11px Trebuchet MS, Verdana, sans-serif'
}
},
title: {
style: {
color: '#333',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
yAxis: {
minorTickInterval: 'auto',
lineColor: '#000',
lineWidth: 1,
tickWidth: 1,
tickColor: '#000',
labels: {
style: {
color: '#000',
font: '11px Trebuchet MS, Verdana, sans-serif'
}
},
title: {
style: {
color: '#333',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: 'black'
},
itemHoverStyle: {
color: '#039'
},
itemHiddenStyle: {
color: 'gray'
}
},
labels: {
style: {
color: '#99b'
}
}
};
// Apply the theme
var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/grid.js | JavaScript | gpl2 | 1,812 |
/**
* Gray theme for Highcharts JS
* @author Torstein Hønsi
*/
Highcharts.theme = {
colors: ["#DDDF0D", "#7798BF", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
"#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
chart: {
backgroundColor: {
linearGradient: [0, 0, 0, 400],
stops: [
[0, 'rgb(96, 96, 96)'],
[1, 'rgb(16, 16, 16)']
]
},
borderWidth: 0,
borderRadius: 15,
plotBackgroundColor: null,
plotShadow: false,
plotBorderWidth: 0
},
title: {
style: {
color: '#FFF',
font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
subtitle: {
style: {
color: '#DDD',
font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
xAxis: {
gridLineWidth: 0,
lineColor: '#999',
tickColor: '#999',
labels: {
style: {
color: '#999',
fontWeight: 'bold'
}
},
title: {
style: {
color: '#AAA',
font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
}
},
yAxis: {
alternateGridColor: null,
minorTickInterval: null,
gridLineColor: 'rgba(255, 255, 255, .1)',
lineWidth: 0,
tickWidth: 0,
labels: {
style: {
color: '#999',
fontWeight: 'bold'
}
},
title: {
style: {
color: '#AAA',
font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
}
},
legend: {
itemStyle: {
color: '#CCC'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#333'
}
},
labels: {
style: {
color: '#CCC'
}
},
tooltip: {
backgroundColor: {
linearGradient: [0, 0, 0, 50],
stops: [
[0, 'rgba(96, 96, 96, .8)'],
[1, 'rgba(16, 16, 16, .8)']
]
},
borderWidth: 0,
style: {
color: '#FFF'
}
},
plotOptions: {
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
},
scatter: {
marker: {
lineColor: '#333'
}
}
},
toolbar: {
itemStyle: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
backgroundColor: {
linearGradient: [0, 0, 0, 20],
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
borderColor: '#000000',
symbolStroke: '#C0C0C0',
hoverSymbolStroke: '#FFFFFF'
}
},
exporting: {
buttons: {
exportButton: {
symbolFill: '#55BE3B'
},
printButton: {
symbolFill: '#7797BE'
}
}
},
// special colors for some of the demo examples
legendBackgroundColor: 'rgba(48, 48, 48, 0.8)',
legendBackgroundColorSolid: 'rgb(70, 70, 70)',
dataLabelsColor: '#444',
textColor: '#E0E0E0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/themes/gray.js | JavaScript | gpl2 | 2,830 |
<?php
function tabs(array $files)
{
$tabshead = <<<HEAD1
<div id="tabs" style="font-size:11px">
<ul>
<li><a href="#DescriptionContent"><span>Info</span></a></li>
<li><a href="#HTMLContent"><span>HTML</span></a></li>
<li><a href="#PHPCode"><span>PHP</span></a></li>
</ul>
<div id="DescriptionContent" style="font-size:1.1em !important">
HEAD1;
echo $tabshead;
// info file
$filename = "info.txt";
$lines = file($filename);
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo $line . "<br />\n";
}
// html content
echo "</div>";
echo '<div id="HTMLContent" style="font-size:1.1em !important">';
$filename = "default.php";
highlight_file($filename);
echo "</div>";
// php code
echo '<div id="PHPCode" style= "font-size:1em !important">';
for($i=0;$i<count($files);$i++)
{
$filename = $files[$i];
echo '<span style="font-size:1.2em !important">';
echo "<b>".$filename."</b>.<br />\n";
if(strlen($filename)>0)
{
highlight_file($filename);
}
echo "<span>";
}
echo "</div>"; // php code
echo "</div>"; // tabs
echo '<script type="text/javascript">';
echo '$("#tabs").tabs();';
echo '</script>';
$google = <<<GOOGLE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try { var pageTracker = _gat._getTracker("UA-5463047-4"); pageTracker._trackPageview(); } catch(err) {}
</script>
GOOGLE;
echo $google;
}
?>
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/tabs2.php | PHP | gpl2 | 1,654 |
<?php
function tabs(array $files)
{
$tabshead = <<<HEAD1
<div id="tabs" style="font-size:75%">
<ul>
<li><a href="#DescriptionContent"><span>Info</span></a></li>
<li><a href="#HTMLContent"><span>HTML</span></a></li>
<li><a href="#PHPCode"><span>PHP</span></a></li>
</ul>
<div id="DescriptionContent" style="font-size:1.1em !important">
HEAD1;
echo $tabshead;
// info file
$filename = "info.txt";
$lines = file($filename);
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo $line . "<br />\n";
}
// html content
echo "</div>";
echo '<div id="HTMLContent" style="font-size:1.1em !important">';
$filename = "default.php";
highlight_file($filename);
echo "</div>";
// php code
echo '<div id="PHPCode" style= "font-size:1em !important">';
for($i=0;$i<count($files);$i++)
{
$filename = $files[$i];
echo '<span style="font-size:1.2em !important">';
echo "<b>".$filename."</b>.<br />\n";
if(strlen($filename)>0)
{
highlight_file($filename);
}
echo "<span>";
}
echo "</div>"; // php code
echo "</div>"; // tabs
echo '<script type="text/javascript">';
echo '$("#tabs").tabs();';
echo '</script>';
$google = <<<GOOGLE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try { var pageTracker = _gat._getTracker("UA-5463047-4"); pageTracker._trackPageview(); } catch(err) {}
</script>
GOOGLE;
echo $google;
}
?>
| zzyn125-bench | BigMelon/Backup/jslib_backup/jqSuitePHP_4_3_2_0/tabs.php | PHP | gpl2 | 1,708 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
<style>
.even td { background : #DDD }
.odd td { background : #FFF }
</style>
</head>
<body>
<!-- HTML template -->
<table>
<tr>
<td></td>
</tr>
</table>
<script>
var directive = {
'tr' : { //trigger a loop
'animal<-animals' : { // loop on the property animals in the JSON
'@class+':function(arg){ // add(+) the return value of the function to the class
var oddEven, firstLast;
oddEven = (arg.pos % 2 == 0) ? ' even' : ' odd';
firstLast = (arg.pos == 0) ?
' first' :
(arg.pos == arg.animal.items.length - 1) ?
' last' :
'';
return oddEven + firstLast;
},
'td':'animal.name'
}
}
};
var data = {
animals:[
{name:'bird'},
{name:'cat'},
{name:'dog'},
{name:'mouse'}
]
};
$('table').render(data, directive);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto6.html | HTML | gpl2 | 1,101 |
<html>
<head>
<!-- Thanks to zackdykes@gmail.com for this example on nested loops -->
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
<style>
ul {list-style: none; padding: 0px 0px 0px 15px;}
li.music {background: #eee; margin-bottom: 10px; padding: 10px;}
</style>
</head>
<body>
<!-- HTML template -->
<ul>
<li class="music">
<ul>
<li>Album: <a class="release" href="#"></a></li>
<li>Artist: <a class="artist" href="#"></a></li>
<li>ID: <a class="label" href="#"></a></li>
<li>Tracks:
<ul>
<li class="track">
<span class="trackNum">:</span>
<span class="title"></span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<script type="text/javascript">
var directive = {
'li.music': {
'obj<-items': { // "for obj in items"
'a.release': 'obj.title',
'a.artist': 'obj.artist',
'a.label': 'obj.id',
'li.track': {
'track<-obj.tracks': { // "for track in obj.tracks"
'span.trackNum': '#{track.trackNumber}:', // prepend
'span.title': 'track.title'
}
}
}
}
};
var data = {
items: [
{
id: 1,
title: 'Mars Attack',
artist: 'Epos',
tracks: [
{
title: 'Epos 1',
trackNumber: '1'
},
{
title: 'Epos 2',
trackNumber: '2'
},
{
title: 'Epos 3',
trackNumber: '3'
}
]
},
{
id: 2,
title: 'Reigni',
artist: 'Alfu',
tracks: [
{
title: 'Alfu 1',
trackNumber: '1'
},
{
title: 'Alfu 2',
trackNumber: '2'
},
{
title: 'Alfu 3',
trackNumber: '3'
}
]
},
]
};
$('ul').render(data, directive);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto5d.html | HTML | gpl2 | 2,441 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://github.com/pure/pure/raw/master/libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
<div class="template">
Hello <a></a>
</div>
<!-- result place -->
<div class="result"></div>
<script>
var jsonData = {'who':'BeeBole!', site:'http://beebole.com'};
$('div.template')
//set the directives
.directives({ 'a':'who', 'a@href':'site' })
//call render with the JSON data
.render(jsonData)
//use any jQuery command on the generated HTML
.appendTo('div.result');
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto9.html | HTML | gpl2 | 702 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
<script>
var cols = ['name', 'food', 'legs', 'button'],
data = {animals:[
{name:'bird', food:'seed', legs:2},
{name:'cat', food:'mouse, bird', legs:4},
{name:'dog', food:'bone', legs:4},
{name:'mouse', food:'cheese', legs:4}
]
},
colsDir = {
'th':{
'col<-':{
'.':'col'
}
},
'td':{
'col<-':{
'@class':'col'
}
}
},
dataDir = {
'tbody tr':{
'animal<-animals':{
'td.name':'animal.name',
'td.food':'animal.food',
'td.legs':'animal.legs',
'td.button':'<button onclick="alert(#{animal.legs})">View</button>'
}
}
};
$('table').render(cols, colsDir).render(data, dataDir);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto5c.html | HTML | gpl2 | 1,006 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
<div class="template">
Hello <a></a>
</div>
<script>
var data = {'who':'BeeBole!', site:'http://beebole.com'},
directive = {
'a':'who', //look for the tag 'a' and place the value of the property 'who' in its node value
'a@href':'site' //look for the tag a, and set its attribute 'href' to the value of the property 'site'
}
//note the use of render instead of autoRender and the 2nd parameter with directive
$('div.template').render(data, directive);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto4.html | HTML | gpl2 | 730 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
<ul>
<li></li>
</ul>
<script>
var data = {
animals:[
{name:'mouse'},
{name:'cat'},
{name:'bird'},
{name:'dog'}
]
};
//declaration of the actions PURE has to do
var directive = {
'li':{
'animal<-animals':{
'.':'animal.name'
}
}
};
// note the use of render instead of autoRender
$('ul').render(data, directive);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto5.html | HTML | gpl2 | 650 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- the HTML template -->
Hello <a class="who" href="#"></a>
<script>
// the JSON data we want to render
var data = {'who':'BeeBole!'};
// run the rendering
$('a').autoRender(data);
</script>
</body>
</html>
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto1.html | HTML | gpl2 | 391 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/mootools.js" type="text/javascript" charset="utf-8"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
<ol>
<!-- Explanation of the classes of the LI:
* "animals" points to an array and will trigger an iteration
* "name" points to the property within the array and will set
the node value of the LI
-->
<li class="animals name"></li>
</ol>
<script>
// animals is an array and will trigger an iteration
var data = {
animals:[
{name:'bird'},
{name:'cat'},
{name:'dog'},
{name:'mouse'}
]
};
//example with mootools
$(document).getElement('ol').autoRender(data);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto3.html | HTML | gpl2 | 770 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
<style>
.even td { background : #DDD }
.odd td { background : #FFF }
</style>
</head>
<body>
<!-- HTML template -->
<table>
<tr>
<td></td>
</tr>
</table>
<script>
//example of building a plugin to postprocess the generated HTML
$p.plugins.renderWithEffects = function(ctxt, directive, postProcess){
var sel, action, elms,
replace_ = function(pobj){
return {
by:function(pobj2){
var i = 0;
pobj.length = Math.max(pobj.length, pobj2.length);
for(; i<pobj.length; i++){
if(typeof pobj2[i] !== 'undefined'){
pobj[i] = pobj2[i];
}else{
delete pobj[i];
}
}
}
}
};
this.render( ctxt, directive );
if(typeof postProcess !== 'undefined'){
for(sel in postProcess){
action = postProcess[sel];
if(typeof action === 'function'){
replace_( this ).by( this.find(sel) );
action.call(this);
}
}
}
return this;
};
//register it as a jquery extension
jQuery.fn.extend({
renderWithEffects:function(ctxt, directive, postProcess){
return jQuery( $p( this[0] ).renderWithEffects( ctxt, directive, postProcess ) );
}
});
var directive = {
'tr' : { //trigger a loop
'animal<-animals' : { // loop on the property animals in the JSON
'@class+':function(arg){ // add(+) the return value of the function to the class
var oddEven, firstLast;
oddEven = (arg.pos % 2 == 0) ? ' even' : ' odd';
firstLast = (arg.pos == 0) ?
' first' :
(arg.pos == arg.animal.items.length - 1) ?
' last' :
'';
return oddEven + firstLast;
},
'td':'animal.name'
}
}
};
var data = {
animals:[
{name:'bird'},
{name:'cat'},
{name:'dog'},
{name:'mouse'}
]
};
var effects = {
tr:function(){
var i = 0;
$(this).each(function(){
i++ % 2 ? $(this).fadeOut(3000) : $(this).hide(3000);
});
}
};
$('table').renderWithEffects(data, directive, effects);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto7.html | HTML | gpl2 | 2,237 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script>
function jsonp(src){
var s = document.createElement("script");
s.charset = "UTF-8";
s.src = encodeURI(src);
document.body.appendChild(s);
return s;
};
function urlParam(name, w){
w = w || window;
var rx = new RegExp('[\&|\?]'+name+'=([^\&\#]+)');
var val = w.location.href.match(rx);
return !val ? '':val[1];
};
</script>
</head>
<body>
<script>
var fp = urlParam('fp'),
gist = urlParam('gist');
if(gist){
jsonp( 'http://gist.github.com/' + gist + '.js');
}else if(fp){
jsonp( 'http://friendpaste.com/' + fp + '.js' );
}else{
document.write('Not a valid gist (gist= ... )or friendpaste fp= ...');
}
</script>
</body>
</html>
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/fp.html | HTML | gpl2 | 806 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!--
same example as before but with an attribute assignment
note the property@attribute notation
'who@value' means place the value of the property who in the value attribute
-->
Hello <a class="who site@href"></a>
<script>
var data = {'who':'BeeBole!', site:'http://beebole.com'};
$('a').autoRender(data);
</script>
</body>
</html>
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto2.html | HTML | gpl2 | 515 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine - Recursion</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<ul class="treeItem">
<li>
<a class="name" href="javascript:void(0)">name</a>
<div class="children"></div>
</li>
</ul>
<script>
var data = {
children: [{
name: 'Europe',
children: [{
name: 'Belgium',
children: [{
name: 'Brussels',
children:null},{
name: 'Namur'},{
name: 'Antwerpen'}]},{
name: 'Germany'},{
name: 'UK'}]},{
name: 'America',
children: [{
name: 'US',
children: [{
name: 'Alabama'},{
name: 'Georgia'}]},{
name: 'Canada'},{
name: 'Argentina'}]},{
name: 'Asia'},{
name: 'Africa'},{
name: 'Antarctica'}
]
};
var directive = {
'li': {
'child <- children': {
'a': 'child.name',
'a@onclick':'alert(\'#{child.name}\');',
'div.children': function(ctxt){
return ctxt.child.item.children ? rfn(ctxt.child.item):'';
}
}
}
};
var rfn = $('ul').compile( directive );
$('ul').render( data, rfn );
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto8.html | HTML | gpl2 | 1,351 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
<ul>
<li></li>
</ul>
<script>
var data = {
legs:4,
animals:[
{name:'dog', legs:4},
{name:'cat', legs:4},
{name:'bird', legs:2},
{name:'mouse', legs:4}
]
};
//declaration of the actions PURE has to do
var directive = {
'li':{
'animal<-animals':{
'.':'animal.name'
},
//sort function like the ususal Array.sort
sort:function(a, b){
return a.name > b.name ? 1 : -1;
},
filter:function(a){
//if the returned value is false, the rendering will be skipped for this entry
return a.context.legs === a.item.legs;
}
}
};
// note the use of render instead of autoRender, and the 2nd argument
$('ul').render(data, directive);
</script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/tutorial/tuto5b.html | HTML | gpl2 | 1,023 |
/*!
* Sizzle CSS Selector Engine
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
* More information: http://sizzlejs.com/
*/
(function(){
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
expando = "sizcache" + (Math.random() + '').replace('.', ''),
done = 0,
toString = Object.prototype.toString,
hasDuplicate = false,
baseHasDuplicate = true,
rBackslash = /\\/g,
rNonWord = /\W/;
// Here we check if the JavaScript engine is using some sort of
// optimization where it does not always call our comparision
// function. If that is the case, discard the hasDuplicate value.
// Thus far that includes Google Chrome.
[0, 0].sort(function() {
baseHasDuplicate = false;
return 0;
});
var Sizzle = function( selector, context, results, seed ) {
results = results || [];
context = context || document;
var origContext = context;
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return [];
}
if ( !selector || typeof selector !== "string" ) {
return results;
}
var m, set, checkSet, extra, ret, cur, pop, i,
prune = true,
contextXML = Sizzle.isXML( context ),
parts = [],
soFar = selector;
// Reset the position of the chunker regexp (start from head)
do {
chunker.exec( "" );
m = chunker.exec( soFar );
if ( m ) {
soFar = m[3];
parts.push( m[1] );
if ( m[2] ) {
extra = m[3];
break;
}
}
} while ( m );
if ( parts.length > 1 && origPOS.exec( selector ) ) {
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
set = posProcess( parts[0] + parts[1], context, seed );
} else {
set = Expr.relative[ parts[0] ] ?
[ context ] :
Sizzle( parts.shift(), context );
while ( parts.length ) {
selector = parts.shift();
if ( Expr.relative[ selector ] ) {
selector += parts.shift();
}
set = posProcess( selector, set, seed );
}
}
} else {
// Take a shortcut and set the context if the root selector is an ID
// (but not if it'll be faster if the inner selector is an ID)
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
ret = Sizzle.find( parts.shift(), context, contextXML );
context = ret.expr ?
Sizzle.filter( ret.expr, ret.set )[0] :
ret.set[0];
}
if ( context ) {
ret = seed ?
{ expr: parts.pop(), set: makeArray(seed) } :
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
set = ret.expr ?
Sizzle.filter( ret.expr, ret.set ) :
ret.set;
if ( parts.length > 0 ) {
checkSet = makeArray( set );
} else {
prune = false;
}
while ( parts.length ) {
cur = parts.pop();
pop = cur;
if ( !Expr.relative[ cur ] ) {
cur = "";
} else {
pop = parts.pop();
}
if ( pop == null ) {
pop = context;
}
Expr.relative[ cur ]( checkSet, pop, contextXML );
}
} else {
checkSet = parts = [];
}
}
if ( !checkSet ) {
checkSet = set;
}
if ( !checkSet ) {
Sizzle.error( cur || selector );
}
if ( toString.call(checkSet) === "[object Array]" ) {
if ( !prune ) {
results.push.apply( results, checkSet );
} else if ( context && context.nodeType === 1 ) {
for ( i = 0; checkSet[i] != null; i++ ) {
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
results.push( set[i] );
}
}
} else {
for ( i = 0; checkSet[i] != null; i++ ) {
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
results.push( set[i] );
}
}
}
} else {
makeArray( checkSet, results );
}
if ( extra ) {
Sizzle( extra, origContext, results, seed );
Sizzle.uniqueSort( results );
}
return results;
};
Sizzle.uniqueSort = function( results ) {
if ( sortOrder ) {
hasDuplicate = baseHasDuplicate;
results.sort( sortOrder );
if ( hasDuplicate ) {
for ( var i = 1; i < results.length; i++ ) {
if ( results[i] === results[ i - 1 ] ) {
results.splice( i--, 1 );
}
}
}
}
return results;
};
Sizzle.matches = function( expr, set ) {
return Sizzle( expr, null, null, set );
};
Sizzle.matchesSelector = function( node, expr ) {
return Sizzle( expr, null, null, [node] ).length > 0;
};
Sizzle.find = function( expr, context, isXML ) {
var set, i, len, match, type, left;
if ( !expr ) {
return [];
}
for ( i = 0, len = Expr.order.length; i < len; i++ ) {
type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
left = match[1];
match.splice( 1, 1 );
if ( left.substr( left.length - 1 ) !== "\\" ) {
match[1] = (match[1] || "").replace( rBackslash, "" );
set = Expr.find[ type ]( match, context, isXML );
if ( set != null ) {
expr = expr.replace( Expr.match[ type ], "" );
break;
}
}
}
}
if ( !set ) {
set = typeof context.getElementsByTagName !== "undefined" ?
context.getElementsByTagName( "*" ) :
[];
}
return { set: set, expr: expr };
};
Sizzle.filter = function( expr, set, inplace, not ) {
var match, anyFound,
type, found, item, filter, left,
i, pass,
old = expr,
result = [],
curLoop = set,
isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
while ( expr && set.length ) {
for ( type in Expr.filter ) {
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
filter = Expr.filter[ type ];
left = match[1];
anyFound = false;
match.splice(1,1);
if ( left.substr( left.length - 1 ) === "\\" ) {
continue;
}
if ( curLoop === result ) {
result = [];
}
if ( Expr.preFilter[ type ] ) {
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
if ( !match ) {
anyFound = found = true;
} else if ( match === true ) {
continue;
}
}
if ( match ) {
for ( i = 0; (item = curLoop[i]) != null; i++ ) {
if ( item ) {
found = filter( item, match, i, curLoop );
pass = not ^ found;
if ( inplace && found != null ) {
if ( pass ) {
anyFound = true;
} else {
curLoop[i] = false;
}
} else if ( pass ) {
result.push( item );
anyFound = true;
}
}
}
}
if ( found !== undefined ) {
if ( !inplace ) {
curLoop = result;
}
expr = expr.replace( Expr.match[ type ], "" );
if ( !anyFound ) {
return [];
}
break;
}
}
}
// Improper expression
if ( expr === old ) {
if ( anyFound == null ) {
Sizzle.error( expr );
} else {
break;
}
}
old = expr;
}
return curLoop;
};
Sizzle.error = function( msg ) {
throw new Error( "Syntax error, unrecognized expression: " + msg );
};
/**
* Utility function for retreiving the text value of an array of DOM nodes
* @param {Array|Element} elem
*/
var getText = Sizzle.getText = function( elem ) {
var i, node,
nodeType = elem.nodeType,
ret = "";
if ( nodeType ) {
if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
// Use textContent for elements
// innerText usage removed for consistency of new lines (see #11153)
if ( typeof elem.textContent === "string" ) {
return elem.textContent;
} else {
// Traverse it's children
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
ret += getText( elem );
}
}
} else if ( nodeType === 3 || nodeType === 4 ) {
return elem.nodeValue;
}
} else {
// If no nodeType, this is expected to be an array
for ( i = 0; (node = elem[i]); i++ ) {
// Do not traverse comment nodes
if ( node.nodeType !== 8 ) {
ret += getText( node );
}
}
}
return ret;
};
var Expr = Sizzle.selectors = {
order: [ "ID", "NAME", "TAG" ],
match: {
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
},
leftMatch: {},
attrMap: {
"class": "className",
"for": "htmlFor"
},
attrHandle: {
href: function( elem ) {
return elem.getAttribute( "href" );
},
type: function( elem ) {
return elem.getAttribute( "type" );
}
},
relative: {
"+": function(checkSet, part){
var isPartStr = typeof part === "string",
isTag = isPartStr && !rNonWord.test( part ),
isPartStrNotTag = isPartStr && !isTag;
if ( isTag ) {
part = part.toLowerCase();
}
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
if ( (elem = checkSet[i]) ) {
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
elem || false :
elem === part;
}
}
if ( isPartStrNotTag ) {
Sizzle.filter( part, checkSet, true );
}
},
">": function( checkSet, part ) {
var elem,
isPartStr = typeof part === "string",
i = 0,
l = checkSet.length;
if ( isPartStr && !rNonWord.test( part ) ) {
part = part.toLowerCase();
for ( ; i < l; i++ ) {
elem = checkSet[i];
if ( elem ) {
var parent = elem.parentNode;
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
}
}
} else {
for ( ; i < l; i++ ) {
elem = checkSet[i];
if ( elem ) {
checkSet[i] = isPartStr ?
elem.parentNode :
elem.parentNode === part;
}
}
if ( isPartStr ) {
Sizzle.filter( part, checkSet, true );
}
}
},
"": function(checkSet, part, isXML){
var nodeCheck,
doneName = done++,
checkFn = dirCheck;
if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
}
checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
},
"~": function( checkSet, part, isXML ) {
var nodeCheck,
doneName = done++,
checkFn = dirCheck;
if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
}
checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
}
},
find: {
ID: function( match, context, isXML ) {
if ( typeof context.getElementById !== "undefined" && !isXML ) {
var m = context.getElementById(match[1]);
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
return m && m.parentNode ? [m] : [];
}
},
NAME: function( match, context ) {
if ( typeof context.getElementsByName !== "undefined" ) {
var ret = [],
results = context.getElementsByName( match[1] );
for ( var i = 0, l = results.length; i < l; i++ ) {
if ( results[i].getAttribute("name") === match[1] ) {
ret.push( results[i] );
}
}
return ret.length === 0 ? null : ret;
}
},
TAG: function( match, context ) {
if ( typeof context.getElementsByTagName !== "undefined" ) {
return context.getElementsByTagName( match[1] );
}
}
},
preFilter: {
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
match = " " + match[1].replace( rBackslash, "" ) + " ";
if ( isXML ) {
return match;
}
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
if ( elem ) {
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
if ( !inplace ) {
result.push( elem );
}
} else if ( inplace ) {
curLoop[i] = false;
}
}
}
return false;
},
ID: function( match ) {
return match[1].replace( rBackslash, "" );
},
TAG: function( match, curLoop ) {
return match[1].replace( rBackslash, "" ).toLowerCase();
},
CHILD: function( match ) {
if ( match[1] === "nth" ) {
if ( !match[2] ) {
Sizzle.error( match[0] );
}
match[2] = match[2].replace(/^\+|\s*/g, '');
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
// calculate the numbers (first)n+(last) including if they are negative
match[2] = (test[1] + (test[2] || 1)) - 0;
match[3] = test[3] - 0;
}
else if ( match[2] ) {
Sizzle.error( match[0] );
}
// TODO: Move to normal caching system
match[0] = done++;
return match;
},
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
// Handle if an un-quoted value was used
match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
if ( match[2] === "~=" ) {
match[4] = " " + match[4] + " ";
}
return match;
},
PSEUDO: function( match, curLoop, inplace, result, not ) {
if ( match[1] === "not" ) {
// If we're dealing with a complex expression, or a simple one
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
match[3] = Sizzle(match[3], null, null, curLoop);
} else {
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
if ( !inplace ) {
result.push.apply( result, ret );
}
return false;
}
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true;
}
return match;
},
POS: function( match ) {
match.unshift( true );
return match;
}
},
filters: {
enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden";
},
disabled: function( elem ) {
return elem.disabled === true;
},
checked: function( elem ) {
return elem.checked === true;
},
selected: function( elem ) {
// Accessing this property makes selected-by-default
// options in Safari work properly
if ( elem.parentNode ) {
elem.parentNode.selectedIndex;
}
return elem.selected === true;
},
parent: function( elem ) {
return !!elem.firstChild;
},
empty: function( elem ) {
return !elem.firstChild;
},
has: function( elem, i, match ) {
return !!Sizzle( match[3], elem ).length;
},
header: function( elem ) {
return (/h\d/i).test( elem.nodeName );
},
text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
},
radio: function( elem ) {
return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
},
checkbox: function( elem ) {
return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
},
file: function( elem ) {
return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
},
password: function( elem ) {
return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
},
submit: function( elem ) {
var name = elem.nodeName.toLowerCase();
return (name === "input" || name === "button") && "submit" === elem.type;
},
image: function( elem ) {
return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
},
reset: function( elem ) {
var name = elem.nodeName.toLowerCase();
return (name === "input" || name === "button") && "reset" === elem.type;
},
button: function( elem ) {
var name = elem.nodeName.toLowerCase();
return name === "input" && "button" === elem.type || name === "button";
},
input: function( elem ) {
return (/input|select|textarea|button/i).test( elem.nodeName );
},
focus: function( elem ) {
return elem === elem.ownerDocument.activeElement;
}
},
setFilters: {
first: function( elem, i ) {
return i === 0;
},
last: function( elem, i, match, array ) {
return i === array.length - 1;
},
even: function( elem, i ) {
return i % 2 === 0;
},
odd: function( elem, i ) {
return i % 2 === 1;
},
lt: function( elem, i, match ) {
return i < match[3] - 0;
},
gt: function( elem, i, match ) {
return i > match[3] - 0;
},
nth: function( elem, i, match ) {
return match[3] - 0 === i;
},
eq: function( elem, i, match ) {
return match[3] - 0 === i;
}
},
filter: {
PSEUDO: function( elem, match, i, array ) {
var name = match[1],
filter = Expr.filters[ name ];
if ( filter ) {
return filter( elem, i, match, array );
} else if ( name === "contains" ) {
return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
} else if ( name === "not" ) {
var not = match[3];
for ( var j = 0, l = not.length; j < l; j++ ) {
if ( not[j] === elem ) {
return false;
}
}
return true;
} else {
Sizzle.error( name );
}
},
CHILD: function( elem, match ) {
var first, last,
doneName, parent, cache,
count, diff,
type = match[1],
node = elem;
switch ( type ) {
case "only":
case "first":
while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) {
return false;
}
}
if ( type === "first" ) {
return true;
}
node = elem;
/* falls through */
case "last":
while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) {
return false;
}
}
return true;
case "nth":
first = match[2];
last = match[3];
if ( first === 1 && last === 0 ) {
return true;
}
doneName = match[0];
parent = elem.parentNode;
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
node.nodeIndex = ++count;
}
}
parent[ expando ] = doneName;
}
diff = elem.nodeIndex - last;
if ( first === 0 ) {
return diff === 0;
} else {
return ( diff % first === 0 && diff / first >= 0 );
}
}
},
ID: function( elem, match ) {
return elem.nodeType === 1 && elem.getAttribute("id") === match;
},
TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
},
CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1;
},
ATTR: function( elem, match ) {
var name = match[1],
result = Sizzle.attr ?
Sizzle.attr( elem, name ) :
Expr.attrHandle[ name ] ?
Expr.attrHandle[ name ]( elem ) :
elem[ name ] != null ?
elem[ name ] :
elem.getAttribute( name ),
value = result + "",
type = match[2],
check = match[4];
return result == null ?
type === "!=" :
!type && Sizzle.attr ?
result != null :
type === "=" ?
value === check :
type === "*=" ?
value.indexOf(check) >= 0 :
type === "~=" ?
(" " + value + " ").indexOf(check) >= 0 :
!check ?
value && result !== false :
type === "!=" ?
value !== check :
type === "^=" ?
value.indexOf(check) === 0 :
type === "$=" ?
value.substr(value.length - check.length) === check :
type === "|=" ?
value === check || value.substr(0, check.length + 1) === check + "-" :
false;
},
POS: function( elem, match, i, array ) {
var name = match[2],
filter = Expr.setFilters[ name ];
if ( filter ) {
return filter( elem, i, match, array );
}
}
}
};
var origPOS = Expr.match.POS,
fescape = function(all, num){
return "\\" + (num - 0 + 1);
};
for ( var type in Expr.match ) {
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
}
// Expose origPOS
// "global" as in regardless of relation to brackets/parens
Expr.match.globalPOS = origPOS;
var makeArray = function( array, results ) {
array = Array.prototype.slice.call( array, 0 );
if ( results ) {
results.push.apply( results, array );
return results;
}
return array;
};
// Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods.
// Also verifies that the returned array holds DOM nodes
// (which is not the case in the Blackberry browser)
try {
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
// Provide a fallback method if it does not work
} catch( e ) {
makeArray = function( array, results ) {
var i = 0,
ret = results || [];
if ( toString.call(array) === "[object Array]" ) {
Array.prototype.push.apply( ret, array );
} else {
if ( typeof array.length === "number" ) {
for ( var l = array.length; i < l; i++ ) {
ret.push( array[i] );
}
} else {
for ( ; array[i]; i++ ) {
ret.push( array[i] );
}
}
}
return ret;
};
}
var sortOrder, siblingCheck;
if ( document.documentElement.compareDocumentPosition ) {
sortOrder = function( a, b ) {
if ( a === b ) {
hasDuplicate = true;
return 0;
}
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
return a.compareDocumentPosition ? -1 : 1;
}
return a.compareDocumentPosition(b) & 4 ? -1 : 1;
};
} else {
sortOrder = function( a, b ) {
// The nodes are identical, we can exit early
if ( a === b ) {
hasDuplicate = true;
return 0;
// Fallback to using sourceIndex (in IE) if it's available on both nodes
} else if ( a.sourceIndex && b.sourceIndex ) {
return a.sourceIndex - b.sourceIndex;
}
var al, bl,
ap = [],
bp = [],
aup = a.parentNode,
bup = b.parentNode,
cur = aup;
// If the nodes are siblings (or identical) we can do a quick check
if ( aup === bup ) {
return siblingCheck( a, b );
// If no parents were found then the nodes are disconnected
} else if ( !aup ) {
return -1;
} else if ( !bup ) {
return 1;
}
// Otherwise they're somewhere else in the tree so we need
// to build up a full list of the parentNodes for comparison
while ( cur ) {
ap.unshift( cur );
cur = cur.parentNode;
}
cur = bup;
while ( cur ) {
bp.unshift( cur );
cur = cur.parentNode;
}
al = ap.length;
bl = bp.length;
// Start walking down the tree looking for a discrepancy
for ( var i = 0; i < al && i < bl; i++ ) {
if ( ap[i] !== bp[i] ) {
return siblingCheck( ap[i], bp[i] );
}
}
// We ended someplace up the tree so do a sibling check
return i === al ?
siblingCheck( a, bp[i], -1 ) :
siblingCheck( ap[i], b, 1 );
};
siblingCheck = function( a, b, ret ) {
if ( a === b ) {
return ret;
}
var cur = a.nextSibling;
while ( cur ) {
if ( cur === b ) {
return -1;
}
cur = cur.nextSibling;
}
return 1;
};
}
// Check to see if the browser returns elements by name when
// querying by getElementById (and provide a workaround)
(function(){
// We're going to inject a fake input element with a specified name
var form = document.createElement("div"),
id = "script" + (new Date()).getTime(),
root = document.documentElement;
form.innerHTML = "<a name='" + id + "'/>";
// Inject it into the root element, check its status, and remove it quickly
root.insertBefore( form, root.firstChild );
// The workaround has to do additional checks after a getElementById
// Which slows things down for other browsers (hence the branching)
if ( document.getElementById( id ) ) {
Expr.find.ID = function( match, context, isXML ) {
if ( typeof context.getElementById !== "undefined" && !isXML ) {
var m = context.getElementById(match[1]);
return m ?
m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
[m] :
undefined :
[];
}
};
Expr.filter.ID = function( elem, match ) {
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
return elem.nodeType === 1 && node && node.nodeValue === match;
};
}
root.removeChild( form );
// release memory in IE
root = form = null;
})();
(function(){
// Check to see if the browser returns only elements
// when doing getElementsByTagName("*")
// Create a fake element
var div = document.createElement("div");
div.appendChild( document.createComment("") );
// Make sure no comments are found
if ( div.getElementsByTagName("*").length > 0 ) {
Expr.find.TAG = function( match, context ) {
var results = context.getElementsByTagName( match[1] );
// Filter out possible comments
if ( match[1] === "*" ) {
var tmp = [];
for ( var i = 0; results[i]; i++ ) {
if ( results[i].nodeType === 1 ) {
tmp.push( results[i] );
}
}
results = tmp;
}
return results;
};
}
// Check to see if an attribute returns normalized href attributes
div.innerHTML = "<a href='#'></a>";
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
div.firstChild.getAttribute("href") !== "#" ) {
Expr.attrHandle.href = function( elem ) {
return elem.getAttribute( "href", 2 );
};
}
// release memory in IE
div = null;
})();
if ( document.querySelectorAll ) {
(function(){
var oldSizzle = Sizzle,
div = document.createElement("div"),
id = "__sizzle__";
div.innerHTML = "<p class='TEST'></p>";
// Safari can't handle uppercase or unicode characters when
// in quirks mode.
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return;
}
Sizzle = function( query, context, extra, seed ) {
context = context || document;
// Only use querySelectorAll on non-XML documents
// (ID selectors don't work in non-HTML documents)
if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG")
if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra );
}
}
if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it
if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) {
var elem = context.getElementById( match[3] );
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if ( elem && elem.parentNode ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra );
}
} else {
return makeArray( [], extra );
}
}
try {
return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {}
// qSA works strangely on Element-rooted queries
// We can work around this by specifying an extra ID on the root
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
var oldContext = context,
old = context.getAttribute( "id" ),
nid = old || id,
hasParent = context.parentNode,
relativeHierarchySelector = /^\s*[+~]/.test( query );
if ( !old ) {
context.setAttribute( "id", nid );
} else {
nid = nid.replace( /'/g, "\\$&" );
}
if ( relativeHierarchySelector && hasParent ) {
context = context.parentNode;
}
try {
if ( !relativeHierarchySelector || hasParent ) {
return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
}
} catch(pseudoError) {
} finally {
if ( !old ) {
oldContext.removeAttribute( "id" );
}
}
}
}
return oldSizzle(query, context, extra, seed);
};
for ( var prop in oldSizzle ) {
Sizzle[ prop ] = oldSizzle[ prop ];
}
// release memory in IE
div = null;
})();
}
(function(){
var html = document.documentElement,
matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
if ( matches ) {
// Check to see if it's possible to do matchesSelector
// on a disconnected node (IE 9 fails this)
var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
pseudoWorks = false;
try {
// This should fail with an exception
// Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) {
pseudoWorks = true;
}
Sizzle.matchesSelector = function( node, expr ) {
// Make sure that attribute selectors are quoted
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) {
try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr );
// IE 9's matchesSelector returns false on disconnected nodes
if ( ret || !disconnectedMatch ||
// As well, disconnected nodes are said to be in a document
// fragment in IE 9, so check for that
node.document && node.document.nodeType !== 11 ) {
return ret;
}
}
} catch(e) {}
}
return Sizzle(expr, null, null, [node]).length > 0;
};
}
})();
(function(){
var div = document.createElement("div");
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
// Opera can't find a second classname (in 9.6)
// Also, make sure that getElementsByClassName actually exists
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
return;
}
// Safari caches class attributes, doesn't catch changes (in 3.2)
div.lastChild.className = "e";
if ( div.getElementsByClassName("e").length === 1 ) {
return;
}
Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
return context.getElementsByClassName(match[1]);
}
};
// release memory in IE
div = null;
})();
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
if ( elem ) {
var match = false;
elem = elem[dir];
while ( elem ) {
if ( elem[ expando ] === doneName ) {
match = checkSet[elem.sizset];
break;
}
if ( elem.nodeType === 1 && !isXML ){
elem[ expando ] = doneName;
elem.sizset = i;
}
if ( elem.nodeName.toLowerCase() === cur ) {
match = elem;
break;
}
elem = elem[dir];
}
checkSet[i] = match;
}
}
}
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
if ( elem ) {
var match = false;
elem = elem[dir];
while ( elem ) {
if ( elem[ expando ] === doneName ) {
match = checkSet[elem.sizset];
break;
}
if ( elem.nodeType === 1 ) {
if ( !isXML ) {
elem[ expando ] = doneName;
elem.sizset = i;
}
if ( typeof cur !== "string" ) {
if ( elem === cur ) {
match = true;
break;
}
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
match = elem;
break;
}
}
elem = elem[dir];
}
checkSet[i] = match;
}
}
}
if ( document.documentElement.contains ) {
Sizzle.contains = function( a, b ) {
return a !== b && (a.contains ? a.contains(b) : true);
};
} else if ( document.documentElement.compareDocumentPosition ) {
Sizzle.contains = function( a, b ) {
return !!(a.compareDocumentPosition(b) & 16);
};
} else {
Sizzle.contains = function() {
return false;
};
}
Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false;
};
var posProcess = function( selector, context, seed ) {
var match,
tmpSet = [],
later = "",
root = context.nodeType ? [context] : context;
// Position selectors must be done after the filter
// And so must :not(positional) so we move all PSEUDOs to the end
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
later += match[0];
selector = selector.replace( Expr.match.PSEUDO, "" );
}
selector = Expr.relative[selector] ? selector + "*" : selector;
for ( var i = 0, l = root.length; i < l; i++ ) {
Sizzle( selector, root[i], tmpSet, seed );
}
return Sizzle.filter( later, tmpSet );
};
// EXPOSE
window.Sizzle = Sizzle;
})(); | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/libs/sizzle.js | JavaScript | gpl2 | 34,244 |
/*!
PURE Unobtrusive Rendering Engine for HTML
Licensed under the MIT licenses.
More information at: http://www.opensource.org
Copyright (c) 2012 Michael Cvilic - BeeBole.com
Thanks to Rog Peppe for the functional JS jump
revision: 2.74
*/
var $p, pure = $p = function(){
var sel = arguments[0],
ctxt = false;
if(typeof sel === 'string'){
ctxt = arguments[1] || false;
}else if(sel && !sel[0] && !sel.length){
sel = [sel];
}
return $p.core(sel, ctxt);
};
$p.core = function(sel, ctxt, plugins){
//get an instance of the plugins
var templates = [];
plugins = plugins || getPlugins();
//search for the template node(s)
switch(typeof sel){
case 'string':
templates = plugins.find(ctxt || document, sel);
if(templates.length === 0) {
error('The template "' + sel + '" was not found');
}
break;
case 'undefined':
error('The root of the template is undefined, check your selector');
break;
default:
templates = sel;
}
for(var i = 0, ii = templates.length; i < ii; i++){
plugins[i] = templates[i];
}
plugins.length = ii;
// set the signature string that will be replaced at render time
var Sig = '_s' + Math.floor( Math.random() * 1000000 ) + '_',
// another signature to prepend to attributes and avoid checks: style, height, on[events]...
attPfx = '_a' + Math.floor( Math.random() * 1000000 ) + '_',
// rx to parse selectors, e.g. "+tr.foo[class]"
selRx = /^(\+)?([^\@\+]+)?\@?([^\+]+)?(\+)?$/,
// set automatically attributes for some tags
autoAttr = {
IMG:'src',
INPUT:'value'
},
// check if the argument is an array - thanks salty-horse (Ori Avtalion)
isArray = Array.isArray ?
function(o) {
return Array.isArray(o);
} :
function(o) {
return Object.prototype.toString.call(o) === "[object Array]";
};
/* * * * * * * * * * * * * * * * * * * * * * * * * *
core functions
* * * * * * * * * * * * * * * * * * * * * * * * * */
// error utility
function error(e){
if(typeof console !== 'undefined'){
console.log(e);
debugger;
}
throw('pure error: ' + e);
}
//return a new instance of plugins
function getPlugins(){
var plugins = $p.plugins,
f = function(){};
f.prototype = plugins;
// do not overwrite functions if external definition
f.prototype.compile = plugins.compile || compile;
f.prototype.render = plugins.render || render;
f.prototype.autoRender = plugins.autoRender || autoRender;
f.prototype.find = plugins.find || find;
// give the compiler and the error handling to the plugin context
f.prototype._compiler = compiler;
f.prototype._error = error;
return new f();
}
// returns the outer HTML of a node
function outerHTML(node){
// if IE, Chrome take the internal method otherwise build one
return node.outerHTML || (
function(n){
var div = document.createElement('div'), h;
div.appendChild( n.cloneNode(true) );
h = div.innerHTML;
div = null;
return h;
})(node);
}
// returns the string generator function
function wrapquote(qfn, f){
return function(ctxt){
return qfn('' + f.call(ctxt.item || ctxt.context, ctxt));
};
}
// default find using querySelector when available on the browser
function find(n, sel){
if(typeof n === 'string'){
sel = n;
n = false;
}
if(typeof document.querySelectorAll !== 'undefined'){
return (n||document).querySelectorAll( sel );
}else{
return error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine');
}
}
// create a function that concatenates constant string
// sections (given in parts) and the results of called
// functions to fill in the gaps between parts (fns).
// fns[n] fills in the gap between parts[n-1] and parts[n];
// fns[0] is unused.
// this is the inner template evaluation loop.
function concatenator(parts, fns){
return function(ctxt){
var strs = [ parts[ 0 ] ],
n = parts.length,
fnVal, pVal, attLine, pos;
for(var i = 1; i < n; i++){
fnVal = fns[i].call( this, ctxt );
pVal = parts[i];
// if the value is empty and attribute, remove it
if(fnVal === ''){
attLine = strs[ strs.length - 1 ];
if( ( pos = attLine.search( /[^\s]+=\"?$/ ) ) > -1){
strs[ strs.length - 1 ] = attLine.substring( 0, pos );
pVal = pVal.substr( 1 );
}
}
strs[ strs.length ] = fnVal;
strs[ strs.length ] = pVal;
}
return strs.join('');
};
}
// parse and check the loop directive
function parseloopspec(p){
var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
if(m === null){
error('bad loop spec: "' + p + '"');
}
if(m[1] === 'item'){
error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
}
if( !m[2] || m[2].toLowerCase() === 'context' ){ //undefined or space(IE)
m[2] = function(ctxt){return ctxt.context;};
}else if( (m[2] && m[2].indexOf('context') === 0 ) ){ //undefined or space(IE)
m[2] = dataselectfn( m[2].replace(/^context\.?/, '') );
}
return {name: m[1], sel: m[2]};
}
// parse a data selector and return a function that
// can traverse the data accordingly, given a context.
function dataselectfn (sel){
if( typeof(sel) === 'function' ){
//handle false values in function directive
return function ( ctxt ){
var r = sel.call( ctxt.item || ctxt.context || ctxt, ctxt );
return !r && r !== 0 ? '' : r;
};
}
//check for a valid js variable name with hyphen(for properties only), $, _ and :
var m = sel.match(/^[\da-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);
if(m === null){
var found = false, s = sel, parts = [], pfns = [], i = 0, retStr;
// check if literal
if(/\'|\"/.test( s.charAt(0) )){
if(/\'|\"/.test( s.charAt(s.length-1) )){
retStr = s.substring(1, s.length-1);
return function(){ return retStr; };
}
}else{
// check if literal + #{var}
while((m = s.match(/#\{([^{}]+)\}/)) !== null){
found = true;
parts[i++] = s.slice(0, m.index);
pfns[i] = dataselectfn(m[1]);
s = s.slice(m.index + m[0].length, s.length);
}
}
if(!found){ //constant, return it
return function(){ return sel; };
}
parts[i] = s;
return concatenator(parts, pfns);
}
m = sel.split('.');
return function(ctxt){
var data = ctxt.context || ctxt,
v = ctxt[m[0]],
i = 0;
if(v && typeof v.item !== 'undefined'){
i += 1;
if(m[i] === 'pos'){
//allow pos to be kept by string. Tx to Adam Freidin
return v.pos;
}else{
data = v.item;
}
}
var n = m.length,
dm;
for(; i < n; i++){
if(!data){break;}
dm = data[ m[i] ];
//if it is a function call it
data = typeof dm === 'function' ? data[ m[i] ].call( data ) : dm;
}
return (!data && data !== 0) ? '':data;
};
}
// wrap in an object the target node/attr and their properties
function gettarget(dom, sel, isloop){
var osel, prepend, selector, attr, append, target = [];
if( typeof sel === 'string' ){
osel = sel;
var m = sel.match(selRx);
if( !m ){
error( 'bad selector syntax: ' + sel );
}
prepend = m[1];
selector = m[2];
attr = m[3];
append = m[4];
if(selector === '.' || ( !selector && attr ) ){
target[0] = dom;
}else{
target = plugins.find(dom, selector);
}
if(!target || target.length === 0){
return error('The node "' + sel + '" was not found in the template:\n' + outerHTML(dom).replace(/\t/g,' '));
}
}else{
// autoRender node
prepend = sel.prepend;
attr = sel.attr;
append = sel.append;
target = [dom];
}
if( prepend || append ){
if( prepend && append ){
error('append/prepend cannot take place at the same time');
}else if( isloop ){
error('no append/prepend/replace modifiers allowed for loop target');
}else if( append && isloop ){
error('cannot append with loop (sel: ' + osel + ')');
}
}
var setstr, getstr, quotefn, isStyle, isClass, attName, setfn;
if(attr){
isStyle = (/^style$/i).test(attr);
isClass = (/^class$/i).test(attr);
attName = isClass ? 'className' : attr;
setstr = function(node, s) {
node.setAttribute(attPfx + attr, s);
if (attName in node && !isStyle) {
try{node[attName] = '';}catch(e){} //FF4 gives an error sometimes
}
if (node.nodeType === 1) {
node.removeAttribute(attr);
isClass && node.removeAttribute(attName);
}
};
if (isStyle || isClass) {//IE no quotes special care
if(isStyle){
getstr = function(n){ return n.style.cssText; };
}else{
getstr = function(n){ return n.className; };
}
}else {
getstr = function(n){ return n.getAttribute(attr); };
}
quotefn = function(s){ return s.replace(/\"/g, '"'); };
if(prepend){
setfn = function(node, s){ setstr( node, s + getstr( node )); };
}else if(append){
setfn = function(node, s){ setstr( node, getstr( node ) + s); };
}else{
setfn = function(node, s){ setstr( node, s ); };
}
}else{
if (isloop) {
setfn = function(node, s) {
var pn = node.parentNode;
if (pn) {
//replace node with s
pn.insertBefore(document.createTextNode(s), node.nextSibling);
pn.removeChild(node);
}
};
} else {
if (prepend) {
setfn = function(node, s) { node.insertBefore(document.createTextNode(s), node.firstChild); };
} else if (append) {
setfn = function(node, s) { node.appendChild(document.createTextNode(s));};
} else {
setfn = function(node, s) {
while (node.firstChild) { node.removeChild(node.firstChild); }
node.appendChild(document.createTextNode(s));
};
}
}
quotefn = function(s) { return s; };
}
return { attr: attr, nodes: target, set: setfn, sel: osel, quotefn: quotefn };
}
function setsig(target, n){
var sig = Sig + n + ':';
for(var i = 0; i < target.nodes.length; i++){
// could check for overlapping targets here.
target.set( target.nodes[i], sig );
}
}
// read de loop data, and pass it to the inner rendering function
function loopfn(name, dselect, inner, sorter, filter){
return function(ctxt){
var a = dselect(ctxt),
old = ctxt[name],
temp = { items : a },
filtered = 0,
length,
strs = [],
buildArg = function(idx, temp, ftr, len){
//keep the current loop. Tx to Adam Freidin
var save_pos = ctxt.pos,
save_item = ctxt.item,
save_items = ctxt.items;
ctxt.pos = temp.pos = idx;
ctxt.item = temp.item = a[ idx ];
ctxt.items = a;
//if array, set a length property - filtered items
typeof len !== 'undefined' && (ctxt.length = len);
//if filter directive
if(typeof ftr === 'function' && ftr.call(ctxt.item, ctxt) === false){
filtered++;
return;
}
strs.push( inner.call(ctxt.item, ctxt ) );
//restore the current loop
ctxt.pos = save_pos;
ctxt.item = save_item;
ctxt.items = save_items;
};
ctxt[name] = temp;
if( isArray(a) ){
length = a.length || 0;
// if sort directive
if(typeof sorter === 'function'){
a.sort(sorter);
}
//loop on array
for(var i = 0, ii = length; i < ii; i++){
buildArg(i, temp, filter, length - filtered);
}
}else{
if(a && typeof sorter !== 'undefined'){
error('sort is only available on arrays, not objects');
}
//loop on collections
for(var prop in a){
a.hasOwnProperty( prop ) && buildArg(prop, temp, filter);
}
}
typeof old !== 'undefined' ? ctxt[name] = old : delete ctxt[name];
return strs.join('');
};
}
// generate the template for a loop node
function loopgen(dom, sel, loop, fns){
var already = false, ls, sorter, filter, prop;
for(prop in loop){
if(loop.hasOwnProperty(prop)){
if(prop === 'sort'){
sorter = loop.sort;
continue;
}else if(prop === 'filter'){
filter = loop.filter;
continue;
}
if(already){
error('cannot have more than one loop on a target');
}
ls = prop;
already = true;
}
}
if(!ls){
error('Error in the selector: ' + sel + '\nA directive action must be a string, a function or a loop(<-)');
}
var dsel = loop[ls];
// if it's a simple data selector then we default to contents, not replacement.
if(typeof(dsel) === 'string' || typeof(dsel) === 'function'){
loop = {};
loop[ls] = {root: dsel};
return loopgen(dom, sel, loop, fns);
}
var spec = parseloopspec(ls),
itersel = dataselectfn(spec.sel),
target = gettarget(dom, sel, true),
nodes = target.nodes;
for(i = 0; i < nodes.length; i++){
var node = nodes[i],
inner = compiler(node, dsel);
fns[fns.length] = wrapquote(target.quotefn, loopfn(spec.name, itersel, inner, sorter, filter));
target.nodes = [node]; // N.B. side effect on target.
setsig(target, fns.length - 1);
}
return target;
}
function getAutoNodes(n, data){
var ns = n.getElementsByTagName('*'),
an = [],
openLoops = {a:[],l:{}},
cspec,
isNodeValue,
i, ii, j, jj, ni, cs, cj;
//for each node found in the template
for(i = -1, ii = ns.length; i < ii; i++){
ni = i > -1 ?ns[i]:n;
if(ni.nodeType === 1 && ni.className !== ''){
//when a className is found
cs = ni.className.split(' ');
// for each className
for(j = 0, jj=cs.length;j<jj;j++){
cj = cs[j];
// check if it is related to a context property
cspec = checkClass(cj, ni.tagName);
// if so, store the node, plus the type of data
if(cspec !== false){
isNodeValue = (/nodevalue/i).test(cspec.attr);
if(cspec.sel.indexOf('@') > -1 || isNodeValue){
ni.className = ni.className.replace('@'+cspec.attr, '');
if(isNodeValue){
cspec.attr = false;
}
}
an.push({n:ni, cspec:cspec});
}
}
}
}
function checkClass(c, tagName){
// read the class
var ca = c.match(selRx),
attr = ca[3] || autoAttr[tagName],
cspec = {prepend:!!ca[1], prop:ca[2], attr:attr, append:!!ca[4], sel:c},
i, ii, loopi, loopil, val;
// check in existing open loops
for(i = openLoops.a.length-1; i >= 0; i--){
loopi = openLoops.a[i];
loopil = loopi.l[0];
val = loopil && loopil[cspec.prop];
if(typeof val !== 'undefined'){
cspec.prop = loopi.p + '.' + cspec.prop;
if(openLoops.l[cspec.prop] === true){
val = val[0];
}
break;
}
}
// not found check first level of data
if(typeof val === 'undefined'){
val = dataselectfn(cspec.prop)(isArray(data) ? data[0] : data);
// nothing found return
if(val === ''){
return false;
}
}
// set the spec for autoNode
if(isArray(val)){
openLoops.a.push( {l:val, p:cspec.prop} );
openLoops.l[cspec.prop] = true;
cspec.t = 'loop';
}else{
cspec.t = 'str';
}
return cspec;
}
return an;
}
// returns a function that, given a context argument,
// will render the template defined by dom and directive.
function compiler(dom, directive, data, ans){
var fns = [], j, jj, cspec, n, target, nodes, itersel, node, inner, dsel, sels, sel, sl, i, h, parts, pfns = [], p;
// autoRendering nodes parsing -> auto-nodes
ans = ans || data && getAutoNodes(dom, data);
if(data){
// for each auto-nodes
while(ans.length > 0){
cspec = ans[0].cspec;
n = ans[0].n;
ans.splice(0, 1);
if(cspec.t === 'str'){
// if the target is a value
target = gettarget(n, cspec, false);
setsig(target, fns.length);
fns[fns.length] = wrapquote(target.quotefn, dataselectfn(cspec.prop));
}else{
// if the target is a loop
itersel = dataselectfn(cspec.sel);
target = gettarget(n, cspec, true);
nodes = target.nodes;
for(j = 0, jj = nodes.length; j < jj; j++){
node = nodes[j];
inner = compiler(node, false, data, ans);
fns[fns.length] = wrapquote(target.quotefn, loopfn(cspec.sel, itersel, inner));
target.nodes = [node];
setsig(target, fns.length - 1);
}
}
}
}
// read directives
for(sel in directive){
if(directive.hasOwnProperty(sel)){
i = 0;
dsel = directive[sel];
sels = sel.split(/\s*,\s*/); //allow selector separation by quotes
sl = sels.length;
do{
if(typeof(dsel) === 'function' || typeof(dsel) === 'string'){
// set the value for the node/attr
sel = sels[i];
target = gettarget(dom, sel, false);
setsig(target, fns.length);
fns[fns.length] = wrapquote(target.quotefn, dataselectfn(dsel));
}else{
// loop on node
loopgen(dom, sel, dsel, fns);
}
}while(++i < sl);
}
}
// convert node to a string
h = outerHTML(dom);
// IE adds an unremovable "selected, value" attribute
// hard replace while waiting for a better solution
h = h.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig, "<$1 $3>");
// remove attribute prefix
h = h.split(attPfx).join('');
// slice the html string at "Sig"
parts = h.split( Sig );
// for each slice add the return string of
for(i = 1; i < parts.length; i++){
p = parts[i];
// part is of the form "fn-number:..." as placed there by setsig.
pfns[i] = fns[ parseInt(p, 10) ];
parts[i] = p.substring( p.indexOf(':') + 1 );
}
return concatenator(parts, pfns);
}
// compile the template with directive
// if a context is passed, the autoRendering is triggered automatically
// return a function waiting the data as argument
function compile(directive, ctxt, template){
var rfn = compiler( ( template || this[0] ).cloneNode(true), directive, ctxt);
return function(context){
return rfn({context:context});
};
}
//compile with the directive as argument
// run the template function on the context argument
// return an HTML string
// should replace the template and return this
function render(ctxt, directive){
var fn = typeof directive === 'function' && directive, i = 0, ii = this.length;
for(; i < ii; i++){
this[i] = replaceWith( this[i], (fn || plugins.compile( directive, false, this[i] ))( ctxt, false ));
}
context = null;
return this;
}
// compile the template with autoRender
// run the template function on the context argument
// return an HTML string
function autoRender(ctxt, directive){
var fn = plugins.compile( directive, ctxt, this[0] );
for(var i = 0, ii = this.length; i < ii; i++){
this[i] = replaceWith( this[i], fn( ctxt, false));
}
context = null;
return this;
}
function replaceWith(elm, html) {
var ne,
ep = elm.parentNode,
depth = 0;
if(!ep){ //if no parents
ep = document.createElement('DIV');
ep.appendChild(elm);
}
switch (elm.tagName) {
case 'TBODY': case 'THEAD': case 'TFOOT':
html = '<TABLE>' + html + '</TABLE>';
depth = 1;
break;
case 'TR':
html = '<TABLE><TBODY>' + html + '</TBODY></TABLE>';
depth = 2;
break;
case 'TD': case 'TH':
html = '<TABLE><TBODY><TR>' + html + '</TR></TBODY></TABLE>';
depth = 3;
break;
}
tmp = document.createElement('SPAN');
tmp.style.display = 'none';
document.body.appendChild(tmp);
tmp.innerHTML = html;
ne = tmp.firstChild;
while (depth--) {
ne = ne.firstChild;
}
ep.insertBefore(ne, elm);
ep.removeChild(elm);
document.body.removeChild(tmp);
elm = ne;
ne = ep = null;
return elm;
}
return plugins;
};
$p.plugins = {};
$p.libs = {
dojo:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
return dojo.query(sel, n);
};
}
},
domassistant:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
return $(n).cssSelect(sel);
};
}
DOMAssistant.attach({
publicMethods : [ 'compile', 'render', 'autoRender'],
compile:function(directive, ctxt){
return $p([this]).compile(directive, ctxt);
},
render:function(ctxt, directive){
return $( $p([this]).render(ctxt, directive) )[0];
},
autoRender:function(ctxt, directive){
return $( $p([this]).autoRender(ctxt, directive) )[0];
}
});
},
jquery:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
return jQuery(n).find(sel);
};
}
jQuery.fn.extend({
directives:function(directive){
this._pure_d = directive; return this;
},
compile:function(directive, ctxt){
return $p(this).compile(this._pure_d || directive, ctxt);
},
render:function(ctxt, directive){
return jQuery( $p( this ).render( ctxt, this._pure_d || directive ) );
},
autoRender:function(ctxt, directive){
return jQuery( $p( this ).autoRender( ctxt, this._pure_d || directive ) );
}
});
},
mootools:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
return $(n).getElements(sel);
};
}
Element.implement({
compile:function(directive, ctxt){
return $p(this).compile(directive, ctxt);
},
render:function(ctxt, directive){
return $p([this]).render(ctxt, directive);
},
autoRender:function(ctxt, directive){
return $p([this]).autoRender(ctxt, directive);
}
});
},
prototype:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
n = n === document ? n.body : n;
return typeof n === 'string' ? $$(n) : $(n).select(sel);
};
}
Element.addMethods({
compile:function(element, directive, ctxt){
return $p([element]).compile(directive, ctxt);
},
render:function(element, ctxt, directive){
return $p([element]).render(ctxt, directive);
},
autoRender:function(element, ctxt, directive){
return $p([element]).autoRender(ctxt, directive);
}
});
},
sizzle:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
return Sizzle(sel, n);
};
}
},
sly:function(){
if(typeof document.querySelector === 'undefined'){
$p.plugins.find = function(n, sel){
return Sly(sel, n);
};
}
},
yui:function(){ //Thanks to https://github.com/soljin
if(typeof document.querySelector === 'undefined'){
YUI().use("node",function(Y){
$p.plugins.find = function(n, sel){
return Y.NodeList.getDOMNodes(Y.one(n).all(sel));
};
});
}
YUI.add("pure-yui",function(Y){
Y.Node.prototype.directives = function(directive){
this._pure_d = directive; return this;
};
Y.Node.prototype.compile = function(directive, ctxt){
return $p([this._node]).compile(this._pure_d || directive, ctxt);
};
Y.Node.prototype.render = function(ctxt, directive){
return Y.one($p([this._node]).render(ctxt, this._pure_d || directive));
};
Y.Node.prototype.autoRender = function(ctxt, directive){
return Y.one($p([this._node]).autoRender(ctxt, this._pure_d || directive));
};
},"0.1",{requires:["node"]});
}
};
// get lib specifics if available
(function(){
var libkey =
typeof dojo !== 'undefined' && 'dojo' ||
typeof DOMAssistant !== 'undefined' && 'domassistant' ||
typeof jQuery !== 'undefined' && 'jquery' ||
typeof MooTools !== 'undefined' && 'mootools' ||
typeof Prototype !== 'undefined' && 'prototype' ||
typeof Sizzle !== 'undefined' && 'sizzle' ||
typeof Sly !== 'undefined' && 'sly' ||
typeof YUI !== 'undefined' && 'yui';
libkey && $p.libs[libkey]();
//for node.js
if(typeof exports !== 'undefined'){
exports.$p = $p;
}
})(); | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/libs/pure.js | JavaScript | gpl2 | 23,591 |
/*! Sly v1.0rc2 <http://sly.digitarald.com> - (C) 2009 Harald Kirschner <http://digitarald.de> - Open source under MIT License */
/**
* Credits
*
* Sly's code and pattern are inspired by several open source developers.
*
* Valerio Proietti & MooTools contributors
* - Idea of modular combinator and pseudo filters
* - Code for several pseudo filters
* - Slickspeed benchmark framework
* Steven Levithan
* - Improved Sly.parse expression
* Diego Perini
* - Research on querySelectorAll and browser quirks
* - Patches for Sly.parse expression
* - Combined tests from jQuery and Prototype
* Thomas Aylott & Slick contributors
* - Idea of using regular expressions in attribute filter.
* John Resig & jQuery/Sizzle contributors
* - Browser feature/quirks detection
* - Additional pseudo filters
* - Extensive Unit Tests, (c) 2008 John Resig, Jörn Zaefferer, MIT/GPL dual license
* Sam Stephenson & Prototype contributors
* - Extensive Unit Tests, (c) 2005-2008 Sam Stephenson, MIT-style license
* Alan Kang & JSSpec contributors
* - JSSpec BDD framework
*
* Kudos to every single one of them for supporting the open web.
*/
var Sly = (function() {
var cache = {};
/**
* Sly::constructor
*
* Acts also as shortcut for Sly::search if context argument is given.
*/
var Sly = function(text, context, results, options) {
// normalise
text = (typeof(text) == 'string') ? text.replace(/^\s+|\s+$/, '') : '';
var cls = cache[text] || (cache[text] = new Sly.initialize(text));
return (context == null) ? cls : cls.search(context, results, options);
};
Sly.initialize = function(text) {
this.text = text;
};
var proto = Sly.initialize.prototype = Sly.prototype;
/**
* Sly.implement
*/
Sly.implement = function(key, properties) {
for (var prop in properties) Sly[key][prop] = properties[prop];
};
/**
* Sly.support
*
* Filled with experiment results.
*/
var support = Sly.support = {};
// Checks similar to NWMatcher, Sizzle
(function() {
// Our guinea pig
var testee = document.createElement('div'), id = (new Date()).getTime();
testee.innerHTML = '<a name="' + id + '" class="€ b"></a>';
testee.appendChild(document.createComment(''));
// IE returns comment nodes for getElementsByTagName('*')
support.byTagAddsComments = (testee.getElementsByTagName('*').length > 1);
// Safari can't handle uppercase or unicode characters when in quirks mode.
support.hasQsa = !!(testee.querySelectorAll && testee.querySelectorAll('.€').length);
support.hasByClass = (function() {
if (!testee.getElementsByClassName || !testee.getElementsByClassName('b').length) return false;
testee.firstChild.className = 'c';
return (testee.getElementsByClassName('c').length == 1);
})();
var root = document.documentElement;
root.insertBefore(testee, root.firstChild);
// IE returns named nodes for getElementById(name)
support.byIdAddsName = !!(document.getElementById(id));
root.removeChild(testee);
})();
var locateFast = function() {
return true;
};
/**
* Sly::search
*/
proto.search = function(context, results, options) {
options = options || {};
var iterate, i, item;
if (!context) {
context = document;
} else if (context.nodeType != 1 && context.nodeType != 9) {
if (typeof(context) == 'string') {
context = Sly.search(context);
iterate = true;
} else if (Object.prototype.toString.call(context) == '[object Array]' || (typeof(context.length) == 'number' && context.item)) { // simple isArray
var filtered = [];
for (i = 0; (item = context[i]); i++) {
if (item.nodeType == 1 || item.nodeType == 9) filtered.push(item);
}
iterate = (filtered.length > 1);
context = (iterate) ? filtered : (filtered[0] || document);
}
}
var mixed, // results need to be sorted, comma
combined, // found nodes from one iteration process
nodes, // context nodes from one iteration process
all = {}, // unique ids for overall result
state = {}; // matchers temporary state
var current = all; // unique ids for one iteration process
// unifiers
var getUid = Sly.getUid;
var locateCurrent = function(node) {
var uid = getUid(node);
return (current[uid]) ? null : (current[uid] = true);
};
if (results && results.length) { // fills unique ids, does not alter the given results
for (i = 0; (item = results[i]); i++) locateCurrent(item);
}
if (support.hasQsa && !iterate && context.nodeType == 9 && !(/\[/).test(this.text)) {
try {
var query = context.querySelectorAll(this.text);
} catch(e) {}
if (query) {
if (!results) return Sly.toArray(query);
for (i = 0; (item = query[i]); i++) {
if (locateCurrent(item)) results.push(item);
}
if (!options.unordered) results.sort(Sly.compare);
return results;
}
}
var parsed = this.parse();
if (!parsed.length) return [];
for (var i = 0, selector; (selector = parsed[i]); i++) {
var locate = locateCurrent;
if (selector.first) {
if (!results) locate = locateFast;
else mixed = true;
if (iterate) nodes = context;
else if (selector.combinator) nodes = [context]; // allows combinators before selectors
}
if (selector.last && results) {
current = all;
combined = results;
} else {
// default stack
current = {};
combined = [];
}
if (!selector.combinator && !iterate) {
// without prepended combinator
combined = selector.combine(combined, context, selector, state, locate, !(combined.length));
} else {
// with prepended combinators
for (var k = 0, l = nodes.length; k < l; k++) {
combined = selector.combine(combined, nodes[k], selector, state, locate);
}
}
if (selector.last) {
if (combined.length) results = combined;
} else {
nodes = combined;
}
}
if (!options.unordered && mixed && results) results.sort(Sly.compare);
return results || [];
};
/**
* Sly::find
*/
proto.find = function(context, results, options) {
return this.search(context, results, options)[0];
};
/**
* Sly::match
*/
proto.match = function(node, parent) {
var parsed = this.parse();
if (parsed.length == 1) return !!(this.parse()[0].match(node, {}));
if (!parent) {
parent = node;
while (parent.parentNode) parent = parent.parentNode
}
var found = this.search(parent), i = found.length;
if (!i--) return false;
while (i--) {
if (found[i] == node) return true;
}
return false;
};
/**
* Sly::filter
*/
proto.filter = function(nodes) {
var results = [], match = this.parse()[0].match;
for (var i = 0, node; (node = nodes[i]); i++) {
if (match(node)) results.push(node);
}
return results;
};
/**
* Sly.recompile()
*/
var pattern;
Sly.recompile = function() {
var key, combList = [','], operList = ['!'];
for (key in combinators) {
if (key != ' ') {
combList[(key.length > 1) ? 'unshift' : 'push'](Sly.escapeRegExp(key));
}
}
for (key in operators) operList.push(key);
/**
The regexp is a group of every possible selector part including combinators.
"|" separates the possible selectors.
Capturing parentheses:
1 - Combinator (only requires to allow multiple-character combinators)
2 - Attribute name
3 - Attribute operator
4, 5, 6 - The value
7 - Pseudo name
8, 9, 10 - The value
*/
pattern = new RegExp(
// A tagname
'[\\w\\u00a1-\\uFFFF][\\w\\u00a1-\\uFFFF-]*|' +
// An id or the classname
'[#.](?:[\\w\\u00a1-\\uFFFF-]|\\\\:|\\\\.)+|' +
// Whitespace (descendant combinator)
'[ \\t\\r\\n\\f](?=[\\w\\u00a1-\\uFFFF*#.[:])|' +
// Other combinators and the comma
'[ \\t\\r\\n\\f]*(' + combList.join('|') + ')[ \\t\\r\\n\\f]*|' +
// An attribute, with the various and optional value formats ([name], [name=value], [name="value"], [name='value']
'\\[([\\w\\u00a1-\\uFFFF-]+)[ \\t\\r\\n\\f]*(?:([' + operList.join('') + ']?=)[ \\t\\r\\n\\f]*(?:"([^"]*)"|\'([^\']*)\'|([^\\]]*)))?]|' +
// A pseudo-class, with various formats
':([-\\w\\u00a1-\\uFFFF]+)(?:\\((?:"([^"]*)"|\'([^\']*)\'|([^)]*))\\))?|' +
// The universial selector, not process
'\\*|(.+)', 'g'
);
};
// I prefer it outside, not sure if this is faster
var create = function(combinator) {
return {
ident: [],
classes: [],
attributes: [],
pseudos: [],
combinator: combinator
};
};
var blank = function($0) {
return $0;
};
/**
* Sly::parse
*
* Returns an array with one object for every selector:
*
* {
* tag: (String) Tagname (defaults to null for universal *)
* id: (String) Id
* classes: (Array) Classnames
* attributes: (Array) Attribute objects with "name", "operator" and "value"
* pseudos: (Array) Pseudo objects with "name" and "value"
* operator: (Char) The prepended operator (not comma)
* first: (Boolean) true if it is the first selector or the first after a comma
* last: (Boolean) true if it is the last selector or the last before a comma
* ident: (Array) All parsed matches, can be used as cache identifier.
* }
*/
proto.parse = function(plain) {
var save = (plain) ? 'plain' : 'parsed';
if (this[save]) return this[save];
var text = this.text;
var compute = (plain) ? blank : this.compute;
var parsed = [], current = create(null);
current.first = true;
var refresh = function(combinator) {
parsed.push(compute(current));
current = create(combinator);
};
pattern.lastIndex = 0; // to fix some weird behavior
var match, $0;
while ((match = pattern.exec(text))) {
if (match[11]) {
if (Sly.verbose) throw SyntaxError('Syntax error, "' + $0 + '" unexpected at #' + pattern.lastIndex + ' in "' + text + '"');
return (this[save] = []);
}
$0 = match[0];
switch ($0.charAt(0)) {
case '.':
current.classes.push($0.slice(1).replace(/\\/g, ''));
break;
case '#':
current.id = $0.slice(1).replace(/\\/g, '');
break;
case '[':
current.attributes.push({
name: match[2],
operator: match[3] || null,
value: match[4] || match[5] || match[6] || null
});
break;
case ':':
current.pseudos.push({
name: match[7],
value: match[8] || match[9] || match[10] || null
});
break;
case ' ': case '\t': case '\r': case '\n': case '\f':
match[1] = match[1] || ' ';
default:
var combinator = match[1];
if (combinator) {
if (combinator == ',') {
current.last = true;
refresh(null);
current.first = true;
continue;
}
if (current.first && !current.ident.length) current.combinator = combinator;
else refresh(combinator);
} else {
if ($0 != '*') current.tag = $0;
}
}
current.ident.push($0);
}
current.last = true;
parsed.push(compute(current));
return (this[save] = parsed);
};
// chains two given functions
function chain(prepend, append, aux, unshift) {
return (prepend) ? ((unshift) ? function(node, state) {
return append(node, aux, state) && prepend(node, state);
} : function(node, state) {
return prepend(node, state) && append(node, aux, state);
}) : function(node, state) {
return append(node, aux, state);
};
// fn.$slyIndex = (prepend) ? (prepend.$slyIndex + 1) : 0;
};
// prepared match comperators, probably needs namespacing
var empty = function() {
return true;
};
var matchId = function(node, id) {
return (node.id == id);
};
var matchTag = function(node, tag) {
return (node.nodeName.toUpperCase() == tag);
};
var prepareClass = function(name) {
return (new RegExp('(?:^|[ \\t\\r\\n\\f])' + name + '(?:$|[ \\t\\r\\n\\f])'));
};
var matchClass = function(node, expr) {
return node.className && expr.test(node.className);
};
var prepareAttribute = function(attr) {
attr.getter = Sly.lookupAttribute(attr.name) || Sly.getAttribute;
if (!attr.operator || !attr.value) return attr;
var parser = operators[attr.operator];
if (parser) { // @todo: Allow functions, not only regex
attr.escaped = Sly.escapeRegExp(attr.value);
attr.pattern = new RegExp(parser(attr.value, attr.escaped, attr));
}
return attr;
};
var matchAttribute = function(node, attr) {
var read = attr.getter(node, attr.name);
switch (attr.operator) {
case null: return read;
case '=': return (read == attr.value);
case '!=': return (read != attr.value);
}
if (!read && attr.value) return false;
return attr.pattern.test(read);
};
/**
* Sly::compute
*
* Attaches the following methods to the selector object:
*
* {
* search: Uses the most convinient properties (id, tag and/or class) of the selector as search.
* matchAux: If search does not contain all selector properties, this method matches an element against the rest.
* match: Matches an element against all properties.
* simple: Set when matchAux is not needed.
* combine: The callback for the combinator
* }
*/
proto.compute = function(selector) {
var i, item, match, search, matchSearch, tagged,
tag = selector.tag,
id = selector.id,
classes = selector.classes;
var nodeName = (tag) ? tag.toUpperCase() : null;
if (id) {
tagged = true;
matchSearch = chain(null, matchId, id);
search = function(context) {
if (context.getElementById) {
var el = context.getElementById(id);
return (el
&& (!nodeName || el.nodeName.toUpperCase() == nodeName)
&& (!support.getIdAdds || el.id == id))
? [el]
: [];
}
var query = context.getElementsByTagName(tag || '*');
for (var j = 0, node; (node = query[j]); j++) {
if (node.id == id) return [node];
}
return [];
};
}
if (classes.length > 0) {
if (!search && support.hasByClass) {
for (i = 0; (item = classes[i]); i++) {
matchSearch = chain(matchSearch, matchClass, prepareClass(item));
}
var joined = classes.join(' ');
search = function(context) {
return context.getElementsByClassName(joined);
};
} else if (!search && classes.length == 1) { // optimised for typical .one-class-only
tagged = true;
var expr = prepareClass(classes[0]);
matchSearch = chain(matchSearch, matchClass, expr);
search = function(context) {
var query = context.getElementsByTagName(tag || '*');
var found = [];
for (var i = 0, node; (node = query[i]); i++) {
if (node.className && expr.test(node.className)) found.push(node);
}
return found;
};
} else {
for (i = 0; (item = classes[i]); i++) {
match = chain(match, matchClass, prepareClass(item));
}
}
}
if (tag) {
if (!search) {
matchSearch = chain(matchSearch, matchTag, nodeName);
search = function(context) {
return context.getElementsByTagName(tag);
};
} else if (!tagged) { // search does not filter by tag yet
match = chain(match, matchTag, nodeName);
}
} else if (!search) { // default engine
search = function(context) {
var query = context.getElementsByTagName('*');
if (!support.byTagAddsComments) return query;
var found = [];
for (var i = 0, node; (node = query[i]); i++) {
if (node.nodeType === 1) found.push(node);
}
return found;
};
}
for (i = 0; (item = selector.pseudos[i]); i++) {
if (item.name == 'not') { // optimised :not(), fast as possible
var not = Sly(item.value);
match = chain(match, function(node, not) {
return !not.match(node);
}, (not.parse().length == 1) ? not.parsed[0] : not);
} else {
var parser = pseudos[item.name];
if (parser) match = chain(match, parser, item.value);
}
}
for (i = 0; (item = selector.attributes[i]); i++) {
match = chain(match, matchAttribute, prepareAttribute(item));
}
if ((selector.simple = !(match))) {
selector.matchAux = empty;
} else {
selector.matchAux = match;
matchSearch = chain(matchSearch, match);
}
selector.match = matchSearch || empty;
selector.combine = Sly.combinators[selector.combinator || ' '];
selector.search = search;
return selector;
};
// Combinators/Pseudos partly from MooTools 1.2-pre, (c) 2006-2009 Valerio Proietti, MIT License
/**
* Combinators
*/
var combinators = Sly.combinators = {
' ': function(combined, context, selector, state, locate, fast) {
var nodes = selector.search(context);
if (fast && selector.simple) return Sly.toArray(nodes);
for (var i = 0, node, aux = selector.matchAux; (node = nodes[i]); i++) {
if (locate(node) && aux(node, state)) combined.push(node);
}
return combined;
},
'>': function(combined, context, selector, state, locate) {
var nodes = selector.search(context);
for (var i = 0, node; (node = nodes[i]); i++) {
if (node.parentNode == context && locate(node) && selector.matchAux(node, state)) combined.push(node);
}
return combined;
},
'+': function(combined, context, selector, state, locate) {
while ((context = context.nextSibling)) {
if (context.nodeType == 1) {
if (locate(context) && selector.match(context, state)) combined.push(context);
break;
}
}
return combined;
},
'~': function(combined, context, selector, state, locate) {
while ((context = context.nextSibling)) {
if (context.nodeType == 1) {
if (!locate(context)) break;
if (selector.match(context, state)) combined.push(context);
}
}
return combined;
}
};
/**
* Pseudo-Classes
*/
var pseudos = Sly.pseudos = {
// w3c pseudo classes
'first-child': function(node) {
return pseudos.index(node, 0);
},
'last-child': function(node) {
while ((node = node.nextSibling)) {
if (node.nodeType === 1) return false;
}
return true;
},
'only-child': function(node) {
var prev = node;
while ((prev = prev.previousSibling)) {
if (prev.nodeType === 1) return false;
}
var next = node;
while ((next = next.nextSibling)) {
if (next.nodeType === 1) return false;
}
return true;
},
'nth-child': function(node, value, state) {
var parsed = Sly.parseNth(value || 'n');
if (parsed.special != 'n') return pseudos[parsed.special](node, parsed.a, state);
state = state || {}; // just to be sure
state.positions = state.positions || {};
var uid = Sly.getUid(node) ;
if (!state.positions[uid]) {
var count = 0;
while ((node = node.previousSibling)) {
if (node.nodeType != 1) continue;
count++;
var position = state.positions[Sly.getUid(node)];
if (position != undefined) {
count = position + count;
break;
}
}
state.positions[uid] = count;
}
return (state.positions[uid] % parsed.a == parsed.b);
},
'empty': function(node) {
return !(node.innerText || node.textContent || '').length;
},
'contains': function(node, text) {
return (node.innerText || node.textContent || '').indexOf(text) != -1;
},
'index': function(node, index) {
var count = 1;
while ((node = node.previousSibling)) {
if (node.nodeType == 1 && ++count > index) return false;
}
return (count == index);
},
'even': function(node, value, state) {
return pseudos['nth-child'](node, '2n+1', state);
},
'odd': function(node, value, state) {
return pseudos['nth-child'](node, '2n', state);
}
};
pseudos.first = pseudos['first-child'];
pseudos.last = pseudos['last-child'];
pseudos.nth = pseudos['nth-child'];
pseudos.eq = pseudos.index;
/**
* Attribute operators
*/
var operators = Sly.operators = {
'*=': function(value, escaped) {
return escaped;
},
'^=': function(value, escaped) {
return '^' + escaped;
},
'$=': function(value, escaped) {
return value + '$';
},
'~=': function(value, escaped) {
return '(?:^|[ \\t\\r\\n\\f])' + escaped + '(?:$|[ \\t\\r\\n\\f])';
},
'|=': function(value, escaped) {
return '(?:^|\\|)' + escaped + '(?:$|\\|)';
}
};
// public, overridable
/**
* Sly.getAttribute & Sly.lookupAttribute
*
* @todo add more translations
*/
var translate = {
'class': 'className'
}
Sly.lookupAttribute = function(name) {
var prop = translate[name];
if (prop) {
return function(node) {
return node[prop];
}
}
var flag = /^(?:src|href|action)$/.test(name) ? 2 : 0;
return function(node) {
return node.getAttribute(name, flag);
}
};
Sly.getAttribute = function(node, name) {
return node.getAttribute(name);
};
/**
* Sly.toArray
*/
var toArray = Array.slice || function(nodes) {
return Array.prototype.slice.call(nodes);
};
try {
toArray(document.documentElement.childNodes);
} catch (e) {
toArray = function(nodes) {
if (nodes instanceof Array) return nodes;
var i = nodes.length, results = new Array(i);
while (i--) results[i] = nodes[i];
return results;
};
}
Sly.toArray = toArray;
Sly.compare = (document.compareDocumentPosition) ? function (a, b) {
return (3 - (a.compareDocumentPosition(b) & 6));
} : function (a, b) {
return (a.sourceIndex - b.sourceIndex);
};
/**
* Sly.getUid
*/
var nextUid = 1;
Sly.getUid = (window.ActiveXObject) ? function(node) {
return (node.$slyUid || (node.$slyUid = {id: nextUid++})).id;
} : function(node) {
return node.$slyUid || (node.$slyUid = nextUid++);
};
var nthCache = {};
Sly.parseNth = function(value) {
if (nthCache[value]) return nthCache[value];
var parsed = value.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);
if (!parsed) return false;
var a = parseInt(parsed[1], 10), b = (parseInt(parsed[3], 10) || 0) - 1;
if ((a = (isNaN(a)) ? 1 : a)) {
while (b < 1) b += a;
while (b >= a) b -= a;
}
switch (parsed[2]) {
case 'n': parsed = {a: a, b: b, special: 'n'}; break;
case 'odd': parsed = {a: 2, b: 0, special: 'n'}; break;
case 'even': parsed = {a: 2, b: 1, special: 'n'}; break;
case 'first': parsed = {a: 0, special: 'index'}; break;
case 'last': parsed = {special: 'last-child'}; break;
case 'only': parsed = {special: 'only-child'}; break;
default: parsed = {a: (a) ? (a - 1) : b, special: 'index'};
}
return (nthCache[value] = parsed);
};
Sly.escapeRegExp = function(text) {
return text.replace(/[-.*+?^${}()|[\]\/\\]/g, '\\$&');
};
// generic accessors
Sly.generise = function(name) {
Sly[name] = function(text) {
var cls = Sly(text);
return cls[name].apply(cls, Array.prototype.slice.call(arguments, 1));
}
};
var generics = ['parse', 'search', 'find', 'match', 'filter'];
for (var i = 0; generics[i]; i++) Sly.generise(generics[i]);
// compile pattern for the first time
Sly.recompile();
// FIN
return Sly;
})(); | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/libs/sly.js | JavaScript | gpl2 | 22,072 |
/*
json2.js
2011-10-19
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or ' '),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
var JSON;
if (!JSON) {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}()); | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/libs/json2.js | JavaScript | gpl2 | 17,520 |
/*
---
MooTools: the javascript framework
web build:
- http://mootools.net/core/76bf47062d6c1983d66ce47ad66aa0e0
packager build:
- packager build Core/Core Core/Array Core/String Core/Number Core/Function Core/Object Core/Event Core/Browser Core/Class Core/Class.Extras Core/Slick.Parser Core/Slick.Finder Core/Element Core/Element.Style Core/Element.Event Core/Element.Delegation Core/Element.Dimensions Core/Fx Core/Fx.CSS Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request Core/Request.HTML Core/Request.JSON Core/Cookie Core/JSON Core/DOMReady Core/Swiff
...
*/
/*
---
name: Core
description: The heart of MooTools.
license: MIT-style license.
copyright: Copyright (c) 2006-2012 [Valerio Proietti](http://mad4milk.net/).
authors: The MooTools production team (http://mootools.net/developers/)
inspiration:
- Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)
- Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)
provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
...
*/
(function(){
this.MooTools = {
version: '1.4.5',
build: '74e34796f5f76640cdb98853004650aea1499d69'
};
// typeOf, instanceOf
var typeOf = this.typeOf = function(item){
if (item == null) return 'null';
if (item.$family != null) return item.$family();
if (item.nodeName){
if (item.nodeType == 1) return 'element';
if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
} else if (typeof item.length == 'number'){
if (item.callee) return 'arguments';
if ('item' in item) return 'collection';
}
return typeof item;
};
var instanceOf = this.instanceOf = function(item, object){
if (item == null) return false;
var constructor = item.$constructor || item.constructor;
while (constructor){
if (constructor === object) return true;
constructor = constructor.parent;
}
/*<ltIE8>*/
if (!item.hasOwnProperty) return false;
/*</ltIE8>*/
return item instanceof object;
};
// Function overloading
var Function = this.Function;
var enumerables = true;
for (var i in {toString: 1}) enumerables = null;
if (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];
Function.prototype.overloadSetter = function(usePlural){
var self = this;
return function(a, b){
if (a == null) return this;
if (usePlural || typeof a != 'string'){
for (var k in a) self.call(this, k, a[k]);
if (enumerables) for (var i = enumerables.length; i--;){
k = enumerables[i];
if (a.hasOwnProperty(k)) self.call(this, k, a[k]);
}
} else {
self.call(this, a, b);
}
return this;
};
};
Function.prototype.overloadGetter = function(usePlural){
var self = this;
return function(a){
var args, result;
if (typeof a != 'string') args = a;
else if (arguments.length > 1) args = arguments;
else if (usePlural) args = [a];
if (args){
result = {};
for (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]);
} else {
result = self.call(this, a);
}
return result;
};
};
Function.prototype.extend = function(key, value){
this[key] = value;
}.overloadSetter();
Function.prototype.implement = function(key, value){
this.prototype[key] = value;
}.overloadSetter();
// From
var slice = Array.prototype.slice;
Function.from = function(item){
return (typeOf(item) == 'function') ? item : function(){
return item;
};
};
Array.from = function(item){
if (item == null) return [];
return (Type.isEnumerable(item) && typeof item != 'string') ? (typeOf(item) == 'array') ? item : slice.call(item) : [item];
};
Number.from = function(item){
var number = parseFloat(item);
return isFinite(number) ? number : null;
};
String.from = function(item){
return item + '';
};
// hide, protect
Function.implement({
hide: function(){
this.$hidden = true;
return this;
},
protect: function(){
this.$protected = true;
return this;
}
});
// Type
var Type = this.Type = function(name, object){
if (name){
var lower = name.toLowerCase();
var typeCheck = function(item){
return (typeOf(item) == lower);
};
Type['is' + name] = typeCheck;
if (object != null){
object.prototype.$family = (function(){
return lower;
}).hide();
}
}
if (object == null) return null;
object.extend(this);
object.$constructor = Type;
object.prototype.$constructor = object;
return object;
};
var toString = Object.prototype.toString;
Type.isEnumerable = function(item){
return (item != null && typeof item.length == 'number' && toString.call(item) != '[object Function]' );
};
var hooks = {};
var hooksOf = function(object){
var type = typeOf(object.prototype);
return hooks[type] || (hooks[type] = []);
};
var implement = function(name, method){
if (method && method.$hidden) return;
var hooks = hooksOf(this);
for (var i = 0; i < hooks.length; i++){
var hook = hooks[i];
if (typeOf(hook) == 'type') implement.call(hook, name, method);
else hook.call(this, name, method);
}
var previous = this.prototype[name];
if (previous == null || !previous.$protected) this.prototype[name] = method;
if (this[name] == null && typeOf(method) == 'function') extend.call(this, name, function(item){
return method.apply(item, slice.call(arguments, 1));
});
};
var extend = function(name, method){
if (method && method.$hidden) return;
var previous = this[name];
if (previous == null || !previous.$protected) this[name] = method;
};
Type.implement({
implement: implement.overloadSetter(),
extend: extend.overloadSetter(),
alias: function(name, existing){
implement.call(this, name, this.prototype[existing]);
}.overloadSetter(),
mirror: function(hook){
hooksOf(this).push(hook);
return this;
}
});
new Type('Type', Type);
// Default Types
var force = function(name, object, methods){
var isType = (object != Object),
prototype = object.prototype;
if (isType) object = new Type(name, object);
for (var i = 0, l = methods.length; i < l; i++){
var key = methods[i],
generic = object[key],
proto = prototype[key];
if (generic) generic.protect();
if (isType && proto) object.implement(key, proto.protect());
}
if (isType){
var methodsEnumerable = prototype.propertyIsEnumerable(methods[0]);
object.forEachMethod = function(fn){
if (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++){
fn.call(prototype, prototype[methods[i]], methods[i]);
}
for (var key in prototype) fn.call(prototype, prototype[key], key)
};
}
return force;
};
force('String', String, [
'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
])('Array', Array, [
'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'
])('Number', Number, [
'toExponential', 'toFixed', 'toLocaleString', 'toPrecision'
])('Function', Function, [
'apply', 'call', 'bind'
])('RegExp', RegExp, [
'exec', 'test'
])('Object', Object, [
'create', 'defineProperty', 'defineProperties', 'keys',
'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames',
'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen'
])('Date', Date, ['now']);
Object.extend = extend.overloadSetter();
Date.extend('now', function(){
return +(new Date);
});
new Type('Boolean', Boolean);
// fixes NaN returning as Number
Number.prototype.$family = function(){
return isFinite(this) ? 'number' : 'null';
}.hide();
// Number.random
Number.extend('random', function(min, max){
return Math.floor(Math.random() * (max - min + 1) + min);
});
// forEach, each
var hasOwnProperty = Object.prototype.hasOwnProperty;
Object.extend('forEach', function(object, fn, bind){
for (var key in object){
if (hasOwnProperty.call(object, key)) fn.call(bind, object[key], key, object);
}
});
Object.each = Object.forEach;
Array.implement({
forEach: function(fn, bind){
for (var i = 0, l = this.length; i < l; i++){
if (i in this) fn.call(bind, this[i], i, this);
}
},
each: function(fn, bind){
Array.forEach(this, fn, bind);
return this;
}
});
// Array & Object cloning, Object merging and appending
var cloneOf = function(item){
switch (typeOf(item)){
case 'array': return item.clone();
case 'object': return Object.clone(item);
default: return item;
}
};
Array.implement('clone', function(){
var i = this.length, clone = new Array(i);
while (i--) clone[i] = cloneOf(this[i]);
return clone;
});
var mergeOne = function(source, key, current){
switch (typeOf(current)){
case 'object':
if (typeOf(source[key]) == 'object') Object.merge(source[key], current);
else source[key] = Object.clone(current);
break;
case 'array': source[key] = current.clone(); break;
default: source[key] = current;
}
return source;
};
Object.extend({
merge: function(source, k, v){
if (typeOf(k) == 'string') return mergeOne(source, k, v);
for (var i = 1, l = arguments.length; i < l; i++){
var object = arguments[i];
for (var key in object) mergeOne(source, key, object[key]);
}
return source;
},
clone: function(object){
var clone = {};
for (var key in object) clone[key] = cloneOf(object[key]);
return clone;
},
append: function(original){
for (var i = 1, l = arguments.length; i < l; i++){
var extended = arguments[i] || {};
for (var key in extended) original[key] = extended[key];
}
return original;
}
});
// Object-less types
['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function(name){
new Type(name);
});
// Unique ID
var UID = Date.now();
String.extend('uniqueID', function(){
return (UID++).toString(36);
});
})();
/*
---
name: Array
description: Contains Array Prototypes like each, contains, and erase.
license: MIT-style license.
requires: Type
provides: Array
...
*/
Array.implement({
/*<!ES5>*/
every: function(fn, bind){
for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && !fn.call(bind, this[i], i, this)) return false;
}
return true;
},
filter: function(fn, bind){
var results = [];
for (var value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this){
value = this[i];
if (fn.call(bind, value, i, this)) results.push(value);
}
return results;
},
indexOf: function(item, from){
var length = this.length >>> 0;
for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){
if (this[i] === item) return i;
}
return -1;
},
map: function(fn, bind){
var length = this.length >>> 0, results = Array(length);
for (var i = 0; i < length; i++){
if (i in this) results[i] = fn.call(bind, this[i], i, this);
}
return results;
},
some: function(fn, bind){
for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && fn.call(bind, this[i], i, this)) return true;
}
return false;
},
/*</!ES5>*/
clean: function(){
return this.filter(function(item){
return item != null;
});
},
invoke: function(methodName){
var args = Array.slice(arguments, 1);
return this.map(function(item){
return item[methodName].apply(item, args);
});
},
associate: function(keys){
var obj = {}, length = Math.min(this.length, keys.length);
for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
return obj;
},
link: function(object){
var result = {};
for (var i = 0, l = this.length; i < l; i++){
for (var key in object){
if (object[key](this[i])){
result[key] = this[i];
delete object[key];
break;
}
}
}
return result;
},
contains: function(item, from){
return this.indexOf(item, from) != -1;
},
append: function(array){
this.push.apply(this, array);
return this;
},
getLast: function(){
return (this.length) ? this[this.length - 1] : null;
},
getRandom: function(){
return (this.length) ? this[Number.random(0, this.length - 1)] : null;
},
include: function(item){
if (!this.contains(item)) this.push(item);
return this;
},
combine: function(array){
for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
return this;
},
erase: function(item){
for (var i = this.length; i--;){
if (this[i] === item) this.splice(i, 1);
}
return this;
},
empty: function(){
this.length = 0;
return this;
},
flatten: function(){
var array = [];
for (var i = 0, l = this.length; i < l; i++){
var type = typeOf(this[i]);
if (type == 'null') continue;
array = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceOf(this[i], Array)) ? Array.flatten(this[i]) : this[i]);
}
return array;
},
pick: function(){
for (var i = 0, l = this.length; i < l; i++){
if (this[i] != null) return this[i];
}
return null;
},
hexToRgb: function(array){
if (this.length != 3) return null;
var rgb = this.map(function(value){
if (value.length == 1) value += value;
return value.toInt(16);
});
return (array) ? rgb : 'rgb(' + rgb + ')';
},
rgbToHex: function(array){
if (this.length < 3) return null;
if (this.length == 4 && this[3] == 0 && !array) return 'transparent';
var hex = [];
for (var i = 0; i < 3; i++){
var bit = (this[i] - 0).toString(16);
hex.push((bit.length == 1) ? '0' + bit : bit);
}
return (array) ? hex : '#' + hex.join('');
}
});
/*
---
name: String
description: Contains String Prototypes like camelCase, capitalize, test, and toInt.
license: MIT-style license.
requires: Type
provides: String
...
*/
String.implement({
test: function(regex, params){
return ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this);
},
contains: function(string, separator){
return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
},
trim: function(){
return String(this).replace(/^\s+|\s+$/g, '');
},
clean: function(){
return String(this).replace(/\s+/g, ' ').trim();
},
camelCase: function(){
return String(this).replace(/-\D/g, function(match){
return match.charAt(1).toUpperCase();
});
},
hyphenate: function(){
return String(this).replace(/[A-Z]/g, function(match){
return ('-' + match.charAt(0).toLowerCase());
});
},
capitalize: function(){
return String(this).replace(/\b[a-z]/g, function(match){
return match.toUpperCase();
});
},
escapeRegExp: function(){
return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
toInt: function(base){
return parseInt(this, base || 10);
},
toFloat: function(){
return parseFloat(this);
},
hexToRgb: function(array){
var hex = String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
return (hex) ? hex.slice(1).hexToRgb(array) : null;
},
rgbToHex: function(array){
var rgb = String(this).match(/\d{1,3}/g);
return (rgb) ? rgb.rgbToHex(array) : null;
},
substitute: function(object, regexp){
return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] != null) ? object[name] : '';
});
}
});
/*
---
name: Number
description: Contains Number Prototypes like limit, round, times, and ceil.
license: MIT-style license.
requires: Type
provides: Number
...
*/
Number.implement({
limit: function(min, max){
return Math.min(max, Math.max(min, this));
},
round: function(precision){
precision = Math.pow(10, precision || 0).toFixed(precision < 0 ? -precision : 0);
return Math.round(this * precision) / precision;
},
times: function(fn, bind){
for (var i = 0; i < this; i++) fn.call(bind, i, this);
},
toFloat: function(){
return parseFloat(this);
},
toInt: function(base){
return parseInt(this, base || 10);
}
});
Number.alias('each', 'times');
(function(math){
var methods = {};
math.each(function(name){
if (!Number[name]) methods[name] = function(){
return Math[name].apply(null, [this].concat(Array.from(arguments)));
};
});
Number.implement(methods);
})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
/*
---
name: Function
description: Contains Function Prototypes like create, bind, pass, and delay.
license: MIT-style license.
requires: Type
provides: Function
...
*/
Function.extend({
attempt: function(){
for (var i = 0, l = arguments.length; i < l; i++){
try {
return arguments[i]();
} catch (e){}
}
return null;
}
});
Function.implement({
attempt: function(args, bind){
try {
return this.apply(bind, Array.from(args));
} catch (e){}
return null;
},
/*<!ES5-bind>*/
bind: function(that){
var self = this,
args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
F = function(){};
var bound = function(){
var context = that, length = arguments.length;
if (this instanceof bound){
F.prototype = self.prototype;
context = new F;
}
var result = (!args && !length)
? self.call(context)
: self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
return context == that ? result : context;
};
return bound;
},
/*</!ES5-bind>*/
pass: function(args, bind){
var self = this;
if (args != null) args = Array.from(args);
return function(){
return self.apply(bind, args || arguments);
};
},
delay: function(delay, bind, args){
return setTimeout(this.pass((args == null ? [] : args), bind), delay);
},
periodical: function(periodical, bind, args){
return setInterval(this.pass((args == null ? [] : args), bind), periodical);
}
});
/*
---
name: Object
description: Object generic methods
license: MIT-style license.
requires: Type
provides: [Object, Hash]
...
*/
(function(){
var hasOwnProperty = Object.prototype.hasOwnProperty;
Object.extend({
subset: function(object, keys){
var results = {};
for (var i = 0, l = keys.length; i < l; i++){
var k = keys[i];
if (k in object) results[k] = object[k];
}
return results;
},
map: function(object, fn, bind){
var results = {};
for (var key in object){
if (hasOwnProperty.call(object, key)) results[key] = fn.call(bind, object[key], key, object);
}
return results;
},
filter: function(object, fn, bind){
var results = {};
for (var key in object){
var value = object[key];
if (hasOwnProperty.call(object, key) && fn.call(bind, value, key, object)) results[key] = value;
}
return results;
},
every: function(object, fn, bind){
for (var key in object){
if (hasOwnProperty.call(object, key) && !fn.call(bind, object[key], key)) return false;
}
return true;
},
some: function(object, fn, bind){
for (var key in object){
if (hasOwnProperty.call(object, key) && fn.call(bind, object[key], key)) return true;
}
return false;
},
keys: function(object){
var keys = [];
for (var key in object){
if (hasOwnProperty.call(object, key)) keys.push(key);
}
return keys;
},
values: function(object){
var values = [];
for (var key in object){
if (hasOwnProperty.call(object, key)) values.push(object[key]);
}
return values;
},
getLength: function(object){
return Object.keys(object).length;
},
keyOf: function(object, value){
for (var key in object){
if (hasOwnProperty.call(object, key) && object[key] === value) return key;
}
return null;
},
contains: function(object, value){
return Object.keyOf(object, value) != null;
},
toQueryString: function(object, base){
var queryString = [];
Object.each(object, function(value, key){
if (base) key = base + '[' + key + ']';
var result;
switch (typeOf(value)){
case 'object': result = Object.toQueryString(value, key); break;
case 'array':
var qs = {};
value.each(function(val, i){
qs[i] = val;
});
result = Object.toQueryString(qs, key);
break;
default: result = key + '=' + encodeURIComponent(value);
}
if (value != null) queryString.push(result);
});
return queryString.join('&');
}
});
})();
/*
---
name: Browser
description: The Browser Object. Contains Browser initialization, Window and Document, and the Browser Hash.
license: MIT-style license.
requires: [Array, Function, Number, String]
provides: [Browser, Window, Document]
...
*/
(function(){
var document = this.document;
var window = document.window = this;
var ua = navigator.userAgent.toLowerCase(),
platform = navigator.platform.toLowerCase(),
UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0],
mode = UA[1] == 'ie' && document.documentMode;
var Browser = this.Browser = {
extend: Function.prototype.extend,
name: (UA[1] == 'version') ? UA[3] : UA[1],
version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
Platform: {
name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
},
Features: {
xpath: !!(document.evaluate),
air: !!(window.runtime),
query: !!(document.querySelector),
json: !!(window.JSON)
},
Plugins: {}
};
Browser[Browser.name] = true;
Browser[Browser.name + parseInt(Browser.version, 10)] = true;
Browser.Platform[Browser.Platform.name] = true;
// Request
Browser.Request = (function(){
var XMLHTTP = function(){
return new XMLHttpRequest();
};
var MSXML2 = function(){
return new ActiveXObject('MSXML2.XMLHTTP');
};
var MSXML = function(){
return new ActiveXObject('Microsoft.XMLHTTP');
};
return Function.attempt(function(){
XMLHTTP();
return XMLHTTP;
}, function(){
MSXML2();
return MSXML2;
}, function(){
MSXML();
return MSXML;
});
})();
Browser.Features.xhr = !!(Browser.Request);
// Flash detection
var version = (Function.attempt(function(){
return navigator.plugins['Shockwave Flash'].description;
}, function(){
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
}) || '0 r0').match(/\d+/g);
Browser.Plugins.Flash = {
version: Number(version[0] || '0.' + version[1]) || 0,
build: Number(version[2]) || 0
};
// String scripts
Browser.exec = function(text){
if (!text) return text;
if (window.execScript){
window.execScript(text);
} else {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.text = text;
document.head.appendChild(script);
document.head.removeChild(script);
}
return text;
};
String.implement('stripScripts', function(exec){
var scripts = '';
var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(all, code){
scripts += code + '\n';
return '';
});
if (exec === true) Browser.exec(scripts);
else if (typeOf(exec) == 'function') exec(scripts, text);
return text;
});
// Window, Document
Browser.extend({
Document: this.Document,
Window: this.Window,
Element: this.Element,
Event: this.Event
});
this.Window = this.$constructor = new Type('Window', function(){});
this.$family = Function.from('window').hide();
Window.mirror(function(name, method){
window[name] = method;
});
this.Document = document.$constructor = new Type('Document', function(){});
document.$family = Function.from('document').hide();
Document.mirror(function(name, method){
document[name] = method;
});
document.html = document.documentElement;
if (!document.head) document.head = document.getElementsByTagName('head')[0];
if (document.execCommand) try {
document.execCommand("BackgroundImageCache", false, true);
} catch (e){}
/*<ltIE9>*/
if (this.attachEvent && !this.addEventListener){
var unloadEvent = function(){
this.detachEvent('onunload', unloadEvent);
document.head = document.html = document.window = null;
};
this.attachEvent('onunload', unloadEvent);
}
// IE fails on collections and <select>.options (refers to <select>)
var arrayFrom = Array.from;
try {
arrayFrom(document.html.childNodes);
} catch(e){
Array.from = function(item){
if (typeof item != 'string' && Type.isEnumerable(item) && typeOf(item) != 'array'){
var i = item.length, array = new Array(i);
while (i--) array[i] = item[i];
return array;
}
return arrayFrom(item);
};
var prototype = Array.prototype,
slice = prototype.slice;
['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice'].each(function(name){
var method = prototype[name];
Array[name] = function(item){
return method.apply(Array.from(item), slice.call(arguments, 1));
};
});
}
/*</ltIE9>*/
})();
/*
---
name: Event
description: Contains the Event Type, to make the event object cross-browser.
license: MIT-style license.
requires: [Window, Document, Array, Function, String, Object]
provides: Event
...
*/
(function() {
var _keys = {};
var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
if (!win) win = window;
event = event || win.event;
if (event.$extended) return event;
this.event = event;
this.$extended = true;
this.shift = event.shiftKey;
this.control = event.ctrlKey;
this.alt = event.altKey;
this.meta = event.metaKey;
var type = this.type = event.type;
var target = event.target || event.srcElement;
while (target && target.nodeType == 3) target = target.parentNode;
this.target = document.id(target);
if (type.indexOf('key') == 0){
var code = this.code = (event.which || event.keyCode);
this.key = _keys[code];
if (type == 'keydown'){
if (code > 111 && code < 124) this.key = 'f' + (code - 111);
else if (code > 95 && code < 106) this.key = code - 96;
}
if (this.key == null) this.key = String.fromCharCode(code).toLowerCase();
} else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'DOMMouseScroll' || type.indexOf('mouse') == 0){
var doc = win.document;
doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
this.page = {
x: (event.pageX != null) ? event.pageX : event.clientX + doc.scrollLeft,
y: (event.pageY != null) ? event.pageY : event.clientY + doc.scrollTop
};
this.client = {
x: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX,
y: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY
};
if (type == 'DOMMouseScroll' || type == 'mousewheel')
this.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
this.rightClick = (event.which == 3 || event.button == 2);
if (type == 'mouseover' || type == 'mouseout'){
var related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];
while (related && related.nodeType == 3) related = related.parentNode;
this.relatedTarget = document.id(related);
}
} else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0){
this.rotation = event.rotation;
this.scale = event.scale;
this.targetTouches = event.targetTouches;
this.changedTouches = event.changedTouches;
var touches = this.touches = event.touches;
if (touches && touches[0]){
var touch = touches[0];
this.page = {x: touch.pageX, y: touch.pageY};
this.client = {x: touch.clientX, y: touch.clientY};
}
}
if (!this.client) this.client = {};
if (!this.page) this.page = {};
});
DOMEvent.implement({
stop: function(){
return this.preventDefault().stopPropagation();
},
stopPropagation: function(){
if (this.event.stopPropagation) this.event.stopPropagation();
else this.event.cancelBubble = true;
return this;
},
preventDefault: function(){
if (this.event.preventDefault) this.event.preventDefault();
else this.event.returnValue = false;
return this;
}
});
DOMEvent.defineKey = function(code, key){
_keys[code] = key;
return this;
};
DOMEvent.defineKeys = DOMEvent.defineKey.overloadSetter(true);
DOMEvent.defineKeys({
'38': 'up', '40': 'down', '37': 'left', '39': 'right',
'27': 'esc', '32': 'space', '8': 'backspace', '9': 'tab',
'46': 'delete', '13': 'enter'
});
})();
/*
---
name: Class
description: Contains the Class Function for easily creating, extending, and implementing reusable Classes.
license: MIT-style license.
requires: [Array, String, Function, Number]
provides: Class
...
*/
(function(){
var Class = this.Class = new Type('Class', function(params){
if (instanceOf(params, Function)) params = {initialize: params};
var newClass = function(){
reset(this);
if (newClass.$prototyping) return this;
this.$caller = null;
var value = (this.initialize) ? this.initialize.apply(this, arguments) : this;
this.$caller = this.caller = null;
return value;
}.extend(this).implement(params);
newClass.$constructor = Class;
newClass.prototype.$constructor = newClass;
newClass.prototype.parent = parent;
return newClass;
});
var parent = function(){
if (!this.$caller) throw new Error('The method "parent" cannot be called.');
var name = this.$caller.$name,
parent = this.$caller.$owner.parent,
previous = (parent) ? parent.prototype[name] : null;
if (!previous) throw new Error('The method "' + name + '" has no parent.');
return previous.apply(this, arguments);
};
var reset = function(object){
for (var key in object){
var value = object[key];
switch (typeOf(value)){
case 'object':
var F = function(){};
F.prototype = value;
object[key] = reset(new F);
break;
case 'array': object[key] = value.clone(); break;
}
}
return object;
};
var wrap = function(self, key, method){
if (method.$origin) method = method.$origin;
var wrapper = function(){
if (method.$protected && this.$caller == null) throw new Error('The method "' + key + '" cannot be called.');
var caller = this.caller, current = this.$caller;
this.caller = current; this.$caller = wrapper;
var result = method.apply(this, arguments);
this.$caller = current; this.caller = caller;
return result;
}.extend({$owner: self, $origin: method, $name: key});
return wrapper;
};
var implement = function(key, value, retain){
if (Class.Mutators.hasOwnProperty(key)){
value = Class.Mutators[key].call(this, value);
if (value == null) return this;
}
if (typeOf(value) == 'function'){
if (value.$hidden) return this;
this.prototype[key] = (retain) ? value : wrap(this, key, value);
} else {
Object.merge(this.prototype, key, value);
}
return this;
};
var getInstance = function(klass){
klass.$prototyping = true;
var proto = new klass;
delete klass.$prototyping;
return proto;
};
Class.implement('implement', implement.overloadSetter());
Class.Mutators = {
Extends: function(parent){
this.parent = parent;
this.prototype = getInstance(parent);
},
Implements: function(items){
Array.from(items).each(function(item){
var instance = new item;
for (var key in instance) implement.call(this, key, instance[key], true);
}, this);
}
};
})();
/*
---
name: Class.Extras
description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.
license: MIT-style license.
requires: Class
provides: [Class.Extras, Chain, Events, Options]
...
*/
(function(){
this.Chain = new Class({
$chain: [],
chain: function(){
this.$chain.append(Array.flatten(arguments));
return this;
},
callChain: function(){
return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;
},
clearChain: function(){
this.$chain.empty();
return this;
}
});
var removeOn = function(string){
return string.replace(/^on([A-Z])/, function(full, first){
return first.toLowerCase();
});
};
this.Events = new Class({
$events: {},
addEvent: function(type, fn, internal){
type = removeOn(type);
this.$events[type] = (this.$events[type] || []).include(fn);
if (internal) fn.internal = true;
return this;
},
addEvents: function(events){
for (var type in events) this.addEvent(type, events[type]);
return this;
},
fireEvent: function(type, args, delay){
type = removeOn(type);
var events = this.$events[type];
if (!events) return this;
args = Array.from(args);
events.each(function(fn){
if (delay) fn.delay(delay, this, args);
else fn.apply(this, args);
}, this);
return this;
},
removeEvent: function(type, fn){
type = removeOn(type);
var events = this.$events[type];
if (events && !fn.internal){
var index = events.indexOf(fn);
if (index != -1) delete events[index];
}
return this;
},
removeEvents: function(events){
var type;
if (typeOf(events) == 'object'){
for (type in events) this.removeEvent(type, events[type]);
return this;
}
if (events) events = removeOn(events);
for (type in this.$events){
if (events && events != type) continue;
var fns = this.$events[type];
for (var i = fns.length; i--;) if (i in fns){
this.removeEvent(type, fns[i]);
}
}
return this;
}
});
this.Options = new Class({
setOptions: function(){
var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));
if (this.addEvent) for (var option in options){
if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
this.addEvent(option, options[option]);
delete options[option];
}
return this;
}
});
})();
/*
---
name: Slick.Parser
description: Standalone CSS3 Selector parser
provides: Slick.Parser
...
*/
;(function(){
var parsed,
separatorIndex,
combinatorIndex,
reversed,
cache = {},
reverseCache = {},
reUnescape = /\\/g;
var parse = function(expression, isReversed){
if (expression == null) return null;
if (expression.Slick === true) return expression;
expression = ('' + expression).replace(/^\s+|\s+$/g, '');
reversed = !!isReversed;
var currentCache = (reversed) ? reverseCache : cache;
if (currentCache[expression]) return currentCache[expression];
parsed = {
Slick: true,
expressions: [],
raw: expression,
reverse: function(){
return parse(this.raw, true);
}
};
separatorIndex = -1;
while (expression != (expression = expression.replace(regexp, parser)));
parsed.length = parsed.expressions.length;
return currentCache[parsed.raw] = (reversed) ? reverse(parsed) : parsed;
};
var reverseCombinator = function(combinator){
if (combinator === '!') return ' ';
else if (combinator === ' ') return '!';
else if ((/^!/).test(combinator)) return combinator.replace(/^!/, '');
else return '!' + combinator;
};
var reverse = function(expression){
var expressions = expression.expressions;
for (var i = 0; i < expressions.length; i++){
var exp = expressions[i];
var last = {parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator)};
for (var j = 0; j < exp.length; j++){
var cexp = exp[j];
if (!cexp.reverseCombinator) cexp.reverseCombinator = ' ';
cexp.combinator = cexp.reverseCombinator;
delete cexp.reverseCombinator;
}
exp.reverse().push(last);
}
return expression;
};
var escapeRegExp = function(string){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License
return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, function(match){
return '\\' + match;
});
};
var regexp = new RegExp(
/*
#!/usr/bin/env ruby
puts "\t\t" + DATA.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'')
__END__
"(?x)^(?:\
\\s* ( , ) \\s* # Separator \n\
| \\s* ( <combinator>+ ) \\s* # Combinator \n\
| ( \\s+ ) # CombinatorChildren \n\
| ( <unicode>+ | \\* ) # Tag \n\
| \\# ( <unicode>+ ) # ID \n\
| \\. ( <unicode>+ ) # ClassName \n\
| # Attribute \n\
\\[ \
\\s* (<unicode1>+) (?: \
\\s* ([*^$!~|]?=) (?: \
\\s* (?:\
([\"']?)(.*?)\\9 \
)\
) \
)? \\s* \
\\](?!\\]) \n\
| :+ ( <unicode>+ )(?:\
\\( (?:\
(?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\
) \\)\
)?\
)"
*/
"^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)"
.replace(/<combinator>/, '[' + escapeRegExp(">+~`!@$%^&={}\\;</") + ']')
.replace(/<unicode>/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
.replace(/<unicode1>/g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
);
function parser(
rawMatch,
separator,
combinator,
combinatorChildren,
tagName,
id,
className,
attributeKey,
attributeOperator,
attributeQuote,
attributeValue,
pseudoMarker,
pseudoClass,
pseudoQuote,
pseudoClassQuotedValue,
pseudoClassValue
){
if (separator || separatorIndex === -1){
parsed.expressions[++separatorIndex] = [];
combinatorIndex = -1;
if (separator) return '';
}
if (combinator || combinatorChildren || combinatorIndex === -1){
combinator = combinator || ' ';
var currentSeparator = parsed.expressions[separatorIndex];
if (reversed && currentSeparator[combinatorIndex])
currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator);
currentSeparator[++combinatorIndex] = {combinator: combinator, tag: '*'};
}
var currentParsed = parsed.expressions[separatorIndex][combinatorIndex];
if (tagName){
currentParsed.tag = tagName.replace(reUnescape, '');
} else if (id){
currentParsed.id = id.replace(reUnescape, '');
} else if (className){
className = className.replace(reUnescape, '');
if (!currentParsed.classList) currentParsed.classList = [];
if (!currentParsed.classes) currentParsed.classes = [];
currentParsed.classList.push(className);
currentParsed.classes.push({
value: className,
regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)')
});
} else if (pseudoClass){
pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue;
pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null;
if (!currentParsed.pseudos) currentParsed.pseudos = [];
currentParsed.pseudos.push({
key: pseudoClass.replace(reUnescape, ''),
value: pseudoClassValue,
type: pseudoMarker.length == 1 ? 'class' : 'element'
});
} else if (attributeKey){
attributeKey = attributeKey.replace(reUnescape, '');
attributeValue = (attributeValue || '').replace(reUnescape, '');
var test, regexp;
switch (attributeOperator){
case '^=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) ); break;
case '$=' : regexp = new RegExp( escapeRegExp(attributeValue) +'$' ); break;
case '~=' : regexp = new RegExp( '(^|\\s)'+ escapeRegExp(attributeValue) +'(\\s|$)' ); break;
case '|=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) +'(-|$)' ); break;
case '=' : test = function(value){
return attributeValue == value;
}; break;
case '*=' : test = function(value){
return value && value.indexOf(attributeValue) > -1;
}; break;
case '!=' : test = function(value){
return attributeValue != value;
}; break;
default : test = function(value){
return !!value;
};
}
if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function(){
return false;
};
if (!test) test = function(value){
return value && regexp.test(value);
};
if (!currentParsed.attributes) currentParsed.attributes = [];
currentParsed.attributes.push({
key: attributeKey,
operator: attributeOperator,
value: attributeValue,
test: test
});
}
return '';
};
// Slick NS
var Slick = (this.Slick || {});
Slick.parse = function(expression){
return parse(expression);
};
Slick.escapeRegExp = escapeRegExp;
if (!this.Slick) this.Slick = Slick;
}).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);
/*
---
name: Slick.Finder
description: The new, superfast css selector engine.
provides: Slick.Finder
requires: Slick.Parser
...
*/
;(function(){
var local = {},
featuresCache = {},
toString = Object.prototype.toString;
// Feature / Bug detection
local.isNativeCode = function(fn){
return (/\{\s*\[native code\]\s*\}/).test('' + fn);
};
local.isXML = function(document){
return (!!document.xmlVersion) || (!!document.xml) || (toString.call(document) == '[object XMLDocument]') ||
(document.nodeType == 9 && document.documentElement.nodeName != 'HTML');
};
local.setDocument = function(document){
// convert elements / window arguments to document. if document cannot be extrapolated, the function returns.
var nodeType = document.nodeType;
if (nodeType == 9); // document
else if (nodeType) document = document.ownerDocument; // node
else if (document.navigator) document = document.document; // window
else return;
// check if it's the old document
if (this.document === document) return;
this.document = document;
// check if we have done feature detection on this document before
var root = document.documentElement,
rootUid = this.getUIDXML(root),
features = featuresCache[rootUid],
feature;
if (features){
for (feature in features){
this[feature] = features[feature];
}
return;
}
features = featuresCache[rootUid] = {};
features.root = root;
features.isXMLDocument = this.isXML(document);
features.brokenStarGEBTN
= features.starSelectsClosedQSA
= features.idGetsName
= features.brokenMixedCaseQSA
= features.brokenGEBCN
= features.brokenCheckedQSA
= features.brokenEmptyAttributeQSA
= features.isHTMLDocument
= features.nativeMatchesSelector
= false;
var starSelectsClosed, starSelectsComments,
brokenSecondClassNameGEBCN, cachedGetElementsByClassName,
brokenFormAttributeGetter;
var selected, id = 'slick_uniqueid';
var testNode = document.createElement('div');
var testRoot = document.body || document.getElementsByTagName('body')[0] || root;
testRoot.appendChild(testNode);
// on non-HTML documents innerHTML and getElementsById doesnt work properly
try {
testNode.innerHTML = '<a id="'+id+'"></a>';
features.isHTMLDocument = !!document.getElementById(id);
} catch(e){};
if (features.isHTMLDocument){
testNode.style.display = 'none';
// IE returns comment nodes for getElementsByTagName('*') for some documents
testNode.appendChild(document.createComment(''));
starSelectsComments = (testNode.getElementsByTagName('*').length > 1);
// IE returns closed nodes (EG:"</foo>") for getElementsByTagName('*') for some documents
try {
testNode.innerHTML = 'foo</foo>';
selected = testNode.getElementsByTagName('*');
starSelectsClosed = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');
} catch(e){};
features.brokenStarGEBTN = starSelectsComments || starSelectsClosed;
// IE returns elements with the name instead of just id for getElementsById for some documents
try {
testNode.innerHTML = '<a name="'+ id +'"></a><b id="'+ id +'"></b>';
features.idGetsName = document.getElementById(id) === testNode.firstChild;
} catch(e){};
if (testNode.getElementsByClassName){
// Safari 3.2 getElementsByClassName caches results
try {
testNode.innerHTML = '<a class="f"></a><a class="b"></a>';
testNode.getElementsByClassName('b').length;
testNode.firstChild.className = 'b';
cachedGetElementsByClassName = (testNode.getElementsByClassName('b').length != 2);
} catch(e){};
// Opera 9.6 getElementsByClassName doesnt detects the class if its not the first one
try {
testNode.innerHTML = '<a class="a"></a><a class="f b a"></a>';
brokenSecondClassNameGEBCN = (testNode.getElementsByClassName('a').length != 2);
} catch(e){};
features.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;
}
if (testNode.querySelectorAll){
// IE 8 returns closed nodes (EG:"</foo>") for querySelectorAll('*') for some documents
try {
testNode.innerHTML = 'foo</foo>';
selected = testNode.querySelectorAll('*');
features.starSelectsClosedQSA = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');
} catch(e){};
// Safari 3.2 querySelectorAll doesnt work with mixedcase on quirksmode
try {
testNode.innerHTML = '<a class="MiX"></a>';
features.brokenMixedCaseQSA = !testNode.querySelectorAll('.MiX').length;
} catch(e){};
// Webkit and Opera dont return selected options on querySelectorAll
try {
testNode.innerHTML = '<select><option selected="selected">a</option></select>';
features.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0);
} catch(e){};
// IE returns incorrect results for attr[*^$]="" selectors on querySelectorAll
try {
testNode.innerHTML = '<a class=""></a>';
features.brokenEmptyAttributeQSA = (testNode.querySelectorAll('[class*=""]').length != 0);
} catch(e){};
}
// IE6-7, if a form has an input of id x, form.getAttribute(x) returns a reference to the input
try {
testNode.innerHTML = '<form action="s"><input id="action"/></form>';
brokenFormAttributeGetter = (testNode.firstChild.getAttribute('action') != 's');
} catch(e){};
// native matchesSelector function
features.nativeMatchesSelector = root.matchesSelector || /*root.msMatchesSelector ||*/ root.mozMatchesSelector || root.webkitMatchesSelector;
if (features.nativeMatchesSelector) try {
// if matchesSelector trows errors on incorrect sintaxes we can use it
features.nativeMatchesSelector.call(root, ':slick');
features.nativeMatchesSelector = null;
} catch(e){};
}
try {
root.slick_expando = 1;
delete root.slick_expando;
features.getUID = this.getUIDHTML;
} catch(e) {
features.getUID = this.getUIDXML;
}
testRoot.removeChild(testNode);
testNode = selected = testRoot = null;
// getAttribute
features.getAttribute = (features.isHTMLDocument && brokenFormAttributeGetter) ? function(node, name){
var method = this.attributeGetters[name];
if (method) return method.call(node);
var attributeNode = node.getAttributeNode(name);
return (attributeNode) ? attributeNode.nodeValue : null;
} : function(node, name){
var method = this.attributeGetters[name];
return (method) ? method.call(node) : node.getAttribute(name);
};
// hasAttribute
features.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function(node, attribute) {
return node.hasAttribute(attribute);
} : function(node, attribute) {
node = node.getAttributeNode(attribute);
return !!(node && (node.specified || node.nodeValue));
};
// contains
// FIXME: Add specs: local.contains should be different for xml and html documents?
var nativeRootContains = root && this.isNativeCode(root.contains),
nativeDocumentContains = document && this.isNativeCode(document.contains);
features.contains = (nativeRootContains && nativeDocumentContains) ? function(context, node){
return context.contains(node);
} : (nativeRootContains && !nativeDocumentContains) ? function(context, node){
// IE8 does not have .contains on document.
return context === node || ((context === document) ? document.documentElement : context).contains(node);
} : (root && root.compareDocumentPosition) ? function(context, node){
return context === node || !!(context.compareDocumentPosition(node) & 16);
} : function(context, node){
if (node) do {
if (node === context) return true;
} while ((node = node.parentNode));
return false;
};
// document order sorting
// credits to Sizzle (http://sizzlejs.com/)
features.documentSorter = (root.compareDocumentPosition) ? function(a, b){
if (!a.compareDocumentPosition || !b.compareDocumentPosition) return 0;
return a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
} : ('sourceIndex' in root) ? function(a, b){
if (!a.sourceIndex || !b.sourceIndex) return 0;
return a.sourceIndex - b.sourceIndex;
} : (document.createRange) ? function(a, b){
if (!a.ownerDocument || !b.ownerDocument) return 0;
var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
aRange.setStart(a, 0);
aRange.setEnd(a, 0);
bRange.setStart(b, 0);
bRange.setEnd(b, 0);
return aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
} : null ;
root = null;
for (feature in features){
this[feature] = features[feature];
}
};
// Main Method
var reSimpleSelector = /^([#.]?)((?:[\w-]+|\*))$/,
reEmptyAttribute = /\[.+[*$^]=(?:""|'')?\]/,
qsaFailExpCache = {};
local.search = function(context, expression, append, first){
var found = this.found = (first) ? null : (append || []);
if (!context) return found;
else if (context.navigator) context = context.document; // Convert the node from a window to a document
else if (!context.nodeType) return found;
// setup
var parsed, i,
uniques = this.uniques = {},
hasOthers = !!(append && append.length),
contextIsDocument = (context.nodeType == 9);
if (this.document !== (contextIsDocument ? context : context.ownerDocument)) this.setDocument(context);
// avoid duplicating items already in the append array
if (hasOthers) for (i = found.length; i--;) uniques[this.getUID(found[i])] = true;
// expression checks
if (typeof expression == 'string'){ // expression is a string
/*<simple-selectors-override>*/
var simpleSelector = expression.match(reSimpleSelector);
simpleSelectors: if (simpleSelector) {
var symbol = simpleSelector[1],
name = simpleSelector[2],
node, nodes;
if (!symbol){
if (name == '*' && this.brokenStarGEBTN) break simpleSelectors;
nodes = context.getElementsByTagName(name);
if (first) return nodes[0] || null;
for (i = 0; node = nodes[i++];){
if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
}
} else if (symbol == '#'){
if (!this.isHTMLDocument || !contextIsDocument) break simpleSelectors;
node = context.getElementById(name);
if (!node) return found;
if (this.idGetsName && node.getAttributeNode('id').nodeValue != name) break simpleSelectors;
if (first) return node || null;
if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
} else if (symbol == '.'){
if (!this.isHTMLDocument || ((!context.getElementsByClassName || this.brokenGEBCN) && context.querySelectorAll)) break simpleSelectors;
if (context.getElementsByClassName && !this.brokenGEBCN){
nodes = context.getElementsByClassName(name);
if (first) return nodes[0] || null;
for (i = 0; node = nodes[i++];){
if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
}
} else {
var matchClass = new RegExp('(^|\\s)'+ Slick.escapeRegExp(name) +'(\\s|$)');
nodes = context.getElementsByTagName('*');
for (i = 0; node = nodes[i++];){
className = node.className;
if (!(className && matchClass.test(className))) continue;
if (first) return node;
if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
}
}
}
if (hasOthers) this.sort(found);
return (first) ? null : found;
}
/*</simple-selectors-override>*/
/*<query-selector-override>*/
querySelector: if (context.querySelectorAll) {
if (!this.isHTMLDocument
|| qsaFailExpCache[expression]
//TODO: only skip when expression is actually mixed case
|| this.brokenMixedCaseQSA
|| (this.brokenCheckedQSA && expression.indexOf(':checked') > -1)
|| (this.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression))
|| (!contextIsDocument //Abort when !contextIsDocument and...
// there are multiple expressions in the selector
// since we currently only fix non-document rooted QSA for single expression selectors
&& expression.indexOf(',') > -1
)
|| Slick.disableQSA
) break querySelector;
var _expression = expression, _context = context;
if (!contextIsDocument){
// non-document rooted QSA
// credits to Andrew Dupont
var currentId = _context.getAttribute('id'), slickid = 'slickid__';
_context.setAttribute('id', slickid);
_expression = '#' + slickid + ' ' + _expression;
context = _context.parentNode;
}
try {
if (first) return context.querySelector(_expression) || null;
else nodes = context.querySelectorAll(_expression);
} catch(e) {
qsaFailExpCache[expression] = 1;
break querySelector;
} finally {
if (!contextIsDocument){
if (currentId) _context.setAttribute('id', currentId);
else _context.removeAttribute('id');
context = _context;
}
}
if (this.starSelectsClosedQSA) for (i = 0; node = nodes[i++];){
if (node.nodeName > '@' && !(hasOthers && uniques[this.getUID(node)])) found.push(node);
} else for (i = 0; node = nodes[i++];){
if (!(hasOthers && uniques[this.getUID(node)])) found.push(node);
}
if (hasOthers) this.sort(found);
return found;
}
/*</query-selector-override>*/
parsed = this.Slick.parse(expression);
if (!parsed.length) return found;
} else if (expression == null){ // there is no expression
return found;
} else if (expression.Slick){ // expression is a parsed Slick object
parsed = expression;
} else if (this.contains(context.documentElement || context, expression)){ // expression is a node
(found) ? found.push(expression) : found = expression;
return found;
} else { // other junk
return found;
}
/*<pseudo-selectors>*//*<nth-pseudo-selectors>*/
// cache elements for the nth selectors
this.posNTH = {};
this.posNTHLast = {};
this.posNTHType = {};
this.posNTHTypeLast = {};
/*</nth-pseudo-selectors>*//*</pseudo-selectors>*/
// if append is null and there is only a single selector with one expression use pushArray, else use pushUID
this.push = (!hasOthers && (first || (parsed.length == 1 && parsed.expressions[0].length == 1))) ? this.pushArray : this.pushUID;
if (found == null) found = [];
// default engine
var j, m, n;
var combinator, tag, id, classList, classes, attributes, pseudos;
var currentItems, currentExpression, currentBit, lastBit, expressions = parsed.expressions;
search: for (i = 0; (currentExpression = expressions[i]); i++) for (j = 0; (currentBit = currentExpression[j]); j++){
combinator = 'combinator:' + currentBit.combinator;
if (!this[combinator]) continue search;
tag = (this.isXMLDocument) ? currentBit.tag : currentBit.tag.toUpperCase();
id = currentBit.id;
classList = currentBit.classList;
classes = currentBit.classes;
attributes = currentBit.attributes;
pseudos = currentBit.pseudos;
lastBit = (j === (currentExpression.length - 1));
this.bitUniques = {};
if (lastBit){
this.uniques = uniques;
this.found = found;
} else {
this.uniques = {};
this.found = [];
}
if (j === 0){
this[combinator](context, tag, id, classes, attributes, pseudos, classList);
if (first && lastBit && found.length) break search;
} else {
if (first && lastBit) for (m = 0, n = currentItems.length; m < n; m++){
this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList);
if (found.length) break search;
} else for (m = 0, n = currentItems.length; m < n; m++) this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList);
}
currentItems = this.found;
}
// should sort if there are nodes in append and if you pass multiple expressions.
if (hasOthers || (parsed.expressions.length > 1)) this.sort(found);
return (first) ? (found[0] || null) : found;
};
// Utils
local.uidx = 1;
local.uidk = 'slick-uniqueid';
local.getUIDXML = function(node){
var uid = node.getAttribute(this.uidk);
if (!uid){
uid = this.uidx++;
node.setAttribute(this.uidk, uid);
}
return uid;
};
local.getUIDHTML = function(node){
return node.uniqueNumber || (node.uniqueNumber = this.uidx++);
};
// sort based on the setDocument documentSorter method.
local.sort = function(results){
if (!this.documentSorter) return results;
results.sort(this.documentSorter);
return results;
};
/*<pseudo-selectors>*//*<nth-pseudo-selectors>*/
local.cacheNTH = {};
local.matchNTH = /^([+-]?\d*)?([a-z]+)?([+-]\d+)?$/;
local.parseNTHArgument = function(argument){
var parsed = argument.match(this.matchNTH);
if (!parsed) return false;
var special = parsed[2] || false;
var a = parsed[1] || 1;
if (a == '-') a = -1;
var b = +parsed[3] || 0;
parsed =
(special == 'n') ? {a: a, b: b} :
(special == 'odd') ? {a: 2, b: 1} :
(special == 'even') ? {a: 2, b: 0} : {a: 0, b: a};
return (this.cacheNTH[argument] = parsed);
};
local.createNTHPseudo = function(child, sibling, positions, ofType){
return function(node, argument){
var uid = this.getUID(node);
if (!this[positions][uid]){
var parent = node.parentNode;
if (!parent) return false;
var el = parent[child], count = 1;
if (ofType){
var nodeName = node.nodeName;
do {
if (el.nodeName != nodeName) continue;
this[positions][this.getUID(el)] = count++;
} while ((el = el[sibling]));
} else {
do {
if (el.nodeType != 1) continue;
this[positions][this.getUID(el)] = count++;
} while ((el = el[sibling]));
}
}
argument = argument || 'n';
var parsed = this.cacheNTH[argument] || this.parseNTHArgument(argument);
if (!parsed) return false;
var a = parsed.a, b = parsed.b, pos = this[positions][uid];
if (a == 0) return b == pos;
if (a > 0){
if (pos < b) return false;
} else {
if (b < pos) return false;
}
return ((pos - b) % a) == 0;
};
};
/*</nth-pseudo-selectors>*//*</pseudo-selectors>*/
local.pushArray = function(node, tag, id, classes, attributes, pseudos){
if (this.matchSelector(node, tag, id, classes, attributes, pseudos)) this.found.push(node);
};
local.pushUID = function(node, tag, id, classes, attributes, pseudos){
var uid = this.getUID(node);
if (!this.uniques[uid] && this.matchSelector(node, tag, id, classes, attributes, pseudos)){
this.uniques[uid] = true;
this.found.push(node);
}
};
local.matchNode = function(node, selector){
if (this.isHTMLDocument && this.nativeMatchesSelector){
try {
return this.nativeMatchesSelector.call(node, selector.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g, '[$1="$2"]'));
} catch(matchError) {}
}
var parsed = this.Slick.parse(selector);
if (!parsed) return true;
// simple (single) selectors
var expressions = parsed.expressions, simpleExpCounter = 0, i;
for (i = 0; (currentExpression = expressions[i]); i++){
if (currentExpression.length == 1){
var exp = currentExpression[0];
if (this.matchSelector(node, (this.isXMLDocument) ? exp.tag : exp.tag.toUpperCase(), exp.id, exp.classes, exp.attributes, exp.pseudos)) return true;
simpleExpCounter++;
}
}
if (simpleExpCounter == parsed.length) return false;
var nodes = this.search(this.document, parsed), item;
for (i = 0; item = nodes[i++];){
if (item === node) return true;
}
return false;
};
local.matchPseudo = function(node, name, argument){
var pseudoName = 'pseudo:' + name;
if (this[pseudoName]) return this[pseudoName](node, argument);
var attribute = this.getAttribute(node, name);
return (argument) ? argument == attribute : !!attribute;
};
local.matchSelector = function(node, tag, id, classes, attributes, pseudos){
if (tag){
var nodeName = (this.isXMLDocument) ? node.nodeName : node.nodeName.toUpperCase();
if (tag == '*'){
if (nodeName < '@') return false; // Fix for comment nodes and closed nodes
} else {
if (nodeName != tag) return false;
}
}
if (id && node.getAttribute('id') != id) return false;
var i, part, cls;
if (classes) for (i = classes.length; i--;){
cls = this.getAttribute(node, 'class');
if (!(cls && classes[i].regexp.test(cls))) return false;
}
if (attributes) for (i = attributes.length; i--;){
part = attributes[i];
if (part.operator ? !part.test(this.getAttribute(node, part.key)) : !this.hasAttribute(node, part.key)) return false;
}
if (pseudos) for (i = pseudos.length; i--;){
part = pseudos[i];
if (!this.matchPseudo(node, part.key, part.value)) return false;
}
return true;
};
var combinators = {
' ': function(node, tag, id, classes, attributes, pseudos, classList){ // all child nodes, any level
var i, item, children;
if (this.isHTMLDocument){
getById: if (id){
item = this.document.getElementById(id);
if ((!item && node.all) || (this.idGetsName && item && item.getAttributeNode('id').nodeValue != id)){
// all[id] returns all the elements with that name or id inside node
// if theres just one it will return the element, else it will be a collection
children = node.all[id];
if (!children) return;
if (!children[0]) children = [children];
for (i = 0; item = children[i++];){
var idNode = item.getAttributeNode('id');
if (idNode && idNode.nodeValue == id){
this.push(item, tag, null, classes, attributes, pseudos);
break;
}
}
return;
}
if (!item){
// if the context is in the dom we return, else we will try GEBTN, breaking the getById label
if (this.contains(this.root, node)) return;
else break getById;
} else if (this.document !== node && !this.contains(node, item)) return;
this.push(item, tag, null, classes, attributes, pseudos);
return;
}
getByClass: if (classes && node.getElementsByClassName && !this.brokenGEBCN){
children = node.getElementsByClassName(classList.join(' '));
if (!(children && children.length)) break getByClass;
for (i = 0; item = children[i++];) this.push(item, tag, id, null, attributes, pseudos);
return;
}
}
getByTag: {
children = node.getElementsByTagName(tag);
if (!(children && children.length)) break getByTag;
if (!this.brokenStarGEBTN) tag = null;
for (i = 0; item = children[i++];) this.push(item, tag, id, classes, attributes, pseudos);
}
},
'>': function(node, tag, id, classes, attributes, pseudos){ // direct children
if ((node = node.firstChild)) do {
if (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);
} while ((node = node.nextSibling));
},
'+': function(node, tag, id, classes, attributes, pseudos){ // next sibling
while ((node = node.nextSibling)) if (node.nodeType == 1){
this.push(node, tag, id, classes, attributes, pseudos);
break;
}
},
'^': function(node, tag, id, classes, attributes, pseudos){ // first child
node = node.firstChild;
if (node){
if (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);
else this['combinator:+'](node, tag, id, classes, attributes, pseudos);
}
},
'~': function(node, tag, id, classes, attributes, pseudos){ // next siblings
while ((node = node.nextSibling)){
if (node.nodeType != 1) continue;
var uid = this.getUID(node);
if (this.bitUniques[uid]) break;
this.bitUniques[uid] = true;
this.push(node, tag, id, classes, attributes, pseudos);
}
},
'++': function(node, tag, id, classes, attributes, pseudos){ // next sibling and previous sibling
this['combinator:+'](node, tag, id, classes, attributes, pseudos);
this['combinator:!+'](node, tag, id, classes, attributes, pseudos);
},
'~~': function(node, tag, id, classes, attributes, pseudos){ // next siblings and previous siblings
this['combinator:~'](node, tag, id, classes, attributes, pseudos);
this['combinator:!~'](node, tag, id, classes, attributes, pseudos);
},
'!': function(node, tag, id, classes, attributes, pseudos){ // all parent nodes up to document
while ((node = node.parentNode)) if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos);
},
'!>': function(node, tag, id, classes, attributes, pseudos){ // direct parent (one level)
node = node.parentNode;
if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos);
},
'!+': function(node, tag, id, classes, attributes, pseudos){ // previous sibling
while ((node = node.previousSibling)) if (node.nodeType == 1){
this.push(node, tag, id, classes, attributes, pseudos);
break;
}
},
'!^': function(node, tag, id, classes, attributes, pseudos){ // last child
node = node.lastChild;
if (node){
if (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);
else this['combinator:!+'](node, tag, id, classes, attributes, pseudos);
}
},
'!~': function(node, tag, id, classes, attributes, pseudos){ // previous siblings
while ((node = node.previousSibling)){
if (node.nodeType != 1) continue;
var uid = this.getUID(node);
if (this.bitUniques[uid]) break;
this.bitUniques[uid] = true;
this.push(node, tag, id, classes, attributes, pseudos);
}
}
};
for (var c in combinators) local['combinator:' + c] = combinators[c];
var pseudos = {
/*<pseudo-selectors>*/
'empty': function(node){
var child = node.firstChild;
return !(child && child.nodeType == 1) && !(node.innerText || node.textContent || '').length;
},
'not': function(node, expression){
return !this.matchNode(node, expression);
},
'contains': function(node, text){
return (node.innerText || node.textContent || '').indexOf(text) > -1;
},
'first-child': function(node){
while ((node = node.previousSibling)) if (node.nodeType == 1) return false;
return true;
},
'last-child': function(node){
while ((node = node.nextSibling)) if (node.nodeType == 1) return false;
return true;
},
'only-child': function(node){
var prev = node;
while ((prev = prev.previousSibling)) if (prev.nodeType == 1) return false;
var next = node;
while ((next = next.nextSibling)) if (next.nodeType == 1) return false;
return true;
},
/*<nth-pseudo-selectors>*/
'nth-child': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTH'),
'nth-last-child': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHLast'),
'nth-of-type': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTHType', true),
'nth-last-of-type': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHTypeLast', true),
'index': function(node, index){
return this['pseudo:nth-child'](node, '' + (index + 1));
},
'even': function(node){
return this['pseudo:nth-child'](node, '2n');
},
'odd': function(node){
return this['pseudo:nth-child'](node, '2n+1');
},
/*</nth-pseudo-selectors>*/
/*<of-type-pseudo-selectors>*/
'first-of-type': function(node){
var nodeName = node.nodeName;
while ((node = node.previousSibling)) if (node.nodeName == nodeName) return false;
return true;
},
'last-of-type': function(node){
var nodeName = node.nodeName;
while ((node = node.nextSibling)) if (node.nodeName == nodeName) return false;
return true;
},
'only-of-type': function(node){
var prev = node, nodeName = node.nodeName;
while ((prev = prev.previousSibling)) if (prev.nodeName == nodeName) return false;
var next = node;
while ((next = next.nextSibling)) if (next.nodeName == nodeName) return false;
return true;
},
/*</of-type-pseudo-selectors>*/
// custom pseudos
'enabled': function(node){
return !node.disabled;
},
'disabled': function(node){
return node.disabled;
},
'checked': function(node){
return node.checked || node.selected;
},
'focus': function(node){
return this.isHTMLDocument && this.document.activeElement === node && (node.href || node.type || this.hasAttribute(node, 'tabindex'));
},
'root': function(node){
return (node === this.root);
},
'selected': function(node){
return node.selected;
}
/*</pseudo-selectors>*/
};
for (var p in pseudos) local['pseudo:' + p] = pseudos[p];
// attributes methods
var attributeGetters = local.attributeGetters = {
'for': function(){
return ('htmlFor' in this) ? this.htmlFor : this.getAttribute('for');
},
'href': function(){
return ('href' in this) ? this.getAttribute('href', 2) : this.getAttribute('href');
},
'style': function(){
return (this.style) ? this.style.cssText : this.getAttribute('style');
},
'tabindex': function(){
var attributeNode = this.getAttributeNode('tabindex');
return (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;
},
'type': function(){
return this.getAttribute('type');
},
'maxlength': function(){
var attributeNode = this.getAttributeNode('maxLength');
return (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;
}
};
attributeGetters.MAXLENGTH = attributeGetters.maxLength = attributeGetters.maxlength;
// Slick
var Slick = local.Slick = (this.Slick || {});
Slick.version = '1.1.7';
// Slick finder
Slick.search = function(context, expression, append){
return local.search(context, expression, append);
};
Slick.find = function(context, expression){
return local.search(context, expression, null, true);
};
// Slick containment checker
Slick.contains = function(container, node){
local.setDocument(container);
return local.contains(container, node);
};
// Slick attribute getter
Slick.getAttribute = function(node, name){
local.setDocument(node);
return local.getAttribute(node, name);
};
Slick.hasAttribute = function(node, name){
local.setDocument(node);
return local.hasAttribute(node, name);
};
// Slick matcher
Slick.match = function(node, selector){
if (!(node && selector)) return false;
if (!selector || selector === node) return true;
local.setDocument(node);
return local.matchNode(node, selector);
};
// Slick attribute accessor
Slick.defineAttributeGetter = function(name, fn){
local.attributeGetters[name] = fn;
return this;
};
Slick.lookupAttributeGetter = function(name){
return local.attributeGetters[name];
};
// Slick pseudo accessor
Slick.definePseudo = function(name, fn){
local['pseudo:' + name] = function(node, argument){
return fn.call(node, argument);
};
return this;
};
Slick.lookupPseudo = function(name){
var pseudo = local['pseudo:' + name];
if (pseudo) return function(argument){
return pseudo.call(this, argument);
};
return null;
};
// Slick overrides accessor
Slick.override = function(regexp, fn){
local.override(regexp, fn);
return this;
};
Slick.isXML = local.isXML;
Slick.uidOf = function(node){
return local.getUIDHTML(node);
};
if (!this.Slick) this.Slick = Slick;
}).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);
/*
---
name: Element
description: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements.
license: MIT-style license.
requires: [Window, Document, Array, String, Function, Object, Number, Slick.Parser, Slick.Finder]
provides: [Element, Elements, $, $$, Iframe, Selectors]
...
*/
var Element = function(tag, props){
var konstructor = Element.Constructors[tag];
if (konstructor) return konstructor(props);
if (typeof tag != 'string') return document.id(tag).set(props);
if (!props) props = {};
if (!(/^[\w-]+$/).test(tag)){
var parsed = Slick.parse(tag).expressions[0][0];
tag = (parsed.tag == '*') ? 'div' : parsed.tag;
if (parsed.id && props.id == null) props.id = parsed.id;
var attributes = parsed.attributes;
if (attributes) for (var attr, i = 0, l = attributes.length; i < l; i++){
attr = attributes[i];
if (props[attr.key] != null) continue;
if (attr.value != null && attr.operator == '=') props[attr.key] = attr.value;
else if (!attr.value && !attr.operator) props[attr.key] = true;
}
if (parsed.classList && props['class'] == null) props['class'] = parsed.classList.join(' ');
}
return document.newElement(tag, props);
};
if (Browser.Element){
Element.prototype = Browser.Element.prototype;
// IE8 and IE9 require the wrapping.
Element.prototype._fireEvent = (function(fireEvent){
return function(type, event){
return fireEvent.call(this, type, event);
};
})(Element.prototype.fireEvent);
}
new Type('Element', Element).mirror(function(name){
if (Array.prototype[name]) return;
var obj = {};
obj[name] = function(){
var results = [], args = arguments, elements = true;
for (var i = 0, l = this.length; i < l; i++){
var element = this[i], result = results[i] = element[name].apply(element, args);
elements = (elements && typeOf(result) == 'element');
}
return (elements) ? new Elements(results) : results;
};
Elements.implement(obj);
});
if (!Browser.Element){
Element.parent = Object;
Element.Prototype = {
'$constructor': Element,
'$family': Function.from('element').hide()
};
Element.mirror(function(name, method){
Element.Prototype[name] = method;
});
}
Element.Constructors = {};
var IFrame = new Type('IFrame', function(){
var params = Array.link(arguments, {
properties: Type.isObject,
iframe: function(obj){
return (obj != null);
}
});
var props = params.properties || {}, iframe;
if (params.iframe) iframe = document.id(params.iframe);
var onload = props.onload || function(){};
delete props.onload;
props.id = props.name = [props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + String.uniqueID()].pick();
iframe = new Element(iframe || 'iframe', props);
var onLoad = function(){
onload.call(iframe.contentWindow);
};
if (window.frames[props.id]) onLoad();
else iframe.addListener('load', onLoad);
return iframe;
});
var Elements = this.Elements = function(nodes){
if (nodes && nodes.length){
var uniques = {}, node;
for (var i = 0; node = nodes[i++];){
var uid = Slick.uidOf(node);
if (!uniques[uid]){
uniques[uid] = true;
this.push(node);
}
}
}
};
Elements.prototype = {length: 0};
Elements.parent = Array;
new Type('Elements', Elements).implement({
filter: function(filter, bind){
if (!filter) return this;
return new Elements(Array.filter(this, (typeOf(filter) == 'string') ? function(item){
return item.match(filter);
} : filter, bind));
}.protect(),
push: function(){
var length = this.length;
for (var i = 0, l = arguments.length; i < l; i++){
var item = document.id(arguments[i]);
if (item) this[length++] = item;
}
return (this.length = length);
}.protect(),
unshift: function(){
var items = [];
for (var i = 0, l = arguments.length; i < l; i++){
var item = document.id(arguments[i]);
if (item) items.push(item);
}
return Array.prototype.unshift.apply(this, items);
}.protect(),
concat: function(){
var newElements = new Elements(this);
for (var i = 0, l = arguments.length; i < l; i++){
var item = arguments[i];
if (Type.isEnumerable(item)) newElements.append(item);
else newElements.push(item);
}
return newElements;
}.protect(),
append: function(collection){
for (var i = 0, l = collection.length; i < l; i++) this.push(collection[i]);
return this;
}.protect(),
empty: function(){
while (this.length) delete this[--this.length];
return this;
}.protect()
});
(function(){
// FF, IE
var splice = Array.prototype.splice, object = {'0': 0, '1': 1, length: 2};
splice.call(object, 1, 1);
if (object[1] == 1) Elements.implement('splice', function(){
var length = this.length;
var result = splice.apply(this, arguments);
while (length >= this.length) delete this[length--];
return result;
}.protect());
Array.forEachMethod(function(method, name){
Elements.implement(name, method);
});
Array.mirror(Elements);
/*<ltIE8>*/
var createElementAcceptsHTML;
try {
createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');
} catch (e){}
var escapeQuotes = function(html){
return ('' + html).replace(/&/g, '&').replace(/"/g, '"');
};
/*</ltIE8>*/
Document.implement({
newElement: function(tag, props){
if (props && props.checked != null) props.defaultChecked = props.checked;
/*<ltIE8>*/// Fix for readonly name and type properties in IE < 8
if (createElementAcceptsHTML && props){
tag = '<' + tag;
if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"';
if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"';
tag += '>';
delete props.name;
delete props.type;
}
/*</ltIE8>*/
return this.id(this.createElement(tag)).set(props);
}
});
})();
(function(){
Slick.uidOf(window);
Slick.uidOf(document);
Document.implement({
newTextNode: function(text){
return this.createTextNode(text);
},
getDocument: function(){
return this;
},
getWindow: function(){
return this.window;
},
id: (function(){
var types = {
string: function(id, nocash, doc){
id = Slick.find(doc, '#' + id.replace(/(\W)/g, '\\$1'));
return (id) ? types.element(id, nocash) : null;
},
element: function(el, nocash){
Slick.uidOf(el);
if (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagName)){
var fireEvent = el.fireEvent;
// wrapping needed in IE7, or else crash
el._fireEvent = function(type, event){
return fireEvent(type, event);
};
Object.append(el, Element.Prototype);
}
return el;
},
object: function(obj, nocash, doc){
if (obj.toElement) return types.element(obj.toElement(doc), nocash);
return null;
}
};
types.textnode = types.whitespace = types.window = types.document = function(zero){
return zero;
};
return function(el, nocash, doc){
if (el && el.$family && el.uniqueNumber) return el;
var type = typeOf(el);
return (types[type]) ? types[type](el, nocash, doc || document) : null;
};
})()
});
if (window.$ == null) Window.implement('$', function(el, nc){
return document.id(el, nc, this.document);
});
Window.implement({
getDocument: function(){
return this.document;
},
getWindow: function(){
return this;
}
});
[Document, Element].invoke('implement', {
getElements: function(expression){
return Slick.search(this, expression, new Elements);
},
getElement: function(expression){
return document.id(Slick.find(this, expression));
}
});
var contains = {contains: function(element){
return Slick.contains(this, element);
}};
if (!document.contains) Document.implement(contains);
if (!document.createElement('div').contains) Element.implement(contains);
// tree walking
var injectCombinator = function(expression, combinator){
if (!expression) return combinator;
expression = Object.clone(Slick.parse(expression));
var expressions = expression.expressions;
for (var i = expressions.length; i--;)
expressions[i][0].combinator = combinator;
return expression;
};
Object.forEach({
getNext: '~',
getPrevious: '!~',
getParent: '!'
}, function(combinator, method){
Element.implement(method, function(expression){
return this.getElement(injectCombinator(expression, combinator));
});
});
Object.forEach({
getAllNext: '~',
getAllPrevious: '!~',
getSiblings: '~~',
getChildren: '>',
getParents: '!'
}, function(combinator, method){
Element.implement(method, function(expression){
return this.getElements(injectCombinator(expression, combinator));
});
});
Element.implement({
getFirst: function(expression){
return document.id(Slick.search(this, injectCombinator(expression, '>'))[0]);
},
getLast: function(expression){
return document.id(Slick.search(this, injectCombinator(expression, '>')).getLast());
},
getWindow: function(){
return this.ownerDocument.window;
},
getDocument: function(){
return this.ownerDocument;
},
getElementById: function(id){
return document.id(Slick.find(this, '#' + ('' + id).replace(/(\W)/g, '\\$1')));
},
match: function(expression){
return !expression || Slick.match(this, expression);
}
});
if (window.$$ == null) Window.implement('$$', function(selector){
if (arguments.length == 1){
if (typeof selector == 'string') return Slick.search(this.document, selector, new Elements);
else if (Type.isEnumerable(selector)) return new Elements(selector);
}
return new Elements(arguments);
});
// Inserters
var inserters = {
before: function(context, element){
var parent = element.parentNode;
if (parent) parent.insertBefore(context, element);
},
after: function(context, element){
var parent = element.parentNode;
if (parent) parent.insertBefore(context, element.nextSibling);
},
bottom: function(context, element){
element.appendChild(context);
},
top: function(context, element){
element.insertBefore(context, element.firstChild);
}
};
inserters.inside = inserters.bottom;
// getProperty / setProperty
var propertyGetters = {}, propertySetters = {};
// properties
var properties = {};
Array.forEach([
'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
'frameBorder', 'rowSpan', 'tabIndex', 'useMap'
], function(property){
properties[property.toLowerCase()] = property;
});
properties.html = 'innerHTML';
properties.text = (document.createElement('div').textContent == null) ? 'innerText': 'textContent';
Object.forEach(properties, function(real, key){
propertySetters[key] = function(node, value){
node[real] = value;
};
propertyGetters[key] = function(node){
return node[real];
};
});
// Booleans
var bools = [
'compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked',
'disabled', 'readOnly', 'multiple', 'selected', 'noresize',
'defer', 'defaultChecked', 'autofocus', 'controls', 'autoplay',
'loop'
];
var booleans = {};
Array.forEach(bools, function(bool){
var lower = bool.toLowerCase();
booleans[lower] = bool;
propertySetters[lower] = function(node, value){
node[bool] = !!value;
};
propertyGetters[lower] = function(node){
return !!node[bool];
};
});
// Special cases
Object.append(propertySetters, {
'class': function(node, value){
('className' in node) ? node.className = (value || '') : node.setAttribute('class', value);
},
'for': function(node, value){
('htmlFor' in node) ? node.htmlFor = value : node.setAttribute('for', value);
},
'style': function(node, value){
(node.style) ? node.style.cssText = value : node.setAttribute('style', value);
},
'value': function(node, value){
node.value = (value != null) ? value : '';
}
});
propertyGetters['class'] = function(node){
return ('className' in node) ? node.className || null : node.getAttribute('class');
};
/* <webkit> */
var el = document.createElement('button');
// IE sets type as readonly and throws
try { el.type = 'button'; } catch(e){}
if (el.type != 'button') propertySetters.type = function(node, value){
node.setAttribute('type', value);
};
el = null;
/* </webkit> */
/*<IE>*/
var input = document.createElement('input');
input.value = 't';
input.type = 'submit';
if (input.value != 't') propertySetters.type = function(node, type){
var value = node.value;
node.type = type;
node.value = value;
};
input = null;
/*</IE>*/
/* getProperty, setProperty */
/* <ltIE9> */
var pollutesGetAttribute = (function(div){
div.random = 'attribute';
return (div.getAttribute('random') == 'attribute');
})(document.createElement('div'));
/* <ltIE9> */
Element.implement({
setProperty: function(name, value){
var setter = propertySetters[name.toLowerCase()];
if (setter){
setter(this, value);
} else {
/* <ltIE9> */
if (pollutesGetAttribute) var attributeWhiteList = this.retrieve('$attributeWhiteList', {});
/* </ltIE9> */
if (value == null){
this.removeAttribute(name);
/* <ltIE9> */
if (pollutesGetAttribute) delete attributeWhiteList[name];
/* </ltIE9> */
} else {
this.setAttribute(name, '' + value);
/* <ltIE9> */
if (pollutesGetAttribute) attributeWhiteList[name] = true;
/* </ltIE9> */
}
}
return this;
},
setProperties: function(attributes){
for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);
return this;
},
getProperty: function(name){
var getter = propertyGetters[name.toLowerCase()];
if (getter) return getter(this);
/* <ltIE9> */
if (pollutesGetAttribute){
var attr = this.getAttributeNode(name), attributeWhiteList = this.retrieve('$attributeWhiteList', {});
if (!attr) return null;
if (attr.expando && !attributeWhiteList[name]){
var outer = this.outerHTML;
// segment by the opening tag and find mention of attribute name
if (outer.substr(0, outer.search(/\/?['"]?>(?![^<]*<['"])/)).indexOf(name) < 0) return null;
attributeWhiteList[name] = true;
}
}
/* </ltIE9> */
var result = Slick.getAttribute(this, name);
return (!result && !Slick.hasAttribute(this, name)) ? null : result;
},
getProperties: function(){
var args = Array.from(arguments);
return args.map(this.getProperty, this).associate(args);
},
removeProperty: function(name){
return this.setProperty(name, null);
},
removeProperties: function(){
Array.each(arguments, this.removeProperty, this);
return this;
},
set: function(prop, value){
var property = Element.Properties[prop];
(property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value);
}.overloadSetter(),
get: function(prop){
var property = Element.Properties[prop];
return (property && property.get) ? property.get.apply(this) : this.getProperty(prop);
}.overloadGetter(),
erase: function(prop){
var property = Element.Properties[prop];
(property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
return this;
},
hasClass: function(className){
return this.className.clean().contains(className, ' ');
},
addClass: function(className){
if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
return this;
},
removeClass: function(className){
this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
return this;
},
toggleClass: function(className, force){
if (force == null) force = !this.hasClass(className);
return (force) ? this.addClass(className) : this.removeClass(className);
},
adopt: function(){
var parent = this, fragment, elements = Array.flatten(arguments), length = elements.length;
if (length > 1) parent = fragment = document.createDocumentFragment();
for (var i = 0; i < length; i++){
var element = document.id(elements[i], true);
if (element) parent.appendChild(element);
}
if (fragment) this.appendChild(fragment);
return this;
},
appendText: function(text, where){
return this.grab(this.getDocument().newTextNode(text), where);
},
grab: function(el, where){
inserters[where || 'bottom'](document.id(el, true), this);
return this;
},
inject: function(el, where){
inserters[where || 'bottom'](this, document.id(el, true));
return this;
},
replaces: function(el){
el = document.id(el, true);
el.parentNode.replaceChild(this, el);
return this;
},
wraps: function(el, where){
el = document.id(el, true);
return this.replaces(el).grab(el, where);
},
getSelected: function(){
this.selectedIndex; // Safari 3.2.1
return new Elements(Array.from(this.options).filter(function(option){
return option.selected;
}));
},
toQueryString: function(){
var queryString = [];
this.getElements('input, select, textarea').each(function(el){
var type = el.type;
if (!el.name || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return;
var value = (el.get('tag') == 'select') ? el.getSelected().map(function(opt){
// IE
return document.id(opt).get('value');
}) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value');
Array.from(value).each(function(val){
if (typeof val != 'undefined') queryString.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(val));
});
});
return queryString.join('&');
}
});
var collected = {}, storage = {};
var get = function(uid){
return (storage[uid] || (storage[uid] = {}));
};
var clean = function(item){
var uid = item.uniqueNumber;
if (item.removeEvents) item.removeEvents();
if (item.clearAttributes) item.clearAttributes();
if (uid != null){
delete collected[uid];
delete storage[uid];
}
return item;
};
var formProps = {input: 'checked', option: 'selected', textarea: 'value'};
Element.implement({
destroy: function(){
var children = clean(this).getElementsByTagName('*');
Array.each(children, clean);
Element.dispose(this);
return null;
},
empty: function(){
Array.from(this.childNodes).each(Element.dispose);
return this;
},
dispose: function(){
return (this.parentNode) ? this.parentNode.removeChild(this) : this;
},
clone: function(contents, keepid){
contents = contents !== false;
var clone = this.cloneNode(contents), ce = [clone], te = [this], i;
if (contents){
ce.append(Array.from(clone.getElementsByTagName('*')));
te.append(Array.from(this.getElementsByTagName('*')));
}
for (i = ce.length; i--;){
var node = ce[i], element = te[i];
if (!keepid) node.removeAttribute('id');
/*<ltIE9>*/
if (node.clearAttributes){
node.clearAttributes();
node.mergeAttributes(element);
node.removeAttribute('uniqueNumber');
if (node.options){
var no = node.options, eo = element.options;
for (var j = no.length; j--;) no[j].selected = eo[j].selected;
}
}
/*</ltIE9>*/
var prop = formProps[element.tagName.toLowerCase()];
if (prop && element[prop]) node[prop] = element[prop];
}
/*<ltIE9>*/
if (Browser.ie){
var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');
for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;
}
/*</ltIE9>*/
return document.id(clone);
}
});
[Element, Window, Document].invoke('implement', {
addListener: function(type, fn){
if (type == 'unload'){
var old = fn, self = this;
fn = function(){
self.removeListener('unload', fn);
old();
};
} else {
collected[Slick.uidOf(this)] = this;
}
if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);
else this.attachEvent('on' + type, fn);
return this;
},
removeListener: function(type, fn){
if (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]);
else this.detachEvent('on' + type, fn);
return this;
},
retrieve: function(property, dflt){
var storage = get(Slick.uidOf(this)), prop = storage[property];
if (dflt != null && prop == null) prop = storage[property] = dflt;
return prop != null ? prop : null;
},
store: function(property, value){
var storage = get(Slick.uidOf(this));
storage[property] = value;
return this;
},
eliminate: function(property){
var storage = get(Slick.uidOf(this));
delete storage[property];
return this;
}
});
/*<ltIE9>*/
if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){
Object.each(collected, clean);
if (window.CollectGarbage) CollectGarbage();
});
/*</ltIE9>*/
Element.Properties = {};
Element.Properties.style = {
set: function(style){
this.style.cssText = style;
},
get: function(){
return this.style.cssText;
},
erase: function(){
this.style.cssText = '';
}
};
Element.Properties.tag = {
get: function(){
return this.tagName.toLowerCase();
}
};
Element.Properties.html = {
set: function(html){
if (html == null) html = '';
else if (typeOf(html) == 'array') html = html.join('');
this.innerHTML = html;
},
erase: function(){
this.innerHTML = '';
}
};
/*<ltIE9>*/
// technique by jdbarlett - http://jdbartlett.com/innershiv/
var div = document.createElement('div');
div.innerHTML = '<nav></nav>';
var supportsHTML5Elements = (div.childNodes.length == 1);
if (!supportsHTML5Elements){
var tags = 'abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' '),
fragment = document.createDocumentFragment(), l = tags.length;
while (l--) fragment.createElement(tags[l]);
}
div = null;
/*</ltIE9>*/
/*<IE>*/
var supportsTableInnerHTML = Function.attempt(function(){
var table = document.createElement('table');
table.innerHTML = '<tr><td></td></tr>';
return true;
});
/*<ltFF4>*/
var tr = document.createElement('tr'), html = '<td></td>';
tr.innerHTML = html;
var supportsTRInnerHTML = (tr.innerHTML == html);
tr = null;
/*</ltFF4>*/
if (!supportsTableInnerHTML || !supportsTRInnerHTML || !supportsHTML5Elements){
Element.Properties.html.set = (function(set){
var translations = {
table: [1, '<table>', '</table>'],
select: [1, '<select>', '</select>'],
tbody: [2, '<table><tbody>', '</tbody></table>'],
tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']
};
translations.thead = translations.tfoot = translations.tbody;
return function(html){
var wrap = translations[this.get('tag')];
if (!wrap && !supportsHTML5Elements) wrap = [0, '', ''];
if (!wrap) return set.call(this, html);
var level = wrap[0], wrapper = document.createElement('div'), target = wrapper;
if (!supportsHTML5Elements) fragment.appendChild(wrapper);
wrapper.innerHTML = [wrap[1], html, wrap[2]].flatten().join('');
while (level--) target = target.firstChild;
this.empty().adopt(target.childNodes);
if (!supportsHTML5Elements) fragment.removeChild(wrapper);
wrapper = null;
};
})(Element.Properties.html.set);
}
/*</IE>*/
/*<ltIE9>*/
var testForm = document.createElement('form');
testForm.innerHTML = '<select><option>s</option></select>';
if (testForm.firstChild.value != 's') Element.Properties.value = {
set: function(value){
var tag = this.get('tag');
if (tag != 'select') return this.setProperty('value', value);
var options = this.getElements('option');
for (var i = 0; i < options.length; i++){
var option = options[i],
attr = option.getAttributeNode('value'),
optionValue = (attr && attr.specified) ? option.value : option.get('text');
if (optionValue == value) return option.selected = true;
}
},
get: function(){
var option = this, tag = option.get('tag');
if (tag != 'select' && tag != 'option') return this.getProperty('value');
if (tag == 'select' && !(option = option.getSelected()[0])) return '';
var attr = option.getAttributeNode('value');
return (attr && attr.specified) ? option.value : option.get('text');
}
};
testForm = null;
/*</ltIE9>*/
/*<IE>*/
if (document.createElement('div').getAttributeNode('id')) Element.Properties.id = {
set: function(id){
this.id = this.getAttributeNode('id').value = id;
},
get: function(){
return this.id || null;
},
erase: function(){
this.id = this.getAttributeNode('id').value = '';
}
};
/*</IE>*/
})();
/*
---
name: Element.Style
description: Contains methods for interacting with the styles of Elements in a fashionable way.
license: MIT-style license.
requires: Element
provides: Element.Style
...
*/
(function(){
var html = document.html;
//<ltIE9>
// Check for oldIE, which does not remove styles when they're set to null
var el = document.createElement('div');
el.style.color = 'red';
el.style.color = null;
var doesNotRemoveStyles = el.style.color == 'red';
el = null;
//</ltIE9>
Element.Properties.styles = {set: function(styles){
this.setStyles(styles);
}};
var hasOpacity = (html.style.opacity != null),
hasFilter = (html.style.filter != null),
reAlpha = /alpha\(opacity=([\d.]+)\)/i;
var setVisibility = function(element, opacity){
element.store('$opacity', opacity);
element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';
};
var setOpacity = (hasOpacity ? function(element, opacity){
element.style.opacity = opacity;
} : (hasFilter ? function(element, opacity){
var style = element.style;
if (!element.currentStyle || !element.currentStyle.hasLayout) style.zoom = 1;
if (opacity == null || opacity == 1) opacity = '';
else opacity = 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')';
var filter = style.filter || element.getComputedStyle('filter') || '';
style.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity;
if (!style.filter) style.removeAttribute('filter');
} : setVisibility));
var getOpacity = (hasOpacity ? function(element){
var opacity = element.style.opacity || element.getComputedStyle('opacity');
return (opacity == '') ? 1 : opacity.toFloat();
} : (hasFilter ? function(element){
var filter = (element.style.filter || element.getComputedStyle('filter')),
opacity;
if (filter) opacity = filter.match(reAlpha);
return (opacity == null || filter == null) ? 1 : (opacity[1] / 100);
} : function(element){
var opacity = element.retrieve('$opacity');
if (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1);
return opacity;
}));
var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat';
Element.implement({
getComputedStyle: function(property){
if (this.currentStyle) return this.currentStyle[property.camelCase()];
var defaultView = Element.getDocument(this).defaultView,
computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;
},
setStyle: function(property, value){
if (property == 'opacity'){
if (value != null) value = parseFloat(value);
setOpacity(this, value);
return this;
}
property = (property == 'float' ? floatName : property).camelCase();
if (typeOf(value) != 'string'){
var map = (Element.Styles[property] || '@').split(' ');
value = Array.from(value).map(function(val, i){
if (!map[i]) return '';
return (typeOf(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;
}).join(' ');
} else if (value == String(Number(value))){
value = Math.round(value);
}
this.style[property] = value;
//<ltIE9>
if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){
this.style.removeAttribute(property);
}
//</ltIE9>
return this;
},
getStyle: function(property){
if (property == 'opacity') return getOpacity(this);
property = (property == 'float' ? floatName : property).camelCase();
var result = this.style[property];
if (!result || property == 'zIndex'){
result = [];
for (var style in Element.ShortStyles){
if (property != style) continue;
for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));
return result.join(' ');
}
result = this.getComputedStyle(property);
}
if (result){
result = String(result);
var color = result.match(/rgba?\([\d\s,]+\)/);
if (color) result = result.replace(color[0], color[0].rgbToHex());
}
if (Browser.ie && isNaN(parseFloat(result))){
if ((/^(height|width)$/).test(property)){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){
size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
}, this);
return this['offset' + property.capitalize()] - size + 'px';
}
if (Browser.opera && String(result).indexOf('px') != -1) return result;
if ((/^border(.+)Width|margin|padding/).test(property)) return '0px';
}
return result;
},
setStyles: function(styles){
for (var style in styles) this.setStyle(style, styles[style]);
return this;
},
getStyles: function(){
var result = {};
Array.flatten(arguments).each(function(key){
result[key] = this.getStyle(key);
}, this);
return result;
}
});
Element.Styles = {
left: '@px', top: '@px', bottom: '@px', right: '@px',
width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',
fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',
margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',
borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',
zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
};
Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};
['Top', 'Right', 'Bottom', 'Left'].each(function(direction){
var Short = Element.ShortStyles;
var All = Element.Styles;
['margin', 'padding'].each(function(style){
var sd = style + direction;
Short[style][sd] = All[sd] = '@px';
});
var bd = 'border' + direction;
Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';
var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';
Short[bd] = {};
Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';
Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
});
})();
/*
---
name: Element.Event
description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events, if necessary.
license: MIT-style license.
requires: [Element, Event]
provides: Element.Event
...
*/
(function(){
Element.Properties.events = {set: function(events){
this.addEvents(events);
}};
[Element, Window, Document].invoke('implement', {
addEvent: function(type, fn){
var events = this.retrieve('events', {});
if (!events[type]) events[type] = {keys: [], values: []};
if (events[type].keys.contains(fn)) return this;
events[type].keys.push(fn);
var realType = type,
custom = Element.Events[type],
condition = fn,
self = this;
if (custom){
if (custom.onAdd) custom.onAdd.call(this, fn, type);
if (custom.condition){
condition = function(event){
if (custom.condition.call(this, event, type)) return fn.call(this, event);
return true;
};
}
if (custom.base) realType = Function.from(custom.base).call(this, type);
}
var defn = function(){
return fn.call(self);
};
var nativeEvent = Element.NativeEvents[realType];
if (nativeEvent){
if (nativeEvent == 2){
defn = function(event){
event = new DOMEvent(event, self.getWindow());
if (condition.call(self, event) === false) event.stop();
};
}
this.addListener(realType, defn, arguments[2]);
}
events[type].values.push(defn);
return this;
},
removeEvent: function(type, fn){
var events = this.retrieve('events');
if (!events || !events[type]) return this;
var list = events[type];
var index = list.keys.indexOf(fn);
if (index == -1) return this;
var value = list.values[index];
delete list.keys[index];
delete list.values[index];
var custom = Element.Events[type];
if (custom){
if (custom.onRemove) custom.onRemove.call(this, fn, type);
if (custom.base) type = Function.from(custom.base).call(this, type);
}
return (Element.NativeEvents[type]) ? this.removeListener(type, value, arguments[2]) : this;
},
addEvents: function(events){
for (var event in events) this.addEvent(event, events[event]);
return this;
},
removeEvents: function(events){
var type;
if (typeOf(events) == 'object'){
for (type in events) this.removeEvent(type, events[type]);
return this;
}
var attached = this.retrieve('events');
if (!attached) return this;
if (!events){
for (type in attached) this.removeEvents(type);
this.eliminate('events');
} else if (attached[events]){
attached[events].keys.each(function(fn){
this.removeEvent(events, fn);
}, this);
delete attached[events];
}
return this;
},
fireEvent: function(type, args, delay){
var events = this.retrieve('events');
if (!events || !events[type]) return this;
args = Array.from(args);
events[type].keys.each(function(fn){
if (delay) fn.delay(delay, this, args);
else fn.apply(this, args);
}, this);
return this;
},
cloneEvents: function(from, type){
from = document.id(from);
var events = from.retrieve('events');
if (!events) return this;
if (!type){
for (var eventType in events) this.cloneEvents(from, eventType);
} else if (events[type]){
events[type].keys.each(function(fn){
this.addEvent(type, fn);
}, this);
}
return this;
}
});
Element.NativeEvents = {
click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons
mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement
keydown: 2, keypress: 2, keyup: 2, //keyboard
orientationchange: 2, // mobile
touchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch
gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture
focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, paste: 2, input: 2, //form elements
load: 2, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window
error: 1, abort: 1, scroll: 1 //misc
};
Element.Events = {mousewheel: {
base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'
}};
if ('onmouseenter' in document.documentElement){
Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;
} else {
var check = function(event){
var related = event.relatedTarget;
if (related == null) return true;
if (!related) return false;
return (related != this && related.prefix != 'xul' && typeOf(this) != 'document' && !this.contains(related));
};
Element.Events.mouseenter = {
base: 'mouseover',
condition: check
};
Element.Events.mouseleave = {
base: 'mouseout',
condition: check
};
}
/*<ltIE9>*/
if (!window.addEventListener){
Element.NativeEvents.propertychange = 2;
Element.Events.change = {
base: function(){
var type = this.type;
return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change'
},
condition: function(event){
return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);
}
}
}
/*</ltIE9>*/
})();
/*
---
name: Element.Delegation
description: Extends the Element native object to include the delegate method for more efficient event management.
license: MIT-style license.
requires: [Element.Event]
provides: [Element.Delegation]
...
*/
(function(){
var eventListenerSupport = !!window.addEventListener;
Element.NativeEvents.focusin = Element.NativeEvents.focusout = 2;
var bubbleUp = function(self, match, fn, event, target){
while (target && target != self){
if (match(target, event)) return fn.call(target, event, target);
target = document.id(target.parentNode);
}
};
var map = {
mouseenter: {
base: 'mouseover'
},
mouseleave: {
base: 'mouseout'
},
focus: {
base: 'focus' + (eventListenerSupport ? '' : 'in'),
capture: true
},
blur: {
base: eventListenerSupport ? 'blur' : 'focusout',
capture: true
}
};
/*<ltIE9>*/
var _key = '$delegation:';
var formObserver = function(type){
return {
base: 'focusin',
remove: function(self, uid){
var list = self.retrieve(_key + type + 'listeners', {})[uid];
if (list && list.forms) for (var i = list.forms.length; i--;){
list.forms[i].removeEvent(type, list.fns[i]);
}
},
listen: function(self, match, fn, event, target, uid){
var form = (target.get('tag') == 'form') ? target : event.target.getParent('form');
if (!form) return;
var listeners = self.retrieve(_key + type + 'listeners', {}),
listener = listeners[uid] || {forms: [], fns: []},
forms = listener.forms, fns = listener.fns;
if (forms.indexOf(form) != -1) return;
forms.push(form);
var _fn = function(event){
bubbleUp(self, match, fn, event, target);
};
form.addEvent(type, _fn);
fns.push(_fn);
listeners[uid] = listener;
self.store(_key + type + 'listeners', listeners);
}
};
};
var inputObserver = function(type){
return {
base: 'focusin',
listen: function(self, match, fn, event, target){
var events = {blur: function(){
this.removeEvents(events);
}};
events[type] = function(event){
bubbleUp(self, match, fn, event, target);
};
event.target.addEvents(events);
}
};
};
if (!eventListenerSupport) Object.append(map, {
submit: formObserver('submit'),
reset: formObserver('reset'),
change: inputObserver('change'),
select: inputObserver('select')
});
/*</ltIE9>*/
var proto = Element.prototype,
addEvent = proto.addEvent,
removeEvent = proto.removeEvent;
var relay = function(old, method){
return function(type, fn, useCapture){
if (type.indexOf(':relay') == -1) return old.call(this, type, fn, useCapture);
var parsed = Slick.parse(type).expressions[0][0];
if (parsed.pseudos[0].key != 'relay') return old.call(this, type, fn, useCapture);
var newType = parsed.tag;
parsed.pseudos.slice(1).each(function(pseudo){
newType += ':' + pseudo.key + (pseudo.value ? '(' + pseudo.value + ')' : '');
});
old.call(this, type, fn);
return method.call(this, newType, parsed.pseudos[0].value, fn);
};
};
var delegation = {
addEvent: function(type, match, fn){
var storage = this.retrieve('$delegates', {}), stored = storage[type];
if (stored) for (var _uid in stored){
if (stored[_uid].fn == fn && stored[_uid].match == match) return this;
}
var _type = type, _match = match, _fn = fn, _map = map[type] || {};
type = _map.base || _type;
match = function(target){
return Slick.match(target, _match);
};
var elementEvent = Element.Events[_type];
if (elementEvent && elementEvent.condition){
var __match = match, condition = elementEvent.condition;
match = function(target, event){
return __match(target, event) && condition.call(target, event, type);
};
}
var self = this, uid = String.uniqueID();
var delegator = _map.listen ? function(event, target){
if (!target && event && event.target) target = event.target;
if (target) _map.listen(self, match, fn, event, target, uid);
} : function(event, target){
if (!target && event && event.target) target = event.target;
if (target) bubbleUp(self, match, fn, event, target);
};
if (!stored) stored = {};
stored[uid] = {
match: _match,
fn: _fn,
delegator: delegator
};
storage[_type] = stored;
return addEvent.call(this, type, delegator, _map.capture);
},
removeEvent: function(type, match, fn, _uid){
var storage = this.retrieve('$delegates', {}), stored = storage[type];
if (!stored) return this;
if (_uid){
var _type = type, delegator = stored[_uid].delegator, _map = map[type] || {};
type = _map.base || _type;
if (_map.remove) _map.remove(this, _uid);
delete stored[_uid];
storage[_type] = stored;
return removeEvent.call(this, type, delegator);
}
var __uid, s;
if (fn) for (__uid in stored){
s = stored[__uid];
if (s.match == match && s.fn == fn) return delegation.removeEvent.call(this, type, match, fn, __uid);
} else for (__uid in stored){
s = stored[__uid];
if (s.match == match) delegation.removeEvent.call(this, type, match, s.fn, __uid);
}
return this;
}
};
[Element, Window, Document].invoke('implement', {
addEvent: relay(addEvent, delegation.addEvent),
removeEvent: relay(removeEvent, delegation.removeEvent)
});
})();
/*
---
name: Element.Dimensions
description: Contains methods to work with size, scroll, or positioning of Elements and the window object.
license: MIT-style license.
credits:
- Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html).
- Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html).
requires: [Element, Element.Style]
provides: [Element.Dimensions]
...
*/
(function(){
var element = document.createElement('div'),
child = document.createElement('div');
element.style.height = '0';
element.appendChild(child);
var brokenOffsetParent = (child.offsetParent === element);
element = child = null;
var isOffset = function(el){
return styleString(el, 'position') != 'static' || isBody(el);
};
var isOffsetStatic = function(el){
return isOffset(el) || (/^(?:table|td|th)$/i).test(el.tagName);
};
Element.implement({
scrollTo: function(x, y){
if (isBody(this)){
this.getWindow().scrollTo(x, y);
} else {
this.scrollLeft = x;
this.scrollTop = y;
}
return this;
},
getSize: function(){
if (isBody(this)) return this.getWindow().getSize();
return {x: this.offsetWidth, y: this.offsetHeight};
},
getScrollSize: function(){
if (isBody(this)) return this.getWindow().getScrollSize();
return {x: this.scrollWidth, y: this.scrollHeight};
},
getScroll: function(){
if (isBody(this)) return this.getWindow().getScroll();
return {x: this.scrollLeft, y: this.scrollTop};
},
getScrolls: function(){
var element = this.parentNode, position = {x: 0, y: 0};
while (element && !isBody(element)){
position.x += element.scrollLeft;
position.y += element.scrollTop;
element = element.parentNode;
}
return position;
},
getOffsetParent: brokenOffsetParent ? function(){
var element = this;
if (isBody(element) || styleString(element, 'position') == 'fixed') return null;
var isOffsetCheck = (styleString(element, 'position') == 'static') ? isOffsetStatic : isOffset;
while ((element = element.parentNode)){
if (isOffsetCheck(element)) return element;
}
return null;
} : function(){
var element = this;
if (isBody(element) || styleString(element, 'position') == 'fixed') return null;
try {
return element.offsetParent;
} catch(e) {}
return null;
},
getOffsets: function(){
if (this.getBoundingClientRect && !Browser.Platform.ios){
var bound = this.getBoundingClientRect(),
html = document.id(this.getDocument().documentElement),
htmlScroll = html.getScroll(),
elemScrolls = this.getScrolls(),
isFixed = (styleString(this, 'position') == 'fixed');
return {
x: bound.left.toInt() + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
y: bound.top.toInt() + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
};
}
var element = this, position = {x: 0, y: 0};
if (isBody(this)) return position;
while (element && !isBody(element)){
position.x += element.offsetLeft;
position.y += element.offsetTop;
if (Browser.firefox){
if (!borderBox(element)){
position.x += leftBorder(element);
position.y += topBorder(element);
}
var parent = element.parentNode;
if (parent && styleString(parent, 'overflow') != 'visible'){
position.x += leftBorder(parent);
position.y += topBorder(parent);
}
} else if (element != this && Browser.safari){
position.x += leftBorder(element);
position.y += topBorder(element);
}
element = element.offsetParent;
}
if (Browser.firefox && !borderBox(this)){
position.x -= leftBorder(this);
position.y -= topBorder(this);
}
return position;
},
getPosition: function(relative){
var offset = this.getOffsets(),
scroll = this.getScrolls();
var position = {
x: offset.x - scroll.x,
y: offset.y - scroll.y
};
if (relative && (relative = document.id(relative))){
var relativePosition = relative.getPosition();
return {x: position.x - relativePosition.x - leftBorder(relative), y: position.y - relativePosition.y - topBorder(relative)};
}
return position;
},
getCoordinates: function(element){
if (isBody(this)) return this.getWindow().getCoordinates();
var position = this.getPosition(element),
size = this.getSize();
var obj = {
left: position.x,
top: position.y,
width: size.x,
height: size.y
};
obj.right = obj.left + obj.width;
obj.bottom = obj.top + obj.height;
return obj;
},
computePosition: function(obj){
return {
left: obj.x - styleNumber(this, 'margin-left'),
top: obj.y - styleNumber(this, 'margin-top')
};
},
setPosition: function(obj){
return this.setStyles(this.computePosition(obj));
}
});
[Document, Window].invoke('implement', {
getSize: function(){
var doc = getCompatElement(this);
return {x: doc.clientWidth, y: doc.clientHeight};
},
getScroll: function(){
var win = this.getWindow(), doc = getCompatElement(this);
return {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop};
},
getScrollSize: function(){
var doc = getCompatElement(this),
min = this.getSize(),
body = this.getDocument().body;
return {x: Math.max(doc.scrollWidth, body.scrollWidth, min.x), y: Math.max(doc.scrollHeight, body.scrollHeight, min.y)};
},
getPosition: function(){
return {x: 0, y: 0};
},
getCoordinates: function(){
var size = this.getSize();
return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x};
}
});
// private methods
var styleString = Element.getComputedStyle;
function styleNumber(element, style){
return styleString(element, style).toInt() || 0;
}
function borderBox(element){
return styleString(element, '-moz-box-sizing') == 'border-box';
}
function topBorder(element){
return styleNumber(element, 'border-top-width');
}
function leftBorder(element){
return styleNumber(element, 'border-left-width');
}
function isBody(element){
return (/^(?:body|html)$/i).test(element.tagName);
}
function getCompatElement(element){
var doc = element.getDocument();
return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
}
})();
//aliases
Element.alias({position: 'setPosition'}); //compatability
[Window, Document, Element].invoke('implement', {
getHeight: function(){
return this.getSize().y;
},
getWidth: function(){
return this.getSize().x;
},
getScrollTop: function(){
return this.getScroll().y;
},
getScrollLeft: function(){
return this.getScroll().x;
},
getScrollHeight: function(){
return this.getScrollSize().y;
},
getScrollWidth: function(){
return this.getScrollSize().x;
},
getTop: function(){
return this.getPosition().y;
},
getLeft: function(){
return this.getPosition().x;
}
});
/*
---
name: Fx
description: Contains the basic animation logic to be extended by all other Fx Classes.
license: MIT-style license.
requires: [Chain, Events, Options]
provides: Fx
...
*/
(function(){
var Fx = this.Fx = new Class({
Implements: [Chain, Events, Options],
options: {
/*
onStart: nil,
onCancel: nil,
onComplete: nil,
*/
fps: 60,
unit: false,
duration: 500,
frames: null,
frameSkip: true,
link: 'ignore'
},
initialize: function(options){
this.subject = this.subject || this;
this.setOptions(options);
},
getTransition: function(){
return function(p){
return -(Math.cos(Math.PI * p) - 1) / 2;
};
},
step: function(now){
if (this.options.frameSkip){
var diff = (this.time != null) ? (now - this.time) : 0, frames = diff / this.frameInterval;
this.time = now;
this.frame += frames;
} else {
this.frame++;
}
if (this.frame < this.frames){
var delta = this.transition(this.frame / this.frames);
this.set(this.compute(this.from, this.to, delta));
} else {
this.frame = this.frames;
this.set(this.compute(this.from, this.to, 1));
this.stop();
}
},
set: function(now){
return now;
},
compute: function(from, to, delta){
return Fx.compute(from, to, delta);
},
check: function(){
if (!this.isRunning()) return true;
switch (this.options.link){
case 'cancel': this.cancel(); return true;
case 'chain': this.chain(this.caller.pass(arguments, this)); return false;
}
return false;
},
start: function(from, to){
if (!this.check(from, to)) return this;
this.from = from;
this.to = to;
this.frame = (this.options.frameSkip) ? 0 : -1;
this.time = null;
this.transition = this.getTransition();
var frames = this.options.frames, fps = this.options.fps, duration = this.options.duration;
this.duration = Fx.Durations[duration] || duration.toInt();
this.frameInterval = 1000 / fps;
this.frames = frames || Math.round(this.duration / this.frameInterval);
this.fireEvent('start', this.subject);
pushInstance.call(this, fps);
return this;
},
stop: function(){
if (this.isRunning()){
this.time = null;
pullInstance.call(this, this.options.fps);
if (this.frames == this.frame){
this.fireEvent('complete', this.subject);
if (!this.callChain()) this.fireEvent('chainComplete', this.subject);
} else {
this.fireEvent('stop', this.subject);
}
}
return this;
},
cancel: function(){
if (this.isRunning()){
this.time = null;
pullInstance.call(this, this.options.fps);
this.frame = this.frames;
this.fireEvent('cancel', this.subject).clearChain();
}
return this;
},
pause: function(){
if (this.isRunning()){
this.time = null;
pullInstance.call(this, this.options.fps);
}
return this;
},
resume: function(){
if ((this.frame < this.frames) && !this.isRunning()) pushInstance.call(this, this.options.fps);
return this;
},
isRunning: function(){
var list = instances[this.options.fps];
return list && list.contains(this);
}
});
Fx.compute = function(from, to, delta){
return (to - from) * delta + from;
};
Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000};
// global timers
var instances = {}, timers = {};
var loop = function(){
var now = Date.now();
for (var i = this.length; i--;){
var instance = this[i];
if (instance) instance.step(now);
}
};
var pushInstance = function(fps){
var list = instances[fps] || (instances[fps] = []);
list.push(this);
if (!timers[fps]) timers[fps] = loop.periodical(Math.round(1000 / fps), list);
};
var pullInstance = function(fps){
var list = instances[fps];
if (list){
list.erase(this);
if (!list.length && timers[fps]){
delete instances[fps];
timers[fps] = clearInterval(timers[fps]);
}
}
};
})();
/*
---
name: Fx.CSS
description: Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements.
license: MIT-style license.
requires: [Fx, Element.Style]
provides: Fx.CSS
...
*/
Fx.CSS = new Class({
Extends: Fx,
//prepares the base from/to object
prepare: function(element, property, values){
values = Array.from(values);
var from = values[0], to = values[1];
if (to == null){
to = from;
from = element.getStyle(property);
var unit = this.options.unit;
// adapted from: https://github.com/ryanmorr/fx/blob/master/fx.js#L299
if (unit && from.slice(-unit.length) != unit && parseFloat(from) != 0){
element.setStyle(property, to + unit);
var value = element.getComputedStyle(property);
// IE and Opera support pixelLeft or pixelWidth
if (!(/px$/.test(value))){
value = element.style[('pixel-' + property).camelCase()];
if (value == null){
// adapted from Dean Edwards' http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
var left = element.style.left;
element.style.left = to + unit;
value = element.style.pixelLeft;
element.style.left = left;
}
}
from = (to || 1) / (parseFloat(value) || 1) * (parseFloat(from) || 0);
element.setStyle(property, from + unit);
}
}
return {from: this.parse(from), to: this.parse(to)};
},
//parses a value into an array
parse: function(value){
value = Function.from(value)();
value = (typeof value == 'string') ? value.split(' ') : Array.from(value);
return value.map(function(val){
val = String(val);
var found = false;
Object.each(Fx.CSS.Parsers, function(parser, key){
if (found) return;
var parsed = parser.parse(val);
if (parsed || parsed === 0) found = {value: parsed, parser: parser};
});
found = found || {value: val, parser: Fx.CSS.Parsers.String};
return found;
});
},
//computes by a from and to prepared objects, using their parsers.
compute: function(from, to, delta){
var computed = [];
(Math.min(from.length, to.length)).times(function(i){
computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});
});
computed.$family = Function.from('fx:css:value');
return computed;
},
//serves the value as settable
serve: function(value, unit){
if (typeOf(value) != 'fx:css:value') value = this.parse(value);
var returned = [];
value.each(function(bit){
returned = returned.concat(bit.parser.serve(bit.value, unit));
});
return returned;
},
//renders the change to an element
render: function(element, property, value, unit){
element.setStyle(property, this.serve(value, unit));
},
//searches inside the page css to find the values for a selector
search: function(selector){
if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];
var to = {}, selectorTest = new RegExp('^' + selector.escapeRegExp() + '$');
Array.each(document.styleSheets, function(sheet, j){
var href = sheet.href;
if (href && href.contains('://') && !href.contains(document.domain)) return;
var rules = sheet.rules || sheet.cssRules;
Array.each(rules, function(rule, i){
if (!rule.style) return;
var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){
return m.toLowerCase();
}) : null;
if (!selectorText || !selectorTest.test(selectorText)) return;
Object.each(Element.Styles, function(value, style){
if (!rule.style[style] || Element.ShortStyles[style]) return;
value = String(rule.style[style]);
to[style] = ((/^rgb/).test(value)) ? value.rgbToHex() : value;
});
});
});
return Fx.CSS.Cache[selector] = to;
}
});
Fx.CSS.Cache = {};
Fx.CSS.Parsers = {
Color: {
parse: function(value){
if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true);
return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false;
},
compute: function(from, to, delta){
return from.map(function(value, i){
return Math.round(Fx.compute(from[i], to[i], delta));
});
},
serve: function(value){
return value.map(Number);
}
},
Number: {
parse: parseFloat,
compute: Fx.compute,
serve: function(value, unit){
return (unit) ? value + unit : value;
}
},
String: {
parse: Function.from(false),
compute: function(zero, one){
return one;
},
serve: function(zero){
return zero;
}
}
};
/*
---
name: Fx.Tween
description: Formerly Fx.Style, effect to transition any CSS property for an element.
license: MIT-style license.
requires: Fx.CSS
provides: [Fx.Tween, Element.fade, Element.highlight]
...
*/
Fx.Tween = new Class({
Extends: Fx.CSS,
initialize: function(element, options){
this.element = this.subject = document.id(element);
this.parent(options);
},
set: function(property, now){
if (arguments.length == 1){
now = property;
property = this.property || this.options.property;
}
this.render(this.element, property, now, this.options.unit);
return this;
},
start: function(property, from, to){
if (!this.check(property, from, to)) return this;
var args = Array.flatten(arguments);
this.property = this.options.property || args.shift();
var parsed = this.prepare(this.element, this.property, args);
return this.parent(parsed.from, parsed.to);
}
});
Element.Properties.tween = {
set: function(options){
this.get('tween').cancel().setOptions(options);
return this;
},
get: function(){
var tween = this.retrieve('tween');
if (!tween){
tween = new Fx.Tween(this, {link: 'cancel'});
this.store('tween', tween);
}
return tween;
}
};
Element.implement({
tween: function(property, from, to){
this.get('tween').start(property, from, to);
return this;
},
fade: function(how){
var fade = this.get('tween'), method, args = ['opacity'].append(arguments), toggle;
if (args[1] == null) args[1] = 'toggle';
switch (args[1]){
case 'in': method = 'start'; args[1] = 1; break;
case 'out': method = 'start'; args[1] = 0; break;
case 'show': method = 'set'; args[1] = 1; break;
case 'hide': method = 'set'; args[1] = 0; break;
case 'toggle':
var flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);
method = 'start';
args[1] = flag ? 0 : 1;
this.store('fade:flag', !flag);
toggle = true;
break;
default: method = 'start';
}
if (!toggle) this.eliminate('fade:flag');
fade[method].apply(fade, args);
var to = args[args.length - 1];
if (method == 'set' || to != 0) this.setStyle('visibility', to == 0 ? 'hidden' : 'visible');
else fade.chain(function(){
this.element.setStyle('visibility', 'hidden');
this.callChain();
});
return this;
},
highlight: function(start, end){
if (!end){
end = this.retrieve('highlight:original', this.getStyle('background-color'));
end = (end == 'transparent') ? '#fff' : end;
}
var tween = this.get('tween');
tween.start('background-color', start || '#ffff88', end).chain(function(){
this.setStyle('background-color', this.retrieve('highlight:original'));
tween.callChain();
}.bind(this));
return this;
}
});
/*
---
name: Fx.Morph
description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.
license: MIT-style license.
requires: Fx.CSS
provides: Fx.Morph
...
*/
Fx.Morph = new Class({
Extends: Fx.CSS,
initialize: function(element, options){
this.element = this.subject = document.id(element);
this.parent(options);
},
set: function(now){
if (typeof now == 'string') now = this.search(now);
for (var p in now) this.render(this.element, p, now[p], this.options.unit);
return this;
},
compute: function(from, to, delta){
var now = {};
for (var p in from) now[p] = this.parent(from[p], to[p], delta);
return now;
},
start: function(properties){
if (!this.check(properties)) return this;
if (typeof properties == 'string') properties = this.search(properties);
var from = {}, to = {};
for (var p in properties){
var parsed = this.prepare(this.element, p, properties[p]);
from[p] = parsed.from;
to[p] = parsed.to;
}
return this.parent(from, to);
}
});
Element.Properties.morph = {
set: function(options){
this.get('morph').cancel().setOptions(options);
return this;
},
get: function(){
var morph = this.retrieve('morph');
if (!morph){
morph = new Fx.Morph(this, {link: 'cancel'});
this.store('morph', morph);
}
return morph;
}
};
Element.implement({
morph: function(props){
this.get('morph').start(props);
return this;
}
});
/*
---
name: Fx.Transitions
description: Contains a set of advanced transitions to be used with any of the Fx Classes.
license: MIT-style license.
credits:
- Easing Equations by Robert Penner, <http://www.robertpenner.com/easing/>, modified and optimized to be used with MooTools.
requires: Fx
provides: Fx.Transitions
...
*/
Fx.implement({
getTransition: function(){
var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
if (typeof trans == 'string'){
var data = trans.split(':');
trans = Fx.Transitions;
trans = trans[data[0]] || trans[data[0].capitalize()];
if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
}
return trans;
}
});
Fx.Transition = function(transition, params){
params = Array.from(params);
var easeIn = function(pos){
return transition(pos, params);
};
return Object.append(easeIn, {
easeIn: easeIn,
easeOut: function(pos){
return 1 - transition(1 - pos, params);
},
easeInOut: function(pos){
return (pos <= 0.5 ? transition(2 * pos, params) : (2 - transition(2 * (1 - pos), params))) / 2;
}
});
};
Fx.Transitions = {
linear: function(zero){
return zero;
}
};
Fx.Transitions.extend = function(transitions){
for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
};
Fx.Transitions.extend({
Pow: function(p, x){
return Math.pow(p, x && x[0] || 6);
},
Expo: function(p){
return Math.pow(2, 8 * (p - 1));
},
Circ: function(p){
return 1 - Math.sin(Math.acos(p));
},
Sine: function(p){
return 1 - Math.cos(p * Math.PI / 2);
},
Back: function(p, x){
x = x && x[0] || 1.618;
return Math.pow(p, 2) * ((x + 1) * p - x);
},
Bounce: function(p){
var value;
for (var a = 0, b = 1; 1; a += b, b /= 2){
if (p >= (7 - 4 * a) / 11){
value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
break;
}
}
return value;
},
Elastic: function(p, x){
return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x && x[0] || 1) / 3);
}
});
['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){
Fx.Transitions[transition] = new Fx.Transition(function(p){
return Math.pow(p, i + 2);
});
});
/*
---
name: Request
description: Powerful all purpose Request Class. Uses XMLHTTPRequest.
license: MIT-style license.
requires: [Object, Element, Chain, Events, Options, Browser]
provides: Request
...
*/
(function(){
var empty = function(){},
progressSupport = ('onprogress' in new Browser.Request);
var Request = this.Request = new Class({
Implements: [Chain, Events, Options],
options: {/*
onRequest: function(){},
onLoadstart: function(event, xhr){},
onProgress: function(event, xhr){},
onComplete: function(){},
onCancel: function(){},
onSuccess: function(responseText, responseXML){},
onFailure: function(xhr){},
onException: function(headerName, value){},
onTimeout: function(){},
user: '',
password: '',*/
url: '',
data: '',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
},
async: true,
format: false,
method: 'post',
link: 'ignore',
isSuccess: null,
emulation: true,
urlEncoded: true,
encoding: 'utf-8',
evalScripts: false,
evalResponse: false,
timeout: 0,
noCache: false
},
initialize: function(options){
this.xhr = new Browser.Request();
this.setOptions(options);
this.headers = this.options.headers;
},
onStateChange: function(){
var xhr = this.xhr;
if (xhr.readyState != 4 || !this.running) return;
this.running = false;
this.status = 0;
Function.attempt(function(){
var status = xhr.status;
this.status = (status == 1223) ? 204 : status;
}.bind(this));
xhr.onreadystatechange = empty;
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
clearTimeout(this.timer);
this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML};
if (this.options.isSuccess.call(this, this.status))
this.success(this.response.text, this.response.xml);
else
this.failure();
},
isSuccess: function(){
var status = this.status;
return (status >= 200 && status < 300);
},
isRunning: function(){
return !!this.running;
},
processScripts: function(text){
if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return Browser.exec(text);
return text.stripScripts(this.options.evalScripts);
},
success: function(text, xml){
this.onSuccess(this.processScripts(text), xml);
},
onSuccess: function(){
this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain();
},
failure: function(){
this.onFailure();
},
onFailure: function(){
this.fireEvent('complete').fireEvent('failure', this.xhr);
},
loadstart: function(event){
this.fireEvent('loadstart', [event, this.xhr]);
},
progress: function(event){
this.fireEvent('progress', [event, this.xhr]);
},
timeout: function(){
this.fireEvent('timeout', this.xhr);
},
setHeader: function(name, value){
this.headers[name] = value;
return this;
},
getHeader: function(name){
return Function.attempt(function(){
return this.xhr.getResponseHeader(name);
}.bind(this));
},
check: function(){
if (!this.running) return true;
switch (this.options.link){
case 'cancel': this.cancel(); return true;
case 'chain': this.chain(this.caller.pass(arguments, this)); return false;
}
return false;
},
send: function(options){
if (!this.check(options)) return this;
this.options.isSuccess = this.options.isSuccess || this.isSuccess;
this.running = true;
var type = typeOf(options);
if (type == 'string' || type == 'element') options = {data: options};
var old = this.options;
options = Object.append({data: old.data, url: old.url, method: old.method}, options);
var data = options.data, url = String(options.url), method = options.method.toLowerCase();
switch (typeOf(data)){
case 'element': data = document.id(data).toQueryString(); break;
case 'object': case 'hash': data = Object.toQueryString(data);
}
if (this.options.format){
var format = 'format=' + this.options.format;
data = (data) ? format + '&' + data : format;
}
if (this.options.emulation && !['get', 'post'].contains(method)){
var _method = '_method=' + method;
data = (data) ? _method + '&' + data : _method;
method = 'post';
}
if (this.options.urlEncoded && ['post', 'put'].contains(method)){
var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
this.headers['Content-type'] = 'application/x-www-form-urlencoded' + encoding;
}
if (!url) url = document.location.pathname;
var trimPosition = url.lastIndexOf('/');
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
if (this.options.noCache)
url += (url.contains('?') ? '&' : '?') + String.uniqueID();
if (data && method == 'get'){
url += (url.contains('?') ? '&' : '?') + data;
data = null;
}
var xhr = this.xhr;
if (progressSupport){
xhr.onloadstart = this.loadstart.bind(this);
xhr.onprogress = this.progress.bind(this);
}
xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password);
if (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true;
xhr.onreadystatechange = this.onStateChange.bind(this);
Object.each(this.headers, function(value, key){
try {
xhr.setRequestHeader(key, value);
} catch (e){
this.fireEvent('exception', [key, value]);
}
}, this);
this.fireEvent('request');
xhr.send(data);
if (!this.options.async) this.onStateChange();
else if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
return this;
},
cancel: function(){
if (!this.running) return this;
this.running = false;
var xhr = this.xhr;
xhr.abort();
clearTimeout(this.timer);
xhr.onreadystatechange = empty;
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
this.xhr = new Browser.Request();
this.fireEvent('cancel');
return this;
}
});
var methods = {};
['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){
methods[method] = function(data){
var object = {
method: method
};
if (data != null) object.data = data;
return this.send(object);
};
});
Request.implement(methods);
Element.Properties.send = {
set: function(options){
var send = this.get('send').cancel();
send.setOptions(options);
return this;
},
get: function(){
var send = this.retrieve('send');
if (!send){
send = new Request({
data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')
});
this.store('send', send);
}
return send;
}
};
Element.implement({
send: function(url){
var sender = this.get('send');
sender.send({data: this, url: url || sender.options.url});
return this;
}
});
})();
/*
---
name: Request.HTML
description: Extends the basic Request Class with additional methods for interacting with HTML responses.
license: MIT-style license.
requires: [Element, Request]
provides: Request.HTML
...
*/
Request.HTML = new Class({
Extends: Request,
options: {
update: false,
append: false,
evalScripts: true,
filter: false,
headers: {
Accept: 'text/html, application/xml, text/xml, */*'
}
},
success: function(text){
var options = this.options, response = this.response;
response.html = text.stripScripts(function(script){
response.javascript = script;
});
var match = response.html.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
if (match) response.html = match[1];
var temp = new Element('div').set('html', response.html);
response.tree = temp.childNodes;
response.elements = temp.getElements(options.filter || '*');
if (options.filter) response.tree = response.elements;
if (options.update){
var update = document.id(options.update).empty();
if (options.filter) update.adopt(response.elements);
else update.set('html', response.html);
} else if (options.append){
var append = document.id(options.append);
if (options.filter) response.elements.reverse().inject(append);
else append.adopt(temp.getChildren());
}
if (options.evalScripts) Browser.exec(response.javascript);
this.onSuccess(response.tree, response.elements, response.html, response.javascript);
}
});
Element.Properties.load = {
set: function(options){
var load = this.get('load').cancel();
load.setOptions(options);
return this;
},
get: function(){
var load = this.retrieve('load');
if (!load){
load = new Request.HTML({data: this, link: 'cancel', update: this, method: 'get'});
this.store('load', load);
}
return load;
}
};
Element.implement({
load: function(){
this.get('load').send(Array.link(arguments, {data: Type.isObject, url: Type.isString}));
return this;
}
});
/*
---
name: JSON
description: JSON encoder and decoder.
license: MIT-style license.
SeeAlso: <http://www.json.org/>
requires: [Array, String, Number, Function]
provides: JSON
...
*/
if (typeof JSON == 'undefined') this.JSON = {};
(function(){
var special = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'};
var escape = function(chr){
return special[chr] || '\\u' + ('0000' + chr.charCodeAt(0).toString(16)).slice(-4);
};
JSON.validate = function(string){
string = string.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, '');
return (/^[\],:{}\s]*$/).test(string);
};
JSON.encode = JSON.stringify ? function(obj){
return JSON.stringify(obj);
} : function(obj){
if (obj && obj.toJSON) obj = obj.toJSON();
switch (typeOf(obj)){
case 'string':
return '"' + obj.replace(/[\x00-\x1f\\"]/g, escape) + '"';
case 'array':
return '[' + obj.map(JSON.encode).clean() + ']';
case 'object': case 'hash':
var string = [];
Object.each(obj, function(value, key){
var json = JSON.encode(value);
if (json) string.push(JSON.encode(key) + ':' + json);
});
return '{' + string + '}';
case 'number': case 'boolean': return '' + obj;
case 'null': return 'null';
}
return null;
};
JSON.decode = function(string, secure){
if (!string || typeOf(string) != 'string') return null;
if (secure || JSON.secure){
if (JSON.parse) return JSON.parse(string);
if (!JSON.validate(string)) throw new Error('JSON could not decode the input; security is enabled and the value is not secure.');
}
return eval('(' + string + ')');
};
})();
/*
---
name: Request.JSON
description: Extends the basic Request Class with additional methods for sending and receiving JSON data.
license: MIT-style license.
requires: [Request, JSON]
provides: Request.JSON
...
*/
Request.JSON = new Class({
Extends: Request,
options: {
/*onError: function(text, error){},*/
secure: true
},
initialize: function(options){
this.parent(options);
Object.append(this.headers, {
'Accept': 'application/json',
'X-Request': 'JSON'
});
},
success: function(text){
var json;
try {
json = this.response.json = JSON.decode(text, this.options.secure);
} catch (error){
this.fireEvent('error', [text, error]);
return;
}
if (json == null) this.onFailure();
else this.onSuccess(json, text);
}
});
/*
---
name: Cookie
description: Class for creating, reading, and deleting browser Cookies.
license: MIT-style license.
credits:
- Based on the functions by Peter-Paul Koch (http://quirksmode.org).
requires: [Options, Browser]
provides: Cookie
...
*/
var Cookie = new Class({
Implements: Options,
options: {
path: '/',
domain: false,
duration: false,
secure: false,
document: document,
encode: true
},
initialize: function(key, options){
this.key = key;
this.setOptions(options);
},
write: function(value){
if (this.options.encode) value = encodeURIComponent(value);
if (this.options.domain) value += '; domain=' + this.options.domain;
if (this.options.path) value += '; path=' + this.options.path;
if (this.options.duration){
var date = new Date();
date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000);
value += '; expires=' + date.toGMTString();
}
if (this.options.secure) value += '; secure';
this.options.document.cookie = this.key + '=' + value;
return this;
},
read: function(){
var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)');
return (value) ? decodeURIComponent(value[1]) : null;
},
dispose: function(){
new Cookie(this.key, Object.merge({}, this.options, {duration: -1})).write('');
return this;
}
});
Cookie.write = function(key, value, options){
return new Cookie(key, options).write(value);
};
Cookie.read = function(key){
return new Cookie(key).read();
};
Cookie.dispose = function(key, options){
return new Cookie(key, options).dispose();
};
/*
---
name: DOMReady
description: Contains the custom event domready.
license: MIT-style license.
requires: [Browser, Element, Element.Event]
provides: [DOMReady, DomReady]
...
*/
(function(window, document){
var ready,
loaded,
checks = [],
shouldPoll,
timer,
testElement = document.createElement('div');
var domready = function(){
clearTimeout(timer);
if (ready) return;
Browser.loaded = ready = true;
document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check);
document.fireEvent('domready');
window.fireEvent('domready');
};
var check = function(){
for (var i = checks.length; i--;) if (checks[i]()){
domready();
return true;
}
return false;
};
var poll = function(){
clearTimeout(timer);
if (!check()) timer = setTimeout(poll, 10);
};
document.addListener('DOMContentLoaded', domready);
/*<ltIE8>*/
// doScroll technique by Diego Perini http://javascript.nwbox.com/IEContentLoaded/
// testElement.doScroll() throws when the DOM is not ready, only in the top window
var doScrollWorks = function(){
try {
testElement.doScroll();
return true;
} catch (e){}
return false;
};
// If doScroll works already, it can't be used to determine domready
// e.g. in an iframe
if (testElement.doScroll && !doScrollWorks()){
checks.push(doScrollWorks);
shouldPoll = true;
}
/*</ltIE8>*/
if (document.readyState) checks.push(function(){
var state = document.readyState;
return (state == 'loaded' || state == 'complete');
});
if ('onreadystatechange' in document) document.addListener('readystatechange', check);
else shouldPoll = true;
if (shouldPoll) poll();
Element.Events.domready = {
onAdd: function(fn){
if (ready) fn.call(this);
}
};
// Make sure that domready fires before load
Element.Events.load = {
base: 'load',
onAdd: function(fn){
if (loaded && this == window) fn.call(this);
},
condition: function(){
if (this == window){
domready();
delete Element.Events.load;
}
return true;
}
};
// This is based on the custom load event
window.addEvent('load', function(){
loaded = true;
});
})(window, document);
/*
---
name: Swiff
description: Wrapper for embedding SWF movies. Supports External Interface Communication.
license: MIT-style license.
credits:
- Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.
requires: [Options, Object, Element]
provides: Swiff
...
*/
(function(){
var Swiff = this.Swiff = new Class({
Implements: Options,
options: {
id: null,
height: 1,
width: 1,
container: null,
properties: {},
params: {
quality: 'high',
allowScriptAccess: 'always',
wMode: 'window',
swLiveConnect: true
},
callBacks: {},
vars: {}
},
toElement: function(){
return this.object;
},
initialize: function(path, options){
this.instance = 'Swiff_' + String.uniqueID();
this.setOptions(options);
options = this.options;
var id = this.id = options.id || this.instance;
var container = document.id(options.container);
Swiff.CallBacks[this.instance] = {};
var params = options.params, vars = options.vars, callBacks = options.callBacks;
var properties = Object.append({height: options.height, width: options.width}, options.properties);
var self = this;
for (var callBack in callBacks){
Swiff.CallBacks[this.instance][callBack] = (function(option){
return function(){
return option.apply(self.object, arguments);
};
})(callBacks[callBack]);
vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;
}
params.flashVars = Object.toQueryString(vars);
if (Browser.ie){
properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
params.movie = path;
} else {
properties.type = 'application/x-shockwave-flash';
}
properties.data = path;
var build = '<object id="' + id + '"';
for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';
build += '>';
for (var param in params){
if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';
}
build += '</object>';
this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;
},
replaces: function(element){
element = document.id(element, true);
element.parentNode.replaceChild(this.toElement(), element);
return this;
},
inject: function(element){
document.id(element, true).appendChild(this.toElement());
return this;
},
remote: function(){
return Swiff.remote.apply(Swiff, [this.toElement()].append(arguments));
}
});
Swiff.CallBacks = {};
Swiff.remote = function(obj, fn){
var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');
return eval(rs);
};
})(); | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/libs/mootools.js | JavaScript | gpl2 | 150,810 |
// Developed by Robert Nyman/DOMAssistant team, code/licensing: http://domassistant.googlecode.com/, documentation: http://www.domassistant.com/documentation, version 2.8.1
var DOMAssistant = function () {
var HTMLArray = function () {
// Constructor
},
w = window, _$ = w.$, _$$ = w.$$,
isIE = /*@cc_on!@*/false,
byTag = !!document.getElementsByTagName("*").length,
strictElmCreation = function() {
if (!isIE) return true;
try {
document.createElement("<img />");
return false;
} catch (e) {
return true;
}
}(),
sort, tagCache = {}, lastCache = {}, useCache = true,
slice = Array.prototype.slice,
camel = {
"accesskey": "accessKey",
"class": "className",
"colspan": "colSpan",
"for": "htmlFor",
"maxlength": "maxLength",
"readonly": "readOnly",
"rowspan": "rowSpan",
"tabindex": "tabIndex",
"valign": "vAlign",
"cellspacing": "cellSpacing",
"cellpadding": "cellPadding"
},
regex = {
rules: /\s*,\s*/g,
selector: /^(\w+|\*)?(#[\w\u00C0-\uFFFF\-=$]+)?((\.[\w\u00C0-\uFFFF\-]+)*)?((\[\w[-\w]*\s*([~^$*|])?(=\s*([-\w\u00C0-\uFFFF\s.]+|"[^"]*"|'[^']*'))?\]+)*)?((:\w[-\w]*(\((odd|even|\-?\d*n?([-+]\d+)?|[:#]?[-\w\u00C0-\uFFFF.]+|"[^"]*"|'[^']*'|((\w*\.[-\w\u00C0-\uFFFF]+)*)?|(\[#?\w[-\w]*([~^$*|])?=?[-\w\u00C0-\uFFFF\s.'"]+\]+)|(:\w[-\w]*\(.+\)))\))?)*)?([+>~])?/,
selectorSplit: /(?:\[.*\]|\(.*\)|[^\s+>~[(])+|[+>~]/g,
id: /^#([-\w\u00C0-\uFFFF=$]+)$/,
tag: /^\w+/,
relation: /^[+>~]$/,
pseudo: /^:(\w[-\w]*)(\((.+)\))?$/,
pseudos: /:(\w[-\w]*)(\((([^(]+)|([^(]+\([^(]+)\))\))?/g,
attribs: /\[(\w[-\w]*)\s*([~^$*|])?(=)?\s*([^\[\]]*|"[^"]*"|'[^']*')?\](?=$|\[|:|\s)/g,
classes: /\.([-\w\u00C0-\uFFFF]+)/g,
quoted: /^["'](.*)["']$/,
nth: /^((odd|even)|([1-9]\d*)|((([1-9]\d*)?)n([-+]\d+)?)|(-(([1-9]\d*)?)n\+(\d+)))$/,
special: /((:check|:enabl|\bselect)ed\b)|[*^$]=\s*(""|'')/
},
navigate = function (node, direction, checkTagName) {
var oldName = node.tagName;
while ((node = node[direction + "Sibling"]) && (node.nodeType !== 1 || (checkTagName? node.tagName !== oldName : node.tagName === "!"))) {}
return node;
},
def = function (obj) {
return typeof obj !== "undefined";
},
sortDocumentOrder = function (elmArray) {
return (sortDocumentOrder = elmArray[0].compareDocumentPosition? function (elmArray) { return elmArray.sort( function (a, b) { return 3 - (a.compareDocumentPosition(b) & 6); } ); } :
isIE? function (elmArray) { return elmArray.sort( function (a, b) { return a.sourceIndex - b.sourceIndex; } ); } :
function (elmArray) { return elmArray.sort( function (a, b) {
var range1 = document.createRange(), range2 = document.createRange();
range1.setStart(a, 0);
range1.setEnd(a, 0);
range2.setStart(b, 0);
range2.setEnd(b, 0);
return range1.compareBoundaryPoints(Range.START_TO_END, range2);
} ); })(elmArray);
};
var pushAll = function (set1, set2) {
set1.push.apply(set1, slice.apply(set2));
return set1;
};
if (isIE) {
pushAll = function (set1, set2) {
if (set2.slice) {
return set1.concat(set2);
}
var i=0, item;
while ((item = set2[i++])) {
set1[set1.length] = item;
}
return set1;
};
}
return {
isIE : isIE,
strictElmCreation : strictElmCreation,
camel : camel,
def : def,
allMethods : [],
publicMethods : [
"prev",
"next",
"hasChild",
"cssSelect",
"elmsByClass",
"elmsByAttribute",
"elmsByTag"
],
harmonize : function () {
w.$ = _$;
w.$$ = _$$;
return this;
},
initCore : function () {
this.applyMethod.call(w, "$", this.$);
this.applyMethod.call(w, "$$", this.$$);
w.DOMAssistant = this;
if (isIE) {
HTMLArray = Array;
}
HTMLArray.prototype = [];
(function (H) {
H.each = function (fn, context) {
for (var i=0, il=this.length; i<il; i++) {
if (fn.call(context || this[i], this[i], i, this) === false) {
break;
}
}
return this;
};
H.first = function () {
return def(this[0])? DOMAssistant.addMethodsToElm(this[0]) : null;
};
H.end = function () {
return this.previousSet;
};
H.indexOf = H.indexOf || function (elm) {
for (var i=0, il=this.length; i<il; i++) {
if (i in this && this[i] === elm) {
return i;
}
}
return -1;
};
H.map = function (fn, context) {
var res = [];
for (var i=0, il=this.length; i<il; i++) {
if (i in this) {
res[i] = fn.call(context || this[i], this[i], i, this);
}
}
return res;
};
H.filter = function (fn, context) {
var res = new HTMLArray();
res.previousSet = this;
for (var i=0, il=this.length; i<il; i++) {
if (i in this && fn.call(context || this[i], this[i], i, this)) {
res.push(this[i]);
}
}
return res;
};
H.every = function (fn, context) {
for (var i=0, il=this.length; i<il; i++) {
if (i in this && !fn.call(context || this[i], this[i], i, this)) {
return false;
}
}
return true;
};
H.some = function (fn, context) {
for (var i=0, il=this.length; i<il; i++) {
if (i in this && fn.call(context || this[i], this[i], i, this)) {
return true;
}
}
return false;
};
})(HTMLArray.prototype);
this.attach(this);
},
addMethods : function (name, method) {
if (!def(this.allMethods[name])) {
this.allMethods[name] = method;
this.addHTMLArrayPrototype(name, method);
}
},
addMethodsToElm : function (elm) {
for (var method in this.allMethods) {
if (def(this.allMethods[method])) {
this.applyMethod.call(elm, method, this.allMethods[method]);
}
}
return elm;
},
applyMethod : function (method, func) {
if (typeof this[method] !== "function") {
this[method] = func;
}
},
attach : function (plugin) {
var publicMethods = plugin.publicMethods;
if (!def(publicMethods)) {
for (var method in plugin) {
if (method !== "init" && def(plugin[method])) {
this.addMethods(method, plugin[method]);
}
}
}
else if (publicMethods.constructor === Array) {
for (var i=0, current; (current=publicMethods[i]); i++) {
this.addMethods(current, plugin[current]);
}
}
if (typeof plugin.init === "function") {
plugin.init();
}
},
addHTMLArrayPrototype : function (name, method) {
HTMLArray.prototype[name] = function () {
var elmsToReturn = new HTMLArray();
elmsToReturn.previousSet = this;
for (var i=0, il=this.length; i<il; i++) {
elmsToReturn.push(method.apply(DOMAssistant.$$(this[i]), arguments));
}
return elmsToReturn;
};
},
cleanUp : function (elm) {
var children = elm.all || elm.getElementsByTagName("*");
for (var i=0, child; (child=children[i++]);) {
if (child.hasData && child.hasData()) {
if (child.removeEvent) { child.removeEvent(); }
child.unstore();
}
}
elm.innerHTML = "";
},
setCache : function (cache) {
useCache = cache;
},
$ : function () {
var obj = arguments[0];
if (arguments.length === 1 && (typeof obj === "object" || (typeof obj === "function" && !!obj.nodeName))) {
return DOMAssistant.$$(obj);
}
var elm = !!obj? new HTMLArray() : null;
for (var i=0, arg, idMatch; (arg=arguments[i]); i++) {
if (typeof arg === "string") {
arg = arg.replace(/^[^#\(]*(#)/, "$1");
if (regex.id.test(arg)) {
if ((idMatch = DOMAssistant.$$(arg.substr(1), false))) {
elm.push(idMatch);
}
}
else {
var doc = (document.all || document.getElementsByTagName("*")).length;
elm = (!document.querySelectorAll && useCache && lastCache.rule && lastCache.rule === arg && lastCache.doc === doc)? lastCache.elms : pushAll(elm, DOMAssistant.cssSelection.call(document, arg));
lastCache = { rule: arg, elms: elm, doc: doc };
}
}
}
return elm;
},
$$ : function (id, addMethods) {
var elm = (typeof id === "object" || typeof id === "function" && !!id.nodeName)? id : document.getElementById(id),
applyMethods = def(addMethods)? addMethods : true,
getId = function(el) { var eid = el.id; return typeof eid !== "object"? eid : el.attributes.id.nodeValue; };
if (typeof id === "string" && elm && getId(elm) !== id) {
elm = null;
for (var i=0, item; (item=document.all[i]); i++) {
if (getId(item) === id) {
elm = item;
break;
}
}
}
if (elm && applyMethods && !elm.next) {
DOMAssistant.addMethodsToElm(elm);
}
return elm;
},
prev : function () {
return DOMAssistant.$$(navigate(this, "previous"));
},
next : function () {
return DOMAssistant.$$(navigate(this, "next"));
},
hasChild: function (elm) {
return this === document || this !== elm && (this.contains? this.contains(elm) : !!(this.compareDocumentPosition(elm) & 16));
},
getSequence : function (expression) {
var start, add = 2, max = -1, modVal = -1,
pseudoVal = regex.nth.exec(expression.replace(/^0n\+/, "").replace(/^2n$/, "even").replace(/^2n+1$/, "odd"));
if (!pseudoVal) {
return null;
}
if (pseudoVal[2]) { // odd or even
start = (pseudoVal[2] === "odd")? 1 : 2;
modVal = (start === 1)? 1 : 0;
}
else if (pseudoVal[3]) { // single digit
start = max = parseInt(pseudoVal[3], 10);
add = 0;
}
else if (pseudoVal[4]) { // an+b
add = pseudoVal[6]? parseInt(pseudoVal[6], 10) : 1;
start = pseudoVal[7]? parseInt(pseudoVal[7], 10) : 0;
while (start < 1) {
start += add;
}
modVal = (start >= add)? (start - add) % add : start;
}
else if (pseudoVal[8]) { // -an+b
add = pseudoVal[10]? parseInt(pseudoVal[10], 10) : 1;
start = max = parseInt(pseudoVal[11], 10);
while (start > add) {
start -= add;
}
modVal = (max >= add)? (max - add) % add : max;
}
return { start: start, add: add, max: max, modVal: modVal };
},
cssByDOM : function (cssRule) {
var prevParents, currentRule, cssSelectors, childOrSiblingRef, nextTag, nextRegExp, current, previous, prevParent, notElm, addElm, iteratorNext, childElm, sequence, anyTag,
elm = new HTMLArray(), index = elm.indexOf, prevElm = [], matchingElms = [], cssRules = cssRule.replace(regex.rules, ",").split(","), splitRule = {};
function clearAdded (elm) {
elm = elm || prevElm;
for (var n=elm.length; n--;) {
elm[n].added = null;
elm[n].removeAttribute("added");
}
}
function clearChildElms () {
for (var n=prevParents.length; n--;) {
prevParents[n].childElms = null;
}
}
function subtractArray (arr1, arr2) {
for (var i=0, src1; (src1=arr1[i]); i++) {
var found = false;
for (var j=0, src2; (src2=arr2[j]); j++) {
if (src2 === src1) {
found = true;
arr2.splice(j, 1);
break;
}
}
if (found) {
arr1.splice(i--, 1);
}
}
return arr1;
}
function hasAttr (elm, attr) {
return elm.hasAttribute? elm.hasAttribute(attr) : (elm.attributes && elm.attributes[attr] && !/type/.test(attr))? !!elm.attributes[attr].specified : (elm.getAttribute(attr) !== null);
}
function getAttr (elm, attr) {
var isSpecial = regex.special.test(attr);
if (isIE && !isSpecial && !hasAttr(elm, attr)) { return undefined; }
return (isIE || isSpecial)? elm[camel[attr.toLowerCase()] || attr] : elm.getAttribute(attr, 2);
}
function attrToRegExp (attrVal, substrOperator) {
attrVal = attrVal? attrVal.replace(regex.quoted, "$1").replace(/(\.|\[|\])/g, "\\$1") : null;
return substrOperator? {
"^": "^" + attrVal,
"$": attrVal + "$",
"*": attrVal,
"|": "^" + attrVal + "(\\-\\w+)*$",
"~": "\\b" + attrVal + "\\b"
}[substrOperator] : (attrVal !== null? "^" + attrVal + "$" : attrVal);
}
function notComment(el) {
return (el || this).tagName !== "!";
}
function getTags (tag, context) {
return byTag? context.getElementsByTagName(tag) : (tag === "*"? context.all : context.all.tags(tag));
}
function getElementsByTagName (tag, parent) {
tag = tag || "*";
parent = parent || document;
return (parent === document || parent.lastModified)? tagCache[tag] || (tagCache[tag] = getTags(tag, document)) : getTags(tag, parent);
}
function getElementsByPseudo (previousMatch, pseudoClass, pseudoValue) {
prevParents = [];
var pseudo = pseudoClass.split("-"), matchingElms = [], idx = 0, checkNodeName = /\-of\-type$/.test(pseudoClass), recur,
match = {
first: function(el) { return !navigate(el, "previous", checkNodeName); },
last: function(el) { return !navigate(el, "next", checkNodeName); },
empty: function(el) {
for (var node=el.firstChild; node!==null; node=node.nextSibling) {
if (node.nodeType === 1 && node.nodeName !== "!" || node.nodeType === 3) { return false; }
}
return true;
},
enabled: function(el) { return !el.disabled && el.type !== "hidden"; },
disabled: function(el) { return el.disabled; },
checked: function(el) { return el.checked; },
contains: function(el) { return (el.innerText || el.textContent || "").indexOf(pseudoValue.replace(regex.quoted, "$1")) > -1; },
other: function(el) { return getAttr(el, pseudoClass) === pseudoValue; }
};
function basicMatch(key) {
while ((previous=previousMatch[idx++])) {
if (notComment(previous) && match[key](previous)) {
matchingElms[matchingElms.length] = previous;
}
}
return matchingElms;
}
var word = pseudo[0] || null;
if (word && match[word]) {
return basicMatch(word);
}
switch (word) {
case "only":
var kParent, kTag;
while ((previous=previousMatch[idx++])) {
prevParent = previous.parentNode;
var q = previous.nodeName;
if (prevParent !== kParent || q !== kTag) {
if (match.first(previous) && match.last(previous)) {
matchingElms[matchingElms.length] = previous;
}
kParent = prevParent;
kTag = q;
}
}
break;
case "nth":
if (pseudoValue === "n") {
matchingElms = previousMatch;
}
else {
var direction = (pseudo[1] === "last")? ["lastChild", "previousSibling"] : ["firstChild", "nextSibling"];
sequence = DOMAssistant.getSequence(pseudoValue);
if (sequence) {
while ((previous=previousMatch[idx++])) {
prevParent = previous.parentNode;
prevParent.childElms = prevParent.childElms || {};
var p = previous.nodeName;
if (!prevParent.childElms[p]) {
var childCount = 0;
iteratorNext = sequence.start;
childElm = prevParent[direction[0]];
while (childElm && (sequence.max < 0 || iteratorNext <= sequence.max)) {
var c = childElm.nodeName;
if ((checkNodeName && c === p) || (!checkNodeName && childElm.nodeType === 1 && c !== "!")) {
if (++childCount === iteratorNext) {
if (c === p) { matchingElms[matchingElms.length] = childElm; }
iteratorNext += sequence.add;
}
}
childElm = childElm[direction[1]];
}
if (anyTag) { sort++; }
prevParent.childElms[p] = true;
prevParents[prevParents.length] = prevParent;
}
}
clearChildElms();
}
}
break;
case "target":
var hash = document.location.hash.slice(1);
if (hash) {
while ((previous=previousMatch[idx++])) {
if (getAttr(previous, "name") === hash || getAttr(previous, "id") === hash) {
matchingElms[matchingElms.length] = previous;
break;
}
}
}
break;
case "not":
if ((recur = regex.pseudo.exec(pseudoValue))) {
matchingElms = subtractArray(previousMatch, getElementsByPseudo(previousMatch, recur[1]? recur[1].toLowerCase() : null, recur[3] || null));
}
else {
for (var re in regex) {
if (regex[re].lastIndex) {
regex[re].lastIndex = 0;
}
}
pseudoValue = pseudoValue.replace(regex.id, "[id=$1]");
var notTag = regex.tag.exec(pseudoValue);
var notClass = regex.classes.exec(pseudoValue);
var notAttr = regex.attribs.exec(pseudoValue);
var notRegExp = new RegExp(notAttr? attrToRegExp(notAttr[4], notAttr[2]) || "" : "(^|\\s)" + (notTag? notTag[0] : notClass? notClass[1] : "") + "(\\s|$)", "i");
while ((notElm=previousMatch[idx++])) {
addElm = null;
if (notTag && !notRegExp.test(notElm.nodeName) || notClass && !notRegExp.test(notElm.className)) {
addElm = notElm;
}
else if (notAttr) {
var att = getAttr(notElm, notAttr[1]);
if (!def(att) || att === false || typeof att === "string" && !notRegExp.test(att)) {
addElm = notElm;
}
}
if (addElm && !addElm.added) {
addElm.added = true;
matchingElms[matchingElms.length] = addElm;
}
}
}
break;
default: return basicMatch("other");
}
return matchingElms;
}
function pushUnique(set1, set2) {
var i=0, s=set1, item;
while ((item = set2[i++])) {
if (!s.length || s.indexOf(item) < 0) {
set1.push(item);
}
}
return set1;
}
sort = -1;
for (var a=0, tagBin=[]; (currentRule=cssRules[a]); a++) {
if (!(cssSelectors = currentRule.match(regex.selectorSplit)) || a && index.call(cssRules.slice(0, a), currentRule) > -1) { continue; }
prevElm = [this];
for (var i=0, rule; (rule=cssSelectors[i]); i++) {
matchingElms = [];
if ((childOrSiblingRef = regex.relation.exec(rule))) {
var idElm = null, nextWord = cssSelectors[i+1];
if ((nextTag = regex.tag.exec(nextWord))) {
nextTag = nextTag[0];
nextRegExp = new RegExp("(^|\\s)" + nextTag + "(\\s|$)", "i");
}
else if (regex.id.test(nextWord)) {
idElm = DOMAssistant.$(nextWord) || null;
}
for (var j=0, prevRef; (prevRef=prevElm[j]); j++) {
switch (childOrSiblingRef[0]) {
case ">":
var children = idElm || getElementsByTagName(nextTag, prevRef);
for (var k=0, child; (child=children[k]); k++) {
if (child.parentNode === prevRef) {
matchingElms[matchingElms.length] = child;
}
}
break;
case "+":
if ((prevRef = navigate(prevRef, "next"))) {
if ((idElm && idElm[0] === prevRef) || (!idElm && (!nextTag || nextRegExp.test(prevRef.nodeName)))) {
matchingElms[matchingElms.length] = prevRef;
}
}
break;
case "~":
while ((prevRef = prevRef.nextSibling) && !prevRef.added) {
if ((idElm && idElm[0] === prevRef) || (!idElm && (!nextTag || nextRegExp.test(prevRef.nodeName)))) {
prevRef.added = true;
matchingElms[matchingElms.length] = prevRef;
}
}
break;
}
}
prevElm = matchingElms;
clearAdded();
rule = cssSelectors[++i];
if (/^\w+$/.test(rule) || regex.id.test(rule)) {
continue;
}
prevElm.skipTag = true;
}
var cssSelector = regex.selector.exec(rule);
splitRule = {
tag : cssSelector[1]? cssSelector[1] : "*",
id : cssSelector[2],
allClasses : cssSelector[3],
allAttr : cssSelector[5],
allPseudos : cssSelector[10]
};
anyTag = (splitRule.tag === "*");
if (splitRule.id) {
var u = 0, DOMElm = document.getElementById(splitRule.id.slice(1));
if (DOMElm) {
while (prevElm[u] && !DOMAssistant.hasChild.call(prevElm[u], DOMElm)) { u++; }
matchingElms = (u < prevElm.length && (anyTag || splitRule.tag === DOMElm.tagName.toLowerCase()))? [DOMElm] : [];
}
prevElm = matchingElms;
}
else if (splitRule.tag && !prevElm.skipTag) {
if (i===0 && !matchingElms.length && prevElm.length === 1) {
prevElm = matchingElms = pushAll([], getElementsByTagName(splitRule.tag, prevElm[0]));
}
else {
for (var l=0, ll=prevElm.length, tagCollectionMatches, tagMatch; l<ll; l++) {
tagCollectionMatches = getElementsByTagName(splitRule.tag, prevElm[l]);
for (var m=0; (tagMatch=tagCollectionMatches[m]); m++) {
if (!tagMatch.added) {
tagMatch.added = true;
matchingElms[matchingElms.length] = tagMatch;
}
}
}
prevElm = matchingElms;
clearAdded();
}
}
if (!matchingElms.length) {
break;
}
prevElm.skipTag = false;
if (splitRule.allClasses) {
var n = 0, matchingClassElms = [], allClasses = splitRule.allClasses.split(".").slice(1);
while ((current = prevElm[n++])) {
var matchCls = true, elmClass = current.className;
if (elmClass && elmClass.length) {
elmClass = elmClass.split(" ");
for (var o=allClasses.length; o--;) {
if (elmClass.indexOf(allClasses[o]) < 0) {
matchCls = false;
break;
}
}
if (matchCls) {
matchingClassElms[matchingClassElms.length] = current;
}
}
}
prevElm = matchingElms = matchingClassElms;
}
if (splitRule.allAttr) {
var matchAttr, r = 0, regExpAttributes = [], matchingAttributeElms = [], allAttr = splitRule.allAttr.match(regex.attribs), emptyAttrRegExp = /^[$^]?$/;
for (var specialStrip = /^\[(selected|readonly)(\s*=.+)?\]$/, q=0, ql=allAttr.length, attributeMatch, attrVal; q<ql; q++) {
regex.attribs.lastIndex = 0;
attributeMatch = regex.attribs.exec(allAttr[q].replace(specialStrip, "[$1]"));
attrVal = attrToRegExp(attributeMatch[4], attributeMatch[2] || null);
regExpAttributes[q] = [attrVal, attributeMatch[1]];
}
while ((current = matchingElms[r++])) {
for (var s=0, sl=regExpAttributes.length; s<sl; s++) {
var attributeRE = regExpAttributes[s][0], attributeRegExp = attributeRE? new RegExp(attributeRE) : null, currentAttr = getAttr(current, regExpAttributes[s][1]);
matchAttr = true;
if (!attributeRegExp && currentAttr === true) { continue; }
if (emptyAttrRegExp.test(attributeRE) || (!attributeRegExp && typeof currentAttr !== "string") || (!!attributeRegExp && !attributeRegExp.test(currentAttr))) {
matchAttr = false;
break;
}
}
if (matchAttr) {
matchingAttributeElms[matchingAttributeElms.length] = current;
}
}
prevElm = matchingElms = matchingAttributeElms;
}
if (splitRule.allPseudos) {
var allPseudos = splitRule.allPseudos.match(regex.pseudos);
for (var t=0, tl=allPseudos.length; t<tl; t++) {
regex.pseudos.lastIndex = 0;
var pseudo = regex.pseudos.exec(allPseudos[t]);
var pseudoClass = pseudo[1]? pseudo[1].toLowerCase() : null;
var pseudoValue = pseudo[3] || null;
matchingElms = getElementsByPseudo(matchingElms, pseudoClass, pseudoValue);
clearAdded(matchingElms);
}
prevElm = matchingElms;
}
}
elm = ((tagBin.length && (anyTag || index.call(tagBin, splitRule.tag) >= 0 || index.call(tagBin, "*") >= 0))? pushUnique : pushAll)(elm, prevElm);
tagBin.push(splitRule.tag);
if (isIE && anyTag) { elm = elm.filter(notComment); }
}
return ((elm.length > 1 && cssRules.length > 1) || sort > 0)? sortDocumentOrder(elm) : elm;
},
cssByXpath : function (cssRule) {
var ns = { xhtml: "http://www.w3.org/1999/xhtml" },
prefix = (document.documentElement.namespaceURI === ns.xhtml)? "xhtml:" : "",
nsResolver = function lookupNamespaceURI (prefix) {
return ns[prefix] || null;
};
DOMAssistant.cssByXpath = function (cssRule) {
var currentRule, cssSelectors, xPathExpression, cssSelector, splitRule, sequence,
elm = new HTMLArray(), cssRules = cssRule.replace(regex.rules, ",").split(",");
function attrToXPath (wrap) {
var pre = wrap? "[" : "", post = wrap? "]" : "";
return function (match, p1, p2, p3, p4) {
p4 = (p4 || "").replace(regex.quoted, "$1");
if (p1 === p4 && p1 === "readonly") { p3 = null; }
return pre + ({
"^": "starts-with(@" + p1 + ", \"" + p4 + "\")",
"$": "substring(@" + p1 + ", (string-length(@" + p1 + ") - " + (p4.length - 1) + "), " + p4.length + ") = \"" + p4 + "\"",
"*": "contains(concat(\" \", @" + p1 + ", \" \"), \"" + p4 + "\")",
"|": "@" + p1 + "=\"" + p4 + "\" or starts-with(@" + p1 + ", \"" + p4 + "-\")",
"~": "contains(concat(\" \", @" + p1 + ", \" \"), \" " + p4 + " \")"
}[p2] || ("@" + p1 + (p3? "=\"" + p4 + "\"" : ""))) + post;
};
}
function pseudoToXPath (tag, pseudoClass, pseudoValue) {
tag = /\-child$/.test(pseudoClass)? "*" : tag;
var pseudo = pseudoClass.split("-"), position = ((pseudo[1] === "last")? "(count(following-sibling::" : "(count(preceding-sibling::") + tag + ") + 1)", recur, hash;
switch (pseudo[0]) {
case "nth": return (pseudoValue !== "n" && (sequence = DOMAssistant.getSequence(pseudoValue)))? ((sequence.start === sequence.max)? position + " = " + sequence.start : position + " mod " + sequence.add + " = " + sequence.modVal + ((sequence.start > 1)? " and " + position + " >= " + sequence.start : "") + ((sequence.max > 0)? " and " + position + " <= " + sequence.max: "")) : "";
case "not": return "not(" + ((recur = regex.pseudo.exec(pseudoValue))? pseudoToXPath(tag, recur[1]? recur[1].toLowerCase() : null, recur[3] || null) : pseudoValue.replace(regex.id, "[id=$1]").replace(regex.tag, "self::$0").replace(regex.classes, "contains(concat(\" \", @class, \" \"), \" $1 \")").replace(regex.attribs, attrToXPath())) + ")";
case "first": return "not(preceding-sibling::" + tag + ")";
case "last": return "not(following-sibling::" + tag + ")";
case "only": return "not(preceding-sibling::" + tag + " or following-sibling::" + tag + ")";
case "empty": return "not(child::*) and not(text())";
case "contains": return "contains(., \"" + pseudoValue.replace(regex.quoted, "$1") + "\")";
case "enabled": return "not(@disabled) and not(@type=\"hidden\")";
case "disabled": return "@disabled";
case "target": return "@name=\"" + (hash = document.location.hash.slice(1)) + "\" or @id=\"" + hash + "\"";
default: return "@" + pseudoClass + "=\"" + pseudoValue + "\"";
}
}
for (var i=0; (currentRule=cssRules[i]); i++) {
if (!(cssSelectors = currentRule.match(regex.selectorSplit)) || i && elm.indexOf.call(cssRules.slice(0, i), currentRule) > -1) { continue; }
xPathExpression = xPathExpression? xPathExpression + " | ." : ".";
for (var j=0, jl=cssSelectors.length; j<jl; j++) {
cssSelector = regex.selector.exec(cssSelectors[j]);
splitRule = {
tag: prefix + (cssSelector[1]? cssSelector[1] : "*"),
id: cssSelector[2],
allClasses: cssSelector[3],
allAttr: cssSelector[5],
allPseudos: cssSelector[10],
tagRelation: cssSelector[20]
};
xPathExpression +=
(splitRule.tagRelation? ({ ">": "/", "+": "/following-sibling::*[1]/self::", "~": "/following-sibling::" }[splitRule.tagRelation] || "") : ((j > 0 && regex.relation.test(cssSelectors[j-1]))? splitRule.tag : ("//" + splitRule.tag))) +
(splitRule.id || "").replace(regex.id, "[@id = \"$1\"]") +
(splitRule.allClasses || "").replace(regex.classes, "[contains(concat(\" \", @class, \" \"), \" $1 \")]") +
(splitRule.allAttr || "").replace(regex.attribs, attrToXPath(true));
if (splitRule.allPseudos) {
var allPseudos = splitRule.allPseudos.match(regex.pseudos);
for (var k=0, kl=allPseudos.length; k<kl; k++) {
regex.pseudos.lastIndex = 0;
var pseudo = regex.pseudos.exec(allPseudos[k]),
pseudoClass = pseudo[1]? pseudo[1].toLowerCase() : null,
pseudoValue = pseudo[3] || null,
xpath = pseudoToXPath(splitRule.tag, pseudoClass, pseudoValue);
if (xpath.length) {
xPathExpression += "[" + xpath + "]";
}
}
}
}
}
try {
var xPathNodes = document.evaluate(xPathExpression, this, nsResolver, 7, null), node, p=0;
while ((node = xPathNodes.snapshotItem(p++))) { elm.push(node); }
} catch (e) {}
return elm;
};
return DOMAssistant.cssByXpath.call(this, cssRule);
},
cssSelection : function (cssRule) {
if (!cssRule) { return null; }
var special = regex.special.test(cssRule);
try {
if (document.querySelectorAll && !special) {
return pushAll(new HTMLArray(), this.querySelectorAll(cssRule));
}
} catch (e) {}
return ((document.evaluate && !special && !/-of-type/.test(cssRule))? DOMAssistant.cssByXpath : DOMAssistant.cssByDOM).call(this, cssRule);
},
cssSelect : function (cssRule) {
return DOMAssistant.cssSelection.call(this, cssRule);
},
elmsByClass : function (className, tag) {
var cssRule = (tag || "") + "." + className;
return DOMAssistant.cssSelection.call(this, cssRule);
},
elmsByAttribute : function (attr, attrVal, tag, substrMatchSelector) {
var cssRule = (tag || "") + "[" + attr + ((attrVal && attrVal !== "*")? ((substrMatchSelector || "") + "=" + attrVal + "]") : "]");
return DOMAssistant.cssSelection.call(this, cssRule);
},
elmsByTag : function (tag) {
return DOMAssistant.cssSelection.call(this, tag);
}
};
}();
DOMAssistant.initCore();
DOMAssistant.Storage = function () {
var uniqueId = 1, data = [], expando = "_da" + +new Date();
return {
hasData : function () {
var uid = this[expando];
return !!uid && !!data[uid];
},
retrieve : function (key) {
if (!DOMAssistant.def(key)) {
return this[expando] || (this[expando] = uniqueId++);
}
if (!this[expando] || !data[this[expando]]) { return; }
return data[this[expando]][key];
},
store : function (key, val) {
var uid = this[expando] || (this[expando] = uniqueId++);
data[uid] = data[uid] || {};
if (typeof key === "object") {
for (var i in key) {
if (typeof i === "string") {
data[uid][i] = key[i];
}
}
}
else {
data[uid][key] = val;
}
return this;
},
unstore : function (key) {
var uid = this[expando] || (this[expando] = uniqueId++);
if (data[uid]) {
if (DOMAssistant.def(key)) {
delete data[uid][key];
}
else {
data[uid] = null;
}
}
return this;
}
};
}();
DOMAssistant.attach(DOMAssistant.Storage);
DOMAssistant.AJAX = function () {
var globalXMLHttp = null,
readyState = 0,
status = -1,
statusText = "",
requestPool = [],
createAjaxObj = function (url, method, callback, addToContent) {
var params = null;
if (/POST/i.test(method)) {
url = url.split("?");
params = url[1];
url = url[0];
}
return {
url : url,
method : method,
callback : callback,
params : params,
headers : {},
responseType : "text",
addToContent : addToContent || false
};
};
return {
publicMethods : [
"ajax",
"get",
"post",
"load"
],
initRequest : function () {
var XMLHttp = null;
if (!!window.XMLHttpRequest && !DOMAssistant.isIE) {
XMLHttp = new XMLHttpRequest();
DOMAssistant.AJAX.initRequest = function () {
return requestPool.length? requestPool.pop() : new XMLHttpRequest();
};
}
else if (!!window.ActiveXObject) {
var XMLHttpMS = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
for (var i=0; i<XMLHttpMS.length; i++) {
try {
XMLHttp = new window.ActiveXObject(XMLHttpMS[i]);
DOMAssistant.AJAX.initRequest = function () {
return requestPool.length? requestPool.pop() : new window.ActiveXObject(XMLHttpMS[i]);
};
break;
}
catch (e) {
XMLHttp = null;
}
}
}
return XMLHttp;
},
ajax : function (ajaxObj) {
if (!ajaxObj.noParse && ajaxObj.url && /\?/.test(ajaxObj.url) && ajaxObj.method && /POST/i.test(ajaxObj.method)) {
var url = ajaxObj.url.split("?");
ajaxObj.url = url[0];
ajaxObj.params = url[1] + ((url[1].length > 0 && ajaxObj.params)? ("&" + ajaxObj.params) : "");
}
return DOMAssistant.AJAX.makeCall.call(this, ajaxObj);
},
get : function (url, callback, addToContent) {
return DOMAssistant.AJAX.makeCall.call(this, createAjaxObj(url, "GET", callback, addToContent));
},
post : function (url, callback) {
return DOMAssistant.AJAX.makeCall.call(this, createAjaxObj(url, "POST", callback));
},
load : function (url, addToContent) {
this.get(url, DOMAssistant.AJAX.replaceWithAJAXContent, addToContent);
},
makeCall : function (ajaxObj) {
var XMLHttp = DOMAssistant.AJAX.initRequest();
if (XMLHttp) {
globalXMLHttp = XMLHttp;
(function (elm) {
var url = ajaxObj.url,
method = ajaxObj.method || "GET",
callback = ajaxObj.callback,
params = ajaxObj.params,
headers = ajaxObj.headers,
responseType = ajaxObj.responseType || "text",
addToContent = ajaxObj.addToContent,
timeout = ajaxObj.timeout || null,
ex = ajaxObj.exception,
timeoutId = null,
done = false;
XMLHttp.open(method, url, true);
XMLHttp.setRequestHeader("AJAX", "true");
XMLHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
if (method === "POST") {
XMLHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttp.setRequestHeader("Content-length", params? params.length : 0);
if (XMLHttp.overrideMimeType) {
XMLHttp.setRequestHeader("Connection", "close");
}
}
if (responseType === "json") {
XMLHttp.setRequestHeader("Accept", "application/json, text/javascript, */*");
}
for (var i in headers) {
if (typeof i === "string") {
XMLHttp.setRequestHeader(i, headers[i]);
}
}
if (typeof callback === "function") {
XMLHttp.onreadystatechange = function () {
try {
if (XMLHttp.readyState === 4 && !done) {
window.clearTimeout(timeoutId);
done = true;
status = XMLHttp.status;
statusText = XMLHttp.statusText;
readyState = 4;
if ((status || location.protocol !== "file:") && (status < 200 || status >= 300)) {
throw new Error(statusText);
}
var response = /xml/i.test(responseType)? XMLHttp.responseXML : XMLHttp.responseText;
if (/json/i.test(responseType) && !!response) {
response = (typeof JSON === "object" && typeof JSON.parse === "function")? JSON.parse(response) : eval("(" + response + ")");
}
globalXMLHttp = null;
XMLHttp.onreadystatechange = function () {};
requestPool.push(XMLHttp);
callback.call(elm, response, addToContent);
}
}
catch (e) {
globalXMLHttp = XMLHttp = null;
if (typeof ex === "function") {
ex.call(elm, e);
ex = null;
}
}
};
}
XMLHttp.send(params);
if (timeout) {
timeoutId = window.setTimeout( function () {
if (!done) {
XMLHttp.abort();
done = true;
if (typeof ex === "function") {
readyState = 0;
status = 408;
statusText = "Request timeout";
globalXMLHttp = XMLHttp = null;
ex.call(elm, new Error(statusText));
ex = null;
}
}
}, timeout);
}
})(this);
}
return this;
},
replaceWithAJAXContent : function (content, add) {
if (add) {
this.innerHTML += content;
}
else {
DOMAssistant.cleanUp(this);
this.innerHTML = content;
}
},
getReadyState : function () {
return (globalXMLHttp && DOMAssistant.def(globalXMLHttp.readyState))? globalXMLHttp.readyState : readyState;
},
getStatus : function () {
return status;
},
getStatusText : function () {
return statusText;
}
};
}();
DOMAssistant.attach(DOMAssistant.AJAX);
DOMAssistant.CSS = function () {
var def = DOMAssistant.def,
direct = { display: true };
return {
addClass : function (className) {
if (!this.hasClass(className)) {
var currentClass = this.className;
this.className = currentClass + (currentClass.length? " " : "") + className;
}
return this;
},
removeClass : function (className) {
return this.replaceClass(className);
},
replaceClass : function (className, newClass) {
var classToRemove = new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i");
this.className = this.className.replace(classToRemove, function (match, p1, p2) {
return newClass? (p1 + newClass + p2) : " ";
}).replace(/^\s+|\s+$/g, "");
return this;
},
hasClass : function (className) {
return (" " + this.className + " ").indexOf(" " + className + " ") > -1;
},
setStyle : function (style, value) {
var css = this.style;
if ("filters" in this && (typeof style === "string"? /opacity/i.test(style) : def(style.opacity))) {
css.zoom = 1;
css.filter = (css.filter || "").replace(/alpha\([^)]*\)/, "") + "alpha(opacity=" + (def(style.opacity)? style.opacity : value) * 100 + ")";
}
if (def(css.cssText)) {
var styleToSet = css.cssText;
if (typeof style === "object") {
for (var i in style) {
if (typeof i === "string") {
if (direct[i]) { css[i] = style[i]; }
styleToSet += ";" + i + ":" + style[i];
}
}
}
else {
if (direct[style]) { css[style] = value; }
styleToSet += ";" + style + ":" + value;
}
css.cssText = styleToSet;
}
return this;
},
getStyle : function (cssRule) {
var val = "", f;
cssRule = cssRule.toLowerCase();
if (window.getComputedStyle) {
val = document.defaultView.getComputedStyle(this, null).getPropertyValue(cssRule);
}
else if (this.currentStyle) {
if ("filters" in this && cssRule === "opacity") {
val = (f = this.style.filter || this.currentStyle.filter) && f.indexOf("opacity=") >= 0? parseFloat(f.match(/opacity=([^)]*)/)[1]) / 100 : 1;
}
else {
cssRule = cssRule.replace(/^float$/, "styleFloat").replace(/\-(\w)/g, function (match, p1) {
return p1.toUpperCase();
});
val = this.currentStyle[cssRule];
}
if (val === "auto" && /^(width|height)$/.test(cssRule) && this.currentStyle.display !== "none") {
val = this["offset" + cssRule.charAt(0).toUpperCase() + cssRule.substr(1)] + "px";
}
}
return val;
}
};
}();
DOMAssistant.attach(DOMAssistant.CSS);
DOMAssistant.Content = function () {
var D$ = DOMAssistant.$$;
return {
init : function () {
DOMAssistant.setCache(false);
},
create : function (name, attr, append, content) {
var elm = D$(document.createElement(name));
if (attr) {
elm = elm.setAttributes(attr);
}
if (DOMAssistant.def(content)) {
elm.addContent(content);
}
if (append) {
this.appendChild(elm);
}
return elm;
},
setAttributes : function (attr) {
if (!DOMAssistant.strictElmCreation) {
var setAttr = function (elm, att, val) {
var attLower = att.toLowerCase();
switch (attLower) {
case "name":
case "type":
case "multiple":
return D$(document.createElement(elm.outerHTML.replace(new RegExp(attLower + "(=[a-zA-Z]+)?"), " ").replace(">", " " + attLower + "=" + val + ">")));
case "style":
elm.style.cssText = val;
return elm;
default:
elm[DOMAssistant.camel[attLower] || att] = val;
return elm;
}
};
DOMAssistant.Content.setAttributes = function (attr) {
var elem = this;
var parent = this.parentNode;
for (var i in attr) {
if (typeof attr[i] === "string" || typeof attr[i] === "number") {
var newElem = setAttr(elem, i, attr[i]);
if (parent && /(name|type)/i.test(i)) {
if (elem.innerHTML) {
newElem.innerHTML = elem.innerHTML;
}
parent.replaceChild(newElem, elem);
}
elem = newElem;
}
}
return elem;
};
}
else {
DOMAssistant.Content.setAttributes = function (attr) {
for (var i in attr) {
if (/class/i.test(i)) {
this.className = attr[i];
}
else {
this.setAttribute(i, attr[i]);
}
}
return this;
};
}
return DOMAssistant.Content.setAttributes.call(this, attr);
},
addContent : function (content) {
var type = typeof content;
if (type === "string" || type === "number") {
if (!this.firstChild) {
this.innerHTML = content;
}
else {
var tmp = document.createElement("div");
tmp.innerHTML = content;
for (var i=tmp.childNodes.length-1, last=null; i>=0; i--) {
last = this.insertBefore(tmp.childNodes[i], last);
}
}
}
else if (type === "object" || (type === "function" && !!content.nodeName)) {
this.appendChild(content);
}
return this;
},
replaceContent : function (content) {
DOMAssistant.cleanUp(this);
return this.addContent(content);
},
replace : function (content, returnNew) {
var type = typeof content;
if (type === "string" || type === "number") {
var parent = this.parentNode;
var tmp = DOMAssistant.Content.create.call(parent, "div", null, false, content);
for (var i=tmp.childNodes.length; i--;) {
parent.insertBefore(tmp.childNodes[i], this.nextSibling);
}
content = this.nextSibling;
parent.removeChild(this);
}
else if (type === "object" || (type === "function" && !!content.nodeName)) {
this.parentNode.replaceChild(content, this);
}
return returnNew? content : this;
},
remove : function () {
DOMAssistant.cleanUp(this);
if (this.hasData()) {
if (this.removeEvent) { this.removeEvent(); }
this.unstore();
}
this.parentNode.removeChild(this);
return null;
}
};
}();
DOMAssistant.attach(DOMAssistant.Content);
DOMAssistant.Events = function () {
var handler,
key = "_events",
w3cMode = !!document.addEventListener,
useCapture = { focus: true, blur: true },
translate = DOMAssistant.isIE? { focus: "activate", blur: "deactivate", mouseenter: "mouseover", mouseleave: "mouseout" } : { mouseenter: "mouseover", mouseleave: "mouseout" },
regex = {
special: /^submit|reset|change|select$/i,
mouseenterleave: /^mouse(enter|leave)$/i,
dom: /^DOM/,
on: /^on/i
},
isBubble = function (e) {
// Test for event bubbling
e = 'on' + e;
var el = document.createElement('div');
el.setAttribute(e, '');
return (typeof el[e] === 'function');
},
special = function (e) {
return regex.special.test(e) && !isBubble(e);
},
fix = function (e) {
return translate[e] || e;
},
createEvent = function (e, type, target) {
e = e || window.event || {};
if (e.event) { return e; }
var event = {
event: e,
type: type || e.type,
bubbles: e.bubbles || true,
cancelable: e.cancelable || false,
target: target || e.target || e.srcElement,
clientX: e.clientX || 0,
clientY: e.clientY || 0,
altKey: e.altKey || false,
ctrlKey: e.ctrlKey || false,
shiftKey: e.shiftKey || false,
button: e.button || null,
timeStamp: +new Date(),
preventDefault: function() {
if (e.preventDefault) { e.preventDefault(); }
this.returnValue = e.returnValue = false;
},
stopPropagation: function() {
if (e.stopPropagation) { e.stopPropagation(); }
this.cancelBubble = e.cancelBubble = true;
}
};
if (event.target && 3 === event.target.nodeType) { // Safari textnode bug
event.target = event.target.parentNode;
}
event.currentTarget = event.target;
event.relatedTarget = e.relatedTarget || (e.fromElement === event.target? e.toElement : e.fromElement) || null;
var de = document.documentElement, b = document.body;
event.pageX = DOMAssistant.def(e.pageX)? e.pageX : (event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0));
event.pageY = DOMAssistant.def(e.pageY)? e.pageY : (event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0));
if ("number" === typeof e.which) {
event.keyCode = e.keyCode;
event.charCode = event.which = e.which;
}
else if (e.keyCode) {
event.keyCode = event.charCode = e.keyCode;
}
return event;
};
return {
publicMethods : [
"triggerEvent",
"addEvent",
"removeEvent",
"relayEvent",
"unrelayEvent",
"preventDefault",
"cancelBubble"
],
init : function () {
DOMAssistant.preventDefault = this.preventDefault;
DOMAssistant.cancelBubble = this.cancelBubble;
handler = this.handleEvent;
},
triggerEvent : function (evt, target, e) {
var fevt = fix(evt),
events = this.retrieve(key),
event = e || createEvent(e, fevt, target || this);
event.currentTarget = this;
if (events && events[fevt]) {
for (var i=0, iL=events[fevt].length; i<iL; i++) {
if (events[fevt][i].call(this, event) === false) { event.stopPropagation(); }
}
}
else if (typeof this["on" + fevt] === "function") {
this["on" + fevt].call(this, event);
}
var p = DOMAssistant.$$(this.parentNode);
if (!event.cancelBubble && p && p.nodeType === 1) {
p.triggerEvent(fevt, target, event);
}
return this;
},
addEvent : function (evt, func, relay, proxy, selector) {
var existingEvent,
fevt = fix(evt),
uid = fevt + this.retrieve(),
onevt = "on" + fevt;
if (!(func.attachedElements && func.attachedElements[uid])) {
var events = this.retrieve(key) || {};
if (!events[fevt]) {
events[fevt] = [];
existingEvent = this[onevt];
this[onevt] = null;
}
if (typeof this.window === "object") { this.window[onevt] = handler; }
else if (!events[fevt].length) {
if (w3cMode) { this.addEventListener(fevt, handler, useCapture[fevt]); }
else { this[onevt] = handler; }
}
if (existingEvent) {
events[fevt].push(existingEvent);
}
if (fevt !== evt) { func.evt = evt; }
func.relay = relay;
func.proxy = proxy;
func.selector = selector;
func.attachedElements = func.attachedElements || {};
func.attachedElements[uid] = true;
events[fevt].push(func);
this.store(key, events);
}
return this;
},
handleEvent : function (evt) {
var currentEvt = (evt && regex.dom.test(evt.type) && w3cMode)? evt : createEvent(evt),
type = fix(currentEvt.type),
targ = currentEvt.target,
relatedTarg = currentEvt.relatedTarget,
eventColl = this.retrieve(key)[type].slice(0), eventCollLength, eventReturn, oevt;
if ((eventCollLength = eventColl.length)) {
for (var i=0; i<eventCollLength; i++) {
if (typeof eventColl[i] === "function") {
if ((oevt = eventColl[i].evt) && oevt !== type) {
currentEvt.type = oevt;
if (relatedTarg && regex.mouseenterleave.test(oevt)) {
if (eventColl[i].relay) {
var elms = eventColl[i].elms || (eventColl[i].elms = this.cssSelect(eventColl[i].selector));
if (elms.indexOf(targ) < 0 || !DOMAssistant.hasChild.call(relatedTarg, targ)) { continue; }
}
else if (this === relatedTarg || this.hasChild(relatedTarg)) { continue; }
}
}
eventReturn = eventColl[i].call(this, currentEvt);
}
}
if (eventReturn === false) { currentEvt.stopPropagation(); }
return eventReturn;
}
},
removeEvent : function (evt, func, relay, proxy) {
var uid = (evt = fix(evt)) + this.retrieve(),
events = this.retrieve(key),
onevt = "on" + evt;
if (events && !evt) {
for (var ev in events) {
if (events[ev].length) { this.removeEvent(ev); }
}
var attr = this.attributes;
for (var att, j=attr.length; j--;) {
att = attr[j].nodeName.toLowerCase();
if (regex.on.test(att) && typeof this[att] === "function") {
this[att] = null;
}
}
}
else if (events && events[evt]) {
var eventColl = events[evt];
for (var fn, i=eventColl.length; i--;) {
fn = func || eventColl[i];
if (eventColl[i] === fn && relay === fn.relay && proxy === fn.proxy) {
eventColl.splice(i, 1);
if (!!proxy && fn.selector) {
this.cssSelect(fn.selector).removeEvent(proxy);
}
if (fn.attachedElements) {
fn.attachedElements[uid] = null;
}
}
}
if (!events[evt].length) {
if (w3cMode) { this.removeEventListener(evt, handler, useCapture[evt]); }
else { this[onevt] = null; }
}
}
else if (this[onevt] && !func && !relay) {
this[onevt] = null;
}
return this;
},
relayEvent: function (evt, selector, fn, proxy) {
if (special(evt)) {
this.relayEvent("focus", selector, function() {
DOMAssistant.$$(this).removeEvent(evt).addEvent(evt, function(e) {
return fn.call(this, createEvent(e));
});
}, evt).relayEvent("blur", selector, function() {
DOMAssistant.$$(this).removeEvent(evt);
}, evt);
return this;
}
return this.addEvent(evt, function(e) {
e = createEvent(e);
var target = e.target, args = arguments, i = 0, elm, elms = this.cssSelect(selector);
while ((elm = elms[i++])) {
if ((elm === target || DOMAssistant.hasChild.call(elm, target)) && !elm.disabled) {
e.currentTarget = elm;
var retVal = fn.apply(elm, args);
if (!retVal) { e.preventDefault(); }
return retVal;
}
}
}, true, proxy, selector);
},
unrelayEvent: function (evt) {
if (special(evt)) {
return this.removeEvent("focus", null, true, evt).removeEvent("blur", null, true, evt);
}
return this.removeEvent(evt, null, true);
},
preventDefault : function (evt) {
if (evt.preventDefault) { evt.preventDefault(); }
evt.returnValue = false;
},
cancelBubble : function (evt) {
if (evt.stopPropagation) { evt.stopPropagation(); }
evt.cancelBubble = true;
}
};
}();
DOMAssistant.attach(DOMAssistant.Events);
DOMAssistant.DOMLoad = function () {
var DOMLoaded = false,
DOMLoadTimer = null,
functionsToCall = [],
addedStrings = {},
errorHandling = null,
execFunctions = function () {
for (var i=0, il=functionsToCall.length; i<il; i++) {
try {
functionsToCall[i]();
}
catch (e) {
if (errorHandling && typeof errorHandling === "function") {
errorHandling(e);
}
}
}
functionsToCall = [];
},
DOMHasLoaded = function () {
if (DOMLoaded) {
return;
}
DOMLoaded = true;
execFunctions();
};
/* Internet Explorer */
/*@cc_on
@if (@_win32 || @_win64)
document.write("<script id=\"ieScriptLoad\" defer src=\"//:\"><\/script>");
document.getElementById("ieScriptLoad").onreadystatechange = function() {
if (this.readyState === "complete") {
DOMHasLoaded();
}
};
@end @*/
/* Mozilla, Chrome, Opera */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", DOMHasLoaded, false);
}
/* Safari, iCab, Konqueror */
if (/KHTML|WebKit|iCab/i.test(navigator.userAgent)) {
DOMLoadTimer = setInterval(function () {
if (/loaded|complete/i.test(document.readyState)) {
DOMHasLoaded();
clearInterval(DOMLoadTimer);
}
}, 10);
}
/* Other web browsers */
window.onload = DOMHasLoaded;
return {
DOMReady : function () {
for (var i=0, il=arguments.length, funcRef; i<il; i++) {
funcRef = arguments[i];
if (!funcRef.DOMReady && !addedStrings[funcRef]) {
if (typeof funcRef === "string") {
addedStrings[funcRef] = true;
funcRef = new Function(funcRef);
}
funcRef.DOMReady = true;
functionsToCall.push(funcRef);
}
}
if (DOMLoaded) {
execFunctions();
}
},
setErrorHandling : function (funcRef) {
errorHandling = funcRef;
}
};
}();
DOMAssistant.DOMReady = DOMAssistant.DOMLoad.DOMReady; | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/libs/domassistant.js | JavaScript | gpl2 | 52,029 |
/*!
PURE Unobtrusive Rendering Engine for HTML
Dual licensed under GPL Version 2 or the MIT licenses
More information at: http://www.opensource.org
Copyright (c) 2012 Michael Cvilic - BeeBole.com
revision: 3.*
*/
var $p, pure = $p = function(){
var sel = arguments[0],
doc = false;
if(typeof sel === 'string'){
doc = arguments[1] || false;
}else if(sel && !sel[0] && !sel.length){
sel = [sel];
}
return new $p.core(sel, doc);
};
$p.core = function(sel, doc, plugins){
//default find method
var selRx = /^(\+)?([^\@\+]+)?\@?([^\+]+)?(\+)?$/,
// check if the argument is an array - thanks salty-horse (Ori Avtalion)
isArray = Array.isArray ?
function(o) {
return Array.isArray(o);
} :
function(o) {
return Object.prototype.toString.call(o) === "[object Array]";
},
find = function(n, sel){
//a node set is passed
if(typeof sel !== 'string'){
return sel;
}
if(typeof n === 'string'){
sel = n;
n = false;
}
if(typeof document.querySelectorAll !== 'undefined'){
return (n||document).querySelectorAll( sel );
}else{
return error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine');
}
},
// error utility
error = function(e){
if(typeof console !== 'undefined'){
console.log(e);
debugger;
}
throw('pure error: ' + e);
},
//find all nodes for the selector
targets = find(doc || document, sel),
i = this.length = targets.length,
ctxt;
//fill an array of the nodes attachted to $p
while(i--){
this[i] = targets[i];
}
this.compile = function(directive){
var root = this[0],
selector,
actions = [],
parseLoopSpec = function(p){
var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
if(m === null){
error('"' + p + '" must have the format loopItem<-loopArray');
}
if(m[1] === 'item'){
error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
}
if( !m[2] || (m[2] && (/context/i).test(m[2]))){ //undefined or space(IE)
m[2] = function(data){return data.context;};
}
return {itemName: m[1], arrayName: m[2]};
},
getLoopDef = function(directive){
var loopProp,
already = false,
loopDef = {/*
filter, sort, loopSpec, directive
*/};
for(loopString in directive){
switch(loopString){
case 'filter':
loopDef.filter = directive[ loopString ];
break;
case 'sort':
loopDef.sorter = directive[ loopString ];
break;
default:
if( already ){
error( 'cannot have a second loop declared for the same node:' + loopString );
}
loopDef.loopSpec = parseLoopSpec( loopString );
if( loopDef.loopSpec ){
loopDef.directive = directive[ loopString ];
}
already = true;
}
}
return loopDef;
},
readData = function(path, data){
var m = path.split('.'),
v = data[m[0]],
i = 0;
if(v && v.item){
i += 1;
if(m[i] === 'pos'){
//allow pos to be kept by string. Tx to Adam Freidin
return v.pos;
}else{
data = v.item;
}
}
var n = m.length;
for(; i < n; i++){
if(!data){break;}
data = data[m[i]];
}
return (!data && data !== 0) ? '' : data;
},
getAction = function(node, selSpec, actionSpec){
var isStyle, isClass, attName, attSet, get, set, init;
if(selSpec.attr){
isStyle = (/^style$/i).test( selSpec.attr );
isClass = (/^class$/i).test( selSpec.attr );
attName = isClass ? 'className' : selSpec.attr;
attSet = function(node, s) {
if(!s && s !== 0){
if (attName in node && !isStyle) {
try{
node[attName] = ''; //needed for IE to properly remove some attributes
}catch(e){} //FF4 gives an error sometimes -> try/catch
}
//no more nodeType check since
node.removeAttribute( attName );
}else{
node.setAttribute( attName, s );
}
};
if ( isStyle ) { //IE
get = function(n){
return n.style.cssText;
};
}else if ( isClass ) { //IE
get = function( n ){
return n.className;
};
}else {
get = function(n){
return n.getAttribute( selSpec.attr );
};
}
if(selSpec.prepend){
init = get( node ) || '';
set = function(s){
attSet( node, s + init );
};
}else if(selSpec.append){
init = get( node ) || '';
set = function(s){
attSet( node, init + s );
};
}else{
set = function(s){
attSet( node, s );
};
}
}else{
if (selSpec.prepend) {
set = function(s) { node.insertBefore( document.createTextNode(s), node.firstChild ); };
} else if (selSpec.append) {
set = function(s) { node.appendChild( document.createTextNode(s) );};
} else {
set = function(s) {
while (node.firstChild) { node.removeChild(node.firstChild); }
node.appendChild( document.createTextNode(s) );
};
}
}
return function(data){
set( ( '' + readData( actionSpec, data ) ) || actionSpec );
};
},
forEachTarget = function(sel, directive, doFn){
var sels = sel.split(/\s*,\s*/), //allow selector separation by quotes
m,
selSpec,
i = sels.length;
while(i--){
m = sels[i].match(selRx);
if( !m ){
error( 'bad selector syntax: ' + sel );
}
selSpec = {
prepend: m[1],
selector: m[2],
attr: m[3],
append: m[4]
};
doFn(directive, root, selSpec);
}
},
loopNode = function(node, directive){
var loopDef = getLoopDef( directive ),
dfrag = document.createDocumentFragment(),
arr = [],
templateNode = node.cloneNode(true),
parentNode = node.parentNode,
compiled = $p( templateNode ).compile( loopDef.directive );
return function(data){
var items = readData( loopDef.loopSpec.arrayName, data ),
il = items.length,
newNode,
al = arr.length,
tempCtxt = { context:ctxt },
loopCtxt = tempCtxt[ loopDef.loopSpec.itemName ] = {},
innerLoop = function(dfrag, tempCtxt, loopCtxt, item, node, pos){
//for each entry prepare the parameters for function directives, and sub templates
tempCtxt.item = loopCtxt.item = item;
tempCtxt.node = loopCtxt.node = node;
tempCtxt.pos = loopCtxt.pos = pos;
//call the compiled template on item context, and return the resulting node
return dfrag.appendChild( compiled( tempCtxt ).cloneNode(true) );
},
pos = 0;
/* //clean the target if nested loops
while(al > 1 && al--){
parentNode.removeChild(arr[al]);
}
if(al > 0){
node = templateNode.cloneNode(true);
parentNode.replaceChild(node, arr[0]);
}*/
tempCtxt.items = loopCtxt.items = items;
if( isArray(items) ){
for( ; pos < il; pos++ ){
arr.push( innerLoop(dfrag, tempCtxt, loopCtxt, items[pos], node, pos) );
}
}else{
for(pos in items){
arr.push( innerLoop(dfrag, tempCtxt, loopCtxt, items[pos], node, pos) );
}
}
//insert the loop elements in the fresh loop template
parentNode.replaceChild( dfrag, node );
};
},
setTarget = function( actionSpec, root, selSpec ){
var nodes = selSpec.selector && selSpec.selector !== '.' ? find( root, selSpec.selector ) : [root],
i = -1,
l = nodes.length;
if(l === 0){
error( 'The selector "' + selSpec.selector + '" didn\'t match any node in:\n' + ( root.outerHTML || (root.tagName + root.className) ) );
}
while(++i < l){
if(typeof actionSpec === 'object'){
//loop
actions.push( loopNode( nodes[i], actionSpec ) );
}else{
//node value or attribute
actions.push( getAction(nodes[i], selSpec, actionSpec ) );
}
}
};
for( selector in directive ){
forEachTarget( selector, directive[ selector ], setTarget );
}
return function(data){
ctxt = ctxt || data;
var i = -1, l = actions.length;
while( ++i < l ){
actions[i](data);
}
return root;
};
};
this.render = function(data, directive){
var i = -1, l = this.length,
compiled = typeof directive === 'function' ? directive : this.compile(directive);
while( ++i < l ){
this[i] = compiled(data);
}
return this;
};
return this;
}; | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/v3_preview/pure3.js | JavaScript | gpl2 | 8,532 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="pure3.js"></script>
</head>
<body>
<!-- HTML template -->
It took:<span id="duration"></span>
<ul class="template">
<!--img /-->
<li class="people">
<span class="name"></span>
<ul>
<!--li class="winner">
<a class="name"></a>
</li-->
<li class="team">
<a class="name"></a>
</li>
</ul>
</li>
</ul>
<script>
function callback(json){
var start = new Date().getTime();
//declaration of the actions PURE has to do
var directive = {
//'img@src':'http://farm8.staticflickr.com/7175/6470586439_11461583a7_s.jpg',
/*'img@src':function(){
return 'http://farm8.staticflickr.com/7175/6470586439_11461583a7_s.jpg';
},*/
//'img@src':'',
'li.people':{
'person<-people':{
// 'span.name':'person.name',
'li.team':{
'teamMember<-person.team':{
'a.name':'teamMember.name',
'a.name@href+':'teamMember.id'
}
}/*,
'li.winner':{
'winner<-winners':{
'a.name':'winner.name',
'a.name@href+':'winner.id'
}
}*/
}
}/*,
'img@src':'http://farm8.staticflickr.com/7175/6470586439_11461583a7_s.jpg'*/
};
/* var compiled = $p( 'ul.template' ).compile( directive );
console.log( compiled( json ).outerHTML );*/
$p('ul.template').render( json, directive );
document.getElementById('duration').innerHTML = ( new Date().getTime() - start ) + 'ms for ' + json.people.length + ' records';
}
</script>
<script src="data.js"></script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/v3_preview/pure3.html | HTML | gpl2 | 1,582 |
callback({
winners:[
{name:'winner 1'},{name:'winner 2'}
],
people:[
{name:"Susan Braunhardt", id:1, team:[
{name:"Kristen Characklis", id:425},
{name:"Jane Tatum", id:426}/*,
{name:"Kelly Gonzalez", id:427},
{name:"Deanne Feldman", id:428},
{name:"Greg Harrigan", id:429},
{name:"Jack Lacy", id:430},
{name:"Shaun Currie", id:431},
{name:"Peter Glaze", id:432},
{name:"Sam Reiten", id:433}*/
]},
{name:"Duane Freymann", id:6, team:[
{name:"Marc O'Brien", id:458}/*,
{name:"Duane Millam", id:459},
{name:"Jennifer Lee", id:460},
{name:"Alex Bloomfield", id:461},
{name:"Jennifer Bolton", id:462},
{name:"Larry Moss", id:463}*/
]}/*,
{name:"Denny Puckett", id:2},
{name:"Thomas Seay", id:3},
{name:"Joel Ruhlin", id:4},
{name:"Dorothy Nugent", id:5},
{name:"Aaron Daugherty", id:7},
{name:"Ross Gomez", id:8},
{name:"Tatiana Goff", id:9},
{name:"Susan Kargatis", id:10, team:[
{name:"Alan Ball", id:479},
{name:"Sharon Reiter", id:480},
{name:"Lauren Twedell", id:481},
{name:"Corey Lichtenstein", id:482},
{name:"Kathryn Talwar", id:483},
{name:"Alyssa Daugherty", id:484},
{name:"Tim Barrera", id:485},
{name:"Sheri Harris", id:486},
{name:"Toby Applegate", id:487},
{name:"Philip Buck", id:488},
{name:"Gordon Dana", id:489}
]},
{name:"Tamara Phelps", id:11},
{name:"Carol Goldwyn", id:12},
{name:"Eileen Cromwell", id:13},
{name:"Mark Ross", id:14},
{name:"Kristine Leinenbach", id:15},
{name:"Susan Dakoulas", id:16},
{name:"Rebecca Loughridge", id:17},
{name:"Peter Zitterkopf", id:18, team:[
{name:"Brian Nielsen", id:324},
{name:"Nathan Eaton", id:325},
{name:"Melissa Sharp", id:326},
{name:"Ben Shisler", id:327},
{name:"George Mackey", id:328},
{name:"Logan Ball", id:329},
{name:"Valerie Cooper", id:330},
{name:"Veronica Juette", id:331},
{name:"Craig Doherty", id:332},
{name:"Aaron Terk", id:333},
{name:"Erica Harper", id:334},
{name:"Nina Schafer", id:335},
{name:"Katrina Hagen", id:336},
{name:"Crystal Reese", id:337},
{name:"Theresa Joy", id:338},
{name:"David Mutchler", id:339},
{name:"Alyssa Elias", id:340},
{name:"Denny Crestani", id:341},
{name:"Caroline O'Connell", id:342}
]},
{name:"Christy Averitt", id:19},
{name:"Scott Luxemburg", id:20},
{name:"Sara Kasper", id:21},
{name:"Brenda Gattis", id:22},
{name:"Andrea Lopez-Bassols", id:23},
{name:"Katrina Stuckey", id:24},
{name:"Eric Carreira", id:25},
{name:"Clay Ledman", id:26},
{name:"Aleksandra Nelson", id:27, team:[{name:"Veronica Juette", id:331},
{name:"Craig Doherty", id:332},
{name:"Aaron Terk", id:333},
{name:"Erica Harper", id:334},
{name:"Nina Schafer", id:335},
{name:"Katrina Hagen", id:336},
{name:"Crystal Reese", id:337},
{name:"Theresa Joy", id:338},
{name:"David Mutchler", id:339}
]},
{name:"Laurie Herbert", id:28},
{name:"Sheri Sims", id:29},
{name:"Aleksandra Honeyman", id:30},
{name:"Scott Foster", id:31},
{name:"Angel Bickford", id:32},
{name:"Alan McNally", id:33},
{name:"Deanne Bruce", id:34},
{name:"Nancy Brockman", id:35},
{name:"Monica Peck", id:36},
{name:"George Sweed", id:37},
{name:"John Dawkins", id:38},
{name:"Patrick Murry", id:39},
{name:"Nancy Morse", id:40},
{name:"Renee Devitt", id:41},
{name:"Frank Grisham", id:42},
{name:"Katharine Magee", id:43},
{name:"Adrian Whitley", id:44},
{name:"Harry Noonan", id:45},
{name:"Scot Paige", id:46},
{name:"Sandra Kamine", id:47},
{name:"Jamie McAfee", id:48},
{name:"Marina House", id:49},
{name:"Daniel Rozendal", id:50},
{name:"Veronica Fargason", id:51},
{name:"Laurel Kamen", id:52},
{name:"Jim Philip", id:53},
{name:"Amy Thomson", id:54},
{name:"Erica Baptist-Nguyen", id:55},
{name:"Theresa Cort", id:56},
{name:"Stephanie Boucher", id:57},
{name:"Katharine Szafranski", id:58},
{name:"Aaron Ausman", id:59},
{name:"Melanie Rosenberg", id:60},
{name:"Angela Close", id:61},
{name:"Janice Schaefer", id:62},
{name:"Sandra Elizabeth", id:63},
{name:"Danielle Kabir", id:64},
{name:"Kara Bixby", id:65},
{name:"Katrina Herman", id:66},
{name:"Dean Rhinehart", id:67},
{name:"Eileen Shaw", id:68},
{name:"Stewart Bailliet", id:69},
{name:"Jason Hood", id:70},
{name:"Jay Thompson", id:71},
{name:"Carlos Martinez", id:72},
{name:"Pamela Schafer", id:73},
{name:"Alex Sabry", id:74},
{name:"Renee Byrd", id:75},
{name:"Clay Nelson", id:76},
{name:"Christopher Lichtenstein", id:77},
{name:"Christina Lomonaco", id:78},
{name:"Tara Fisher", id:79},
{name:"Beatrice Monk", id:80},
{name:"Peter Shidle", id:81},
{name:"Lisa Calhoun", id:82},
{name:"Melanie Nichols", id:83},
{name:"Rachel Reynolds", id:84},
{name:"Lauren Gross", id:85},
{name:"Patricia Dettweiler", id:86},
{name:"Phillip Fawcett", id:87},
{name:"Kevin Young", id:88},
{name:"Charlotte Nelson", id:89},
{name:"Wade Kasper", id:90},
{name:"Art Prischmann", id:91},
{name:"Dean Magee", id:92},
{name:"Kevin Hamilton", id:93},
{name:"Andrew Tran", id:94},
{name:"Melissa Drescher", id:95},
{name:"Chrissy Rosenberg", id:96},
{name:"Rod Holland", id:97},
{name:"Gary Dickinson", id:98},
{name:"Alicia Folk", id:99},
{name:"Derek Pound", id:100},
{name:"Kathleen Wardle", id:101},
{name:"Craig DeMuth", id:102, team:[
{name:"Christina Nathan", id:26},
{name:"William Mullet", id:27},
{name:"Todd Simpson", id:28},
{name:"Sara Gonzalez", id:29},
{name:"Gordon Pistole", id:30},
{name:"Keith MacAllister", id:31},
{name:"Helen Arbore", id:32},
{name:"Sandra Karlin", id:33},
{name:"Dana Hansen", id:34},
{name:"Charles Marie", id:35},
{name:"Sharon Barkauskas", id:36},
{name:"Alyssa Glotzbach", id:37},
{name:"Dianne Fossati", id:38},
{name:"Allen McCrary", id:39},
{name:"Brett Francis", id:40}
]},
{name:"Vicky Arntzen", id:103},
{name:"Kathryn Milstead", id:104},
{name:"Brenda Overcash", id:105},
{name:"Stuart Manthos", id:106},
{name:"Carlos Ferguson", id:107},
{name:"Christine Murphey", id:108},
{name:"Lisa Dodson", id:109},
{name:"Adam Solon", id:110},
{name:"Chris Blanton", id:111},
{name:"Toby Bruce", id:112},
{name:"Derek Howard", id:113},
{name:"Brett McGuire", id:114},
{name:"Dan Boyes", id:115},
{name:"Bradley Diamond", id:116},
{name:"Brooke Loren", id:117},
{name:"Denise Etezadi", id:118},
{name:"Perry Holder", id:119},
{name:"Bill Brantley", id:120},
{name:"Jamie Jarrell", id:121},
{name:"Sharon Grinstein", id:122},
{name:"Chad Platzek", id:123},
{name:"Julia Sunshine", id:124},
{name:"Katrina Dakoulas", id:125},
{name:"Bill DeMuth", id:126},
{name:"Thomas Ziegler", id:127},
{name:"Jeffrey Galeazzi", id:128},
{name:"Christina Haushalter", id:129},
{name:"Tom Kirby", id:130},
{name:"Joanna Barcio", id:131},
{name:"Ann Shidle", id:132},
{name:"Arthur Brantley", id:133},
{name:"Tiffany Callahan", id:134},
{name:"Terri Chern", id:135},
{name:"Heather Luxemburg", id:136},
{name:"Wendy Moss", id:137},
{name:"Wendy Fuentes", id:138},
{name:"Maya Diamond", id:139},
{name:"Kristina Hane", id:140},
{name:"Patrick Hancock", id:141},
{name:"Benjamin Block", id:142},
{name:"Alex Rogers", id:143},
{name:"Stewart Conte", id:144},
{name:"Bryan Dawkins", id:145},
{name:"Aleksandra Szafranski", id:146},
{name:"Brian Terk", id:147},
{name:"Sam Dunham", id:148},
{name:"Brooke Priour", id:149},
{name:"Betty Estades", id:150},
{name:"Dennis Keleher", id:151},
{name:"Stefanie Christensen", id:152},
{name:"Edward Schneider", id:153},
{name:"Tara Barton", id:154},
{name:"Maya Harper", id:155},
{name:"Todd Murry", id:156},
{name:"Gary Dilbeck", id:157},
{name:"Marc Scheer", id:158},
{name:"Martha Stevens", id:159},
{name:"Betty Dortch", id:160},
{name:"Brooke Tilley", id:161},
{name:"Natalie Jumper", id:162},
{name:"Christen Bray", id:163},
{name:"Carol Banks", id:164},
{name:"Marie Massey", id:165},
{name:"Roger Sultan", id:166},
{name:"Denise Hoffmann", id:167},
{name:"David Sachs", id:168},
{name:"Gene Luxemburg", id:169},
{name:"Chris Rhinehart", id:170},
{name:"Joanna Rogers", id:171},
{name:"Cara Philippe", id:172},
{name:"Sheri Crowder", id:173},
{name:"Brad Gilyot", id:174},
{name:"Cassandra Bradley", id:175},
{name:"Russell Mullins", id:176},
{name:"Danielle Caffrey", id:177},
{name:"Brooke Wright", id:178},
{name:"Courtney Lopez-Bassols", id:179},
{name:"Linda Schneider", id:180},
{name:"Crystal Kearsley", id:181},
{name:"Carolyn York", id:182},
{name:"Justin Southworth", id:183},
{name:"Phillip Zettner", id:184},
{name:"Katrina Tyree", id:185},
{name:"Ricardo King", id:186},
{name:"Kristine Adler", id:187},
{name:"Julia Greenwood", id:188},
{name:"Christopher Stobb", id:189},
{name:"Ann Reichenbach", id:190},
{name:"Tracy Marrow", id:191},
{name:"Caroline Federle", id:192},
{name:"George Hutchinson", id:193},
{name:"Betty Nederveld", id:194},
{name:"Caren Wilburn", id:195},
{name:"Keith Hackney", id:196},
{name:"Nathan LeGrand", id:197},
{name:"Mary Stepp", id:198},
{name:"Jane Steele", id:199},
{name:"Ryan Christensen", id:200},
{name:"Nat Spudich", id:201},
{name:"Alex McAlexander", id:202},
{name:"Dennis Harton", id:203},
{name:"Dorothy DeVincentis", id:204},
{name:"Elena Birdwell", id:205},
{name:"Kristina Kirkland", id:206},
{name:"Anna Ferguson", id:207},
{name:"Dianne Carey", id:208},
{name:"Marcia Klamczynski", id:209},
{name:"Toby Bickford", id:210},
{name:"Sharon Bertelson", id:211},
{name:"Suzanne Greer", id:212},
{name:"Renee Glenn", id:213},
{name:"Marina Cyprus", id:214},
{name:"Carrie Jaramillo", id:215},
{name:"Caren Maddox", id:216},
{name:"Shaun Horne", id:217},
{name:"Joe Farry", id:218},
{name:"Edward Braden", id:219},
{name:"Wayne Reitmeier", id:220},
{name:"Troy Eisbach", id:221},
{name:"Suzanne Kaydos", id:222},
{name:"Annie Sweed", id:223},
{name:"Tim Mebane", id:224},
{name:"Lauren Moyer", id:225},
{name:"Dana Chance", id:226},
{name:"Stuart McMahon", id:227},
{name:"Scot Varman", id:228},
{name:"Nathan Elliston", id:229},
{name:"Lori McGoldrick", id:230},
{name:"Stephanie Kirby", id:231},
{name:"Vicky Fletcher", id:232},
{name:"Gene Arntzen", id:233},
{name:"Jim Book", id:234},
{name:"Danielle Raglin", id:235},
{name:"Valerie Arenson", id:236},
{name:"Laurel Braunhardt", id:237},
{name:"Brian Brauner", id:238},
{name:"Joanna Shidle", id:239},
{name:"Cassandra Tyree", id:240},
{name:"Jonathan Leslie", id:241},
{name:"Clay Blankinship", id:242},
{name:"Nat Dabak", id:243},
{name:"Justin Trevas", id:244},
{name:"Lauren Jarboe", id:245},
{name:"Christine Manning", id:246},
{name:"Deanne Rawles", id:247},
{name:"Laurie Lichtenstein", id:248},
{name:"Monica Coyne", id:249},
{name:"Tom Kaydos", id:250},
{name:"Aleksandra Mallinson", id:251},
{name:"Peter Hernandez", id:252},
{name:"Maya Weien", id:253},
{name:"Larry Norris", id:254},
{name:"Sonia Thornton", id:255},
{name:"Barbara Athanas", id:256},
{name:"Scot Shidle", id:257},
{name:"Kevin Dorsey", id:258},
{name:"Gene Barkauskas", id:259},
{name:"Shirley Patton", id:260},
{name:"Katherine Mullet", id:261},
{name:"Sheri Kauffman", id:262},
{name:"Duane Klein", id:263},
{name:"Monica Braby", id:264},
{name:"Maria Odegard", id:265},
{name:"Anna Andreou", id:266},
{name:"Ricardo Kane", id:267},
{name:"Jeff Wendt", id:268},
{name:"Caroline Shifley", id:269},
{name:"Denny Roth", id:270},
{name:"Carlos Schoppe", id:271},
{name:"Edward Baggerly", id:272},
{name:"Jeff Weimer", id:273},
{name:"Laurie Stubbers", id:274},
{name:"Vivian Baer", id:275},
{name:"Margaret Tatum", id:276},
{name:"Ben Murray", id:277},
{name:"Monica Warnes", id:278},
{name:"Randy Parham", id:279},
{name:"Dan Merwin", id:280},
{name:"David LaWare", id:281},
{name:"Wendy Spencer", id:282},
{name:"Courtney Poirier", id:283},
{name:"Marina Hendricks", id:284},
{name:"Sean Gerbino", id:285},
{name:"Catherine Bolding", id:286},
{name:"Randy Conway", id:287},
{name:"Alex Thomas", id:288},
{name:"Lori Cox", id:289},
{name:"Tara Syzdek", id:290},
{name:"Frank Harton", id:291},
{name:"Keith Weinheimer", id:292},
{name:"Erin Glenn", id:293},
{name:"Bart Buck", id:294},
{name:"Steven Kastensmidt", id:295},
{name:"Andrea Moss", id:296},
{name:"Nathan Aleman", id:297},
{name:"Tim Reynolds", id:298},
{name:"Mary Dooley", id:299},
{name:"Chad Van", id:300},
{name:"Katherine Griffin", id:301},
{name:"Candace Walton", id:302},
{name:"Nathan Atkinson", id:303},
{name:"Rob Luers", id:304},
{name:"Marie Wright", id:305},
{name:"Nancy Danenhauer", id:306},
{name:"Wendy Caffrey", id:307},
{name:"Joanna Yen", id:308},
{name:"Tatiana Rodriguez", id:309},
{name:"Adrian Garneau", id:310},
{name:"Walter Minyard", id:311},
{name:"Courtney Kirby", id:312},
{name:"Gina Meade", id:313},
{name:"Anthony Barchas", id:314},
{name:"Don Carswell", id:315},
{name:"Stewart Hunter", id:316},
{name:"Beth Goffin", id:317},
{name:"Ross Tanner", id:318},
{name:"Barry Blackmon", id:319},
{name:"Tiffany Schaefer", id:320},
{name:"Bruce Nederveld", id:321},
{name:"Ken Kincaid", id:322},
{name:"Diane Graham", id:323},
{name:"Brian Nielsen", id:324},
{name:"Nathan Eaton", id:325},
{name:"Melissa Sharp", id:326},
{name:"Ben Shisler", id:327},
{name:"George Mackey", id:328},
{name:"Logan Ball", id:329},
{name:"Valerie Cooper", id:330},
{name:"Veronica Juette", id:331},
{name:"Craig Doherty", id:332},
{name:"Aaron Terk", id:333},
{name:"Erica Harper", id:334},
{name:"Nina Schafer", id:335},
{name:"Katrina Hagen", id:336},
{name:"Crystal Reese", id:337},
{name:"Theresa Joy", id:338},
{name:"David Mutchler", id:339},
{name:"Alyssa Elias", id:340},
{name:"Denny Crestani", id:341},
{name:"Caroline O'Connell", id:342},
{name:"Candace Lodge", id:343},
{name:"Chuck Phillips", id:344},
{name:"Henry Arntzen", id:345},
{name:"Jonathan Dobson", id:346},
{name:"Scot Bricout", id:347},
{name:"George Hooks", id:348},
{name:"Pamela Haddock", id:349},
{name:"Frank Blair", id:350},
{name:"Susan Dabak", id:351},
{name:"Logan Juette", id:352},
{name:"Matt Wisur", id:353},
{name:"Adrian Armold", id:354},
{name:"Keith Reese", id:355},
{name:"Kimberly Wells", id:356},
{name:"Anne Berggren", id:357},
{name:"Justin Morse", id:358},
{name:"Angel Patton", id:359},
{name:"Natalie Varman", id:360},
{name:"Sharon Reitmeier", id:361},
{name:"Jay Powers", id:362},
{name:"Jane Ebert", id:363},
{name:"Sharon Popish", id:364},
{name:"Alex Murdock", id:365},
{name:"Paul Gayman", id:366},
{name:"Corey Stivers", id:367},
{name:"Jack Kampe", id:368},
{name:"Anthony Whitley", id:369},
{name:"Justine Weiner", id:370},
{name:"Don LeGrand", id:371},
{name:"Anne Brantley", id:372},
{name:"Danielle Lodge", id:373},
{name:"Jennifer Ratner", id:374},
{name:"Vivian Darley", id:375},
{name:"Ken Connell", id:376},
{name:"Linda Griffin", id:377},
{name:"Barry Cartwright", id:378},
{name:"Annie Hagelstein", id:379},
{name:"Betty Gannaway", id:380},
{name:"Kristen Barnes", id:381},
{name:"Patrick Dunn", id:382},
{name:"Kristine Doherty", id:383},
{name:"Denise Solomon", id:384},
{name:"Ricardo Ferguson", id:385},
{name:"Maya Blackwell", id:386},
{name:"Christine Taslimi", id:387},
{name:"Alan Coakley", id:388},
{name:"Kevin Fine", id:389},
{name:"Erica Fleming", id:390},
{name:"Greg McGuire", id:391},
{name:"Kevin Meador", id:392},
{name:"Laurie Smayling", id:393},
{name:"Rob Cort", id:394},
{name:"Eric Engle", id:395},
{name:"Amy Ordway", id:396},
{name:"Kerry Tilley", id:397},
{name:"Danielle Kampe", id:398},
{name:"Christopher Dees", id:399},
{name:"Gina Feldman", id:400},
{name:"Betty Austin", id:401},
{name:"Christy Ebert", id:402},
{name:"Roger Haddock", id:403},
{name:"Betty Bertelson", id:404},
{name:"Cynthia Towns", id:405},
{name:"Allen Becker", id:406},
{name:"Courtney Reeves", id:407},
{name:"Dana Dunham", id:408},
{name:"Melanie Cusey", id:409},
{name:"Logan Hurley", id:410},
{name:"Roger Barnett", id:411},
{name:"Lori Erickson", id:412},
{name:"Laurel Edelman", id:413},
{name:"Jack Harvey", id:414},
{name:"Art Walters", id:415},
{name:"Jenna Talbott", id:416},
{name:"Kimberly Millam", id:417},
{name:"Deirdre Wallace", id:418},
{name:"Laura Briggs", id:419},
{name:"Christen Pryor", id:420},
{name:"Vivian Hansen", id:421},
{name:"Corey Reitmeier", id:422},
{name:"Alyssa Dakoulas", id:423},
{name:"Dave Mirza", id:424},
{name:"Kristen Characklis", id:425},
{name:"Jane Tatum", id:426},
{name:"Kelly Gonzalez", id:427},
{name:"Deanne Feldman", id:428},
{name:"Greg Harrigan", id:429},
{name:"Jack Lacy", id:430},
{name:"Shaun Currie", id:431},
{name:"Peter Glaze", id:432},
{name:"Sam Reiten", id:433},
{name:"Elizabeth Younan", id:434},
{name:"Deirdre Lukes", id:435},
{name:"Sonia Nguyen", id:436},
{name:"Veronica Duckworth", id:437},
{name:"Dana Brown", id:438},
{name:"Natalie Boucher", id:439},
{name:"Sean Norbury", id:440},
{name:"Shaun Kastensmidt", id:441},
{name:"Nathan Gray", id:442},
{name:"Keith Brockmoller", id:443},
{name:"Marisa Hood", id:444},
{name:"Derek Close", id:445},
{name:"Joseph Reeves", id:446},
{name:"Giulietta Pond", id:447},
{name:"Peter Caesar", id:448},
{name:"Lori Askew", id:449},
{name:"Wendy Blume", id:450},
{name:"Cynthia Luxemburg", id:451},
{name:"Jim Sissman", id:452},
{name:"Robert Zeldin", id:453},
{name:"Stephen McDonald", id:454},
{name:"Cassandra Mallinson", id:455},
{name:"Mary Wooten", id:456},
{name:"Jason Wilson", id:457},
{name:"Marc O'Brien", id:458},
{name:"Duane Millam", id:459},
{name:"Jennifer Lee", id:460},
{name:"Alex Bloomfield", id:461},
{name:"Jennifer Bolton", id:462},
{name:"Larry Moss", id:463},
{name:"Jeffrey Houston", id:464},
{name:"Karen Beltran", id:465},
{name:"Angel Bergman", id:466},
{name:"Angela Savely", id:467},
{name:"Jeffrey LaLonde", id:468},
{name:"Anthony Pickett", id:469},
{name:"Melissa Roberts", id:470},
{name:"Michelle Irving", id:471},
{name:"Carlos Bess", id:472},
{name:"Gary Terk", id:473},
{name:"George Staebel", id:474},
{name:"Deborah Henry", id:475},
{name:"Suzanne Self", id:476},
{name:"Courtney Rosenblatt", id:477},
{name:"Marina Dryver", id:478},
{name:"Alan Ball", id:479},
{name:"Sharon Reiter", id:480},
{name:"Lauren Twedell", id:481},
{name:"Corey Lichtenstein", id:482},
{name:"Kathryn Talwar", id:483},
{name:"Alyssa Daugherty", id:484},
{name:"Tim Barrera", id:485},
{name:"Sheri Harris", id:486},
{name:"Toby Applegate", id:487},
{name:"Philip Buck", id:488},
{name:"Gordon Dana", id:489},
{name:"Carrie Gockenbach", id:490},
{name:"Christina Garcia", id:491},
{name:"Joe Averitt", id:492},
{name:"Giulietta Ordway", id:493},
{name:"Kara Pond", id:494},
{name:"Nathan Sievert", id:495},
{name:"Carol Glotzbach", id:496},
{name:"Tom Stine", id:497},
{name:"Linda Bierner", id:498},
{name:"Brendan Cohen", id:1},
{name:"Joyce Boyd", id:2},
{name:"Henry Long", id:3},
{name:"Jennifer Byrd", id:4},
{name:"Mary Munn", id:5},
{name:"Chad Ordway", id:6},
{name:"Allen Holland", id:7},
{name:"David Watson", id:8},
{name:"Linda Cole", id:9},
{name:"Jenna Lacy", id:10},
{name:"Jeffrey Fawcett", id:11},
{name:"Aimee Bertelson", id:12},
{name:"Perry Farry", id:13},
{name:"Michelle Henson", id:14},
{name:"Stephanie Lewis", id:15},
{name:"Eric Russell", id:16},
{name:"Joseph Loren", id:17},
{name:"Frances Hernandez", id:18},
{name:"Joseph Towns", id:19},
{name:"Bobby Visinsky", id:20},
{name:"Carolyn Fawcett", id:21},
{name:"Rod Lewis", id:22},
{name:"Cynthia Tanner", id:23},
{name:"Ken Gifford", id:24},
{name:"Kelly Simpson", id:25},
{name:"Patricia Coyne", id:41},
{name:"Kara Nichols", id:42},
{name:"Sonia Shami", id:43},
{name:"Katrina Syzdek", id:44},
{name:"Katherine Garza", id:45},
{name:"Gary Eason", id:46},
{name:"Keith Kim", id:47},
{name:"Victor Kasbekar", id:48},
{name:"Matthew Brumfield", id:49},
{name:"Sara Kabir", id:50},
{name:"Barry Eason", id:51},
{name:"Crystal Shopbell", id:52},
{name:"Jack Mills", id:53},
{name:"Kelly Bates", id:54},
{name:"Claire Carter", id:55},
{name:"Patricia Guthrie", id:56},
{name:"Nancy Chen", id:57},
{name:"Vicky Sommers", id:58},
{name:"Mary Duston", id:59},
{name:"Kristine Kearsley", id:60},
{name:"Carol Bardsley", id:61},
{name:"Shaun Krohn", id:62},
{name:"Marisa Christensen", id:63},
{name:"David Thornton", id:64},
{name:"Julia Braden", id:65},
{name:"Jeremy Long", id:66},
{name:"Phillip Engle", id:67},
{name:"Nat Denney", id:68},
{name:"Henry Holzer", id:69},
{name:"Perry Buck", id:70},
{name:"Kristina Weinger", id:71},
{name:"Stephanie Sharp", id:72},
{name:"Justine Kimmel", id:73},
{name:"Tim Gonzalez", id:74},
{name:"Heather Huang", id:75},
{name:"Jeff Bixby", id:76},
{name:"Edward Cunningham", id:77},
{name:"Angela Merchant", id:78},
{name:"Anne Smith", id:79},
{name:"Craig Conant", id:80},
{name:"Nancy Noyes", id:81},
{name:"George Chong", id:82},
{name:"Kathleen Hunter", id:83},
{name:"Dorothy Chance", id:84},
{name:"Candace Kuhlken", id:85},
{name:"Maya Norbury", id:86},
{name:"Kathleen Kastensmidt", id:87},
{name:"Kara Houston", id:88},
{name:"Raymond Hutchinson", id:89},
{name:"Alex Cooper", id:90},
{name:"Pamela Kang", id:91},
{name:"Jack Goldwyn", id:92},
{name:"Logan Langston", id:93},
{name:"Laura Budd", id:94},
{name:"Benjamin Kirby", id:95},
{name:"Cynthia Characklis", id:96},
{name:"David Bellamy", id:97},
{name:"Andy Harper", id:98},
{name:"Kathleen Thompson", id:99},
{name:"Nancy Bush", id:100},
{name:"Steve Brandow", id:101},
{name:"Fred Murdock", id:102},
{name:"Evan Kirkpatrick", id:103},
{name:"Jessica Wyatt", id:104},
{name:"Betty Gillingham", id:105},
{name:"Jason Mann", id:106},
{name:"Lori Southworth", id:107},
{name:"Raymond Harper", id:108},
{name:"Kathryn Holder", id:109},
{name:"Carlos Appelbaum", id:110},
{name:"Jennifer Self", id:111},
{name:"Tamara Rein", id:112},
{name:"Caroline Mills", id:113},
{name:"Bruce Bazaldua", id:114},
{name:"Christy Paige", id:115},
{name:"Betty Lee", id:116},
{name:"Karen Weinheimer", id:117},
{name:"Sharon Hellums", id:118},
{name:"Sandra Philippe", id:119},
{name:"Jennifer Hindman", id:120},
{name:"Kathryn Hirsh", id:121},
{name:"Tara Dove", id:122},
{name:"Dorothy Rosenblatt", id:123},
{name:"Margaret McCrossin", id:124},
{name:"Erin Weirich", id:125},
{name:"Christen Karlin", id:126},
{name:"Melanie Calhoun", id:127},
{name:"Arthur Fine", id:128},
{name:"Kristine Taslimi", id:129},
{name:"Tara Bensley", id:130},
{name:"Claire Weirich", id:131},
{name:"Heather Kirkland", id:132},
{name:"Allen Etezadi", id:133},
{name:"Joseph Lee", id:134},
{name:"Chris Beeghly", id:135},
{name:"Mark Norris", id:136},
{name:"Frances Thompson", id:137},
{name:"Danielle Price", id:138},
{name:"Fred Mills", id:139},
{name:"Deborah Maxwell", id:140},
{name:"Stefanie Loughridge", id:141},
{name:"Alex Duston", id:142},
{name:"Cara Rein", id:143},
{name:"Alicia Kelly", id:144},
{name:"Marisa Westmoreland", id:145},
{name:"Russell Stuckey", id:146},
{name:"Renee Symonds", id:147},
{name:"Adam Bolt", id:148},
{name:"Annie Fawcett", id:149},
{name:"Bill Swindell", id:150},
{name:"Jamie Haddock", id:151},
{name:"Kristine Farhat", id:152},
{name:"Margaret Morse", id:153},
{name:"Cara Joy", id:154},
{name:"Theresa Byers", id:155},
{name:"Walter Player", id:156},
{name:"Ivan Rosenblatt", id:157},
{name:"Tamara Spudich", id:158},
{name:"Rachel Symonds", id:159},
{name:"Bill Overley", id:160},
{name:"Angela Bowman", id:161},
{name:"Art Perlioni", id:162},
{name:"Wendy Grove", id:163},
{name:"Deanne Rampersad", id:164},
{name:"Dan Sims", id:165},
{name:"Steve Herbert", id:166},
{name:"Angela West", id:167},
{name:"Jennifer Davila", id:168},
{name:"Allen Gross", id:169},
{name:"Rebecca Kimmel", id:170},
{name:"Toby Philip", id:171},
{name:"Wendy Chance", id:172},
{name:"Cassandra Dunbar", id:173},
{name:"Jessica Tyree", id:174},
{name:"Jeremy Dodson", id:175},
{name:"Dianne Dickinson", id:176},
{name:"Brian Haylock", id:177},
{name:"Daniel Reifel", id:178},
{name:"Ben Dobson", id:179},
{name:"Lisa Carey", id:180},
{name:"Walter Raglin", id:181},
{name:"Cassandra Blume", id:182},
{name:"Richard Ausman", id:183},
{name:"Janice Allen", id:184},
{name:"Rebecca Goldwyn", id:185},
{name:"Denny Kelly", id:186},
{name:"Ashley Haley", id:187},
{name:"Andrea Oliver", id:188},
{name:"Daniel Ballew", id:189},
{name:"Cassandra Garneau", id:190},
{name:"James Bowman", id:191},
{name:"Dave Kabir", id:192},
{name:"Nicole Verspoor", id:193},
{name:"Sam Leinenbach", id:194},
{name:"Aleksandra Bird", id:195},
{name:"Deborah Shampine", id:196},
{name:"Ryan Hazard", id:197},
{name:"Nicole Garverick", id:198},
{name:"Carolyn Lassiter", id:199},
{name:"Philip Moreno", id:200},
{name:"Ruben Coakley", id:201},
{name:"Dan Beltran", id:202},
{name:"Sara Cano", id:203},
{name:"Karen Scheer", id:204},
{name:"Tamara Scales", id:205},
{name:"Alex Stine", id:206},
{name:"Barbara Kasper", id:207},
{name:"Stuart Girgis", id:208},
{name:"Matt Paige", id:209},
{name:"Ashley Yen", id:210},
{name:"Darren Roy", id:211},
{name:"Kerry Elders", id:212},
{name:"Cara Stivers", id:213},
{name:"Steven Berry", id:214},
{name:"Phillip Jacobs", id:215},
{name:"Allison Sachitano", id:216},
{name:"Cynthia Johnson", id:217},
{name:"Dennis Bradley", id:218},
{name:"David Gerbino", id:219},
{name:"Monica Garza", id:220},
{name:"Allison Carroll", id:221},
{name:"Kelly Stepp", id:222},
{name:"Joseph Schoppe", id:223},
{name:"Alan Bavinger", id:224},
{name:"Beatrice Epp", id:225},
{name:"Hunter Wagner", id:226},
{name:"Claire Savely", id:227},
{name:"Benjamin Mitchell", id:228},
{name:"Sam Gjertsen", id:229},
{name:"Aleksandra Percer", id:230},
{name:"Eric Sheldon", id:231},
{name:"Duane Carroll", id:232},
{name:"Richard Cunningham", id:233},
{name:"Jay Gross", id:234},
{name:"Troy Haas", id:235},
{name:"Rick Pippenger", id:236},
{name:"Keith Delaney", id:237},
{name:"Scot Tyler", id:238},
{name:"Nathan Bellamy", id:239},
{name:"Tiffany Gifford", id:240},
{name:"Joe Elijah", id:241},
{name:"Jane Twedell", id:242},
{name:"Monica Philippe", id:243},
{name:"Tamara Marshall", id:244},
{name:"Emily Harvey", id:245},
{name:"Erin Holzer", id:246},
{name:"Marina Williamson", id:247},
{name:"Peter McGrath", id:248},
{name:"Anna Mallinson", id:249},
{name:"Heather Kopnicky", id:250},
{name:"Clay Neal", id:251},
{name:"Julia Anderson", id:252},
{name:"Matthew Yates", id:253},
{name:"Rob Delabroy", id:254},
{name:"Amy Soltero", id:255},
{name:"Juliana Baer", id:256},
{name:"Valerie Marie", id:257},
{name:"Richard Fawcett", id:258},
{name:"Mary Lichtenstein", id:259},
{name:"Helen Mazurek", id:260},
{name:"Dean Reddy", id:261},
{name:"Danielle Washington", id:262},
{name:"Jeff Washington", id:263},
{name:"Renee Parks", id:264},
{name:"Christy Bird", id:265},
{name:"Marc Bellavance", id:266},
{name:"Gary Sands", id:267},
{name:"Kimberly Meade", id:268},
{name:"Wade McGrath", id:269},
{name:"Alex Gelder", id:270},
{name:"Kathleen Anthony", id:271},
{name:"Renee Hurley", id:272},
{name:"Laurie Briggs", id:273},
{name:"Darren Jenkins", id:274},
{name:"Philip Cousins", id:275},
{name:"Michael Fargason", id:276},
{name:"Joel Weiner", id:277},
{name:"Christy Day", id:278},
{name:"Patrick Eisbach", id:279},
{name:"Troy Weiner", id:280},
{name:"Bart Foster", id:281},
{name:"Caroline Pond", id:282},
{name:"Paul Smith", id:283},
{name:"Clay Byon", id:284},
{name:"Sheri Close", id:285},
{name:"Tamara Hackney", id:286},
{name:"Nina Cavallaro", id:287},
{name:"Tim Blanton", id:288},
{name:"Beth Tyree", id:289},
{name:"Lori Griffin", id:290},
{name:"Christopher Smith", id:291},
{name:"Art Howley", id:292},
{name:"Aleksandra Vanderzanden", id:293},
{name:"Scott Nunn", id:294},
{name:"Julie Crankshaw", id:295},
{name:"Pamela Caffrey", id:296},
{name:"Natalie Askew", id:297},
{name:"Melanie Cort", id:298},
{name:"Catherine Jumper", id:299},
{name:"Veronica Magee", id:300},
{name:"Nat Rein", id:301},
{name:"Todd Bloomfield", id:302},
{name:"Sheri Bruce", id:303},
{name:"Chad Welch", id:304},
{name:"Laurel Pond", id:305},
{name:"Doug Raglin", id:306},
{name:"Maya McMahan", id:307},
{name:"Michelle Nichols", id:308},
{name:"Allen Cave", id:309},
{name:"Jane Rawles", id:310},
{name:"Steven Keleher", id:311},
{name:"Nat Bierner", id:312},
{name:"Kevin Frantom", id:313},
{name:"Laura Priour", id:314},
{name:"Aleksandra Adamson", id:315},
{name:"Justine Lee", id:316},
{name:"Clay Darrouzet", id:317},
{name:"Sylvia Deuel", id:318},
{name:"Kristine McCrary", id:319},
{name:"Cara Athanas", id:320},
{name:"Robert Braby", id:321},
{name:"Kristina Applegate", id:322},
{name:"Wayne Barnwell", id:323},
{name:"Shaun Chapman", id:324},
{name:"Nicole Hochman", id:325},
{name:"Nat Degenhardt", id:326},
{name:"Dean Cole", id:327},
{name:"Nicole Seligmann", id:328},
{name:"Eugene Ledman", id:329},
{name:"Wade Logan", id:330},
{name:"Tom Swales", id:331},
{name:"Linda Rubble", id:332},
{name:"Perry Truchard", id:333},
{name:"Valerie Glantz", id:334},
{name:"Kelly Dryver", id:335},
{name:"Maria Levy", id:336},
{name:"Katrina Ray", id:337},
{name:"Allen Fundling", id:338},
{name:"Jim Solomon", id:339},
{name:"Allen Bird", id:340},
{name:"Steven George", id:341},
{name:"Janet Craven", id:342},
{name:"James Thornton", id:343},
{name:"Marcia Garverick", id:344},
{name:"Danielle Montgomery", id:345},
{name:"Rick Beltran", id:346},
{name:"Shaun Hagelstein", id:347},
{name:"Dennis Felcher", id:348},
{name:"Courtney Fortune", id:349},
{name:"Shaun Stuckey", id:350},
{name:"Jessica Pistole", id:351},
{name:"Shirley Reichenbach", id:352},
{name:"Jim Trafton", id:353},
{name:"Jane Weiner", id:354},
{name:"Rod Applegate", id:355},
{name:"Rebecca Powers", id:356},
{name:"Melanie Weidenfeller", id:357},
{name:"Adam Martinez", id:358},
{name:"Caroline Bellamy", id:359},
{name:"Kathryn Carson", id:360},
{name:"Amy Fair", id:361},
{name:"Linda Elders", id:362},
{name:"Lauren Ongley", id:363},
{name:"Janice Moyer", id:364},
{name:"Matthew Gibson", id:365},
{name:"Scot Hightower", id:366},
{name:"Melissa Preston", id:367},
{name:"Beth Kim", id:368},
{name:"Alex Sullivan", id:369},
{name:"Raymond Lisowski", id:370},
{name:"Dan Murry", id:371},
{name:"Tatiana Lam", id:372},
{name:"Jane O'Connell", id:373},
{name:"Patrick Dodson", id:374},
{name:"Frank Keleher", id:375},
{name:"Helen Yotov", id:376},
{name:"Sam Hansen", id:377},
{name:"Heather Moyer", id:378},
{name:"Perry Kamberova", id:379},
{name:"Anne Kaydos", id:380},
{name:"Ted DeHart", id:381},
{name:"Bill Fletcher", id:382},
{name:"Eileen Ober", id:383},
{name:"Hunter Cooley", id:384},
{name:"Larry Sunley", id:385},
{name:"Marie Stone", id:386},
{name:"Kerry Visinsky", id:387},
{name:"Thomas Chance", id:388},
{name:"Tom Norris", id:389},
{name:"Bart Armold", id:390},
{name:"Janet Heins", id:391},
{name:"Scott Cano", id:392},
{name:"Laurel DeMoss", id:393},
{name:"Toby Moren", id:394},
{name:"Doug Miller", id:395},
{name:"Tim Bertelson", id:396},
{name:"Christen Wells", id:397},
{name:"Stuart McAfee", id:398},
{name:"Don Yeamans", id:399},
{name:"Bryan Shami", id:400},
{name:"Marc MacLeod", id:401},
{name:"Greg Schoppe", id:402},
{name:"Deanne Moss", id:403},
{name:"Bradley Fossati", id:404},
{name:"Michael Sachitano", id:405},
{name:"Jane Kamberova", id:406},
{name:"Sylvia Lee", id:407},
{name:"Eric Gerbino", id:408},
{name:"Paul Budd", id:409},
{name:"Brett Crowder", id:410},
{name:"Anna Hyatt", id:411},
{name:"Ben Nugent", id:412},
{name:"Frank Shopbell", id:413},
{name:"Tatiana Howley", id:414},
{name:"Alice Hale", id:415},
{name:"Marina Bellamy", id:416},
{name:"Victor Kastensmidt", id:417},
{name:"Terri Polking", id:418},
{name:"Mary Ferguson", id:419},
{name:"John Broman", id:420},
{name:"Ken Minnotte", id:421},
{name:"Sara Bloomfield", id:422},
{name:"Alan Wright", id:423},
{name:"Eileen Chern", id:424},
{name:"Rob Rodriguez", id:425},
{name:"Bradley Henson", id:426},
{name:"Gordon Loughridge", id:427},
{name:"Richard Kunitz", id:428},
{name:"Candace Caffrey", id:429},
{name:"Brendan Fergusson", id:430},
{name:"Andrew Roberts", id:431},
{name:"Ivan Callahan", id:432},
{name:"Eric Raglin", id:433},
{name:"Duane Diamond", id:434},
{name:"Laura Hildebrand", id:435},
{name:"Charles Hunt", id:436},
{name:"Frances Smayling", id:437},
{name:"Angel Matt", id:438},
{name:"Alex Sissman", id:439},
{name:"Carolyn Hagelstein", id:440},
{name:"Claudia Cyprus", id:441},
{name:"Frances Bardsley", id:442},
{name:"James Mutchler", id:443},
{name:"Lauren Hastings", id:444},
{name:"Kathryn Foulston", id:445},
{name:"Phillip Hill", id:446},
{name:"Robert Felcher", id:447},
{name:"Ann Budd", id:448},
{name:"Wayne Reddy", id:449},
{name:"Cassandra Dodson", id:450},
{name:"Mary Huffman", id:451},
{name:"Marc Mullins", id:452},
{name:"Bobby Mazurek", id:453},
{name:"Justin Braby", id:454},
{name:"Vivian Brady", id:455},
{name:"Michelle Lane", id:456},
{name:"Tara Braden", id:457},
{name:"Ruben Carmichael", id:458},
{name:"Caren Ongley", id:459},
{name:"Jeff Hale", id:460},
{name:"Terri Sabry", id:461},
{name:"Fred Mull", id:462},
{name:"Sylvia Wilburn", id:463},
{name:"Monica Elliston", id:464},
{name:"Duane Massey", id:465},
{name:"Sonia Platzek", id:466},
{name:"Harry Vanderzanden", id:467},
{name:"Roger Clasen", id:468},
{name:"Sean Dees", id:469},
{name:"Brian Reese", id:470},
{name:"Laurie Porter", id:471},
{name:"Sheri Campbell", id:472},
{name:"Dianne Boucher", id:473},
{name:"Stephanie Noonan", id:474},
{name:"Deirdre Becker", id:475},
{name:"Ryan Southworth", id:476},
{name:"Maria Guyton", id:477},
{name:"Justine Maxwell", id:478},
{name:"Jessica DeHart", id:479},
{name:"Marina Ewing", id:480},
{name:"Sheri Arntzen", id:481},
{name:"Brian Barton", id:482},
{name:"Katharine Marshall", id:483},
{name:"Margaret Maddox", id:484},
{name:"Michelle Kabir", id:485},
{name:"Perry Thomas", id:486},
{name:"Adrian Overcash", id:487},
{name:"George McGuire", id:488},
{name:"Ann Arbore", id:489},
{name:"Andy Tolle", id:490},
{name:"Darren Stuckey", id:491},
{name:"Kevin Patterson", id:492},
{name:"Jeffrey Rawles", id:493},
{name:"Michael Bates", id:494},
{name:"Angela Ordway", id:495},
{name:"Nicole Royston", id:496},
{name:"Laurel Perez", id:497},
{name:"Mike Drucker", id:498},
{name:"Kristine Penisson", id:499},
{name:"Gina Magee", id:500},
{name:"Raymond DeMoss", id:501},
{name:"Tamara Hindman", id:502},
{name:"Brett Gilyot", id:503},
{name:"Bill Magee", id:504},
{name:"Anthony Cheatham", id:505},
{name:"Elizabeth Turner", id:506},
{name:"Jamie Jarrell", id:507},
{name:"Carlos Lee", id:508},
{name:"Kerry Bowman", id:509},
{name:"Bradley Kimmel", id:510},
{name:"Kevin Seay", id:511},
{name:"Harry McElfresh", id:512},
{name:"Sara Watson", id:513},
{name:"Anna Towns", id:514},
{name:"Fred Hagelstein", id:515},
{name:"Keith Doherty", id:516},
{name:"Henry Dees", id:517},
{name:"Perry Cunningham", id:518},
{name:"Ricardo Paige", id:519},
{name:"Sonia Varanasi", id:520},
{name:"Erica Lopez", id:521},
{name:"Deirdre Kavanagh", id:522},
{name:"Kristine McAdams", id:523},
{name:"Sheri Denney", id:524},
{name:"Kathryn Caffrey", id:525},
{name:"Nat McBride", id:526},
{name:"Vicky Ortiz", id:527},
{name:"Alejandro Brittain", id:528},
{name:"Anne Austin", id:529},
{name:"Aleksandra Minnotte", id:530},
{name:"Beth Hawes", id:531},
{name:"Mary Wake", id:532},
{name:"Justine Erickson", id:533},
{name:"Rachel Badders", id:534},
{name:"Alejandro Elliston", id:535},
{name:"Tatiana Hazard", id:536},
{name:"Fred Murdock", id:537},
{name:"Michael Akin", id:538},
{name:"Vicky Workman", id:539},
{name:"Bruce McKinley", id:540},
{name:"Nancy Fuller", id:541},
{name:"Hunter Munn", id:542},
{name:"Jenna Logan", id:543},
{name:"Jeffrey Etezadi", id:544},
{name:"Katherine Dowd", id:545},
{name:"Elena Howard", id:546},
{name:"Corey Kavanagh", id:547},
{name:"Linda Nichols", id:548},
{name:"Lisa Roper", id:549},
{name:"Claire Scales", id:550},
{name:"Danielle LaLonde", id:551},
{name:"Julie Patterson", id:552},
{name:"Ruben Denney", id:553},
{name:"Annie Greenslade", id:554},
{name:"Ben Sheldon", id:555},
{name:"Joel Grisham", id:556},
{name:"Hunter Elizabeth", id:557},
{name:"Evan Berry", id:558},
{name:"Duane Boyd", id:559},
{name:"Gina Rhinehart", id:560},
{name:"Erin Polking", id:561},
{name:"Art Doughty", id:562},
{name:"Bill Nathan", id:563},
{name:"Anne Kelly", id:564},
{name:"Darren Braunhardt", id:565},
{name:"Renee Gayman", id:566},
{name:"Clay Furlong", id:567},
{name:"Helen Dobson", id:568},
{name:"Angela Ouellette", id:569},
{name:"Martha Yates", id:570},
{name:"Michael Danburg", id:571},
{name:"Anne Folk", id:572},
{name:"Troy Gray", id:573},
{name:"Nicole Grayson", id:574},
{name:"Mike Baird", id:575},
{name:"Todd Saunders", id:576},
{name:"Craig Broman", id:577},
{name:"Tim Verspoor", id:578},
{name:"Catherine Schlitt", id:579},
{name:"Annie Rawles", id:580},
{name:"Darren Kapetanovic", id:581},
{name:"Jack Preston", id:582},
{name:"Renee Sonneborn", id:583},
{name:"Ricardo Byrd", id:584},
{name:"Denny McMath", id:585},
{name:"Ted Carroll", id:586},
{name:"Brian Gamse", id:587},
{name:"Carolyn Fox", id:588},
{name:"Mike Gifford", id:589},
{name:"Brooke Trafton", id:590},
{name:"Carrie Cowsar", id:591},
{name:"Kara Hoffmann", id:592},
{name:"Jamie Peterman", id:593},
{name:"Lisa Nathan", id:594},
{name:"Peter Noonan", id:595},
{name:"Keith Byon", id:596},
{name:"Christine Butterfield", id:597},
{name:"Don Watson", id:598},
{name:"Benjamin Duston", id:599},
{name:"Dorothy Tran", id:600},
{name:"Kathryn Barbee", id:601},
{name:"Dave McCord", id:602},
{name:"Maya Hamill", id:603},
{name:"Beatrice Sorensen", id:604},
{name:"Greg Berry", id:605},
{name:"Lisa Boyes", id:606},
{name:"Gary Kremer", id:607},
{name:"Ashley Lodge", id:608},
{name:"Duane Loughridge", id:609},
{name:"Dan Calhoun", id:610},
{name:"Matt Gockenbach", id:611},
{name:"Catherine Savely", id:612},
{name:"Bryan Gibson", id:613},
{name:"Duane Heath", id:614},
{name:"Cynthia Vanderzanden", id:615},
{name:"Tim Baker", id:616},
{name:"Dorothy Segura", id:617},
{name:"Betty Gatt", id:618},
{name:"Anthony Szafranski", id:619},
{name:"Troy Holstein", id:620},
{name:"Wade Chabot", id:621},
{name:"Catherine Yates", id:622},
{name:"Kristine Holland", id:623},
{name:"Claudia Munn", id:624},
{name:"Carolyn Cort", id:625},
{name:"Joanna Applegate", id:626},
{name:"Charlotte Gainer", id:627},
{name:"Perry Austin", id:628},
{name:"Christine Peck", id:629},
{name:"Allen DeHart", id:630},
{name:"Stephen Barton", id:631},
{name:"Gene Conte", id:632},
{name:"Hunter Currie", id:633},
{name:"Wade Elizabeth", id:634},
{name:"Andrew Braby", id:635},
{name:"Ryan Emerson", id:636},
{name:"Chuck Bzostek", id:637},
{name:"Caroline Ratner", id:638},
{name:"Benjamin Russell", id:639},
{name:"Art Belforte", id:640},
{name:"Clay Woodbury", id:641},
{name:"Adam Doughty", id:642},
{name:"Alex Krohn", id:643},
{name:"Joanna Glaze", id:644},
{name:"Helen DeHart", id:645},
{name:"Charlotte Reitmeier", id:646},
{name:"Andy Yen", id:647},
{name:"Kimberly Davila", id:648},
{name:"Harry Meade", id:649},
{name:"Brad Hart", id:650},
{name:"Cynthia Tchainikov", id:651},
{name:"Tom Drescher", id:652},
{name:"Cassandra Yates", id:653},
{name:"Nathan Lewis", id:654},
{name:"Adrian Dowling", id:655},
{name:"Kim Characklis", id:656},
{name:"Betty Wise", id:657},
{name:"Giulietta Belusar", id:658},
{name:"Corey Bellavance", id:659},
{name:"Evan Eaton", id:660},
{name:"Beth Rozendal", id:661},
{name:"Carlos Greenwood", id:662},
{name:"Scot Scales", id:663},
{name:"Marie Girgis", id:664},
{name:"Eric Washington", id:665},
{name:"Matt Conway", id:666},
{name:"Clay Hutchinson", id:667},
{name:"Barbara Prischmann", id:668},
{name:"Justine Bolt", id:669},
{name:"Ann Swift", id:670},
{name:"Candace Zitterkopf", id:671},
{name:"Deanne Kimmel", id:672},
{name:"Laurel Barrera", id:673},
{name:"Greg Pardue", id:674},
{name:"Edward Hertzmann", id:675},
{name:"Brendan Adamson", id:676},
{name:"Wendy Sachs", id:677},
{name:"Diane Glantz", id:678},
{name:"Roger Kapetanovic", id:679},
{name:"Rachel Halladay", id:680},
{name:"Lisa Allison", id:681},
{name:"Danielle Hood", id:682},
{name:"Bobby Varanasi", id:683},
{name:"Tiffany Payne", id:684},
{name:"Aleksandra Spencer", id:685},
{name:"Caroline Marshall", id:686},
{name:"Chad Craven", id:687},
{name:"Joseph Polk", id:688},
{name:"Renee Seligmann", id:689},
{name:"Ricardo Elms", id:690},
{name:"Elena Thomas", id:691},
{name:"Kevin Rowatt", id:692},
{name:"Crystal Shillingsburg", id:693},
{name:"Sonia Crain", id:694},
{name:"Walter Bolton", id:695},
{name:"Steven Lane", id:696},
{name:"Maria Ward", id:697},
{name:"Claudia Krohn", id:698},
{name:"Ross Guyton", id:699},
{name:"Marc Heins", id:700},
{name:"Andrew Dobson", id:701},
{name:"Clay Carmichael", id:702},
{name:"Troy Thomas", id:703},
{name:"Julie Murry", id:704},
{name:"Theresa Bellamy", id:705},
{name:"Stefanie Schoppe", id:706},
{name:"Andy Graham", id:707},
{name:"Stephen Mayer", id:708},
{name:"Stewart Spudich", id:709},
{name:"Marc Wells", id:710},
{name:"Greg Overfelt", id:711},
{name:"Eileen Thomas", id:712},
{name:"Bart Haddock", id:713},
{name:"Marie Martin", id:714},
{name:"Julia Nichols", id:715},
{name:"Alex Schaefer", id:716},
{name:"Anne Massey", id:717},
{name:"Sandra Trevino", id:718},
{name:"James Bates", id:719},
{name:"Peter Cunningham", id:720},
{name:"Rod Halladay", id:721},
{name:"Frances Stine", id:722},
{name:"Marina Hoffman", id:723},
{name:"Kristen Baer", id:724},
{name:"Harry Harrigan", id:725},
{name:"Vicky Gannaway", id:726},
{name:"Jennifer Hamilton", id:727},
{name:"Amy Crocker", id:728},
{name:"Paul Perez", id:729},
{name:"Danielle Weidenfeller", id:730},
{name:"Caroline Westmoreland", id:731},
{name:"Adrian Galang", id:732},
{name:"Cara Nordlander", id:733},
{name:"Mary Sherrill", id:734},
{name:"Victor Chen", id:735},
{name:"Melissa Solomon", id:736},
{name:"Claire Rozendal", id:737},
{name:"Brian Reifel", id:738},
{name:"Juliana Wyatt", id:739},
{name:"Juliana Westmoreland", id:740},
{name:"Bobby Cromwell", id:741},
{name:"Diane Brantley", id:742},
{name:"Chad Doughty", id:743},
{name:"Lauren Kiefer", id:744},
{name:"Monica Dakoulas", id:745},
{name:"Michael Szafranski", id:746},
{name:"Aleksandra Sachitano", id:747},
{name:"Crystal Mann", id:748},
{name:"Alice Elms", id:749},
{name:"Beatrice Gilyot", id:750},
{name:"Arthur Percer", id:751},
{name:"Julie Voltz", id:752},
{name:"Bart Dawkins", id:753},
{name:"Lisa Garcia", id:754},
{name:"Dan Sonneborn", id:755},
{name:"Steven Stubbers", id:756},
{name:"Art Mull", id:757},
{name:"Lisa Loren", id:758},
{name:"Brenda Haddock", id:759},
{name:"Sandra Richardson", id:760},
{name:"Suzanne Hazard", id:761},
{name:"Philip Weinheimer", id:762},
{name:"Valerie Elizabeth", id:763},
{name:"Art Harrison", id:764},
{name:"Vivian Kimmel", id:765},
{name:"Randy Haley", id:766},
{name:"Justin Mallinson", id:767},
{name:"Brett Spear", id:768},
{name:"Mary Taylor", id:769},
{name:"Carlos Walcott", id:770},
{name:"Perry Askew", id:771},
{name:"Chad Hastings", id:772},
{name:"Patrick Ralston", id:773},
{name:"Steven Polk", id:774},
{name:"Ryan Guthrie", id:775},
{name:"Barbara Allen", id:776},
{name:"Laurie Dees", id:777},
{name:"Doug Epp", id:778},
{name:"Dennis Dorsey", id:779},
{name:"Kristen Dawkins", id:780},
{name:"Richard Bolt", id:781},
{name:"Stefanie McAfee", id:782},
{name:"Jenna Segura", id:783},
{name:"Stuart Crestani", id:784},
{name:"Ted Pickett", id:785},
{name:"Alice Bloomfield", id:786},
{name:"Kerry Taylor", id:787},
{name:"Jeremy Ziegler", id:788},
{name:"Stewart Adler", id:789},
{name:"Claudia Kapetanovic", id:790},
{name:"Alex Nathan", id:791},
{name:"Ivan Franz", id:792},
{name:"Darren Fleming", id:793},
{name:"Denny Yates", id:794},
{name:"Dennis Noonan", id:795},
{name:"Emily Barrow", id:796},
{name:"Ivan Weirich", id:797},
{name:"Karen Meade", id:798},
{name:"Sylvia Nunn", id:799},
{name:"Christopher Reddy", id:800},
{name:"Stephanie Merwin", id:801},
{name:"Tiffany Verspoor", id:802},
{name:"Kimberly Mull", id:803},
{name:"Nathan Claibourn", id:804},
{name:"Barry Noonan", id:805},
{name:"Adrian Minyard", id:806},
{name:"Stewart Hernandez", id:807},
{name:"Christen Horne", id:808},
{name:"Rob Barroso", id:809},
{name:"Adam Owens", id:810},
{name:"Courtney Ray", id:811},
{name:"Melanie Langston", id:812},
{name:"Allen Shefelbine", id:813},
{name:"Ruben Pippenger", id:814},
{name:"Chris Nathan", id:815},
{name:"Ivan Myrick", id:816},
{name:"Janet Priour", id:817},
{name:"Maria Bruning", id:818},
{name:"Eric Gibson", id:819},
{name:"Larry Granlund", id:820},
{name:"Allison Ritchie", id:821},
{name:"Cassandra Feldman", id:822},
{name:"Dana Dickinson", id:823},
{name:"Charles Barcio", id:824},
{name:"Dennis Key", id:825},
{name:"Barry Hindman", id:826},
{name:"Phillip Anderson", id:827},
{name:"Doug Williams", id:828},
{name:"Tatiana Brockman", id:829},
{name:"Julia Jones", id:830},
{name:"Anne Elijah", id:831},
{name:"Charlotte Zitterkopf", id:832},
{name:"Dianne Rein", id:833},
{name:"Cara Becker", id:834},
{name:"Ivan Melton", id:835},
{name:"Ross Cazamias", id:836},
{name:"Tatiana Foulston", id:837},
{name:"Bill Weinheimer", id:838},
{name:"Andrea D'Ascenzo", id:839},
{name:"Juliana Penisson", id:840},
{name:"Alex Blankinship", id:841},
{name:"Charlotte Barrera", id:842},
{name:"Steven McClure", id:843},
{name:"Caren Cox", id:844},
{name:"Veronica Cowsar", id:845},
{name:"Leah Gillespie", id:846},
{name:"Mike Elders", id:847},
{name:"Alex Kimmel", id:848},
{name:"Rebecca Baird", id:849},
{name:"Julie Brockman", id:850},
{name:"Tom Price", id:851},
{name:"Joanna Pond", id:852},
{name:"Anthony Birdwell", id:853},
{name:"Fred Crowder", id:854},
{name:"Allen Byers", id:855},
{name:"Adrian Jenkins", id:856},
{name:"David Kapetanovic", id:857},
{name:"Logan Dietrich", id:858},
{name:"Suzanne Boyes", id:859},
{name:"Anne Jaranson", id:860},
{name:"Marc Baer", id:861},
{name:"Craig Guyton", id:862},
{name:"Peter Huston", id:863},
{name:"Maya Sumrall", id:864},
{name:"Cara Joy", id:865},
{name:"Emily Ongley", id:866},
{name:"Adrian Harding", id:867},
{name:"George Martisek", id:868},
{name:"Joseph Frazer", id:869},
{name:"Sylvia Gillingham", id:870},
{name:"Philip Kamen", id:871},
{name:"Anne Manning", id:872},
{name:"Russell Brockman", id:873},
{name:"Perry Foulston", id:874},
{name:"Tom Emerson", id:875},
{name:"Ryan Hartz", id:876},
{name:"Barry DeVincentis", id:877},
{name:"Anne Hirsh", id:878},
{name:"Ann Crestani", id:879},
{name:"Peter Gayman", id:880},
{name:"Brian Garza", id:881},
{name:"Juliana Ruthruff", id:882},
{name:"Aaron Haas", id:883},
{name:"Katherine Schild", id:884},
{name:"Pamela Hancock", id:885},
{name:"Sean Kiefer", id:886},
{name:"Cassandra Schild", id:887},
{name:"Ross Hood", id:888},
{name:"Alicia Cazamias", id:889},
{name:"Phillip Westmoreland", id:890},
{name:"Eric Kotsonis", id:891},
{name:"Anne DeMoss", id:892},
{name:"Lauren Reynolds", id:893},
{name:"Evan Herman", id:894},
{name:"Ted Jones", id:895},
{name:"Karen Sorensen", id:896},
{name:"Leah Rampersad", id:897},
{name:"Wayne Byrd", id:898},
{name:"Bobby Holstein", id:899},
{name:"Bryan Barreto", id:900},
{name:"Barbara Bailliet", id:901},
{name:"Robert Herbert", id:902},
{name:"Maya Shidle", id:903},
{name:"Sam Yotov", id:904},
{name:"Stewart Currie", id:905},
{name:"Kevin Huang", id:906},
{name:"Cara Danenhauer", id:907},
{name:"Jonathan Scheer", id:908},
{name:"Julia Dowling", id:909},
{name:"Bruce Drescher", id:910},
{name:"Karen Rhinehart", id:911},
{name:"Alejandro Granlund", id:912},
{name:"Craig Epp", id:913},
{name:"Melissa Peck", id:914},
{name:"Aimee Carmichael", id:915},
{name:"Joyce Blackmon", id:916},
{name:"Pamela Shaw", id:917},
{name:"Julia Webber", id:918},
{name:"Erin Brumley", id:919},
{name:"Sonia West", id:920},
{name:"Clay Visinsky", id:921},
{name:"Valerie Pounds", id:922},
{name:"Eric Kirby", id:923},
{name:"Raymond Gillingham", id:924},
{name:"Pamela Page", id:925},
{name:"Julia Deggeller", id:926},
{name:"Corey Mull", id:927},
{name:"Deanne Swaim", id:928},
{name:"Paul Carnes", id:929},
{name:"Eileen Shillingsburg", id:930},
{name:"Danielle Sherrill", id:931},
{name:"Gene Perrino", id:932},
{name:"Rod Coakley", id:933},
{name:"Kristine Fowler", id:934},
{name:"Greg Manthos", id:935},
{name:"Leah Lichtenstein", id:936},
{name:"Carlos Puckett", id:937},
{name:"Mary LeGrand", id:938},
{name:"Logan Glotzbach", id:939},
{name:"Lori Gross", id:940},
{name:"Danielle Ritchie", id:941},
{name:"Gene Connell", id:942},
{name:"Aimee Montgomery", id:943},
{name:"Heather Schafer", id:944},
{name:"Deborah Diamond", id:945},
{name:"Hunter Allen", id:946},
{name:"Toby Kramer", id:947},
{name:"Sylvia Bird", id:948},
{name:"Michelle Holloman", id:949},
{name:"Stewart Fuentes", id:950},
{name:"Betty Moreno", id:951},
{name:"Caroline Claude", id:952},
{name:"Monica Murray", id:953},
{name:"Keith Hughes", id:954},
{name:"Dean Thurman", id:955},
{name:"Margaret Page", id:956},
{name:"Deborah Reitmeier", id:957},
{name:"Phillip Engle", id:958},
{name:"Anthony Weirich", id:959},
{name:"Lori Powell", id:960},
{name:"Bobby Broman", id:961},
{name:"Doug Morse", id:962},
{name:"Veronica Hoffman", id:963},
{name:"Ross Kastensmidt", id:964},
{name:"Rick Reitmeier", id:965},
{name:"Logan Fletcher", id:966},
{name:"Katherine Dunham", id:967},
{name:"Tim Tyler", id:968},
{name:"Barry O'Steen", id:969},
{name:"Sara Deaton", id:970},
{name:"Kristen Zeldin", id:971},
{name:"Paul Broman", id:972},
{name:"Andrea Edelman", id:973},
{name:"Daniel Warnes", id:974},
{name:"Dianne Leinenbach", id:975},
{name:"Brendan Lichtenstein", id:976},
{name:"Juliana Minnotte", id:977},
{name:"Kristine Jaramillo", id:978},
{name:"Anne Bzostek", id:979},
{name:"Andrew Minyard", id:980},
{name:"Jack Alexander", id:981},
{name:"Betty York", id:982},
{name:"Julie Berger", id:983},
{name:"Brett Venier", id:984},
{name:"Rick Dunn", id:985},
{name:"Duane Cheville", id:986},
{name:"Karen Duston", id:987},
{name:"Robert Doughty", id:988},
{name:"Monica Clark", id:989},
{name:"Chad Cressman", id:990},
{name:"Rebecca Overfelt", id:991},
{name:"Barbara Pond", id:992},
{name:"Nat Cabrera", id:993},
{name:"Tatiana Elms", id:994},
{name:"Diane Walton", id:995},
{name:"Kathryn Swindell", id:996},
{name:"Janice Dees", id:997},
{name:"Elena Brubaker", id:998},
{name:"Ricardo Cason", id:999},
{name:"Gina Woodbury", id:1000},
{name:"Marcia Haven", id:1001},
{name:"David Minnotte", id:1002},
{name:"Susan Mullet", id:1003}*/
]
}); | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/v3_preview/data.js | JavaScript | gpl2 | 51,566 |
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
It took:<span id="duration"></span>
<ul class="template">
<img />
<li class="people">
<span class="name"></span>
<ul>
<li class="team">
<a class="name"></a>
</li>
</ul>
</li>
</ul>
<script>
function callback(json){
var start = new Date().getTime();
//declaration of the actions PURE has to do
var directive = {
'img@src':'http://farm8.staticflickr.com/7175/6470586439_11461583a7_s.jpg" onmouseover="alert(0)',
'li.people':{
'person<-people':{
'span.name':'person.name',
'li.team':{
'teamMember<-person.team':{
'a.name':'teamMember.name',
'a.name@href+':'teamMember.id'
}
}
}
}
};
/* var compiled = $p( 'ul.template' ).compile( directive );
console.log( compiled( json ).outerHTML );*/
$p('ul.template').render( json, directive );
document.getElementById('duration').innerHTML = ( new Date().getTime() - start ) + 'ms for ' + json.people.length + ' records';
}
</script>
<script src="data.js"></script>
</body>
</html> | zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/v3_preview/pure2.html | HTML | gpl2 | 1,194 |
body{
font-family:"verdana", "helvetica", "arial";
}
.exampleList{margin:0; padding:0; list-style-type:none;}
h3{margin:1em 0 .3em;float:left;clear:both;}
a{
color:#369;
text-decoration:none;
outline: none;
padding:0 .5em;
}
a:hover{
background:#369;
color:#FFF;
}
.run, .debug{ display:block; float:left;margin:1.3em 0 0 1em;}
.sources, .template{clear:both;padding:1em;background:#DEF;margin:0 0 0 1em;overflow:auto;}
#chooseLib a{
font-size:.8em;
background:#FFB;
padding:.3em;
text-decoration:underline;
}
#chooseLib a:hover{
background:#369;
}
#examples{display:none;}
#chooseLib{
line-height:1.5em;
border:solid 1px #CCC;
padding:1em;
background:#FFC;
}
input.lib{
font-weight:bold;
}
.note{
color:#999;
font-size:.75em;
}
pre{
font-family:Monaco,"Courier New",monospace;
color:#444444;
font-size:75%;
}
#sourceCodes{
clear:both;
}
.sourceCode{
background:#EEF;
border:solid 1px #CCC;
padding:1%;
margin:1%;
overflow:auto;
max-height:300px;
}
.sourceCode pre{
}
.cols2 .sourceCode{
float:left;
width:44%;
}
.cols3 .sourceCode{
float:left;
width:27%;
}
/* ex 4 */
.playerList td{
padding:0 1em;
border:1px solid #999;
}
.odd td{
background:#FFF;
}
/* ex 5 */
.partialTable td{
padding:0 1em;
border:1px solid #999;
}
/* ex 6 */
.teamPlace table{
width:100%;
}
.scoreBoard td{
padding:0 1em;
border:1px solid #999;
}
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/index.css | CSS | gpl2 | 1,370 |
// examples data
var ex01 = {
template:'div.who',
data:{ who:'Hello Wrrrld' }
};
var ex02 = {
template:'div.hello',
data:{ who:'Hello Wrrrld' },
directive:{ 'span':'who' }
};
var ex03 = {
template:'div.friends',
directive:{
'.who':'who2.name',
'.who@title':'See the tweets of #{who2.twitter}',
'.who@href+':'who2.twitter'
},
data:{
friend:[
{
name:'Hughes',
twitter:'hugheswaroquier'
},{
name:'Yves',
twitter:'yveshiernaux'
}
],
who:'dono',
who2:{
name:'Mic',
twitter:'tchvil'
}
}
};
var ex04 = {
template:'table.playerList',
directive:{
'tbody tr':{
'player<-players':{
'@class+':function(arg){
//arg => {data:data, items:items, pos:pos, item:items[pos]};
var oddEven = (arg.pos % 2 == 0) ? 'even' : 'odd';
var firstLast = (arg.pos == 0) ? 'first' : (arg.pos == arg.player.items.length - 1) ? 'last' : '';
return ' ' + oddEven + ' ' + firstLast;
},
'td':'player',
'td@style': 'cursor:pointer',
'td@onclick':'clickLine(this);'
},
sort:function(a, b){
return a > b ? 1 : -1;
}
}
},
data:{
players:[
"Adrian Meador","Wendy Leatherbury","Michèle Noïjû","Chloé Ellemême","Bryan O'Connor","Walter Hagelstein",
"La \"volante\"","Todd Swift","Valerie Paige"
]
}
};
function clickLine(elm){
alert(elm.innerHTML);
}
var ex05 = {
template:'table.partialTable',
data:{
cols:['name', 'food', 'legs'],
animals:[
{name:'bird', food:'seed', legs:2},
{name:'cat', food:'mouse, bird', legs:4},
{name:'dog', food:'bone', legs:4},
{name:'mouse', food:'cheese', legs:4}
]
},
directive1:{
'th':{
'col<-cols':{
'.':'col'
}
},
'td':{
'col<-cols':{
'@class':'col'
}
}
},
directive2:{
'tbody tr':{
'animal<-animals':{
'td.name':'animal.name',
'td.food':'animal.food',
'td.legs':'animal.legs'
}
}
}
};
var ex06 = {
//template:'table.scoreBoard',
template:'div.scoreBoard',
data:{
teams: [{
name: 'Cats',
players: [
{first: 'Alicé', last: 'Kea\'sler', score: [16, 15, 99, 100]},
{first: '', name: '', score: 0},
{first: 'Vicky', last: 'Benoit', score: [3, 5]},
{first: 'Wayne', last: 'Dartt', score: [9, 10]}
]
},{
name: 'Dogs',
players: [
{first: 'Ray', last: 'Braun', score: 14},
{first: 'Aaron', last: 'Ben', score: 24},
{first: 'Steven', last: 'Smith', score: 1},
{first: 'Kim', last: 'Caffey', score: 19}
]
},{
name:'Birds',
players:null
},{
name: 'Mice',
players: [
{first: 'Natalie', last: 'Kinney', score: 16},
{first: 'Caren', last: 'Cohen', score: 3}
]
}]
},
directive:{
'tr.scoreBoard': {
'team <- teams': {
'td.teamName' : 'team.name',
'tr.teamList': {
'player <- team.players': {
'td.player': '#{player.first} (#{player.last})',
'td.score': '#{player.score}',
'td.position':
function(arg){
return arg.pos + 1;
},
'@class+':
function(arg){
return (arg.player.pos % 2 == 1) ? ' odd' : ' even';
}
}
}
}
}
}
};
var ex07 = {
template:'ul.treeItem',
data:{
children: [{
name: 'Europe',
children: [{
name: 'Belgium',
children: [{
name: 'Brussels',
children:null},{
name: 'Namur'},{
name: 'Antwerpen'}]},{
name: 'Germany'},{
name: 'UK'}]},{
name: 'America',
children: [{
name: 'US',
children: [{
name: 'Alabama'},{
name: 'Georgia'}]},{
name: 'Canada'},{
name: 'Argentina'}]},{
name: 'Asia'},{
name: 'Africa'},{
name: 'Antarctica'}
]
},
directive:{
'li': {
'child <- children': {
'a': 'child.name',
'a@onclick':'alert(\'#{child.name}\');',
'div.children': function(ctxt){
return ctxt.child.item.children ? ex07.rfn(ctxt.child.item):'';
}
}
}
}
};
var ex08 = function(){
var
// Get the html source (cross lib using $p)
// adapt it to your library if you want. i.e: $( '#clock' ) for jQuery
html = $p( '#clock' ),
// json service returning the current time for a timezone
tz = 'Europe/Brussels',
url = 'http://json-time.appspot.com/time.json?tz='+tz+'&callback=showTime&cache=',
//directive to render the template
directive = {
'span.hour': overlay('hour'),
'span.minute': overlay('minute'),
'span.second': overlay('second'),
'span.tz': 'tz'
},
// compile the template once
template = html.compile( directive );
// utility fn to add leading 0 to numbers
function overlay(what){
return function(a){
var val = a.context[what];
return val === 0 ? '00' : val < 10 ? '0' + val : val;
};
}
// JSONP load - script injection with callback function (cross lib GET example)
var noCache = 0;
function loadTime(){
var old = document.getElementById('dataLoad08'),
s = document.createElement("script");
s.src = url + noCache++;
!old ? document.body.appendChild(s) : document.body.replaceChild(s, old);
s.id = 'dataLoad08';
}
// Render the template
window.showTime = function(data){
// rendering but reusing the compiled function template
html = html.render( data, template );
// redo it every sec
window._to = setTimeout( loadTime, 1000 );
};
// Call the time service
loadTime();
};
var ex09 = function() {
//thanks to Ivo Beckers for this example
var noCache = 0; //Safari and Opera
function doYQL(YQ,community,path) {
var URI = "http://query.yahooapis.com/v1/public/yql?&nocache=_nocache&callback=showQuotes&format=json";
URI += ( community ) ? "&env=http://datatables.org/alltables.env" : "";
var YQU = URI + "&q=" + YQ;
var old = document.getElementById('dataLoad09'),
s = document.createElement("script");
s.src = encodeURI(YQU).replace(/_nocache/, noCache++);
!old ? document.body.appendChild(s) : document.body.replaceChild(s, old);
s.id = 'dataLoad09';
}
var symbols = ["^n225","^hsi","^gdaxi","^fchi","^ftse","^dji","^ixic"].sort().join('","');
var YQL_QUERY = 'select symbol, Name, Change, LastTradePriceOnly from yahoo.finance.quotes where symbol in ("'+symbols+'")';
var WI = {
"template":"table.indices",
"header": {
"column":[ "symbol","name","change", "percent", "price" ]
},
"directivehead": {
"th": {
"c<-column": {
".":"c"
}
},
'td':{
"c<-column":{
"@class":"c"
}
}
},
"directivebody": {
"tbody tr": {
"q<-quote":{
"td.symbol":"q.symbol",
"td.name":"q.Name",
"td.change":"q.Change",
"td.percent":function(a){
return Math.floor(parseFloat(a.item.Change) / parseFloat(a.item.LastTradePriceOnly) * 1000000) / 10000 + ' %';
},
"td.price":"q.LastTradePriceOnly",
"td@class+":function(a){
return (/^-/).test(a.item.Change) ? ' red' : ' green';
}
}
}
}
};
var TEMPLATE = $p( WI.template ).render( WI.header, WI.directivehead ).compile( WI.directivebody );
doYQL(YQL_QUERY,true,null);
window.showQuotes = function(data){
if(typeof data.error !== 'undefined'){
$p('table.indices')[0].innerHTML = '<tr><td>Error in the service: ' + data.error.description + '</td></tr>';
}else{
var PAYLOAD = data.query.results;
$p('table.indices').render( PAYLOAD, TEMPLATE );
window._to10 = setTimeout(function(){
doYQL(YQL_QUERY,true,null);
}, 10000);
}
};
};
var ex10 = {
template:'form.sizes',
directive:{
'option': {
'size <- sizes': {
'.':'#{size.val} - #{size.name}',
'@value':'size.val',
'@selected':'size.sel'
}
}
},
data:{
sizes: [{ val:'S', name: 'small' }, { val:'M', name: 'medium', sel: true }, {val:'L', name:'large'}]
}
};
var ex11 = function(){
var data = {
'makes':[
{
"name":"Ford",
"models":[
{"name":"Fusion"},
{"name":"Mustang"}
]
},
{
"name":"Chevrolet",
"models":[
{"name":"Aveo"},
{"name":"Camaro"}
]
}
]
};
// render the first drop down
$p('select.make').render(data, {
'@onchange':'"clickSelect(this);"',
'option.values':{
'make <- makes':{
'.':'make.name'
}
}
});
// compile the second drop down to reuse it for each changes
var subSel = $p('select.model').compile({
'@disabled':function(a){
return a.context === false ? 'x':'';
},
'option':{
'model <-':{
'.':'model.name'
}
}
});
// the onchange function for the first drop down
window.clickSelect = function(sel){
var idx = sel.selectedIndex-1,
models;
if(idx >= 0){
models = data.makes[idx].models;
$p('select.model').render(models, subSel);
}else{
$p('select.model').render(false, subSel);
}
};
};
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/js/examples.js | JavaScript | gpl2 | 8,657 |
// global functions for cross site example
var loadLib, runAll, run, transform;
(function(){
var currLib = 'jquery'; //default lib
loadLib = function(lib){
currLib = lib;
document.getElementById( 'chooseLib' ).innerHTML = '<div id="libLoaded"> Loading... '+ lib + '</div>';
if(lib === 'pure'){
showExamples();
return;
}
loadScript([ 'libs/' + lib + '.js'], showExamples);
};
//load scripts in sequence
function loadScript(srcs, done, howMany) {
if (srcs.length === 0) { return; }
howMany = howMany || srcs.length;
var s = document.createElement('script'), clunky = false;
var almostDone = function() {
if ( !clunky || (clunky && (s.readyState === 'complete' || s.readyState === 'loaded') ) ) {
loadScript(srcs, done, --howMany);
done();
}
};
s.charset = "UTF-8";
s.src = srcs.shift();
if (typeof s.addEventListener !== 'undefined') {
s.addEventListener('load', almostDone, false);
} else if (typeof s.attachEvent !== 'undefined') {
clunky = true;
s.attachEvent('onreadystatechange', almostDone);
}
document.body.appendChild(s);
}
function showExamples(){
//initialise the lib
currLib !== 'pure' && $p.libs[currLib]();
document.getElementById( 'libLoaded' ).innerHTML = '<b>'+ currLib + '</b> is loaded<br />You can run the examples below individually or <a href="javascript:void(0)" onclick="runAll(this);">all at once</a><br />';
document.getElementById( 'examples' ).style.display = 'block';
var lis = $p( 'ul.exampleList li' ),
lii,
cn,
span;
for(var i = 0, ii = lis.length; i < ii; i++){
lii = lis[i];
if(!(/^ex[0-9]+$/).test(lis[i].className)){
continue;
}
var h = $p('h3', lii);
if(h[0]){
h = h[0];
if(!(/SPAN/).test(h.nextSibling.tagName)){
span = document.createElement( 'SPAN' );
h.parentNode.insertBefore(span, h.nextSibling);
}else{
span = h.nextSibling;
}
cn = lis[i].className;
window[cn].id = cn;
span.id = cn;
span.innerHTML =
'<a class="run" href="javascript:void(0)" onclick="run(this, '+cn+');">Run</a>';
}
}
}
// run all examples at once
runAll = function(a){
a.onclick = function(){return false;};
var lis = $p( 'ul.exampleList li' ),
lii;
for(var i = 0, ii = lis.length; i < ii; i++){
lii = lis[i];
if(!(/^ex[0-9]+$/).test(lis[i].className)){
continue;
}
run( $p('a.run', lii)[0], window[lii.className] );
}
};
//example of plugin to debug a transformation
$p.plugins.compileDebug = function(directive, ctxt, template){
debugger;
var rfn = this._compiler( ( template || this[0] ).cloneNode( true ), directive, ctxt);
var json;
return function(data){
json = json || data;
return rfn( { data: data, json:json } );
};
};
// choose between run or debug
run = function(elm, fn, debug){
if(!elm){return;}
elm.innerHTML = 'Show Source';
elm.onclick = function(){
showSource(fn, this);
return false;
};
if(debug === true){
$p.plugins.__compile = $p.plugins.compile;
$p.plugins.compile = $p.plugins.compileDebug;
}
transform(fn, debug);
if(debug === true){
$p.plugins.compile = $p.plugins.__compile;
}
};
function showSource(o, a){
var li = $p('li.' + o.id + ' div.template')[0],
old = document.getElementById('sourceCodes'),
src = document.createElement('DIV'),
srcNb = 0,
txtShow = 'Show Source',
txtHide = 'Hide Source',
addSrc = function(title, source){
srcNb++;
var t = document.createElement('DIV'),
tt = document.createElement('DIV');
t.className = 'sourceTitle';
t.innerHTML = title;
tt.className = 'sourceCode';
tt.innerHTML = '<pre>'+source+'</pre>';
tt.insertBefore(t, tt.firstChild);
src.appendChild(tt);
};
if(old){
$p('a', old.parentNode)[0].innerHTML = txtShow;
old.parentNode.removeChild(old);
}
src.id = 'sourceCodes';
if(typeof o === 'function'){
addSrc('Function', o.toString());
}else{
o.template && addSrc('HTML', o.original.replace(/\</g,'<').replace(/\>/g,'>').replace(/\t/g, ' '));
o.directive && addSrc('Directive', JSON.stringify(o.directive, null, 2));
o.data && addSrc('Data', JSON.stringify(o.data, null, 2));
};
src.className = 'cols' + srcNb;
li.parentNode.insertBefore(src, li);
var oldClick = a.onclick;
a.innerHTML = txtHide;
a.onclick = function(){
a.innerHTML = txtShow;
try{li.parentNode.removeChild(src);}catch(e){};//IE fails sometimes on it
a.onclick = oldClick;
return false;
};
};
// run a transformation
transform = function(ex, debug){
var template;
if(typeof ex === 'function'){
ex();
}else{
switch(currLib){
case 'domassistant':
case 'jquery':
template = $( ex.template );
break;
case 'mootools':
template = $(document).getElement( ex.template );
case 'prototype':
template = $$( ex.template )[0];
default:
template = $p( ex.template );
}
//keep a copy of the template
var dv = document.createElement('DIV');
dv.appendChild((template[0] || template).cloneNode(true));
ex.original = dv.innerHTML;
switch(ex.id){
case 'ex01':
case 'ex02':
case 'ex03':
case 'ex04':
case 'ex06':
//autoRender with data (and directives)
template.autoRender( ex.data , ex.directive );
break;
case 'ex05':
/* double rendering */
template.render( ex.data, ex.directive1 ).render( ex.data, ex.directive2 );
break;
case 'ex07':
/* Recursion */
var rfn = template.compile( ex.directive );
if(typeof rfn[0] === 'function'){ //DOMAssistant sends back an array?
rfn = rfn[0];
}
ex.rfn = rfn;
//some libs send back an array, some send the node
( template[0] || template ).parentNode.innerHTML = rfn( ex.data );
break;
default:
// default rendering with data and directive
template.render( ex.data, ex.directive );
}
}
};
}());
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/js/demo.js | JavaScript | gpl2 | 5,976 |
//test from https://gist.github.com/729432
var doc = require('jsdom').jsdom(),
window = doc.createWindow(),
jQueryElement = doc.createElement('script'),
pureElement = doc.createElement('script'),
body = doc.getElementsByTagName('body').item(0),
directive = { 'span.who': 'who' },
data = { 'who': 'Hello Wrrrld' };
body.innerHTML = '<div id="template"><div class="hello">\
<span class="who"></span>\
</div></div>';
// Load up jQuery
jQueryElement.src = 'http://code.jquery.com/jquery-1.4.4.js';
doc.head.appendChild(jQueryElement);
// Load up PURE
pureElement.src = 'http://beebole.com/pure/wp-content/themes/BeeBole-pure/libs/pure.js';
doc.head.appendChild(pureElement);
http.createServer(function (req, res) {
window.jQuery('div#template').render(data, directive);
}).listen(1234, '127.0.0.1');
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/node/test.js | JavaScript | gpl2 | 873 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>PURE Unobtrusive Rendering Engine for HTML - Version 2</title>
<link rel="stylesheet" type="text/css" href="index.css" />
<!--JSON needed to show the source code only -->
<script src="libs/json2.js"></script>
<script src="libs/pure_min.js"></script>
<!-- Example page files -->
<script src="js/demo.js"></script>
<script src="js/examples.js"></script>
</head>
<body>
<a href="http://github.com/pure/pure/tree/version2" style="float:right;margin:1em">Project site & Download</a>
<div id="chooseLib">
Choose a library to run the examples with:<br />
<a class="lib" href="javascript:void(0)" onclick="loadLib('dojo');">dojo</a>
<a class="lib" href="javascript:void(0)" onclick="loadLib('domassistant');">DomAssistant</a>
<a class="lib" href="javascript:void(0)" onclick="loadLib('jquery');">jQuery</a>
<a class="lib" href="javascript:void(0)" onclick="loadLib('mootools');">Mootools</a>
<a class="lib" href="javascript:void(0)" onclick="loadLib('prototype');">Prototype</a>
<a class="lib" href="javascript:void(0)" onclick="loadLib('sizzle');">Sizzle</a>
<a class="lib" href="javascript:void(0)" onclick="loadLib('sly');">Sly</a> -
<a class="lib" href="javascript:void(0)" onclick="loadLib('pure');">PURE Alone (modern browsers only)</a>
<p>Or look at the source code of the tutorials:</p>
<ul>
<li>Automatic rendering(autoRender):
<ol>
<li><a href="tutorial/tuto1.html">Set the value of an HTML node</a>
<li><a href="tutorial/tuto2.html">Set the value to an HTML attribute</a>
<li><a href="tutorial/tuto3.html">Repeat a HTML node (loop)</a>
</ol>
<li>Render with directives:
<ol>
<li><a href="tutorial/tuto4.html">Set the value of an HTML node and attribute</a>
<li><a href="tutorial/tuto5.html">Repeat an HTML node (loop)</a>
<li><a href="tutorial/tuto9.html">How to use PURE with jQuery</a>
<li><a href="tutorial/tuto5b.html">Use sort and filter on loops</a>
<li><a href="tutorial/tuto5c.html">Chaining multiple rendering</a>
<li><a href="tutorial/tuto5d.html">Nested loops</a>
<li><a href="tutorial/tuto6.html">Using function as directive for more complex needs</a>
<li><a href="tutorial/tuto8.html">Recursion example</a>
<li><a href="tutorial/tuto7.html">Extend PURE with a plugin. Here an post rendering animation.</a>
</ol>
</ul>
</div>
<div id="examples">
<ul class="exampleList">
<li class="ex01">
<h3>1. Hello World</h3>
<div class="template">
<div class="who"></div>
</div>
</li>
<li class="ex02">
<h3>2. Hello World with directives</h3>
<div class="template">
<div class="hello">
<span></span>
</div>
</div>
</li>
<li class="ex03">
<h3>3. Auto Rendering with loops (+ directives)</h3>
<div class="template">
<div class="friends">
The friends of <a target="_blank" href="http://twitter.com/" class="who"></a> are
<ul>
<li class="friend">
<a target="_blank" class="name twitter@title twitter@href+" href="http://twitter.com/"></a>
</li>
</ul>
</div>
</div>
</li>
<li class="ex04">
<h3>4. Loop on a table and events</h3>
<div class="template">
<table class="playerList">
<thead>
<tr>
<th>Player</th>
</tr>
</thead>
<tbody>
<tr class="player">
<td>Chloe</td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="ex05">
<h3>5. Dynamic table</h3>
<div class="template">
<table class="partialTable">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="ex06">
<h3>6. Nested loops</h3>
<div class="template">
<div class="scoreBoard">
<table>
<tbody>
<tr class="scoreBoard">
<td class="teamName">Team Name</td>
<td class="teamPlace">
<table>
<thead>
<tr>
<th class="position">Position</th>
<th class="player">Player</th>
<th class="score">Score</th>
</tr>
</thead>
<tbody>
<tr class="teamList">
<td class="position">1</td>
<td class="player">Chloe</td>
<td class="score">3</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</li>
<li class="ex07">
<h3>7. Recursion</h3>
<div class="template">
<ul class="treeItem">
<li>
<a class="name" href="javascript:void(0)">name</a>
<div class="children"></div>
</li>
</ul>
</div>
</li>
<li class="ex08">
<h3>8. Reuse a template and load JSONP data every sec</h3>
<div class="template">
<div id="clock">
It is now <span class="hour"></span> : <span class="minute"></span> : <span class="second"></span><br />
In <span class="tz"></span>
</div>
</div>
<p><a href="javascript:void(0)" onclick="clearTimeout(_to);">stop it!</a></p>
</li>
<li class="ex09">
<style>
.ex09 table { border:1px solid #999; text-align:left; border-collapse:collapse;}
.ex09 th { padding:.5em; background:#FFC;text-align:center;border-bottom:1px solid #999;border-right:1px solid #999;}
.ex09 td { padding:.3em; border-right:1px solid #999;border-bottom:1px solid #999;background:#FFF;}
.ex09 .percent, .price, .change{text-align:right;}
.ex09 .red { color:#900; }
.ex09 .green { color:#090; }
</style>
<h3>9. World Indices: dynamic table, reuse a template and JSONP load every 10 sec</h3>
<div class="template">
<table class="indices">
<thead><tr><th></th></tr></thead>
<tbody><tr><td></td></tr></tbody>
</table>
</div>
<a href="javascript:void(0)" onclick="clearTimeout(_to10);this.style.visibility='hidden';">stop it!</a>
</li>
<li class="ex10">
<h3>10. Populate a drop down list and set a default value</h3>
<div class="template">
<form class="sizes">
<select>
<option value="XXS">Extra Small</option>
</select>
</form>
</div>
</li>
<li class="ex11">
<h3>11. Linked drop down boxes</h3>
<div class="template">
Make:
<select class="make">
<option>Choose..</option>
<option class="values"></option>
</select>
Model:
<select disabled class="model">
<option></option>
</select>
</div>
</li>
</ul>
</div>
</body>
</html>
| zzyn125-bench | BigMelon/Backup/jslib_backup/pure-pure-26579d6/index.html | HTML | gpl2 | 6,610 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BigMelon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BigMelon")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8b7adc11-159c-416d-ac3f-5678504b073e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| zzyn125-bench | BigMelon/Properties/AssemblyInfo.cs | C# | gpl2 | 1,387 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class CostController : Controller
{
//
// GET: /Cost/
public ActionResult Index()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/CostController.cs | C# | gpl2 | 342 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class ScheduleController : Controller
{
//
// GET: /Schedule/
public ActionResult Index()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/ScheduleController.cs | C# | gpl2 | 350 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class SettingController : Controller
{
//
// GET: /Setting/
public ActionResult Index()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/SettingController.cs | C# | gpl2 | 348 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class EmployeeController : Controller
{
//
// GET: /Employee/
public ActionResult Index()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/EmployeeController.cs | C# | gpl2 | 350 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class OrderController : Controller
{
//
// GET: /Order/
public ActionResult Index()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/OrderController.cs | C# | gpl2 | 344 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Linq;
namespace BigMelon.Controllers
{
public class ProductController : Controller
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
return View();
}
public ActionResult App()
{
return View("Products");
}
public void GetAppData()
{
List<string> test = new List<string>();
Response.Write(JToken.FromObject(test).ToString());
}
public ActionResult Type()
{
var members = new List<string>();
for (var i = 0; i < 100; i++)
{
members.Add(string.Format("Test Member {0}",i));
}
ViewBag.Members = members;
return View("ProductsCategories");
}
}
}
| zzyn125-bench | BigMelon/Controllers/ProductController.cs | C# | gpl2 | 1,167 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class StoreController : Controller
{
//
// GET: /Store/
public ActionResult Index()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/StoreController.cs | C# | gpl2 | 344 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BigMelon.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Store System";
return View();
}
public ActionResult About()
{
return View();
}
}
}
| zzyn125-bench | BigMelon/Controllers/HomeController.cs | C# | gpl2 | 440 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using BigMelon.Models;
using Newtonsoft.Json;
namespace BigMelon.Controllers
{
public class AccountController : Controller
{
//
// GET: /Account/LogOn
public ActionResult LogOn()
{
return View();
}
//
// POST: /Account/LogOn
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
//
// GET: /Account/LogOff
public ActionResult LogOff()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
//
// GET: /Account/Register
public ActionResult Register()
{
return View();
}
//
// POST: /Account/Register
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", ErrorCodeToString(createStatus));
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
//
// GET: /Account/ChangePassword
[Authorize]
public ActionResult ChangePassword()
{
return View();
}
//
// POST: /Account/ChangePassword
[Authorize]
[HttpPost]
public ActionResult ChangePassword(ChangePasswordModel model)
{
if (ModelState.IsValid)
{
// ChangePassword will throw an exception rather
// than return false in certain failure scenarios.
bool changePasswordSucceeded;
try
{
MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
}
catch (Exception)
{
changePasswordSucceeded = false;
}
if (changePasswordSucceeded)
{
return RedirectToAction("ChangePasswordSuccess");
}
else
{
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
//
// GET: /Account/ChangePasswordSuccess
public ActionResult ChangePasswordSuccess()
{
return View();
}
#region Status Codes
private static string ErrorCodeToString(MembershipCreateStatus createStatus)
{
// See http://go.microsoft.com/fwlink/?LinkID=177550 for
// a full list of status codes.
switch (createStatus)
{
case MembershipCreateStatus.DuplicateUserName:
return "User name already exists. Please enter a different user name.";
case MembershipCreateStatus.DuplicateEmail:
return "A user name for that e-mail address already exists. Please enter a different e-mail address.";
case MembershipCreateStatus.InvalidPassword:
return "The password provided is invalid. Please enter a valid password value.";
case MembershipCreateStatus.InvalidEmail:
return "The e-mail address provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidAnswer:
return "The password retrieval answer provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidQuestion:
return "The password retrieval question provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidUserName:
return "The user name provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
#endregion
}
}
| zzyn125-bench | BigMelon/Controllers/AccountController.cs | C# | gpl2 | 6,796 |
-----------------------------------------
*** product all template ***
-----------------------------------------
*** main template ***
-----------------------------------------
{#template main}
<div>
<div>{$T.name.bold()}</div>
{#include table root=$T.table}
</div>
{#/template main}
-----------------------------------------
*** main table ***
-----------------------------------------
{#template table}
<table>
{#foreach $T as r}
{#include row root=$T.r}
{#/for}
</table>
{#/template table}
-----------------------------------------
*** for each row ***
-----------------------------------------
{#template row}
<tr bgcolor="{#cycle values=['#AAAAEE','#CCCCFF']}">
<td>{$T.name.bold()}</td>
<td>{$T.age}</td>
<td>{$T.mail.link('mailto:'+$T.mail)}</td>
</tr>
{#/template row}
-----------------------------------------
*** product edit form ***
-----------------------------------------
{#template list}
<div>
<div>{$T.name.bold()}</div>
{#include table root=$T.table}
</div>
{#/template list}
-----------------------------------------
| zzyn125-bench | BigMelon/Templates/Product.tpl | Smarty | gpl2 | 1,123 |
#!/usr/bin/perl
#
# ConnectBot: simple, powerful, open-source SSH client for Android
# Copyright 2011 Kenny Root, Jeffrey Sharkey
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use LWP::UserAgent;
#use LWP::Debug qw(+);
use HTTP::Cookies;
use HTML::Form;
use Data::Dumper;
use IO::File;
use XML::LibXML;
use Locale::Language;
use Locale::Country;
my %config = (
'url' => undef,
'username' => undef,
'password' => undef,
'build' => undef,
'branch' => undef,
);
my $baseUrl;
my $fileRegex;
sub setupUA() {
my $ua = LWP::UserAgent->new;
push @{ $ua->requests_redirectable }, 'POST';
$ua->cookie_jar(HTTP::Cookies->new);
return $ua;
}
sub getLoginToken($) {
my $ua = shift;
my $response = $ua->get("https://www.google.com/accounts/Login");
my @forms = HTML::Form->parse($response->content, $response->base);
my $f = shift @forms;
$f->param('Email', $config{'username'});
$f->param('Passwd', $config{'password'});
my $req = $f->click();
$response = $ua->request($req);
if (not $response->is_success) {
print "Got the error " . $response->status_line . "\n";
die "cannot login";
}
}
sub uploadFile($$) {
my $ua = shift;
my $targetFile = shift;
# Go to package upload
my $response = $ua->get($baseUrl . "entry");
my @forms = HTML::Form->parse($response->content, $response->base);
my $f = $forms[$#forms];
my $summary = $config{'appname'} . " " . $config{'branch'} . " development snapshot";
if (defined($config{'build'})) {
$summary .= " " . $config{'build'};
}
$f->param('summary', $summary);
$f->param('file', $targetFile);
$f->param('label', 'Type-Installer', 'Featured');
my $req = $f->click('btn');
$response = $ua->request($req);
return ($response->code eq "302");
}
sub unfeature($$) {
my $ua = shift;
my $url = shift;
print "unfeaturing $url\n";
my $response = $ua->get($url);
if (not $response->is_success) {
warn "couldn't reach $url";
return 0;
}
my @forms = HTML::Form->parse($response->content, $response->base);
my $f = $forms[2];
my $i = 0;
my $input = $f->find_input('label', 'text', $i++);
while ($i != -1 and defined($input)) {
if ($input->value eq 'Featured') {
$input->value('');
$i = -1;
} else {
$input = $f->find_input('label', 'text', $i++);
}
}
my $req = $f->click();
$response = $ua->request($req);
if (not $response->is_success) {
warn "unfeature: got the error " . $response->status_line . "\n";
return 0;
}
return 1;
}
sub deleteFile($$) {
my $ua = shift;
my $name = shift;
my $url = $baseUrl . "delete?name=" . $name;
my $response = $ua->get($url);
if (not $response->is_success) {
warn "deleteFile: couldn't reach $url";
return 0;
}
my @forms = HTML::Form->parse($response->content, $response->base);
my $f = $forms[2];
my $req = $f->click('delete');
$response = $ua->request($req);
if (not $response->is_success) {
warn "deleteFile: got the error " . $response->status_line . "\n";
return 0;
}
print "Deleted $name\n";
return 1;
}
sub fixFeatured($) {
my $ua = shift;
my $response = $ua->get($baseUrl . 'list?q=label:Featured');
my $parser = XML::LibXML->new();
$parser->recover(1);
my $doc = $parser->parse_html_string($response->content);
my $root = $doc->getDocumentElement;
my @nodes = $root->findnodes('//table[@id="resultstable"]//td[contains(@class, "col_1") and a[@class="label" and contains(@href, "Featured")]]/a[1]/@href');
foreach my $node (@nodes) {
my $href = $node->findvalue('.');
next if ($href !~ $fileRegex);
unfeature($ua, $baseUrl . $href) if ($2 ne $config{'build'} and $1 eq $config{'branch'});
}
}
sub deleteUndownloaded($$) {
my $ua = shift;
my $threshhold = shift;
my $offset = 0;
my $parser = XML::LibXML->new();
$parser->recover(1);
my @toDelete = ();
while (1) {
my $response = $ua->get($baseUrl . 'list?start=' . $offset);
my $doc = $parser->parse_html_string($response->content);
my $root = $doc->getDocumentElement;
my @nodes = $root->findnodes('//div[contains(., "Your search did not generate any results.")]');
last if $#nodes > -1;
@nodes = $root->findnodes('//table[@id="resultstable"]//tr[@id="headingrow"]/th[starts-with(normalize-space(a), "DownloadCount")]/@class');
die 'Could not find DownloadCount header column' if ($#nodes == -1);
my $downloadCountClass = $nodes[0]->findvalue('.');
@nodes = $root->findnodes('//table[@id="resultstable"]//td[contains(@class, "col_1") and not(a[@class="label" and contains(@href, "Featured")]) and ../td[contains(@class, "'.$downloadCountClass.'") and normalize-space(.) <= "'.$threshhold.'"]]/a[1]/@href');
foreach my $node (@nodes) {
my $href = $node->findvalue('.');
next if ($href !~ $fileRegex);
if ($href =~ /detail\?name=([^&]+)&/) {
push @toDelete, $1;
print "Pushing on $1\n";
}
}
$offset += 100;
}
#foreach my $href (@toDelete) {
# deleteFile($ua, $href);
#}
}
pod2usage(1) if ($#ARGV < 0);
GetOptions(\%config,
'appname=s',
'username=s',
'password=s',
'build=s',
'branch=s',
);
my $projectName = lc($config{'appname'});
$baseUrl = 'http://code.google.com/p/' . $projectName . '/downloads/';
$fileRegex = qr/$config{'appname'}-git-([a-z]*)-([0-9_-]*)(-[a-zA-Z]*)?\.apk/;
my $ua = setupUA();
getLoginToken($ua);
my $file = shift @ARGV;
uploadFile($ua, $file);
fixFeatured($ua);
deleteUndownloaded($ua, 10);
__END__
=head1 NAME
google-code-upload.pl - Upload builds to Google Code
=head1 SYNOPSIS
google-code-upload.pl [options] <file>
=head1 OPTIONS
=over 8
=item B<--username>
Username which has permission to uplaod files.
=item B<--password>
Password for user matching the username.
=item B<--appname>
Name used for the project's name (lowercase) and for matching existing
files in download.
=item B<--build>
Build identifier (e.g., 2011-08-01-0001)
=item B<--branch>
Branch that this build belongs to. Optional.
=back
=head1 DESCRIPTION
B<This program> uploads builds to a Google Code website, features the new
uploads, and unfeatures any old uploades.
=head1 AUTHOR
Kenny Root
=head1 COPYRIGHT and LICENSE
Copyright 2011 Kenny Root, Jeffrey Sharkey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
| zzsuper001-linuxshell | tools/google-code-upload.pl | Perl | asf20 | 7,224 |
<html>
<body style="background-color: #000; color: #fff">
<h2>Helpful hints</h2>
<p>When you have multiple sessions open, you can 'pan' between them by swiping your finger left-to-right or right-to-left over the screen.</p>
<p>Long-press on your Android desktop to create direct shortcuts to frequently-used SSH hosts.</p>
<p>Slide your finger up/down on the right-half of the terminal screen to look at the scrollback history. Slide up/down on the left-half to send the page up/down keys.</p>
</body>
</html> | zzsuper001-linuxshell | assets/help/Hints.html | HTML | asf20 | 515 |
<html>
<body style="background-color: #000; color: #fff">
<p><img src="http://connectbot.googlecode.com/svn/trunk/www/magic-cb-screen.png" width="100%" /></p>
<h2>Caveats</h2>
<p>Since ConnectBot doesn't use any of the normal TextView
widgets, Android's IME structure isn't designed to directly
support it.</p>
<p>The best way to use Android with a virtual keyboard is in <strong>Portrait</strong>
mode. By default, ConnectBot is set to use <strong>Portrait</strong>
mode when no hardware keyboard is present. To change this setting, go to
<strong>Preferences</strong> from the <strong>Host List</strong>.</p>
<p>In <strong>Landscape</strong> mode, the Android virtual keyboard
(or other IMEs) will take up the entire screen. Android provides no way
for ConnectBot to resize the terminal view in <strong>Landscape</strong>.
However, you may use a <i>work-around</i>: <strong>Force Resize</strong>
to fit above the virtual keyboard if desired.</p>
<p>On devices without a hardware keyboard, you may press and hold
the <strong>MENU</strong> button to bring up the virtual keyboard. NOTE:
This applies to any program on the Android platform; it is not
ConnectBot specific.</p>
<h2>How to Enter Control, Alt, Escape, and Function Keys</h2>
<p>You can enter any key combination with ConnectBot and the virtual
keyboard, but you must know how keys are mapped on a normal console. For
instance, usually combinations of ALT+letter on a PC keyboard are
actually mapped to sending, sequentially, ESC key then the letter.</p>
<p>Note there are also screen gestures: see the ScreenGestures help topic.</a>
for <strong>Page Up</strong> and <strong>Page Down</strong>.</p>
<ul>
<li>Trackball: 1 press is <strong>CTRL</strong>, 2 presses sends <strong>ESC</strong>
</li>
<li><strong>Tab key</strong> = <strong>CTRL + i</strong></li>
<li><strong>Function key</strong> = <strong>CTRL + number</strong>
</li>
</ul>
<h2>Examples</h2>
<ul>
<li><strong>ESC</strong> = Press the trackball twice.</li>
<li><strong>ALT + Right Arrow</strong> = Press trackball twice
then move trackball to right.</li>
<li><strong>CTRL + A</strong> = Press trackball once then tap the
"A" key on the soft keyboard.</li>
<li><strong>F3</strong> = Press trackball once then tap the
"3" key on the soft keyboard.</li>
</ul>
</body>
</html>
| zzsuper001-linuxshell | assets/help/VirtualKeyboard.html | HTML | asf20 | 2,345 |
<html>
<body style="background-color: #000; color: #fff">
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/keyboard.jpg" /></p>
<p>Here are some keyboard shortcuts available when a <strong>hardware
keyboard</strong> is present. If you're using a phone where the main input
type is a <strong>virtual keyboard</strong>, please see the VirtualKeyboard help topic.
</p>
<p><strong>Note:</strong> the side that <strong>shift</strong>, <strong>alt</strong>,
<strong>slash</strong>, and <strong>tab</strong> uses can be changed in
preferences between left, right, and disabled.</p>
<ul>
<li>Control key (CTRL)</li>
<blockquote>Pressing once on the trackball will toggle on
<strong>control</strong> for the next character typed. The cursor will
indicate this state with a < symbol. Note that pressing the
trackball again will send an <strong>escape</strong> key.</blockquote>
</ul>
<ul>
<li>Escape (ESC)</li>
<blockquote>Pressing twice on the trackball will send <strong>escape</strong>
key. Note that some other terminal emulators map pressing <strong>ALT-<i>key</i></strong>
to <strong>escape + <i>key</i></strong>.</blockquote>
</ul>
<ul>
<li>Shift</li>
<blockquote>Pressing the <strong>shift</strong> (up arrow)
key once will make the next key typed its uppercase variant according
to the keyboard layout. This state is indicated with an outline of a
triangle on the top of the cursor. Pressing it twice will turn on <strong>shift
lock</strong> which is indicated by a solid triangle on the top of the cursor.</blockquote>
</ul>
<ul>
<li>Alt</li>
<blockquote>Pressing the <strong>Alt</strong> key once
will make the next key typed its symbol as indicated on the keyboard.
This state is indicated with the outline of a triangle on the bottom of
the cursor. Pressing it twice will turn on <strong>alt lock</strong>
which is indicated by a solid triangle on the bottom of the cursor.</blockquote>
</ul>
<ul>
<li>Slash (opposite side Alt)</li>
<blockquote>The opposite side <strong>alt</strong> key can
be used as a shortcut for the forward slash / character. This aids in
quickly typing directories on the G1.</blockquote>
</ul>
<ul>
<li>Tab (opposite side Shift)</li>
<blockquote>The opposite side <strong>shift</strong> key
can be used as a shortcut for the <strong>tab</strong> key (CTRL-i) for
quick completion in many shells.</blockquote>
</ul>
<ul>
<li>Function keys (F1 through F10)</li>
<blockquote>Hold down the shift key and press numbers 1
through 10 to send F1 through F10 respectively.</blockquote>
</ul>
</body>
</html>
| zzsuper001-linuxshell | assets/help/PhysicalKeyboard.html | HTML | asf20 | 2,582 |
<html>
<body style="background-color: #000; color: #fff">
<p>Gestures in ConnectBot allow a user to do several things for
which there's no keyboard equivalent. If the gestures seem
backward, then imagine that you're grabbing the text and moving it
with your finger.</p>
<h1><a name="Page_Up_/_Page_Down" />Page Up / Page Down</h1>
<p>Swiping your finger up and down on the left third of the screen
will send a page up and page down key to the remote host. Many programs
map this to scrolling back into history such as irssi or tinyfugue.</p>
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/gesture-pgup.png" />
Page Up gesture</p>
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/gesture-pgdn.png" />
Page Down gesture</p>
<h1><a name="Scroll_back_/_Scroll_forward" />Scroll back / Scroll
forward</h1>
<p>Swiping your finger up on the right side of the screen allows you
to scroll backward and forward in the local terminal buffer history.</p>
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/gesture-scrollback.png" />
Scroll back gesture</p>
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/gesture-scrollforward.png" />
Scroll forward gesture</p>
<h1><a name="Switching_hosts" />Switching hosts</h1>
<p>Swiping your finger from one side of the screen to the other will
switch between currently connected hosts.</p>
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/gesture-hostprev.png" />
Previous host gesture</p>
<p><img
src="http://connectbot.googlecode.com/svn/trunk/www/gesture-hostnext.png" />
Next host gesture</p>
</body>
</html> | zzsuper001-linuxshell | assets/help/ScreenGestures.html | HTML | asf20 | 1,613 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot;
import java.util.List;
import org.connectbot.bean.HostBean;
import org.connectbot.service.TerminalBridge;
import org.connectbot.service.TerminalManager;
import org.connectbot.transport.TransportFactory;
import org.connectbot.util.HostDatabase;
import org.connectbot.util.PreferenceConstants;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.Intent.ShortcutIconResource;
import android.content.SharedPreferences.Editor;
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View.OnKeyListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
public class HostListActivity extends ListActivity {
public final static int REQUEST_EDIT = 1;
public final static int REQUEST_EULA = 2;
protected TerminalManager bound = null;
protected HostDatabase hostdb;
private List<HostBean> hosts;
protected LayoutInflater inflater = null;
protected boolean sortedByColor = false;
private MenuItem sortcolor;
private MenuItem sortlast;
private Spinner transportSpinner;
private TextView quickconnect;
private SharedPreferences prefs = null;
protected boolean makingShortcut = false;
protected Handler updateHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
HostListActivity.this.updateList();
}
};
private ServiceConnection connection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
bound = ((TerminalManager.TerminalBinder) service).getService();
// update our listview binder to find the service
HostListActivity.this.updateList();
}
public void onServiceDisconnected(ComponentName className) {
bound = null;
HostListActivity.this.updateList();
}
};
@Override
public void onStart() {
super.onStart();
// start the terminal manager service
this.bindService(new Intent(this, TerminalManager.class), connection, Context.BIND_AUTO_CREATE);
if(this.hostdb == null)
this.hostdb = new HostDatabase(this);
}
@Override
public void onStop() {
super.onStop();
this.unbindService(connection);
if(this.hostdb != null) {
this.hostdb.close();
this.hostdb = null;
}
}
@Override
public void onResume() {
super.onResume();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_EULA) {
if(resultCode == Activity.RESULT_OK) {
// yay they agreed, so store that info
Editor edit = prefs.edit();
edit.putBoolean(PreferenceConstants.EULA, true);
edit.commit();
} else {
// user didnt agree, so close
this.finish();
}
} else if (requestCode == REQUEST_EDIT) {
this.updateList();
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.act_hostlist);
this.setTitle(String.format("%s: %s",
getResources().getText(R.string.app_name),
getResources().getText(R.string.title_hosts_list)));
// check for eula agreement
this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean agreed = prefs.getBoolean(PreferenceConstants.EULA, false);
if(!agreed) {
this.startActivityForResult(new Intent(this, WizardActivity.class), REQUEST_EULA);
}
this.makingShortcut = Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())
|| Intent.ACTION_PICK.equals(getIntent().getAction());
// connect with hosts database and populate list
this.hostdb = new HostDatabase(this);
ListView list = this.getListView();
this.sortedByColor = prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false);
//this.list.setSelector(R.drawable.highlight_disabled_pressed);
list.setOnItemClickListener(new OnItemClickListener() {
public synchronized void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// launch off to console details
HostBean host = (HostBean) parent.getAdapter().getItem(position);
Uri uri = host.getUri();
Intent contents = new Intent(Intent.ACTION_VIEW, uri);
contents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (makingShortcut) {
// create shortcut if requested
ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(HostListActivity.this, R.drawable.icon);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, contents);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, host.getNickname());
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
setResult(RESULT_OK, intent);
finish();
} else {
// otherwise just launch activity to show this host
HostListActivity.this.startActivity(contents);
}
}
});
this.registerForContextMenu(list);
quickconnect = (TextView) this.findViewById(R.id.front_quickconnect);
quickconnect.setVisibility(makingShortcut ? View.GONE : View.VISIBLE);
quickconnect.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_UP) return false;
if(keyCode != KeyEvent.KEYCODE_ENTER) return false;
return startConsoleActivity();
}
});
transportSpinner = (Spinner)findViewById(R.id.transport_selection);
transportSpinner.setVisibility(makingShortcut ? View.GONE : View.VISIBLE);
ArrayAdapter<String> transportSelection = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, TransportFactory.getTransportNames());
transportSelection.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
transportSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) {
String formatHint = TransportFactory.getFormatHint(
(String) transportSpinner.getSelectedItem(),
HostListActivity.this);
quickconnect.setHint(formatHint);
quickconnect.setError(null);
quickconnect.requestFocus();
}
public void onNothingSelected(AdapterView<?> arg0) { }
});
transportSpinner.setAdapter(transportSelection);
this.inflater = LayoutInflater.from(this);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
// don't offer menus when creating shortcut
if (makingShortcut) return true;
sortcolor.setVisible(!sortedByColor);
sortlast.setVisible(sortedByColor);
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
// don't offer menus when creating shortcut
if(makingShortcut) return true;
// add host, ssh keys, about
sortcolor = menu.add(R.string.list_menu_sortcolor);
sortcolor.setIcon(android.R.drawable.ic_menu_share);
sortcolor.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
sortedByColor = true;
updateList();
return true;
}
});
sortlast = menu.add(R.string.list_menu_sortname);
sortlast.setIcon(android.R.drawable.ic_menu_share);
sortlast.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
sortedByColor = false;
updateList();
return true;
}
});
MenuItem keys = menu.add(R.string.list_menu_pubkeys);
keys.setIcon(android.R.drawable.ic_lock_lock);
keys.setIntent(new Intent(HostListActivity.this, PubkeyListActivity.class));
MenuItem colors = menu.add("Colors");
colors.setIcon(android.R.drawable.ic_menu_slideshow);
colors.setIntent(new Intent(HostListActivity.this, ColorsActivity.class));
MenuItem settings = menu.add(R.string.list_menu_settings);
settings.setIcon(android.R.drawable.ic_menu_preferences);
settings.setIntent(new Intent(HostListActivity.this, SettingsActivity.class));
MenuItem help = menu.add(R.string.title_help);
help.setIcon(android.R.drawable.ic_menu_help);
help.setIntent(new Intent(HostListActivity.this, HelpActivity.class));
return true;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
// create menu to handle hosts
// create menu to handle deleting and sharing lists
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
final HostBean host = (HostBean) this.getListView().getItemAtPosition(info.position);
menu.setHeaderTitle(host.getNickname());
// edit, disconnect, delete
MenuItem connect = menu.add(R.string.list_host_disconnect);
final TerminalBridge bridge = bound.getConnectedBridge(host);
connect.setEnabled((bridge != null));
connect.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
bridge.dispatchDisconnect(true);
updateHandler.sendEmptyMessage(-1);
return true;
}
});
MenuItem edit = menu.add(R.string.list_host_edit);
edit.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(HostListActivity.this, HostEditorActivity.class);
intent.putExtra(Intent.EXTRA_TITLE, host.getId());
HostListActivity.this.startActivityForResult(intent, REQUEST_EDIT);
return true;
}
});
MenuItem portForwards = menu.add(R.string.list_host_portforwards);
portForwards.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(HostListActivity.this, PortForwardListActivity.class);
intent.putExtra(Intent.EXTRA_TITLE, host.getId());
HostListActivity.this.startActivityForResult(intent, REQUEST_EDIT);
return true;
}
});
if (!TransportFactory.canForwardPorts(host.getProtocol()))
portForwards.setEnabled(false);
MenuItem delete = menu.add(R.string.list_host_delete);
delete.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
// prompt user to make sure they really want this
new AlertDialog.Builder(HostListActivity.this)
.setMessage(getString(R.string.delete_message, host.getNickname()))
.setPositiveButton(R.string.delete_pos, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// make sure we disconnect
if(bridge != null)
bridge.dispatchDisconnect(true);
hostdb.deleteHost(host);
updateHandler.sendEmptyMessage(-1);
}
})
.setNegativeButton(R.string.delete_neg, null).create().show();
return true;
}
});
}
/**
* @param text
* @return
*/
private boolean startConsoleActivity() {
Uri uri = TransportFactory.getUri((String) transportSpinner
.getSelectedItem(), quickconnect.getText().toString());
if (uri == null) {
quickconnect.setError(getString(R.string.list_format_error,
TransportFactory.getFormatHint(
(String) transportSpinner.getSelectedItem(),
HostListActivity.this)));
return false;
}
HostBean host = TransportFactory.findHost(hostdb, uri);
if (host == null) {
host = TransportFactory.getTransport(uri.getScheme()).createHost(uri);
host.setColor(HostDatabase.COLOR_GRAY);
host.setPubkeyId(HostDatabase.PUBKEYID_ANY);
hostdb.saveHost(host);
}
Intent intent = new Intent(HostListActivity.this, ConsoleActivity.class);
intent.setData(uri);
startActivity(intent);
return true;
}
protected void updateList() {
if (prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false) != sortedByColor) {
Editor edit = prefs.edit();
edit.putBoolean(PreferenceConstants.SORT_BY_COLOR, sortedByColor);
edit.commit();
}
if (hostdb == null)
hostdb = new HostDatabase(this);
hosts = hostdb.getHosts(sortedByColor);
// Don't lose hosts that are connected via shortcuts but not in the database.
if (bound != null) {
for (TerminalBridge bridge : bound.bridges) {
if (!hosts.contains(bridge.host))
hosts.add(0, bridge.host);
}
}
HostAdapter adapter = new HostAdapter(this, hosts, bound);
this.setListAdapter(adapter);
}
class HostAdapter extends ArrayAdapter<HostBean> {
private List<HostBean> hosts;
private final TerminalManager manager;
private final ColorStateList red, green, blue;
public final static int STATE_UNKNOWN = 1, STATE_CONNECTED = 2, STATE_DISCONNECTED = 3;
class ViewHolder {
public TextView nickname;
public TextView caption;
public ImageView icon;
}
public HostAdapter(Context context, List<HostBean> hosts, TerminalManager manager) {
super(context, R.layout.item_host, hosts);
this.hosts = hosts;
this.manager = manager;
red = context.getResources().getColorStateList(R.color.red);
green = context.getResources().getColorStateList(R.color.green);
blue = context.getResources().getColorStateList(R.color.blue);
}
/**
* Check if we're connected to a terminal with the given host.
*/
private int getConnectedState(HostBean host) {
// always disconnected if we dont have backend service
if (this.manager == null)
return STATE_UNKNOWN;
if (manager.getConnectedBridge(host) != null)
return STATE_CONNECTED;
if (manager.disconnected.contains(host))
return STATE_DISCONNECTED;
return STATE_UNKNOWN;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_host, null, false);
holder = new ViewHolder();
holder.nickname = (TextView)convertView.findViewById(android.R.id.text1);
holder.caption = (TextView)convertView.findViewById(android.R.id.text2);
holder.icon = (ImageView)convertView.findViewById(android.R.id.icon);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
HostBean host = hosts.get(position);
if (host == null) {
// Well, something bad happened. We can't continue.
Log.e("HostAdapter", "Host bean is null!");
holder.nickname.setText("Error during lookup");
holder.caption.setText("see 'adb logcat' for more");
return convertView;
}
holder.nickname.setText(host.getNickname());
switch (this.getConnectedState(host)) {
case STATE_UNKNOWN:
holder.icon.setImageState(new int[] { }, true);
break;
case STATE_CONNECTED:
holder.icon.setImageState(new int[] { android.R.attr.state_checked }, true);
break;
case STATE_DISCONNECTED:
holder.icon.setImageState(new int[] { android.R.attr.state_expanded }, true);
break;
}
ColorStateList chosen = null;
if (HostDatabase.COLOR_RED.equals(host.getColor()))
chosen = this.red;
else if (HostDatabase.COLOR_GREEN.equals(host.getColor()))
chosen = this.green;
else if (HostDatabase.COLOR_BLUE.equals(host.getColor()))
chosen = this.blue;
Context context = convertView.getContext();
if (chosen != null) {
// set color normally if not selected
holder.nickname.setTextColor(chosen);
holder.caption.setTextColor(chosen);
} else {
// selected, so revert back to default black text
holder.nickname.setTextAppearance(context, android.R.attr.textAppearanceLarge);
holder.caption.setTextAppearance(context, android.R.attr.textAppearanceSmall);
}
long now = System.currentTimeMillis() / 1000;
String nice = context.getString(R.string.bind_never);
if (host.getLastConnect() > 0) {
int minutes = (int)((now - host.getLastConnect()) / 60);
if (minutes >= 60) {
int hours = (minutes / 60);
if (hours >= 24) {
int days = (hours / 24);
nice = context.getString(R.string.bind_days, days);
} else
nice = context.getString(R.string.bind_hours, hours);
} else
nice = context.getString(R.string.bind_minutes, minutes);
}
holder.caption.setText(nice);
return convertView;
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/HostListActivity.java | Java | asf20 | 17,497 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot;
import android.os.StrictMode;
public class StrictModeSetup {
public static void run() {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.LAX);
}
}
| zzsuper001-linuxshell | src/org/connectbot/StrictModeSetup.java | Java | asf20 | 856 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2010 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.io.IOException;
import org.connectbot.TerminalView;
import org.connectbot.bean.SelectionArea;
import org.connectbot.util.PreferenceConstants;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import de.mud.terminal.VDUBuffer;
import de.mud.terminal.vt320;
/**
* @author kenny
*
*/
@SuppressWarnings("deprecation") // for ClipboardManager
public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceChangeListener {
private static final String TAG = "ConnectBot.OnKeyListener";
public final static int META_CTRL_ON = 0x01;
public final static int META_CTRL_LOCK = 0x02;
public final static int META_ALT_ON = 0x04;
public final static int META_ALT_LOCK = 0x08;
public final static int META_SHIFT_ON = 0x10;
public final static int META_SHIFT_LOCK = 0x20;
public final static int META_SLASH = 0x40;
public final static int META_TAB = 0x80;
// The bit mask of momentary and lock states for each
public final static int META_CTRL_MASK = META_CTRL_ON | META_CTRL_LOCK;
public final static int META_ALT_MASK = META_ALT_ON | META_ALT_LOCK;
public final static int META_SHIFT_MASK = META_SHIFT_ON | META_SHIFT_LOCK;
// backport constants from api level 11
public final static int KEYCODE_ESCAPE = 111;
public final static int HC_META_CTRL_ON = 4096;
// All the transient key codes
public final static int META_TRANSIENT = META_CTRL_ON | META_ALT_ON
| META_SHIFT_ON;
private final TerminalManager manager;
private final TerminalBridge bridge;
private final VDUBuffer buffer;
private String keymode = null;
private boolean hardKeyboard = false;
private int metaState = 0;
private int mDeadKey = 0;
// TODO add support for the new API.
private ClipboardManager clipboard = null;
private boolean selectingForCopy = false;
private final SelectionArea selectionArea;
private String encoding;
private final SharedPreferences prefs;
public TerminalKeyListener(TerminalManager manager,
TerminalBridge bridge,
VDUBuffer buffer,
String encoding) {
this.manager = manager;
this.bridge = bridge;
this.buffer = buffer;
this.encoding = encoding;
selectionArea = new SelectionArea();
prefs = PreferenceManager.getDefaultSharedPreferences(manager);
prefs.registerOnSharedPreferenceChangeListener(this);
hardKeyboard = (manager.res.getConfiguration().keyboard
== Configuration.KEYBOARD_QWERTY);
updateKeymode();
}
/**
* Handle onKey() events coming down from a {@link TerminalView} above us.
* Modify the keys to make more sense to a host then pass it to the transport.
*/
public boolean onKey(View v, int keyCode, KeyEvent event) {
try {
final boolean hardKeyboardHidden = manager.hardKeyboardHidden;
// Ignore all key-up events except for the special keys
if (event.getAction() == KeyEvent.ACTION_UP) {
// There's nothing here for virtual keyboard users.
if (!hardKeyboard || (hardKeyboard && hardKeyboardHidden))
return false;
// skip keys if we aren't connected yet or have been disconnected
if (bridge.isDisconnected() || bridge.transport == null)
return false;
if (PreferenceConstants.KEYMODE_RIGHT.equals(keymode)) {
if (keyCode == KeyEvent.KEYCODE_ALT_RIGHT
&& (metaState & META_SLASH) != 0) {
metaState &= ~(META_SLASH | META_TRANSIENT);
bridge.transport.write('/');
return true;
} else if (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT
&& (metaState & META_TAB) != 0) {
metaState &= ~(META_TAB | META_TRANSIENT);
bridge.transport.write(0x09);
return true;
}
} else if (PreferenceConstants.KEYMODE_LEFT.equals(keymode)) {
if (keyCode == KeyEvent.KEYCODE_ALT_LEFT
&& (metaState & META_SLASH) != 0) {
metaState &= ~(META_SLASH | META_TRANSIENT);
bridge.transport.write('/');
return true;
} else if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
&& (metaState & META_TAB) != 0) {
metaState &= ~(META_TAB | META_TRANSIENT);
bridge.transport.write(0x09);
return true;
}
}
return false;
}
// check for terminal resizing keys
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
bridge.increaseFontSize();
return true;
} else if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
bridge.decreaseFontSize();
return true;
}
// skip keys if we aren't connected yet or have been disconnected
if (bridge.isDisconnected() || bridge.transport == null)
return false;
bridge.resetScrollPosition();
if (keyCode == KeyEvent.KEYCODE_UNKNOWN &&
event.getAction() == KeyEvent.ACTION_MULTIPLE) {
byte[] input = event.getCharacters().getBytes(encoding);
bridge.transport.write(input);
return true;
}
int curMetaState = event.getMetaState();
final int orgMetaState = curMetaState;
if ((metaState & META_SHIFT_MASK) != 0) {
curMetaState |= KeyEvent.META_SHIFT_ON;
}
if ((metaState & META_ALT_MASK) != 0) {
curMetaState |= KeyEvent.META_ALT_ON;
}
int key = event.getUnicodeChar(curMetaState);
// no hard keyboard? ALT-k should pass through to below
if ((orgMetaState & KeyEvent.META_ALT_ON) != 0 &&
(!hardKeyboard || hardKeyboardHidden)) {
key = 0;
}
if ((key & KeyCharacterMap.COMBINING_ACCENT) != 0) {
mDeadKey = key & KeyCharacterMap.COMBINING_ACCENT_MASK;
return true;
}
if (mDeadKey != 0) {
key = KeyCharacterMap.getDeadChar(mDeadKey, keyCode);
mDeadKey = 0;
}
final boolean printing = (key != 0);
// otherwise pass through to existing session
// print normal keys
if (printing) {
metaState &= ~(META_SLASH | META_TAB);
// Remove shift and alt modifiers
final int lastMetaState = metaState;
metaState &= ~(META_SHIFT_ON | META_ALT_ON);
if (metaState != lastMetaState) {
bridge.redraw();
}
if ((metaState & META_CTRL_MASK) != 0) {
metaState &= ~META_CTRL_ON;
bridge.redraw();
// If there is no hard keyboard or there is a hard keyboard currently hidden,
// CTRL-1 through CTRL-9 will send F1 through F9
if ((!hardKeyboard || (hardKeyboard && hardKeyboardHidden))
&& sendFunctionKey(keyCode))
return true;
key = keyAsControl(key);
}
// handle pressing f-keys
if ((hardKeyboard && !hardKeyboardHidden)
&& (curMetaState & KeyEvent.META_SHIFT_ON) != 0
&& sendFunctionKey(keyCode))
return true;
if (key < 0x80)
bridge.transport.write(key);
else
// TODO write encoding routine that doesn't allocate each time
bridge.transport.write(new String(Character.toChars(key))
.getBytes(encoding));
return true;
}
// send ctrl and meta-keys as appropriate
if (!hardKeyboard || hardKeyboardHidden) {
int k = event.getUnicodeChar(0);
int k0 = k;
boolean sendCtrl = false;
boolean sendMeta = false;
if (k != 0) {
if ((orgMetaState & HC_META_CTRL_ON) != 0) {
k = keyAsControl(k);
if (k != k0)
sendCtrl = true;
// send F1-F10 via CTRL-1 through CTRL-0
if (!sendCtrl && sendFunctionKey(keyCode))
return true;
} else if ((orgMetaState & KeyEvent.META_ALT_ON) != 0) {
sendMeta = true;
sendEscape();
}
if (sendMeta || sendCtrl) {
bridge.transport.write(k);
return true;
}
}
}
// try handling keymode shortcuts
if (hardKeyboard && !hardKeyboardHidden &&
event.getRepeatCount() == 0) {
if (PreferenceConstants.KEYMODE_RIGHT.equals(keymode)) {
switch (keyCode) {
case KeyEvent.KEYCODE_ALT_RIGHT:
metaState |= META_SLASH;
return true;
case KeyEvent.KEYCODE_SHIFT_RIGHT:
metaState |= META_TAB;
return true;
case KeyEvent.KEYCODE_SHIFT_LEFT:
metaPress(META_SHIFT_ON);
return true;
case KeyEvent.KEYCODE_ALT_LEFT:
metaPress(META_ALT_ON);
return true;
}
} else if (PreferenceConstants.KEYMODE_LEFT.equals(keymode)) {
switch (keyCode) {
case KeyEvent.KEYCODE_ALT_LEFT:
metaState |= META_SLASH;
return true;
case KeyEvent.KEYCODE_SHIFT_LEFT:
metaState |= META_TAB;
return true;
case KeyEvent.KEYCODE_SHIFT_RIGHT:
metaPress(META_SHIFT_ON);
return true;
case KeyEvent.KEYCODE_ALT_RIGHT:
metaPress(META_ALT_ON);
return true;
}
} else {
switch (keyCode) {
case KeyEvent.KEYCODE_ALT_LEFT:
case KeyEvent.KEYCODE_ALT_RIGHT:
metaPress(META_ALT_ON);
return true;
case KeyEvent.KEYCODE_SHIFT_LEFT:
case KeyEvent.KEYCODE_SHIFT_RIGHT:
metaPress(META_SHIFT_ON);
return true;
}
}
}
// look for special chars
switch(keyCode) {
case KEYCODE_ESCAPE:
sendEscape();
return true;
case KeyEvent.KEYCODE_TAB:
bridge.transport.write(0x09);
return true;
case KeyEvent.KEYCODE_CAMERA:
// check to see which shortcut the camera button triggers
String camera = manager.prefs.getString(
PreferenceConstants.CAMERA,
PreferenceConstants.CAMERA_CTRLA_SPACE);
if(PreferenceConstants.CAMERA_CTRLA_SPACE.equals(camera)) {
bridge.transport.write(0x01);
bridge.transport.write(' ');
} else if(PreferenceConstants.CAMERA_CTRLA.equals(camera)) {
bridge.transport.write(0x01);
} else if(PreferenceConstants.CAMERA_ESC.equals(camera)) {
((vt320)buffer).keyTyped(vt320.KEY_ESCAPE, ' ', 0);
} else if(PreferenceConstants.CAMERA_ESC_A.equals(camera)) {
((vt320)buffer).keyTyped(vt320.KEY_ESCAPE, ' ', 0);
bridge.transport.write('a');
}
break;
case KeyEvent.KEYCODE_DEL:
((vt320) buffer).keyPressed(vt320.KEY_BACK_SPACE, ' ',
getStateForBuffer());
metaState &= ~META_TRANSIENT;
return true;
case KeyEvent.KEYCODE_ENTER:
((vt320)buffer).keyTyped(vt320.KEY_ENTER, ' ', 0);
metaState &= ~META_TRANSIENT;
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
if (selectingForCopy) {
selectionArea.decrementColumn();
bridge.redraw();
} else {
((vt320) buffer).keyPressed(vt320.KEY_LEFT, ' ',
getStateForBuffer());
metaState &= ~META_TRANSIENT;
bridge.tryKeyVibrate();
}
return true;
case KeyEvent.KEYCODE_DPAD_UP:
if (selectingForCopy) {
selectionArea.decrementRow();
bridge.redraw();
} else {
((vt320) buffer).keyPressed(vt320.KEY_UP, ' ',
getStateForBuffer());
metaState &= ~META_TRANSIENT;
bridge.tryKeyVibrate();
}
return true;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (selectingForCopy) {
selectionArea.incrementRow();
bridge.redraw();
} else {
((vt320) buffer).keyPressed(vt320.KEY_DOWN, ' ',
getStateForBuffer());
metaState &= ~META_TRANSIENT;
bridge.tryKeyVibrate();
}
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (selectingForCopy) {
selectionArea.incrementColumn();
bridge.redraw();
} else {
((vt320) buffer).keyPressed(vt320.KEY_RIGHT, ' ',
getStateForBuffer());
metaState &= ~META_TRANSIENT;
bridge.tryKeyVibrate();
}
return true;
case KeyEvent.KEYCODE_DPAD_CENTER:
if (selectingForCopy) {
if (selectionArea.isSelectingOrigin())
selectionArea.finishSelectingOrigin();
else {
if (clipboard != null) {
// copy selected area to clipboard
String copiedText = selectionArea.copyFrom(buffer);
clipboard.setText(copiedText);
// XXX STOPSHIP
// manager.notifyUser(manager.getString(
// R.string.console_copy_done,
// copiedText.length()));
selectingForCopy = false;
selectionArea.reset();
}
}
} else {
if ((metaState & META_CTRL_ON) != 0) {
sendEscape();
metaState &= ~META_CTRL_ON;
} else
metaPress(META_CTRL_ON);
}
bridge.redraw();
return true;
}
} catch (IOException e) {
Log.e(TAG, "Problem while trying to handle an onKey() event", e);
try {
bridge.transport.flush();
} catch (IOException ioe) {
Log.d(TAG, "Our transport was closed, dispatching disconnect event");
bridge.dispatchDisconnect(false);
}
} catch (NullPointerException npe) {
Log.d(TAG, "Input before connection established ignored.");
return true;
}
return false;
}
public int keyAsControl(int key) {
// Support CTRL-a through CTRL-z
if (key >= 0x61 && key <= 0x7A)
key -= 0x60;
// Support CTRL-A through CTRL-_
else if (key >= 0x41 && key <= 0x5F)
key -= 0x40;
// CTRL-space sends NULL
else if (key == 0x20)
key = 0x00;
// CTRL-? sends DEL
else if (key == 0x3F)
key = 0x7F;
return key;
}
public void sendEscape() {
((vt320)buffer).keyTyped(vt320.KEY_ESCAPE, ' ', 0);
}
/**
* @param key
* @return successful
*/
private boolean sendFunctionKey(int keyCode) {
switch (keyCode) {
case KeyEvent.KEYCODE_1:
((vt320) buffer).keyPressed(vt320.KEY_F1, ' ', 0);
return true;
case KeyEvent.KEYCODE_2:
((vt320) buffer).keyPressed(vt320.KEY_F2, ' ', 0);
return true;
case KeyEvent.KEYCODE_3:
((vt320) buffer).keyPressed(vt320.KEY_F3, ' ', 0);
return true;
case KeyEvent.KEYCODE_4:
((vt320) buffer).keyPressed(vt320.KEY_F4, ' ', 0);
return true;
case KeyEvent.KEYCODE_5:
((vt320) buffer).keyPressed(vt320.KEY_F5, ' ', 0);
return true;
case KeyEvent.KEYCODE_6:
((vt320) buffer).keyPressed(vt320.KEY_F6, ' ', 0);
return true;
case KeyEvent.KEYCODE_7:
((vt320) buffer).keyPressed(vt320.KEY_F7, ' ', 0);
return true;
case KeyEvent.KEYCODE_8:
((vt320) buffer).keyPressed(vt320.KEY_F8, ' ', 0);
return true;
case KeyEvent.KEYCODE_9:
((vt320) buffer).keyPressed(vt320.KEY_F9, ' ', 0);
return true;
case KeyEvent.KEYCODE_0:
((vt320) buffer).keyPressed(vt320.KEY_F10, ' ', 0);
return true;
default:
return false;
}
}
/**
* Handle meta key presses where the key can be locked on.
* <p>
* 1st press: next key to have meta state<br />
* 2nd press: meta state is locked on<br />
* 3rd press: disable meta state
*
* @param code
*/
public void metaPress(int code) {
if ((metaState & (code << 1)) != 0) {
metaState &= ~(code << 1);
} else if ((metaState & code) != 0) {
metaState &= ~code;
metaState |= code << 1;
} else
metaState |= code;
bridge.redraw();
}
public void setTerminalKeyMode(String keymode) {
this.keymode = keymode;
}
private int getStateForBuffer() {
int bufferState = 0;
if ((metaState & META_CTRL_MASK) != 0)
bufferState |= vt320.KEY_CONTROL;
if ((metaState & META_SHIFT_MASK) != 0)
bufferState |= vt320.KEY_SHIFT;
if ((metaState & META_ALT_MASK) != 0)
bufferState |= vt320.KEY_ALT;
return bufferState;
}
public int getMetaState() {
return metaState;
}
public int getDeadKey() {
return mDeadKey;
}
public void setClipboardManager(ClipboardManager clipboard) {
this.clipboard = clipboard;
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (PreferenceConstants.KEYMODE.equals(key)) {
updateKeymode();
}
}
private void updateKeymode() {
keymode = prefs.getString(PreferenceConstants.KEYMODE, PreferenceConstants.KEYMODE_RIGHT);
}
public void setCharset(String encoding) {
this.encoding = encoding;
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/TerminalKeyListener.java | Java | asf20 | 16,393 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.connectbot.R;
import org.connectbot.TerminalView;
import org.connectbot.bean.HostBean;
import org.connectbot.bean.PortForwardBean;
import org.connectbot.bean.SelectionArea;
import org.connectbot.transport.AbsTransport;
import org.connectbot.transport.TransportFactory;
import org.connectbot.util.HostDatabase;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.graphics.Typeface;
import android.text.ClipboardManager;
import android.util.Log;
import de.mud.terminal.VDUBuffer;
import de.mud.terminal.VDUDisplay;
import de.mud.terminal.vt320;
/**
* Provides a bridge between a MUD terminal buffer and a possible TerminalView.
* This separation allows us to keep the TerminalBridge running in a background
* service. A TerminalView shares down a bitmap that we can use for rendering
* when available.
*
* This class also provides SSH hostkey verification prompting, and password
* prompting.
*/
@SuppressWarnings("deprecation") // for ClipboardManager
public class TerminalBridge implements VDUDisplay {
public final static String TAG = "ConnectBot.TerminalBridge";
public final static int DEFAULT_FONT_SIZE = 10;
private final static int FONT_SIZE_STEP = 2;
public Integer[] color;
public int defaultFg = HostDatabase.DEFAULT_FG_COLOR;
public int defaultBg = HostDatabase.DEFAULT_BG_COLOR;
protected final TerminalManager manager;
public HostBean host;
/* package */ AbsTransport transport;
final Paint defaultPaint;
private Relay relay;
private final String emulation;
private final int scrollback;
public Bitmap bitmap = null;
public VDUBuffer buffer = null;
private TerminalView parent = null;
private final Canvas canvas = new Canvas();
private boolean disconnected = false;
private boolean awaitingClose = false;
private boolean forcedSize = false;
private int columns;
private int rows;
/* package */ final TerminalKeyListener keyListener;
private boolean selectingForCopy = false;
private final SelectionArea selectionArea;
// TODO add support for the new clipboard API
private ClipboardManager clipboard;
public int charWidth = -1;
public int charHeight = -1;
private int charTop = -1;
private float fontSize = -1;
private final List<FontSizeChangedListener> fontSizeChangedListeners;
private final List<String> localOutput;
/**
* Flag indicating if we should perform a full-screen redraw during our next
* rendering pass.
*/
private boolean fullRedraw = false;
public PromptHelper promptHelper;
protected BridgeDisconnectedListener disconnectListener = null;
/**
* Create a new terminal bridge suitable for unit testing.
*/
public TerminalBridge() {
buffer = new vt320() {
@Override
public void write(byte[] b) {}
@Override
public void write(int b) {}
@Override
public void sendTelnetCommand(byte cmd) {}
@Override
public void setWindowSize(int c, int r) {}
@Override
public void debug(String s) {}
};
emulation = null;
manager = null;
defaultPaint = new Paint();
selectionArea = new SelectionArea();
scrollback = 1;
localOutput = new LinkedList<String>();
fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>();
transport = null;
keyListener = new TerminalKeyListener(manager, this, buffer, null);
}
/**
* Create new terminal bridge with following parameters. We will immediately
* launch thread to start SSH connection and handle any hostkey verification
* and password authentication.
*/
public TerminalBridge(final TerminalManager manager, final HostBean host) throws IOException {
this.manager = manager;
this.host = host;
emulation = manager.getEmulation();
scrollback = manager.getScrollback();
// create prompt helper to relay password and hostkey requests up to gui
promptHelper = new PromptHelper(this);
// create our default paint
defaultPaint = new Paint();
defaultPaint.setAntiAlias(true);
defaultPaint.setTypeface(Typeface.MONOSPACE);
defaultPaint.setFakeBoldText(true); // more readable?
localOutput = new LinkedList<String>();
fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>();
int hostFontSize = host.getFontSize();
if (hostFontSize <= 0)
hostFontSize = DEFAULT_FONT_SIZE;
setFontSize(hostFontSize);
// create terminal buffer and handle outgoing data
// this is probably status reply information
buffer = new vt320() {
@Override
public void debug(String s) {
Log.d(TAG, s);
}
@Override
public void write(byte[] b) {
try {
if (b != null && transport != null)
transport.write(b);
} catch (IOException e) {
Log.e(TAG, "Problem writing outgoing data in vt320() thread", e);
}
}
@Override
public void write(int b) {
try {
if (transport != null)
transport.write(b);
} catch (IOException e) {
Log.e(TAG, "Problem writing outgoing data in vt320() thread", e);
}
}
// We don't use telnet sequences.
@Override
public void sendTelnetCommand(byte cmd) {
}
// We don't want remote to resize our window.
@Override
public void setWindowSize(int c, int r) {
}
@Override
public void beep() {
if (parent.isShown())
manager.playBeep();
else
manager.sendActivityNotification(host);
}
};
// Don't keep any scrollback if a session is not being opened.
if (host.getWantSession())
buffer.setBufferSize(scrollback);
else
buffer.setBufferSize(0);
resetColors();
buffer.setDisplay(this);
selectionArea = new SelectionArea();
keyListener = new TerminalKeyListener(manager, this, buffer, host.getEncoding());
}
public PromptHelper getPromptHelper() {
return promptHelper;
}
/**
* Spawn thread to open connection and start login process.
*/
protected void startConnection() {
transport = TransportFactory.getTransport(host.getProtocol());
transport.setBridge(this);
transport.setManager(manager);
transport.setHost(host);
// TODO make this more abstract so we don't litter on AbsTransport
transport.setCompression(host.getCompression());
transport.setUseAuthAgent(host.getUseAuthAgent());
transport.setEmulation(emulation);
if (transport.canForwardPorts()) {
for (PortForwardBean portForward : manager.hostdb.getPortForwardsForHost(host))
transport.addPortForward(portForward);
}
outputLine(manager.res.getString(R.string.terminal_connecting, host.getHostname(), host.getPort(), host.getProtocol()));
Thread connectionThread = new Thread(new Runnable() {
public void run() {
transport.connect();
}
});
connectionThread.setName("Connection");
connectionThread.setDaemon(true);
connectionThread.start();
}
/**
* Handle challenges from keyboard-interactive authentication mode.
*/
public String[] replyToChallenge(String name, String instruction, int numPrompts, String[] prompt, boolean[] echo) {
String[] responses = new String[numPrompts];
for(int i = 0; i < numPrompts; i++) {
// request response from user for each prompt
responses[i] = promptHelper.requestStringPrompt(instruction, prompt[i]);
}
return responses;
}
/**
* @return charset in use by bridge
*/
public Charset getCharset() {
return relay.getCharset();
}
/**
* Sets the encoding used by the terminal. If the connection is live,
* then the character set is changed for the next read.
* @param encoding the canonical name of the character encoding
*/
public void setCharset(String encoding) {
if (relay != null)
relay.setCharset(encoding);
keyListener.setCharset(encoding);
}
/**
* Convenience method for writing a line into the underlying MUD buffer.
* Should never be called once the session is established.
*/
public final void outputLine(String line) {
if (transport != null && transport.isSessionOpen())
Log.e(TAG, "Session established, cannot use outputLine!", new IOException("outputLine call traceback"));
synchronized (localOutput) {
final String s = line + "\r\n";
localOutput.add(s);
((vt320) buffer).putString(s);
// For accessibility
final char[] charArray = s.toCharArray();
propagateConsoleText(charArray, charArray.length);
}
}
/**
* Inject a specific string into this terminal. Used for post-login strings
* and pasting clipboard.
*/
public void injectString(final String string) {
if (string == null || string.length() == 0)
return;
Thread injectStringThread = new Thread(new Runnable() {
public void run() {
try {
transport.write(string.getBytes(host.getEncoding()));
} catch (Exception e) {
Log.e(TAG, "Couldn't inject string to remote host: ", e);
}
}
});
injectStringThread.setName("InjectString");
injectStringThread.start();
}
/**
* Internal method to request actual PTY terminal once we've finished
* authentication. If called before authenticated, it will just fail.
*/
public void onConnected() {
disconnected = false;
((vt320) buffer).reset();
// We no longer need our local output.
localOutput.clear();
// previously tried vt100 and xterm for emulation modes
// "screen" works the best for color and escape codes
((vt320) buffer).setAnswerBack(emulation);
if (HostDatabase.DELKEY_BACKSPACE.equals(host.getDelKey()))
((vt320) buffer).setBackspace(vt320.DELETE_IS_BACKSPACE);
else
((vt320) buffer).setBackspace(vt320.DELETE_IS_DEL);
// create thread to relay incoming connection data to buffer
relay = new Relay(this, transport, (vt320) buffer, host.getEncoding());
Thread relayThread = new Thread(relay);
relayThread.setDaemon(true);
relayThread.setName("Relay");
relayThread.start();
// force font-size to make sure we resizePTY as needed
setFontSize(fontSize);
// finally send any post-login string, if requested
injectString(host.getPostLogin());
}
/**
* @return whether a session is open or not
*/
public boolean isSessionOpen() {
if (transport != null)
return transport.isSessionOpen();
return false;
}
public void setOnDisconnectedListener(BridgeDisconnectedListener disconnectListener) {
this.disconnectListener = disconnectListener;
}
/**
* Force disconnection of this terminal bridge.
*/
public void dispatchDisconnect(boolean immediate) {
// We don't need to do this multiple times.
synchronized (this) {
if (disconnected && !immediate)
return;
disconnected = true;
}
// Cancel any pending prompts.
promptHelper.cancelPrompt();
// disconnection request hangs if we havent really connected to a host yet
// temporary fix is to just spawn disconnection into a thread
Thread disconnectThread = new Thread(new Runnable() {
public void run() {
if (transport != null && transport.isConnected())
transport.close();
}
});
disconnectThread.setName("Disconnect");
disconnectThread.start();
if (immediate) {
awaitingClose = true;
if (disconnectListener != null)
disconnectListener.onDisconnected(TerminalBridge.this);
} else {
{
final String line = manager.res.getString(R.string.alert_disconnect_msg);
((vt320) buffer).putString("\r\n" + line + "\r\n");
}
if (host.getStayConnected()) {
manager.requestReconnect(this);
return;
}
Thread disconnectPromptThread = new Thread(new Runnable() {
public void run() {
Boolean result = promptHelper.requestBooleanPrompt(null,
manager.res.getString(R.string.prompt_host_disconnected));
if (result == null || result.booleanValue()) {
awaitingClose = true;
// Tell the TerminalManager that we can be destroyed now.
if (disconnectListener != null)
disconnectListener.onDisconnected(TerminalBridge.this);
}
}
});
disconnectPromptThread.setName("DisconnectPrompt");
disconnectPromptThread.setDaemon(true);
disconnectPromptThread.start();
}
}
public void setSelectingForCopy(boolean selectingForCopy) {
this.selectingForCopy = selectingForCopy;
}
public boolean isSelectingForCopy() {
return selectingForCopy;
}
public SelectionArea getSelectionArea() {
return selectionArea;
}
public synchronized void tryKeyVibrate() {
manager.tryKeyVibrate();
}
/**
* Request a different font size. Will make call to parentChanged() to make
* sure we resize PTY if needed.
*/
/* package */ final void setFontSize(float size) {
if (size <= 0.0)
return;
defaultPaint.setTextSize(size);
fontSize = size;
// read new metrics to get exact pixel dimensions
FontMetrics fm = defaultPaint.getFontMetrics();
charTop = (int)Math.ceil(fm.top);
float[] widths = new float[1];
defaultPaint.getTextWidths("X", widths);
charWidth = (int)Math.ceil(widths[0]);
charHeight = (int)Math.ceil(fm.descent - fm.top);
// refresh any bitmap with new font size
if(parent != null)
parentChanged(parent);
for (FontSizeChangedListener ofscl : fontSizeChangedListeners)
ofscl.onFontSizeChanged(size);
host.setFontSize((int) fontSize);
manager.hostdb.updateFontSize(host);
forcedSize = false;
}
/**
* Add an {@link FontSizeChangedListener} to the list of listeners for this
* bridge.
*
* @param listener
* listener to add
*/
public void addFontSizeChangedListener(FontSizeChangedListener listener) {
fontSizeChangedListeners.add(listener);
}
/**
* Remove an {@link FontSizeChangedListener} from the list of listeners for
* this bridge.
*
* @param listener
*/
public void removeFontSizeChangedListener(FontSizeChangedListener listener) {
fontSizeChangedListeners.remove(listener);
}
/**
* Something changed in our parent {@link TerminalView}, maybe it's a new
* parent, or maybe it's an updated font size. We should recalculate
* terminal size information and request a PTY resize.
*/
public final synchronized void parentChanged(TerminalView parent) {
if (manager != null && !manager.isResizeAllowed()) {
Log.d(TAG, "Resize is not allowed now");
return;
}
this.parent = parent;
final int width = parent.getWidth();
final int height = parent.getHeight();
// Something has gone wrong with our layout; we're 0 width or height!
if (width <= 0 || height <= 0)
return;
clipboard = (ClipboardManager) parent.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
keyListener.setClipboardManager(clipboard);
if (!forcedSize) {
// recalculate buffer size
int newColumns, newRows;
newColumns = width / charWidth;
newRows = height / charHeight;
// If nothing has changed in the terminal dimensions and not an intial
// draw then don't blow away scroll regions and such.
if (newColumns == columns && newRows == rows)
return;
columns = newColumns;
rows = newRows;
}
// reallocate new bitmap if needed
boolean newBitmap = (bitmap == null);
if(bitmap != null)
newBitmap = (bitmap.getWidth() != width || bitmap.getHeight() != height);
if (newBitmap) {
discardBitmap();
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
canvas.setBitmap(bitmap);
}
// clear out any old buffer information
defaultPaint.setColor(Color.BLACK);
canvas.drawPaint(defaultPaint);
// Stroke the border of the terminal if the size is being forced;
if (forcedSize) {
int borderX = (columns * charWidth) + 1;
int borderY = (rows * charHeight) + 1;
defaultPaint.setColor(Color.GRAY);
defaultPaint.setStrokeWidth(0.0f);
if (width >= borderX)
canvas.drawLine(borderX, 0, borderX, borderY + 1, defaultPaint);
if (height >= borderY)
canvas.drawLine(0, borderY, borderX + 1, borderY, defaultPaint);
}
try {
// request a terminal pty resize
synchronized (buffer) {
buffer.setScreenSize(columns, rows, true);
}
if(transport != null)
transport.setDimensions(columns, rows, width, height);
} catch(Exception e) {
Log.e(TAG, "Problem while trying to resize screen or PTY", e);
}
// redraw local output if we don't have a sesson to receive our resize request
if (transport == null) {
synchronized (localOutput) {
((vt320) buffer).reset();
for (String line : localOutput)
((vt320) buffer).putString(line);
}
}
// force full redraw with new buffer size
fullRedraw = true;
redraw();
parent.notifyUser(String.format("%d x %d", columns, rows));
Log.i(TAG, String.format("parentChanged() now width=%d, height=%d", columns, rows));
}
/**
* Somehow our parent {@link TerminalView} was destroyed. Now we don't need
* to redraw anywhere, and we can recycle our internal bitmap.
*/
public synchronized void parentDestroyed() {
parent = null;
discardBitmap();
}
private void discardBitmap() {
if (bitmap != null)
bitmap.recycle();
bitmap = null;
}
public void setVDUBuffer(VDUBuffer buffer) {
this.buffer = buffer;
}
public VDUBuffer getVDUBuffer() {
return buffer;
}
public void propagateConsoleText(char[] rawText, int length) {
if (parent != null) {
parent.propagateConsoleText(rawText, length);
}
}
public void onDraw() {
int fg, bg;
synchronized (buffer) {
boolean entireDirty = buffer.update[0] || fullRedraw;
boolean isWideCharacter = false;
// walk through all lines in the buffer
for(int l = 0; l < buffer.height; l++) {
// check if this line is dirty and needs to be repainted
// also check for entire-buffer dirty flags
if (!entireDirty && !buffer.update[l + 1]) continue;
// reset dirty flag for this line
buffer.update[l + 1] = false;
// walk through all characters in this line
for (int c = 0; c < buffer.width; c++) {
int addr = 0;
int currAttr = buffer.charAttributes[buffer.windowBase + l][c];
{
int fgcolor = defaultFg;
// check if foreground color attribute is set
if ((currAttr & VDUBuffer.COLOR_FG) != 0)
fgcolor = ((currAttr & VDUBuffer.COLOR_FG) >> VDUBuffer.COLOR_FG_SHIFT) - 1;
if (fgcolor < 8 && (currAttr & VDUBuffer.BOLD) != 0)
fg = color[fgcolor + 8];
else
fg = color[fgcolor];
}
// check if background color attribute is set
if ((currAttr & VDUBuffer.COLOR_BG) != 0)
bg = color[((currAttr & VDUBuffer.COLOR_BG) >> VDUBuffer.COLOR_BG_SHIFT) - 1];
else
bg = color[defaultBg];
// support character inversion by swapping background and foreground color
if ((currAttr & VDUBuffer.INVERT) != 0) {
int swapc = bg;
bg = fg;
fg = swapc;
}
// set underlined attributes if requested
defaultPaint.setUnderlineText((currAttr & VDUBuffer.UNDERLINE) != 0);
isWideCharacter = (currAttr & VDUBuffer.FULLWIDTH) != 0;
if (isWideCharacter)
addr++;
else {
// determine the amount of continuous characters with the same settings and print them all at once
while(c + addr < buffer.width
&& buffer.charAttributes[buffer.windowBase + l][c + addr] == currAttr) {
addr++;
}
}
// Save the current clip region
canvas.save(Canvas.CLIP_SAVE_FLAG);
// clear this dirty area with background color
defaultPaint.setColor(bg);
if (isWideCharacter) {
canvas.clipRect(c * charWidth,
l * charHeight,
(c + 2) * charWidth,
(l + 1) * charHeight);
} else {
canvas.clipRect(c * charWidth,
l * charHeight,
(c + addr) * charWidth,
(l + 1) * charHeight);
}
canvas.drawPaint(defaultPaint);
// write the text string starting at 'c' for 'addr' number of characters
defaultPaint.setColor(fg);
if((currAttr & VDUBuffer.INVISIBLE) == 0)
canvas.drawText(buffer.charArray[buffer.windowBase + l], c,
addr, c * charWidth, (l * charHeight) - charTop,
defaultPaint);
// Restore the previous clip region
canvas.restore();
// advance to the next text block with different characteristics
c += addr - 1;
if (isWideCharacter)
c++;
}
}
// reset entire-buffer flags
buffer.update[0] = false;
}
fullRedraw = false;
}
public void redraw() {
if (parent != null)
parent.postInvalidate();
}
// We don't have a scroll bar.
public void updateScrollBar() {
}
/**
* Resize terminal to fit [rows]x[cols] in screen of size [width]x[height]
* @param rows
* @param cols
* @param width
* @param height
*/
public synchronized void resizeComputed(int cols, int rows, int width, int height) {
float size = 8.0f;
float step = 8.0f;
float limit = 0.125f;
int direction;
while ((direction = fontSizeCompare(size, cols, rows, width, height)) < 0)
size += step;
if (direction == 0) {
Log.d("fontsize", String.format("Found match at %f", size));
return;
}
step /= 2.0f;
size -= step;
while ((direction = fontSizeCompare(size, cols, rows, width, height)) != 0
&& step >= limit) {
step /= 2.0f;
if (direction > 0) {
size -= step;
} else {
size += step;
}
}
if (direction > 0)
size -= step;
this.columns = cols;
this.rows = rows;
setFontSize(size);
forcedSize = true;
}
private int fontSizeCompare(float size, int cols, int rows, int width, int height) {
// read new metrics to get exact pixel dimensions
defaultPaint.setTextSize(size);
FontMetrics fm = defaultPaint.getFontMetrics();
float[] widths = new float[1];
defaultPaint.getTextWidths("X", widths);
int termWidth = (int)widths[0] * cols;
int termHeight = (int)Math.ceil(fm.descent - fm.top) * rows;
Log.d("fontsize", String.format("font size %f resulted in %d x %d", size, termWidth, termHeight));
// Check to see if it fits in resolution specified.
if (termWidth > width || termHeight > height)
return 1;
if (termWidth == width || termHeight == height)
return 0;
return -1;
}
/**
* @return whether underlying transport can forward ports
*/
public boolean canFowardPorts() {
return transport.canForwardPorts();
}
/**
* Adds the {@link PortForwardBean} to the list.
* @param portForward the port forward bean to add
* @return true on successful addition
*/
public boolean addPortForward(PortForwardBean portForward) {
return transport.addPortForward(portForward);
}
/**
* Removes the {@link PortForwardBean} from the list.
* @param portForward the port forward bean to remove
* @return true on successful removal
*/
public boolean removePortForward(PortForwardBean portForward) {
return transport.removePortForward(portForward);
}
/**
* @return the list of port forwards
*/
public List<PortForwardBean> getPortForwards() {
return transport.getPortForwards();
}
/**
* Enables a port forward member. After calling this method, the port forward should
* be operational.
* @param portForward member of our current port forwards list to enable
* @return true on successful port forward setup
*/
public boolean enablePortForward(PortForwardBean portForward) {
if (!transport.isConnected()) {
Log.i(TAG, "Attempt to enable port forward while not connected");
return false;
}
return transport.enablePortForward(portForward);
}
/**
* Disables a port forward member. After calling this method, the port forward should
* be non-functioning.
* @param portForward member of our current port forwards list to enable
* @return true on successful port forward tear-down
*/
public boolean disablePortForward(PortForwardBean portForward) {
if (!transport.isConnected()) {
Log.i(TAG, "Attempt to disable port forward while not connected");
return false;
}
return transport.disablePortForward(portForward);
}
/**
* @return whether the TerminalBridge should close
*/
public boolean isAwaitingClose() {
return awaitingClose;
}
/**
* @return whether this connection had started and subsequently disconnected
*/
public boolean isDisconnected() {
return disconnected;
}
/* (non-Javadoc)
* @see de.mud.terminal.VDUDisplay#setColor(byte, byte, byte, byte)
*/
public void setColor(int index, int red, int green, int blue) {
// Don't allow the system colors to be overwritten for now. May violate specs.
if (index < color.length && index >= 16)
color[index] = 0xff000000 | red << 16 | green << 8 | blue;
}
public final void resetColors() {
int[] defaults = manager.hostdb.getDefaultColorsForScheme(HostDatabase.DEFAULT_COLOR_SCHEME);
defaultFg = defaults[0];
defaultBg = defaults[1];
color = manager.hostdb.getColorsForScheme(HostDatabase.DEFAULT_COLOR_SCHEME);
}
private static Pattern urlPattern = null;
/**
* @return
*/
public List<String> scanForURLs() {
List<String> urls = new LinkedList<String>();
if (urlPattern == null) {
// based on http://www.ietf.org/rfc/rfc2396.txt
String scheme = "[A-Za-z][-+.0-9A-Za-z]*";
String unreserved = "[-._~0-9A-Za-z]";
String pctEncoded = "%[0-9A-Fa-f]{2}";
String subDelims = "[!$&'()*+,;:=]";
String userinfo = "(?:" + unreserved + "|" + pctEncoded + "|" + subDelims + "|:)*";
String h16 = "[0-9A-Fa-f]{1,4}";
String decOctet = "(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])";
String ipv4address = decOctet + "\\." + decOctet + "\\." + decOctet + "\\." + decOctet;
String ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4address + ")";
String ipv6address = "(?:(?:" + h16 + "){6}" + ls32 + ")";
String ipvfuture = "v[0-9A-Fa-f]+.(?:" + unreserved + "|" + subDelims + "|:)+";
String ipLiteral = "\\[(?:" + ipv6address + "|" + ipvfuture + ")\\]";
String regName = "(?:" + unreserved + "|" + pctEncoded + "|" + subDelims + ")*";
String host = "(?:" + ipLiteral + "|" + ipv4address + "|" + regName + ")";
String port = "[0-9]*";
String authority = "(?:" + userinfo + "@)?" + host + "(?::" + port + ")?";
String pchar = "(?:" + unreserved + "|" + pctEncoded + "|" + subDelims + "|@)";
String segment = pchar + "*";
String pathAbempty = "(?:/" + segment + ")*";
String segmentNz = pchar + "+";
String pathAbsolute = "/(?:" + segmentNz + "(?:/" + segment + ")*)?";
String pathRootless = segmentNz + "(?:/" + segment + ")*";
String hierPart = "(?://" + authority + pathAbempty + "|" + pathAbsolute + "|" + pathRootless + ")";
String query = "(?:" + pchar + "|/|\\?)*";
String fragment = "(?:" + pchar + "|/|\\?)*";
String uriRegex = scheme + ":" + hierPart + "(?:" + query + ")?(?:#" + fragment + ")?";
urlPattern = Pattern.compile(uriRegex);
}
char[] visibleBuffer = new char[buffer.height * buffer.width];
for (int l = 0; l < buffer.height; l++)
System.arraycopy(buffer.charArray[buffer.windowBase + l], 0,
visibleBuffer, l * buffer.width, buffer.width);
Matcher urlMatcher = urlPattern.matcher(new String(visibleBuffer));
while (urlMatcher.find())
urls.add(urlMatcher.group());
return urls;
}
/**
* @return
*/
public boolean isUsingNetwork() {
return transport.usesNetwork();
}
/**
* @return
*/
public TerminalKeyListener getKeyHandler() {
return keyListener;
}
/**
*
*/
public void resetScrollPosition() {
// if we're in scrollback, scroll to bottom of window on input
if (buffer.windowBase != buffer.screenBase)
buffer.setWindowBase(buffer.screenBase);
}
/**
*
*/
public void increaseFontSize() {
setFontSize(fontSize + FONT_SIZE_STEP);
}
/**
*
*/
public void decreaseFontSize() {
setFontSize(fontSize - FONT_SIZE_STEP);
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/TerminalBridge.java | Java | asf20 | 28,432 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import org.apache.harmony.niochar.charset.additional.IBM437;
import org.connectbot.transport.AbsTransport;
import org.connectbot.util.EastAsianWidth;
import android.util.Log;
import de.mud.terminal.vt320;
/**
* @author Kenny Root
*/
public class Relay implements Runnable {
private static final String TAG = "ConnectBot.Relay";
private static final int BUFFER_SIZE = 4096;
private TerminalBridge bridge;
private Charset currentCharset;
private CharsetDecoder decoder;
private AbsTransport transport;
private vt320 buffer;
private ByteBuffer byteBuffer;
private CharBuffer charBuffer;
private byte[] byteArray;
private char[] charArray;
public Relay(TerminalBridge bridge, AbsTransport transport, vt320 buffer, String encoding) {
setCharset(encoding);
this.bridge = bridge;
this.transport = transport;
this.buffer = buffer;
}
public void setCharset(String encoding) {
Log.d("ConnectBot.Relay", "changing charset to " + encoding);
Charset charset;
if (encoding.equals("CP437"))
charset = new IBM437("IBM437",
new String[] { "IBM437", "CP437" });
else
charset = Charset.forName(encoding);
if (charset == currentCharset || charset == null)
return;
CharsetDecoder newCd = charset.newDecoder();
newCd.onUnmappableCharacter(CodingErrorAction.REPLACE);
newCd.onMalformedInput(CodingErrorAction.REPLACE);
currentCharset = charset;
synchronized (this) {
decoder = newCd;
}
}
public Charset getCharset() {
return currentCharset;
}
public void run() {
byteBuffer = ByteBuffer.allocate(BUFFER_SIZE);
charBuffer = CharBuffer.allocate(BUFFER_SIZE);
/* for East Asian character widths */
byte[] wideAttribute = new byte[BUFFER_SIZE];
byteArray = byteBuffer.array();
charArray = charBuffer.array();
CoderResult result;
int bytesRead = 0;
byteBuffer.limit(0);
int bytesToRead;
int offset;
int charWidth;
EastAsianWidth measurer = EastAsianWidth.getInstance();
try {
while (true) {
charWidth = bridge.charWidth;
bytesToRead = byteBuffer.capacity() - byteBuffer.limit();
offset = byteBuffer.arrayOffset() + byteBuffer.limit();
bytesRead = transport.read(byteArray, offset, bytesToRead);
if (bytesRead > 0) {
byteBuffer.limit(byteBuffer.limit() + bytesRead);
synchronized (this) {
result = decoder.decode(byteBuffer, charBuffer, false);
}
if (result.isUnderflow() &&
byteBuffer.limit() == byteBuffer.capacity()) {
byteBuffer.compact();
byteBuffer.limit(byteBuffer.position());
byteBuffer.position(0);
}
offset = charBuffer.position();
measurer.measure(charArray, 0, offset, wideAttribute, bridge.defaultPaint, charWidth);
buffer.putString(charArray, wideAttribute, 0, charBuffer.position());
bridge.propagateConsoleText(charArray, charBuffer.position());
charBuffer.clear();
bridge.redraw();
}
}
} catch (IOException e) {
Log.e(TAG, "Problem while handling incoming data in relay thread", e);
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/Relay.java | Java | asf20 | 3,977 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
/**
* @author Kenny Root
*
*/
public interface FontSizeChangedListener {
/**
* @param size
* new font size
*/
void onFontSizeChanged(float size);
}
| zzsuper001-linuxshell | src/org/connectbot/service/FontSizeChangedListener.java | Java | asf20 | 884 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
public interface BridgeDisconnectedListener {
public void onDisconnected(TerminalBridge bridge);
}
| zzsuper001-linuxshell | src/org/connectbot/service/BridgeDisconnectedListener.java | Java | asf20 | 813 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2010 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.io.IOException;
import org.connectbot.util.HostDatabase;
import org.connectbot.util.PreferenceConstants;
import org.connectbot.util.PubkeyDatabase;
import android.app.backup.BackupAgentHelper;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.app.backup.FileBackupHelper;
import android.app.backup.SharedPreferencesBackupHelper;
import android.os.ParcelFileDescriptor;
import android.util.Log;
/**
* @author kroot
*
*/
public class BackupAgent extends BackupAgentHelper {
@Override
public void onCreate() {
Log.d("ConnectBot.BackupAgent", "onCreate called");
SharedPreferencesBackupHelper prefs = new SharedPreferencesBackupHelper(this, getPackageName() + "_preferences");
addHelper(PreferenceConstants.BACKUP_PREF_KEY, prefs);
FileBackupHelper hosts = new FileBackupHelper(this, "../databases/" + HostDatabase.DB_NAME);
addHelper(HostDatabase.DB_NAME, hosts);
FileBackupHelper pubkeys = new FileBackupHelper(this, "../databases/" + PubkeyDatabase.DB_NAME);
addHelper(PubkeyDatabase.DB_NAME, pubkeys);
}
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException {
synchronized (HostDatabase.dbLock) {
super.onBackup(oldState, data, newState);
}
}
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
Log.d("ConnectBot.BackupAgent", "onRestore called");
synchronized (HostDatabase.dbLock) {
Log.d("ConnectBot.BackupAgent", "onRestore in-lock");
super.onRestore(data, appVersionCode, newState);
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/BackupAgent.java | Java | asf20 | 2,398 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import org.connectbot.R;
import org.connectbot.bean.HostBean;
import org.connectbot.bean.PubkeyBean;
import org.connectbot.transport.TransportFactory;
import org.connectbot.util.HostDatabase;
import org.connectbot.util.PreferenceConstants;
import org.connectbot.util.PubkeyDatabase;
import org.connectbot.util.PubkeyUtils;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.AssetFileDescriptor;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;
/**
* Manager for SSH connections that runs as a service. This service holds a list
* of currently connected SSH bridges that are ready for connection up to a GUI
* if needed.
*
* @author jsharkey
*/
public class TerminalManager extends Service implements BridgeDisconnectedListener, OnSharedPreferenceChangeListener {
public final static String TAG = "ConnectBot.TerminalManager";
public List<TerminalBridge> bridges = new LinkedList<TerminalBridge>();
public Map<HostBean, WeakReference<TerminalBridge>> mHostBridgeMap =
new HashMap<HostBean, WeakReference<TerminalBridge>>();
public Map<String, WeakReference<TerminalBridge>> mNicknameBridgeMap =
new HashMap<String, WeakReference<TerminalBridge>>();
public TerminalBridge defaultBridge = null;
public List<HostBean> disconnected = new LinkedList<HostBean>();
public Handler disconnectHandler = null;
public Map<String, KeyHolder> loadedKeypairs = new HashMap<String, KeyHolder>();
public Resources res;
public HostDatabase hostdb;
public PubkeyDatabase pubkeydb;
protected SharedPreferences prefs;
final private IBinder binder = new TerminalBinder();
private ConnectivityReceiver connectivityManager;
private MediaPlayer mediaPlayer;
private Timer pubkeyTimer;
private Timer idleTimer;
private final long IDLE_TIMEOUT = 300000; // 5 minutes
private Vibrator vibrator;
private volatile boolean wantKeyVibration;
public static final long VIBRATE_DURATION = 30;
private boolean wantBellVibration;
private boolean resizeAllowed = true;
private boolean savingKeys;
protected List<WeakReference<TerminalBridge>> mPendingReconnect
= new LinkedList<WeakReference<TerminalBridge>>();
public boolean hardKeyboardHidden;
@Override
public void onCreate() {
Log.i(TAG, "Starting service");
prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
res = getResources();
pubkeyTimer = new Timer("pubkeyTimer", true);
hostdb = new HostDatabase(this);
pubkeydb = new PubkeyDatabase(this);
// load all marked pubkeys into memory
updateSavingKeys();
List<PubkeyBean> pubkeys = pubkeydb.getAllStartPubkeys();
for (PubkeyBean pubkey : pubkeys) {
try {
PrivateKey privKey = PubkeyUtils.decodePrivate(pubkey.getPrivateKey(), pubkey.getType());
PublicKey pubKey = pubkey.getPublicKey();
Object trileadKey = PubkeyUtils.convertToTrilead(privKey, pubKey);
addKey(pubkey, trileadKey);
} catch (Exception e) {
Log.d(TAG, String.format("Problem adding key '%s' to in-memory cache", pubkey.getNickname()), e);
}
}
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
wantKeyVibration = prefs.getBoolean(PreferenceConstants.BUMPY_ARROWS, true);
wantBellVibration = prefs.getBoolean(PreferenceConstants.BELL_VIBRATE, true);
enableMediaPlayer();
hardKeyboardHidden = (res.getConfiguration().hardKeyboardHidden ==
Configuration.HARDKEYBOARDHIDDEN_YES);
final boolean lockingWifi = prefs.getBoolean(PreferenceConstants.WIFI_LOCK, true);
connectivityManager = new ConnectivityReceiver(this, lockingWifi);
}
private void updateSavingKeys() {
savingKeys = prefs.getBoolean(PreferenceConstants.MEMKEYS, true);
}
@Override
public void onDestroy() {
Log.i(TAG, "Destroying service");
disconnectAll(true);
if(hostdb != null) {
hostdb.close();
hostdb = null;
}
if(pubkeydb != null) {
pubkeydb.close();
pubkeydb = null;
}
synchronized (this) {
if (idleTimer != null)
idleTimer.cancel();
if (pubkeyTimer != null)
pubkeyTimer.cancel();
}
connectivityManager.cleanup();
ConnectionNotifier.getInstance().hideRunningNotification(this);
disableMediaPlayer();
}
/**
* Disconnect all currently connected bridges.
*/
private void disconnectAll(final boolean immediate) {
TerminalBridge[] tmpBridges = null;
synchronized (bridges) {
if (bridges.size() > 0) {
tmpBridges = bridges.toArray(new TerminalBridge[bridges.size()]);
}
}
if (tmpBridges != null) {
// disconnect and dispose of any existing bridges
for (int i = 0; i < tmpBridges.length; i++)
tmpBridges[i].dispatchDisconnect(immediate);
}
}
/**
* Open a new SSH session using the given parameters.
*/
private TerminalBridge openConnection(HostBean host) throws IllegalArgumentException, IOException {
// throw exception if terminal already open
if (getConnectedBridge(host) != null) {
throw new IllegalArgumentException("Connection already open for that nickname");
}
TerminalBridge bridge = new TerminalBridge(this, host);
bridge.setOnDisconnectedListener(this);
bridge.startConnection();
synchronized (bridges) {
bridges.add(bridge);
WeakReference<TerminalBridge> wr = new WeakReference<TerminalBridge>(bridge);
mHostBridgeMap.put(bridge.host, wr);
mNicknameBridgeMap.put(bridge.host.getNickname(), wr);
}
synchronized (disconnected) {
disconnected.remove(bridge.host);
}
if (bridge.isUsingNetwork()) {
connectivityManager.incRef();
}
if (prefs.getBoolean(PreferenceConstants.CONNECTION_PERSIST, true)) {
ConnectionNotifier.getInstance().showRunningNotification(this);
}
// also update database with new connected time
touchHost(host);
return bridge;
}
public String getEmulation() {
return prefs.getString(PreferenceConstants.EMULATION, "screen");
}
public int getScrollback() {
int scrollback = 140;
try {
scrollback = Integer.parseInt(prefs.getString(PreferenceConstants.SCROLLBACK, "140"));
} catch(Exception e) {
}
return scrollback;
}
/**
* Open a new connection by reading parameters from the given URI. Follows
* format specified by an individual transport.
*/
public TerminalBridge openConnection(Uri uri) throws Exception {
HostBean host = TransportFactory.findHost(hostdb, uri);
if (host == null)
host = TransportFactory.getTransport(uri.getScheme()).createHost(uri);
return openConnection(host);
}
/**
* Update the last-connected value for the given nickname by passing through
* to {@link HostDatabase}.
*/
private void touchHost(HostBean host) {
hostdb.touchHost(host);
}
/**
* Find a connected {@link TerminalBridge} with the given HostBean.
*
* @param host the HostBean to search for
* @return TerminalBridge that uses the HostBean
*/
public TerminalBridge getConnectedBridge(HostBean host) {
WeakReference<TerminalBridge> wr = mHostBridgeMap.get(host);
if (wr != null) {
return wr.get();
} else {
return null;
}
}
/**
* Find a connected {@link TerminalBridge} using its nickname.
*
* @param nickname
* @return TerminalBridge that matches nickname
*/
public TerminalBridge getConnectedBridge(final String nickname) {
if (nickname == null) {
return null;
}
WeakReference<TerminalBridge> wr = mNicknameBridgeMap.get(nickname);
if (wr != null) {
return wr.get();
} else {
return null;
}
}
/**
* Called by child bridge when somehow it's been disconnected.
*/
public void onDisconnected(TerminalBridge bridge) {
boolean shouldHideRunningNotification = false;
synchronized (bridges) {
// remove this bridge from our list
bridges.remove(bridge);
mHostBridgeMap.remove(bridge.host);
mNicknameBridgeMap.remove(bridge.host.getNickname());
if (bridge.isUsingNetwork()) {
connectivityManager.decRef();
}
if (bridges.size() == 0 &&
mPendingReconnect.size() == 0) {
shouldHideRunningNotification = true;
}
}
synchronized (disconnected) {
disconnected.add(bridge.host);
}
if (shouldHideRunningNotification) {
ConnectionNotifier.getInstance().hideRunningNotification(this);
}
// pass notification back up to gui
if (disconnectHandler != null)
Message.obtain(disconnectHandler, -1, bridge).sendToTarget();
}
public boolean isKeyLoaded(String nickname) {
return loadedKeypairs.containsKey(nickname);
}
public void addKey(PubkeyBean pubkey, Object trileadKey) {
addKey(pubkey, trileadKey, false);
}
public void addKey(PubkeyBean pubkey, Object trileadKey, boolean force) {
if (!savingKeys && !force)
return;
removeKey(pubkey.getNickname());
byte[] sshPubKey = PubkeyUtils.extractOpenSSHPublic(trileadKey);
KeyHolder keyHolder = new KeyHolder();
keyHolder.bean = pubkey;
keyHolder.trileadKey = trileadKey;
keyHolder.openSSHPubkey = sshPubKey;
loadedKeypairs.put(pubkey.getNickname(), keyHolder);
if (pubkey.getLifetime() > 0) {
final String nickname = pubkey.getNickname();
pubkeyTimer.schedule(new TimerTask() {
@Override
public void run() {
Log.d(TAG, "Unloading from memory key: " + nickname);
removeKey(nickname);
}
}, pubkey.getLifetime() * 1000);
}
Log.d(TAG, String.format("Added key '%s' to in-memory cache", pubkey.getNickname()));
}
public boolean removeKey(String nickname) {
Log.d(TAG, String.format("Removed key '%s' to in-memory cache", nickname));
return loadedKeypairs.remove(nickname) != null;
}
public boolean removeKey(byte[] publicKey) {
String nickname = null;
for (Entry<String,KeyHolder> entry : loadedKeypairs.entrySet()) {
if (Arrays.equals(entry.getValue().openSSHPubkey, publicKey)) {
nickname = entry.getKey();
break;
}
}
if (nickname != null) {
Log.d(TAG, String.format("Removed key '%s' to in-memory cache", nickname));
return removeKey(nickname);
} else
return false;
}
public Object getKey(String nickname) {
if (loadedKeypairs.containsKey(nickname)) {
KeyHolder keyHolder = loadedKeypairs.get(nickname);
return keyHolder.trileadKey;
} else
return null;
}
public Object getKey(byte[] publicKey) {
for (KeyHolder keyHolder : loadedKeypairs.values()) {
if (Arrays.equals(keyHolder.openSSHPubkey, publicKey))
return keyHolder.trileadKey;
}
return null;
}
public String getKeyNickname(byte[] publicKey) {
for (Entry<String,KeyHolder> entry : loadedKeypairs.entrySet()) {
if (Arrays.equals(entry.getValue().openSSHPubkey, publicKey))
return entry.getKey();
}
return null;
}
private void stopWithDelay() {
// TODO add in a way to check whether keys loaded are encrypted and only
// set timer when we have an encrypted key loaded
if (loadedKeypairs.size() > 0) {
synchronized (this) {
if (idleTimer == null)
idleTimer = new Timer("idleTimer", true);
idleTimer.schedule(new IdleTask(), IDLE_TIMEOUT);
}
} else {
Log.d(TAG, "Stopping service immediately");
stopSelf();
}
}
protected void stopNow() {
if (bridges.size() == 0) {
stopSelf();
}
}
private synchronized void stopIdleTimer() {
if (idleTimer != null) {
idleTimer.cancel();
idleTimer = null;
}
}
public class TerminalBinder extends Binder {
public TerminalManager getService() {
return TerminalManager.this;
}
}
@Override
public IBinder onBind(Intent intent) {
Log.i(TAG, "Someone bound to TerminalManager");
setResizeAllowed(true);
stopIdleTimer();
// Make sure we stay running to maintain the bridges
startService(new Intent(this, TerminalManager.class));
return binder;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
/*
* We want this service to continue running until it is explicitly
* stopped, so return sticky.
*/
return START_STICKY;
}
@Override
public void onRebind(Intent intent) {
super.onRebind(intent);
setResizeAllowed(true);
Log.i(TAG, "Someone rebound to TerminalManager");
stopIdleTimer();
}
@Override
public boolean onUnbind(Intent intent) {
Log.i(TAG, "Someone unbound from TerminalManager");
setResizeAllowed(true);
if (bridges.size() == 0) {
stopWithDelay();
}
return true;
}
private class IdleTask extends TimerTask {
/* (non-Javadoc)
* @see java.util.TimerTask#run()
*/
@Override
public void run() {
Log.d(TAG, String.format("Stopping service after timeout of ~%d seconds", IDLE_TIMEOUT / 1000));
TerminalManager.this.stopNow();
}
}
public void tryKeyVibrate() {
if (wantKeyVibration)
vibrate();
}
private void vibrate() {
if (vibrator != null)
vibrator.vibrate(VIBRATE_DURATION);
}
private void enableMediaPlayer() {
mediaPlayer = new MediaPlayer();
float volume = prefs.getFloat(PreferenceConstants.BELL_VOLUME,
PreferenceConstants.DEFAULT_BELL_VOLUME);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
mediaPlayer.setOnCompletionListener(new BeepListener());
AssetFileDescriptor file = res.openRawResourceFd(R.raw.bell);
try {
mediaPlayer.setDataSource(file.getFileDescriptor(), file
.getStartOffset(), file.getLength());
file.close();
mediaPlayer.setVolume(volume, volume);
mediaPlayer.prepare();
} catch (IOException e) {
Log.e(TAG, "Error setting up bell media player", e);
}
}
private void disableMediaPlayer() {
if (mediaPlayer != null) {
mediaPlayer.release();
mediaPlayer = null;
}
}
public void playBeep() {
if (mediaPlayer != null)
mediaPlayer.start();
if (wantBellVibration)
vibrate();
}
private static class BeepListener implements OnCompletionListener {
public void onCompletion(MediaPlayer mp) {
mp.seekTo(0);
}
}
/**
* Send system notification to user for a certain host. When user selects
* the notification, it will bring them directly to the ConsoleActivity
* displaying the host.
*
* @param host
*/
public void sendActivityNotification(HostBean host) {
if (!prefs.getBoolean(PreferenceConstants.BELL_NOTIFICATION, false))
return;
ConnectionNotifier.getInstance().showActivityNotification(this, host);
}
/* (non-Javadoc)
* @see android.content.SharedPreferences.OnSharedPreferenceChangeListener#onSharedPreferenceChanged(android.content.SharedPreferences, java.lang.String)
*/
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (PreferenceConstants.BELL.equals(key)) {
boolean wantAudible = sharedPreferences.getBoolean(
PreferenceConstants.BELL, true);
if (wantAudible && mediaPlayer == null)
enableMediaPlayer();
else if (!wantAudible && mediaPlayer != null)
disableMediaPlayer();
} else if (PreferenceConstants.BELL_VOLUME.equals(key)) {
if (mediaPlayer != null) {
float volume = sharedPreferences.getFloat(
PreferenceConstants.BELL_VOLUME,
PreferenceConstants.DEFAULT_BELL_VOLUME);
mediaPlayer.setVolume(volume, volume);
}
} else if (PreferenceConstants.BELL_VIBRATE.equals(key)) {
wantBellVibration = sharedPreferences.getBoolean(
PreferenceConstants.BELL_VIBRATE, true);
} else if (PreferenceConstants.BUMPY_ARROWS.equals(key)) {
wantKeyVibration = sharedPreferences.getBoolean(
PreferenceConstants.BUMPY_ARROWS, true);
} else if (PreferenceConstants.WIFI_LOCK.equals(key)) {
final boolean lockingWifi = prefs.getBoolean(PreferenceConstants.WIFI_LOCK, true);
connectivityManager.setWantWifiLock(lockingWifi);
} else if (PreferenceConstants.MEMKEYS.equals(key)) {
updateSavingKeys();
}
}
/**
* Allow {@link TerminalBridge} to resize when the parent has changed.
* @param resizeAllowed
*/
public void setResizeAllowed(boolean resizeAllowed) {
this.resizeAllowed = resizeAllowed;
}
public boolean isResizeAllowed() {
return resizeAllowed;
}
public static class KeyHolder {
public PubkeyBean bean;
public Object trileadKey;
public byte[] openSSHPubkey;
}
/**
* Called when connectivity to the network is lost and it doesn't appear
* we'll be getting a different connection any time soon.
*/
public void onConnectivityLost() {
final Thread t = new Thread() {
@Override
public void run() {
disconnectAll(false);
}
};
t.setName("Disconnector");
t.start();
}
/**
* Called when connectivity to the network is restored.
*/
public void onConnectivityRestored() {
final Thread t = new Thread() {
@Override
public void run() {
reconnectPending();
}
};
t.setName("Reconnector");
t.start();
}
/**
* Insert request into reconnect queue to be executed either immediately
* or later when connectivity is restored depending on whether we're
* currently connected.
*
* @param bridge the TerminalBridge to reconnect when possible
*/
public void requestReconnect(TerminalBridge bridge) {
synchronized (mPendingReconnect) {
mPendingReconnect.add(new WeakReference<TerminalBridge>(bridge));
if (!bridge.isUsingNetwork() ||
connectivityManager.isConnected()) {
reconnectPending();
}
}
}
/**
* Reconnect all bridges that were pending a reconnect when connectivity
* was lost.
*/
private void reconnectPending() {
synchronized (mPendingReconnect) {
for (WeakReference<TerminalBridge> ref : mPendingReconnect) {
TerminalBridge bridge = ref.get();
if (bridge == null) {
continue;
}
bridge.startConnection();
}
mPendingReconnect.clear();
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/TerminalManager.java | Java | asf20 | 19,065 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.util.concurrent.Semaphore;
import android.os.Handler;
import android.os.Message;
/**
* Helps provide a relay for prompts and responses between a possible user
* interface and some underlying service.
*
* @author jsharkey
*/
public class PromptHelper {
private final Object tag;
private Handler handler = null;
private Semaphore promptToken;
private Semaphore promptResponse;
public String promptInstructions = null;
public String promptHint = null;
public Object promptRequested = null;
private Object response = null;
public PromptHelper(Object tag) {
this.tag = tag;
// Threads must acquire this before they can send a prompt.
promptToken = new Semaphore(1);
// Responses will release this semaphore.
promptResponse = new Semaphore(0);
}
/**
* Register a user interface handler, if available.
*/
public void setHandler(Handler handler) {
this.handler = handler;
}
/**
* Set an incoming value from an above user interface. Will automatically
* notify any waiting requests.
*/
public void setResponse(Object value) {
response = value;
promptRequested = null;
promptInstructions = null;
promptHint = null;
promptResponse.release();
}
/**
* Return the internal response value just before erasing and returning it.
*/
protected Object popResponse() {
Object value = response;
response = null;
return value;
}
/**
* Request a prompt response from parent. This is a blocking call until user
* interface returns a value.
* Only one thread can call this at a time. cancelPrompt() will force this to
* immediately return.
*/
private Object requestPrompt(String instructions, String hint, Object type) throws InterruptedException {
Object response = null;
promptToken.acquire();
try {
promptInstructions = instructions;
promptHint = hint;
promptRequested = type;
// notify any parent watching for live events
if (handler != null)
Message.obtain(handler, -1, tag).sendToTarget();
// acquire lock until user passes back value
promptResponse.acquire();
response = popResponse();
} finally {
promptToken.release();
}
return response;
}
/**
* Request a string response from parent. This is a blocking call until user
* interface returns a value.
* @param hint prompt hint for user to answer
* @return string user has entered
*/
public String requestStringPrompt(String instructions, String hint) {
String value = null;
try {
value = (String)this.requestPrompt(instructions, hint, String.class);
} catch(Exception e) {
}
return value;
}
/**
* Request a boolean response from parent. This is a blocking call until user
* interface returns a value.
* @param hint prompt hint for user to answer
* @return choice user has made (yes/no)
*/
public Boolean requestBooleanPrompt(String instructions, String hint) {
Boolean value = null;
try {
value = (Boolean)this.requestPrompt(instructions, hint, Boolean.class);
} catch(Exception e) {
}
return value;
}
/**
* Cancel an in-progress prompt.
*/
public void cancelPrompt() {
if (!promptToken.tryAcquire()) {
// A thread has the token, so try to interrupt it
response = null;
promptResponse.release();
} else {
// No threads have acquired the token
promptToken.release();
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/PromptHelper.java | Java | asf20 | 4,054 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2010 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import org.connectbot.util.PreferenceConstants;
import android.app.backup.BackupManager;
import android.content.Context;
/**
* @author kroot
*
*/
public abstract class BackupWrapper {
public static BackupWrapper getInstance() {
if (PreferenceConstants.PRE_FROYO)
return PreFroyo.Holder.sInstance;
else
return FroyoAndBeyond.Holder.sInstance;
}
public abstract void onDataChanged(Context context);
private static class PreFroyo extends BackupWrapper {
private static class Holder {
private static final PreFroyo sInstance = new PreFroyo();
}
@Override
public void onDataChanged(Context context) {
// do nothing for now
}
}
private static class FroyoAndBeyond extends BackupWrapper {
private static class Holder {
private static final FroyoAndBeyond sInstance = new FroyoAndBeyond();
}
private static BackupManager mBackupManager;
@Override
public void onDataChanged(Context context) {
checkBackupManager(context);
if (mBackupManager != null) {
mBackupManager.dataChanged();
}
}
private void checkBackupManager(Context context) {
if (mBackupManager == null) {
mBackupManager = new BackupManager(context);
}
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/BackupWrapper.java | Java | asf20 | 1,911 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2010 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot.service;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.connectbot.ConsoleActivity;
import org.connectbot.R;
import org.connectbot.bean.HostBean;
import org.connectbot.util.HostDatabase;
import org.connectbot.util.PreferenceConstants;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
/**
* @author Kenny Root
*
* Based on the concept from jasta's blog post.
*/
public abstract class ConnectionNotifier {
private static final int ONLINE_NOTIFICATION = 1;
private static final int ACTIVITY_NOTIFICATION = 2;
public static ConnectionNotifier getInstance() {
if (PreferenceConstants.PRE_ECLAIR)
return PreEclair.Holder.sInstance;
else
return EclairAndBeyond.Holder.sInstance;
}
protected NotificationManager getNotificationManager(Context context) {
return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
}
protected Notification newNotification(Context context) {
Notification notification = new Notification();
notification.icon = R.drawable.notification_icon;
notification.when = System.currentTimeMillis();
return notification;
}
protected Notification newActivityNotification(Context context, HostBean host) {
Notification notification = newNotification(context);
Resources res = context.getResources();
String contentText = res.getString(
R.string.notification_text, host.getNickname());
Intent notificationIntent = new Intent(context, ConsoleActivity.class);
notificationIntent.setAction("android.intent.action.VIEW");
notificationIntent.setData(host.getUri());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, res.getString(R.string.app_name), contentText, contentIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.DEFAULT_LIGHTS;
if (HostDatabase.COLOR_RED.equals(host.getColor()))
notification.ledARGB = Color.RED;
else if (HostDatabase.COLOR_GREEN.equals(host.getColor()))
notification.ledARGB = Color.GREEN;
else if (HostDatabase.COLOR_BLUE.equals(host.getColor()))
notification.ledARGB = Color.BLUE;
else
notification.ledARGB = Color.WHITE;
notification.ledOnMS = 300;
notification.ledOffMS = 1000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
return notification;
}
protected Notification newRunningNotification(Context context) {
Notification notification = newNotification(context);
notification.flags = Notification.FLAG_ONGOING_EVENT
| Notification.FLAG_NO_CLEAR;
notification.when = 0;
notification.contentIntent = PendingIntent.getActivity(context,
ONLINE_NOTIFICATION,
new Intent(context, ConsoleActivity.class), 0);
Resources res = context.getResources();
notification.setLatestEventInfo(context,
res.getString(R.string.app_name),
res.getString(R.string.app_is_running),
notification.contentIntent);
return notification;
}
public void showActivityNotification(Service context, HostBean host) {
getNotificationManager(context).notify(ACTIVITY_NOTIFICATION, newActivityNotification(context, host));
}
public void hideActivityNotification(Service context) {
getNotificationManager(context).cancel(ACTIVITY_NOTIFICATION);
}
public abstract void showRunningNotification(Service context);
public abstract void hideRunningNotification(Service context);
private static class PreEclair extends ConnectionNotifier {
private static final Class<?>[] setForegroundSignature = new Class[] {boolean.class};
private Method setForeground = null;
private static class Holder {
private static final PreEclair sInstance = new PreEclair();
}
public PreEclair() {
try {
setForeground = Service.class.getMethod("setForeground", setForegroundSignature);
} catch (Exception e) {
}
}
@Override
public void showRunningNotification(Service context) {
if (setForeground != null) {
Object[] setForegroundArgs = new Object[1];
setForegroundArgs[0] = Boolean.TRUE;
try {
setForeground.invoke(context, setForegroundArgs);
} catch (InvocationTargetException e) {
} catch (IllegalAccessException e) {
}
getNotificationManager(context).notify(ONLINE_NOTIFICATION, newRunningNotification(context));
}
}
@Override
public void hideRunningNotification(Service context) {
if (setForeground != null) {
Object[] setForegroundArgs = new Object[1];
setForegroundArgs[0] = Boolean.FALSE;
try {
setForeground.invoke(context, setForegroundArgs);
} catch (InvocationTargetException e) {
} catch (IllegalAccessException e) {
}
getNotificationManager(context).cancel(ONLINE_NOTIFICATION);
}
}
}
private static class EclairAndBeyond extends ConnectionNotifier {
private static class Holder {
private static final EclairAndBeyond sInstance = new EclairAndBeyond();
}
@Override
public void showRunningNotification(Service context) {
context.startForeground(ONLINE_NOTIFICATION, newRunningNotification(context));
}
@Override
public void hideRunningNotification(Service context) {
context.stopForeground(true);
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/ConnectionNotifier.java | Java | asf20 | 6,136 |
/**
*
*/
package org.connectbot.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.WifiLock;
import android.util.Log;
/**
* @author kroot
*
*/
public class ConnectivityReceiver extends BroadcastReceiver {
private static final String TAG = "ConnectBot.ConnectivityManager";
private boolean mIsConnected = false;
final private TerminalManager mTerminalManager;
final private WifiLock mWifiLock;
private int mNetworkRef = 0;
private boolean mLockingWifi;
private Object[] mLock = new Object[0];
public ConnectivityReceiver(TerminalManager manager, boolean lockingWifi) {
mTerminalManager = manager;
final ConnectivityManager cm =
(ConnectivityManager) manager.getSystemService(Context.CONNECTIVITY_SERVICE);
final WifiManager wm = (WifiManager) manager.getSystemService(Context.WIFI_SERVICE);
mWifiLock = wm.createWifiLock(TAG);
final NetworkInfo info = cm.getActiveNetworkInfo();
if (info != null) {
mIsConnected = (info.getState() == State.CONNECTED);
}
mLockingWifi = lockingWifi;
final IntentFilter filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
manager.registerReceiver(this, filter);
}
/* (non-Javadoc)
* @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
*/
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
Log.w(TAG, "onReceived() called: " + intent);
return;
}
boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
boolean isFailover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);
Log.d(TAG, "onReceived() called; noConnectivity? " + noConnectivity + "; isFailover? " + isFailover);
if (noConnectivity && !isFailover && mIsConnected) {
mIsConnected = false;
mTerminalManager.onConnectivityLost();
} else if (!mIsConnected) {
NetworkInfo info = (NetworkInfo) intent.getExtras()
.get(ConnectivityManager.EXTRA_NETWORK_INFO);
if (mIsConnected = (info.getState() == State.CONNECTED)) {
mTerminalManager.onConnectivityRestored();
}
}
}
/**
*
*/
public void cleanup() {
if (mWifiLock.isHeld())
mWifiLock.release();
mTerminalManager.unregisterReceiver(this);
}
/**
* Increase the number of things using the network. Acquire a Wi-Fi lock
* if necessary.
*/
public void incRef() {
synchronized (mLock) {
mNetworkRef += 1;
acquireWifiLockIfNecessaryLocked();
}
}
/**
* Decrease the number of things using the network. Release the Wi-Fi lock
* if necessary.
*/
public void decRef() {
synchronized (mLock) {
mNetworkRef -= 1;
releaseWifiLockIfNecessaryLocked();
}
}
/**
* @param mLockingWifi
*/
public void setWantWifiLock(boolean lockingWifi) {
synchronized (mLock) {
mLockingWifi = lockingWifi;
if (mLockingWifi) {
acquireWifiLockIfNecessaryLocked();
} else {
releaseWifiLockIfNecessaryLocked();
}
}
}
private void acquireWifiLockIfNecessaryLocked() {
if (mLockingWifi && mNetworkRef > 0 && !mWifiLock.isHeld()) {
mWifiLock.acquire();
}
}
private void releaseWifiLockIfNecessaryLocked() {
if (mNetworkRef == 0 && mWifiLock.isHeld()) {
mWifiLock.release();
}
}
/**
* @return whether we're connected to a network
*/
public boolean isConnected() {
return mIsConnected;
}
}
| zzsuper001-linuxshell | src/org/connectbot/service/ConnectivityReceiver.java | Java | asf20 | 3,788 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot;
import org.connectbot.util.HelpTopicView;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ViewFlipper;
/**
* Show a series of wizard-like steps to the user, which might include an EULA,
* program credits, and helpful hints.
*
* @author jsharkey
*/
public class WizardActivity extends Activity {
protected ViewFlipper flipper = null;
private Button next, prev;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_wizard);
this.flipper = (ViewFlipper) findViewById(R.id.wizard_flipper);
// inflate the layout for EULA step
LayoutInflater inflater = LayoutInflater.from(this);
this.flipper.addView(inflater.inflate(R.layout.wiz_eula, this.flipper, false));
// Add a view for each help topic we want the user to see.
String[] topics = getResources().getStringArray(R.array.list_wizard_topics);
for (String topic : topics) {
flipper.addView(new HelpTopicView(this).setTopic(topic));
}
next = (Button)this.findViewById(R.id.action_next);
next.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(isLastDisplayed()) {
// user walked past end of wizard, so return okay
WizardActivity.this.setResult(Activity.RESULT_OK);
WizardActivity.this.finish();
} else {
// show next step and update buttons
flipper.showNext();
updateButtons();
}
}
});
prev = (Button)this.findViewById(R.id.action_prev);
prev.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(isFirstDisplayed()) {
// user walked past beginning of wizard, so return that they cancelled
WizardActivity.this.setResult(Activity.RESULT_CANCELED);
WizardActivity.this.finish();
} else {
// show previous step and update buttons
flipper.showPrevious();
updateButtons();
}
}
});
this.updateButtons();
}
protected boolean isFirstDisplayed() {
return (flipper.getDisplayedChild() == 0);
}
protected boolean isLastDisplayed() {
return (flipper.getDisplayedChild() == flipper.getChildCount() - 1);
}
protected void updateButtons() {
boolean eula = (flipper.getDisplayedChild() == 0);
next.setText(eula ? getString(R.string.wizard_agree) : getString(R.string.wizard_next));
prev.setText(eula ? getString(R.string.delete_neg) : getString(R.string.wizard_back));
}
}
| zzsuper001-linuxshell | src/org/connectbot/WizardActivity.java | Java | asf20 | 3,293 |
/*
* ConnectBot: simple, powerful, open-source SSH client for Android
* Copyright 2007 Kenny Root, Jeffrey Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.connectbot;
import java.util.List;
import org.connectbot.bean.HostBean;
import org.connectbot.bean.PortForwardBean;
import org.connectbot.service.TerminalBridge;
import org.connectbot.service.TerminalManager;
import org.connectbot.util.HostDatabase;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.Resources;
import android.database.SQLException;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.MenuItem.OnMenuItemClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
/**
* List all portForwards for a particular host and provide a way for users to add more portForwards,
* edit existing portForwards, and delete portForwards.
*
* @author Kenny Root
*/
public class PortForwardListActivity extends ListActivity {
public final static String TAG = "ConnectBot.PortForwardListActivity";
private static final int LISTENER_CYCLE_TIME = 500;
protected HostDatabase hostdb;
private List<PortForwardBean> portForwards;
private ServiceConnection connection = null;
protected TerminalBridge hostBridge = null;
protected LayoutInflater inflater = null;
private HostBean host;
@Override
public void onStart() {
super.onStart();
this.bindService(new Intent(this, TerminalManager.class), connection, Context.BIND_AUTO_CREATE);
if(this.hostdb == null)
this.hostdb = new HostDatabase(this);
}
@Override
public void onStop() {
super.onStop();
this.unbindService(connection);
if(this.hostdb != null) {
this.hostdb.close();
this.hostdb = null;
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
long hostId = this.getIntent().getLongExtra(Intent.EXTRA_TITLE, -1);
setContentView(R.layout.act_portforwardlist);
// connect with hosts database and populate list
this.hostdb = new HostDatabase(this);
host = hostdb.findHostById(hostId);
{
final String nickname = host != null ? host.getNickname() : null;
final Resources resources = getResources();
if (nickname != null) {
this.setTitle(String.format("%s: %s (%s)",
resources.getText(R.string.app_name),
resources.getText(R.string.title_port_forwards_list),
nickname));
} else {
this.setTitle(String.format("%s: %s",
resources.getText(R.string.app_name),
resources.getText(R.string.title_port_forwards_list)));
}
}
connection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
TerminalManager bound = ((TerminalManager.TerminalBinder) service).getService();
hostBridge = bound.getConnectedBridge(host);
updateHandler.sendEmptyMessage(-1);
}
public void onServiceDisconnected(ComponentName name) {
hostBridge = null;
}
};
this.updateList();
this.registerForContextMenu(this.getListView());
this.getListView().setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
ListView lv = PortForwardListActivity.this.getListView();
PortForwardBean pfb = (PortForwardBean) lv.getItemAtPosition(position);
if (hostBridge != null) {
if (pfb.isEnabled())
hostBridge.disablePortForward(pfb);
else {
if (!hostBridge.enablePortForward(pfb))
Toast.makeText(PortForwardListActivity.this, getString(R.string.portforward_problem), Toast.LENGTH_LONG).show();
}
updateHandler.sendEmptyMessage(-1);
}
}
});
this.inflater = LayoutInflater.from(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuItem add = menu.add(R.string.portforward_menu_add);
add.setIcon(android.R.drawable.ic_menu_add);
add.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
// build dialog to prompt user about updating
final View portForwardView = inflater.inflate(R.layout.dia_portforward, null, false);
final EditText destEdit = (EditText) portForwardView.findViewById(R.id.portforward_destination);
final Spinner typeSpinner = (Spinner)portForwardView.findViewById(R.id.portforward_type);
typeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> value, View view,
int position, long id) {
destEdit.setEnabled(position != 2);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
new AlertDialog.Builder(PortForwardListActivity.this)
.setView(portForwardView)
.setPositiveButton(R.string.portforward_pos, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
final EditText nicknameEdit = (EditText) portForwardView.findViewById(R.id.nickname);
final EditText sourcePortEdit = (EditText) portForwardView.findViewById(R.id.portforward_source);
String type = HostDatabase.PORTFORWARD_LOCAL;
switch (typeSpinner.getSelectedItemPosition()) {
case 0:
type = HostDatabase.PORTFORWARD_LOCAL;
break;
case 1:
type = HostDatabase.PORTFORWARD_REMOTE;
break;
case 2:
type = HostDatabase.PORTFORWARD_DYNAMIC5;
break;
}
PortForwardBean pfb = new PortForwardBean(
host != null ? host.getId() : -1,
nicknameEdit.getText().toString(), type,
sourcePortEdit.getText().toString(),
destEdit.getText().toString());
if (hostBridge != null) {
hostBridge.addPortForward(pfb);
hostBridge.enablePortForward(pfb);
}
if (host != null && !hostdb.savePortForward(pfb))
throw new SQLException("Could not save port forward");
updateHandler.sendEmptyMessage(-1);
} catch (Exception e) {
Log.e(TAG, "Could not update port forward", e);
// TODO Show failure dialog.
}
}
})
.setNegativeButton(R.string.delete_neg, null).create().show();
return true;
}
});
return true;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
// Create menu to handle deleting and editing port forward
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
final PortForwardBean pfb = (PortForwardBean) this.getListView().getItemAtPosition(info.position);
menu.setHeaderTitle(pfb.getNickname());
MenuItem edit = menu.add(R.string.portforward_edit);
edit.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
final View editTunnelView = inflater.inflate(R.layout.dia_portforward, null, false);
final Spinner typeSpinner = (Spinner) editTunnelView.findViewById(R.id.portforward_type);
if (HostDatabase.PORTFORWARD_LOCAL.equals(pfb.getType()))
typeSpinner.setSelection(0);
else if (HostDatabase.PORTFORWARD_REMOTE.equals(pfb.getType()))
typeSpinner.setSelection(1);
else
typeSpinner.setSelection(2);
final EditText nicknameEdit = (EditText) editTunnelView.findViewById(R.id.nickname);
nicknameEdit.setText(pfb.getNickname());
final EditText sourcePortEdit = (EditText) editTunnelView.findViewById(R.id.portforward_source);
sourcePortEdit.setText(String.valueOf(pfb.getSourcePort()));
final EditText destEdit = (EditText) editTunnelView.findViewById(R.id.portforward_destination);
if (HostDatabase.PORTFORWARD_DYNAMIC5.equals(pfb.getType())) {
destEdit.setEnabled(false);
} else {
destEdit.setText(String.format("%s:%d", pfb.getDestAddr(), pfb.getDestPort()));
}
typeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> value, View view,
int position, long id) {
destEdit.setEnabled(position != 2);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
new AlertDialog.Builder(PortForwardListActivity.this)
.setView(editTunnelView)
.setPositiveButton(R.string.button_change, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
if (hostBridge != null)
hostBridge.disablePortForward(pfb);
pfb.setNickname(nicknameEdit.getText().toString());
switch (typeSpinner.getSelectedItemPosition()) {
case 0:
pfb.setType(HostDatabase.PORTFORWARD_LOCAL);
break;
case 1:
pfb.setType(HostDatabase.PORTFORWARD_REMOTE);
break;
case 2:
pfb.setType(HostDatabase.PORTFORWARD_DYNAMIC5);
break;
}
pfb.setSourcePort(Integer.parseInt(sourcePortEdit.getText().toString()));
pfb.setDest(destEdit.getText().toString());
// Use the new settings for the existing connection.
if (hostBridge != null)
updateHandler.postDelayed(new Runnable() {
public void run() {
hostBridge.enablePortForward(pfb);
updateHandler.sendEmptyMessage(-1);
}
}, LISTENER_CYCLE_TIME);
if (!hostdb.savePortForward(pfb))
throw new SQLException("Could not save port forward");
updateHandler.sendEmptyMessage(-1);
} catch (Exception e) {
Log.e(TAG, "Could not update port forward", e);
// TODO Show failure dialog.
}
}
})
.setNegativeButton(android.R.string.cancel, null).create().show();
return true;
}
});
MenuItem delete = menu.add(R.string.portforward_delete);
delete.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
// prompt user to make sure they really want this
new AlertDialog.Builder(PortForwardListActivity.this)
.setMessage(getString(R.string.delete_message, pfb.getNickname()))
.setPositiveButton(R.string.delete_pos, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
// Delete the port forward from the host if needed.
if (hostBridge != null)
hostBridge.removePortForward(pfb);
hostdb.deletePortForward(pfb);
} catch (Exception e) {
Log.e(TAG, "Could not delete port forward", e);
}
updateHandler.sendEmptyMessage(-1);
}
})
.setNegativeButton(R.string.delete_neg, null).create().show();
return true;
}
});
}
protected Handler updateHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
PortForwardListActivity.this.updateList();
}
};
protected void updateList() {
if (hostBridge != null) {
this.portForwards = hostBridge.getPortForwards();
} else {
if (this.hostdb == null) return;
this.portForwards = this.hostdb.getPortForwardsForHost(host);
}
PortForwardAdapter adapter = new PortForwardAdapter(this, portForwards);
this.setListAdapter(adapter);
}
class PortForwardAdapter extends ArrayAdapter<PortForwardBean> {
class ViewHolder {
public TextView nickname;
public TextView caption;
}
private List<PortForwardBean> portForwards;
public PortForwardAdapter(Context context, List<PortForwardBean> portForwards) {
super(context, R.layout.item_portforward, portForwards);
this.portForwards = portForwards;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_portforward, null, false);
holder = new ViewHolder();
holder.nickname = (TextView)convertView.findViewById(android.R.id.text1);
holder.caption = (TextView)convertView.findViewById(android.R.id.text2);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
PortForwardBean pfb = portForwards.get(position);
holder.nickname.setText(pfb.getNickname());
holder.caption.setText(pfb.getDescription());
if (hostBridge != null && !pfb.isEnabled()) {
holder.nickname.setPaintFlags(holder.nickname.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
holder.caption.setPaintFlags(holder.caption.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
return convertView;
}
}
}
| zzsuper001-linuxshell | src/org/connectbot/PortForwardListActivity.java | Java | asf20 | 13,807 |