merge upstream, slider work, refactor ping module, language selection work

This commit is contained in:
friendica 2012-07-13 07:09:29 -07:00
parent 599f3d2961
commit a20a637727
42 changed files with 11867 additions and 286 deletions

View File

@ -7,6 +7,66 @@ require_once("include/html2bbcode.php");
require_once("include/bbcode.php");
require_once("include/markdownify/markdownify.php");
function get_bb_tag_pos($s, $name, $occurance = 1) {
if($occurance < 1)
$occurance = 1;
$start_open = -1;
for($i = 1; $i <= $occurance; $i++) {
if( $start_open !== false)
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
}
if( $start_open === false)
return false;
$start_equal = strpos($s, '=', $start_open);
$start_close = strpos($s, ']', $start_open);
if( $start_close === false)
return false;
$start_close++;
$end_open = strpos($s, '[/' . $name . ']', $start_close);
if( $end_open === false)
return false;
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
if( $start_equal !== false)
$res['start']['equal'] = $start_equal + 1;
return $res;
}
function bb_tag_preg_replace($pattern, $replace, $name, $s) {
$string = $s;
$occurance = 1;
$pos = get_bb_tag_pos($string, $name, $occurance);
while($pos !== false && $occurance < 1000) {
$start = substr($string, 0, $pos['start']['open']);
$subject = substr($string, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
$end = substr($string, $pos['end']['close']);
if($end === false)
$end = '';
$subject = preg_replace($pattern, $replace, $subject);
$string = $start . $subject . $end;
$occurance++;
$pos = get_bb_tag_pos($string, $name, $occurance);
}
return $string;
}
// we don't want to support a bbcode specific markdown interpreter
// and the markdown library we have is pretty good, but provides HTML output.
// So we'll use that to convert to HTML, then convert the HTML back to bbcode,
@ -51,10 +111,10 @@ function diaspora2bb($s) {
$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]',$s);
$s = preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]',$s);
$s = preg_replace("/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]',$s);
$s = preg_replace("/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism",'[vimeo]$1[/vimeo]',$s);
$s = bb_tag_preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]','url',$s);
$s = bb_tag_preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]','url',$s);
$s = bb_tag_preg_replace("/\[url\=?(.*?)\]https?:\/ \/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]','url',$s);
$s = bb_tag_preg_replace("/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism",'[vimeo]$1[/vimeo]','url',$s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s);

View File

@ -1221,6 +1221,7 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['type'] = 'remote-comment';
$datarray['wall'] = $parent_item['wall'];
$datarray['gravity'] = GRAVITY_COMMENT;
$datarray['guid'] = $guid;
@ -1658,8 +1659,8 @@ function diaspora_like($importer,$xml,$msg) {
// likes on comments not supported here and likes on photos not supported by Diaspora
if($target_type !== 'Post')
return;
// if($target_type !== 'Post')
// return;
$contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
if(! $contact) {
@ -2232,22 +2233,30 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
// $theiraddr = $contact['addr'];
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
// return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
// The only item with `parent` and `id` as the parent id is the parent item.
$p = q("select guid from item where parent = %d and id = %d limit 1",
intval($item['parent']),
intval($item['parent'])
);
if($item['thr-parent']) {
$p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
dbesc($item['thr-parent'])
);
}
else {
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
// return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
// The only item with `parent` and `id` as the parent id is the parent item.
$p = q("select guid, type, uri, `parent-uri` from item where parent = %d and id = %d limit 1",
intval($item['parent']),
intval($item['parent'])
);
}
if(count($p))
$parent_guid = $p[0]['guid'];
$parent = $p[0];
else
return;
if($item['verb'] === ACTIVITY_LIKE) {
$tpl = get_markup_template('diaspora_like.tpl');
$like = true;
$target_type = 'Post';
$target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
// $target_type = (strpos($parent['type'], 'comment') ? 'Comment' : 'Post');
// $positive = (($item['deleted']) ? 'false' : 'true');
$positive = 'true';
@ -2264,15 +2273,15 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
// sign it
if($like)
$signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $myaddr;
$signed_text = $item['guid'] . ';' . $target_type . ';' . $parent['guid'] . ';' . $positive . ';' . $myaddr;
else
$signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
$signed_text = $item['guid'] . ';' . $parent['guid'] . ';' . $text . ';' . $myaddr;
$authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
'$parent_guid' => xmlify($parent_guid),
'$parent_guid' => xmlify($parent['guid']),
'$target_type' =>xmlify($target_type),
'$authorsig' => xmlify($authorsig),
'$body' => xmlify($text),
@ -2300,15 +2309,22 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$text = html_entity_decode(bb2diaspora($body));
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
// return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
// The only item with `parent` and `id` as the parent id is the parent item.
$p = q("select guid from item where parent = %d and id = %d limit 1",
intval($item['parent']),
intval($item['parent'])
);
if($item['thr-parent']) {
$p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
dbesc($item['thr-parent'])
);
}
else {
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
// return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
// The only item with `parent` and `id` as the parent id is the parent item.
$p = q("select guid, type, uri, `parent-uri` from item where parent = %d and id = %d limit 1",
intval($item['parent']),
intval($item['parent'])
);
}
if(count($p))
$parent_guid = $p[0]['guid'];
$parent = $p[0];
else
return;
@ -2326,7 +2342,8 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
elseif($item['verb'] === ACTIVITY_LIKE) {
$like = true;
$target_type = 'Post';
$target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
// $target_type = (strpos($parent['type'], 'comment') ? 'Comment' : 'Post');
// $positive = (($item['deleted']) ? 'false' : 'true');
$positive = 'true';
@ -2361,9 +2378,9 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
if($relay_retract)
$sender_signed_text = $item['guid'] . ';' . $target_type;
elseif($like)
$sender_signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $handle;
$sender_signed_text = $item['guid'] . ';' . $target_type . ';' . $parent['guid'] . ';' . $positive . ';' . $handle;
else
$sender_signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $handle;
$sender_signed_text = $item['guid'] . ';' . $parent['guid'] . ';' . $text . ';' . $handle;
// Sign the relayable with the top-level owner's signature
//
@ -2380,7 +2397,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
'$parent_guid' => xmlify($parent_guid),
'$parent_guid' => xmlify($parent['guid']),
'$target_type' =>xmlify($target_type),
'$authorsig' => xmlify($authorsig),
'$parentsig' => xmlify($parentauthorsig),

View File

@ -236,10 +236,10 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0
$tpl = get_markup_template("group_side.tpl");
$o = replace_macros($tpl, array(
'$title' => t('Groups'),
'$edittext' => t('Edit group'),
'$createtext' => t('Create a new group'),
'$ungrouped' => (($every === 'contacts') ? t('Contacts not in any group') : ''),
'$title' => t('Contact Groups'),
'$edittext' => t('Edit contact group'),
'$createtext' => t('Create a new contact group'),
'$ungrouped' => (($every === 'contacts') ? t('Contacts not in any contact group') : ''),
'$groups' => $groups,
'$add' => t('add'),
));

View File

@ -896,7 +896,7 @@ function item_store($arr,$force_parent = false) {
if($r[0]['uri'] != $r[0]['parent-uri']) {
$arr['thr-parent'] = $arr['parent-uri'];
$arr['parent-uri'] = $r[0]['parent-uri'];
$z = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d
$z = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d
ORDER BY `id` ASC LIMIT 1",
dbesc($r[0]['parent-uri']),
dbesc($r[0]['parent-uri']),

92
include/language.php Normal file
View File

@ -0,0 +1,92 @@
<?php
function detect_language($s) {
$detected_languages = array(
'Albanian' => 'sq',
'Arabic' => 'ar',
'Azeri' => 'az',
'Bengali' => 'bn',
'Bulgarian' => 'bg',
'Cebuano' => '',
'Croatian' => 'hr',
'Czech' => 'cz',
'Danish' => 'da',
'Dutch' => 'nl',
'English' => 'en',
'Estonian' => 'et',
'Farsi' => 'fa',
'Finnish' => 'fi',
'French' => 'fr',
'German' => 'de',
'Hausa' => 'ha',
'Hawaiian' => '',
'Hindi' => 'hi',
'Hungarian' => 'hu',
'Icelandic' => 'is',
'Indonesian' => 'id',
'Italian' => 'it',
'Kazakh' => 'kk',
'Kyrgyz' => 'ky',
'Latin' => 'la',
'Latvian' => 'lv',
'Lithuanian' => 'lt',
'Macedonian' => 'mk',
'Mongolian' => 'mn',
'Nepali' => 'ne',
'Norwegian' => 'no',
'Pashto' => 'ps',
'Pidgin' => '',
'Polish' => 'pl',
'Portuguese' => 'pt',
'Romanian' => 'ro',
'Russian' => 'ru',
'Serbian' => 'sr',
'Slovak' => 'sk',
'Slovene' => 'sl',
'Somali' => 'so',
'Spanish' => 'es',
'Swahili' => 'sw',
'Swedish' => 'sv',
'Tagalog' => 'tl',
'Turkish' => 'tr',
'Ukrainian' => 'uk',
'Urdu' => 'ur',
'Uzbek' => 'uz',
'Vietnamese' => 'vi',
'Welsh' => 'cy'
);
require_once('Text/LanguageDetect.php');
$min_length = get_config('system','language_detect_min_length');
if($min_length === false)
$min_length = LANGUAGE_DETECT_MIN_LENGTH;
$min_confidence = get_config('system','language_detect_min_confidence');
if($min_confidence === false)
$min_confidence = LANGUAGE_DETECT_MIN_CONFIDENCE;
$naked_body = preg_replace('/\[(.+?)\]/','',$s);
if(mb_strlen($naked_body) < intval($min_length))
return '';
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
logger('detect language: ' . print_r($lng,true) . $naked_body, LOGGER_DATA);
if((! $lng) || (! (x($lng,'language')))) {
return '';
}
if($lng['confidence'] < (float) $min_confidence) {
logger('detect language: confidence less than ' . (float) $min_confidence, LOGGER_DATA);
return '';
}
return(($lng && (x($lng,'language'))) ? $detected_languages[ucfirst($lng['language'])] : '');
}

View File

@ -356,7 +356,10 @@ if($a->module != 'install') {
* Build the page - now that we have all the components
*/
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => current_theme_url()));
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'],
array('$stylesheet' => current_theme_url(),
'$theme' => current_theme()
));
$page = $a->page;
$profile = $a->profile;

2
library/jslider/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*/.DS_Store
.DS_Store

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2012 Egor Khmelev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

15
library/jslider/Makefile Normal file
View File

@ -0,0 +1,15 @@
css_compiler: js_compiler
mkdir -p bin
cat css/jslider.css css/jslider.blue.css css/jslider.plastic.css css/jslider.round.css css/jslider.round.plastic.css > bin/jquery.slider.all.css
java -jar tools/yuicompressor-2.4.7.jar --type=css bin/jquery.slider.all.css > bin/jquery.slider.min.css
rm -f bin/jquery.slider.all.css
js_compiler:
mkdir -p bin
rm -f bin/jquery.slider.all.js bin/jquery.slider.min.js
cat js/jshashtable-2.1_src.js js/jquery.numberformatter-1.2.3.js js/tmpl.js js/jquery.dependClass-0.1.js js/draggable-0.1.js js/jquery.slider.js > bin/jquery.slider.all.js
uglifyjs -nc bin/jquery.slider.all.js > bin/jquery.slider.min.js
rm -f bin/jquery.slider.all.js

View File

@ -0,0 +1,9 @@
# jQuery Slider plugin
jQuery Slider is easy to use and multifunctional jQuery plugin.
[Check out demos and documentations here](http://egorkhmelev.github.com/jslider/)
## License
(MIT License) — Copyright &copy; 2012 Egor Khmelev

View File

@ -0,0 +1 @@
.jslider .jslider-bg i,.jslider .jslider-pointer{background:url(../img/jslider.png) no-repeat 0 0}.jslider{display:block;width:100%;height:1em;position:relative;top:.6em;font-family:Arial,sans-serif}.jslider table{width:100%;border-collapse:collapse;border:0}.jslider td,.jslider th{padding:0;vertical-align:top;text-align:left;border:0}.jslider table,.jslider table tr,.jslider table tr td{width:100%;vertical-align:top}.jslider .jslider-bg{position:relative}.jslider .jslider-bg i{height:5px;position:absolute;font-size:0;top:0}.jslider .jslider-bg .l{width:50%;background-position:0 0;left:0}.jslider .jslider-bg .r{width:50%;left:50%;background-position:right 0}.jslider .jslider-bg .v{position:absolute;width:60%;left:20%;top:0;height:5px;background-position:0 -20px}.jslider .jslider-pointer{width:13px;height:15px;background-position:0 -40px;position:absolute;left:20%;top:-4px;margin-left:-6px;cursor:pointer;cursor:hand}.jslider .jslider-pointer-hover{background-position:-20px -40px}.jslider .jslider-pointer-to{left:80%}.jslider .jslider-label{font-size:9px;line-height:12px;color:black;opacity:.4;white-space:nowrap;padding:0 2px;position:absolute;top:-18px;left:0}.jslider .jslider-label-to{left:auto;right:0}.jslider .jslider-value{font-size:9px;white-space:nowrap;padding:1px 2px 0;position:absolute;top:-19px;left:20%;background:white;line-height:12px;-moz-border-radius:2px;-webkit-border-radius:2px;-o-border-radius:2px;border-radius:2px}.jslider .jslider-value-to{left:80%}.jslider .jslider-label small,.jslider .jslider-value small{position:relative;top:-0.4em}.jslider .jslider-scale{position:relative;top:9px}.jslider .jslider-scale span{position:absolute;height:5px;border-left:1px solid #999;font-size:0}.jslider .jslider-scale ins{font-size:9px;text-decoration:none;position:absolute;left:0;top:5px;color:#999}.jslider-single .jslider-pointer-to,.jslider-single .jslider-value-to,.jslider-single .jslider-bg .v,.jslider-limitless .jslider-label{display:none}.jslider_blue .jslider-bg i,.jslider_blue .jslider-pointer{background-image:url(../img/jslider.blue.png)}.jslider_plastic .jslider-bg i,.jslider_plastic .jslider-pointer{background-image:url(../img/jslider.plastic.png)}.jslider_round .jslider-bg i,.jslider_round .jslider-pointer{background-image:url(../img/jslider.round.png)}.jslider_round .jslider-pointer{width:17px;height:17px;top:-6px;margin-left:-8px}.jslider_round_plastic .jslider-bg i,.jslider_round_plastic .jslider-pointer{background-image:url(../img/jslider.round.plastic.png)}.jslider_round_plastic .jslider-pointer{width:18px;height:18px;top:-7px;margin-left:-8px}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
.jslider_blue .jslider-bg i,
.jslider_blue .jslider-pointer { background-image: url(../img/jslider.blue.png); }

View File

@ -0,0 +1,39 @@
.jslider .jslider-bg i,
.jslider .jslider-pointer { background: url(../img/jslider.png) no-repeat 0 0; }
.jslider { display: block; width: 100%; height: 1em; position: relative; top: 0.6em; font-family: Arial, sans-serif; }
.jslider table { width: 100%; border-collapse: collapse; border: 0; }
.jslider td, .jslider th { padding: 0; vertical-align: top; text-align: left; border: 0; }
.jslider table,
.jslider table tr,
.jslider table tr td { width: 100%; vertical-align: top; }
.jslider .jslider-bg { position: relative; }
.jslider .jslider-bg i { height: 5px; position: absolute; font-size: 0; top: 0; }
.jslider .jslider-bg .l { width: 50%; background-position: 0 0; left: 0; }
.jslider .jslider-bg .r { width: 50%; left: 50%; background-position: right 0; }
.jslider .jslider-bg .v { position: absolute; width: 60%; left: 20%; top: 0; height: 5px; background-position: 0 -20px; }
.jslider .jslider-pointer { width: 13px; height: 15px; background-position: 0 -40px; position: absolute; left: 20%; top: -4px; margin-left: -6px; cursor: pointer; cursor: hand; }
.jslider .jslider-pointer-hover { background-position: -20px -40px; }
.jslider .jslider-pointer-to { left: 80%; }
.jslider .jslider-label { font-size: 9px; line-height: 12px; color: black; opacity: 0.4; white-space: nowrap; padding: 0px 2px; position: absolute; top: -18px; left: 0px; }
.jslider .jslider-label-to { left: auto; right: 0; }
.jslider .jslider-value { font-size: 9px; white-space: nowrap; padding: 1px 2px 0; position: absolute; top: -19px; left: 20%; background: white; line-height: 12px; -moz-border-radius: 2px; -webkit-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; }
.jslider .jslider-value-to { left: 80%; }
.jslider .jslider-label small,
.jslider .jslider-value small { position: relative; top: -0.4em; }
.jslider .jslider-scale { position: relative; top: 9px; }
.jslider .jslider-scale span { position: absolute; height: 5px; border-left: 1px solid #999; font-size: 0; }
.jslider .jslider-scale ins { font-size: 9px; text-decoration: none; position: absolute; left: 0px; top: 5px; color: #999; }
.jslider-single .jslider-pointer-to,
.jslider-single .jslider-value-to,
.jslider-single .jslider-bg .v,
.jslider-limitless .jslider-label { display: none; }

View File

@ -0,0 +1,3 @@
.jslider_plastic .jslider-bg i,
.jslider_plastic .jslider-pointer { background-image: url(../img/jslider.plastic.png); }

View File

@ -0,0 +1,5 @@
.jslider_round .jslider-bg i,
.jslider_round .jslider-pointer { background-image: url(../img/jslider.round.png); }
.jslider_round .jslider-pointer { width: 17px; height: 17px; top: -6px; margin-left: -8px; }

View File

@ -0,0 +1,5 @@
.jslider_round_plastic .jslider-bg i,
.jslider_round_plastic .jslider-pointer { background-image: url(../img/jslider.round.plastic.png); }
.jslider_round_plastic .jslider-pointer { width: 18px; height: 18px; top: -7px; margin-left: -8px; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

152
library/jslider/index.html Normal file
View File

@ -0,0 +1,152 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>jSlider</title>
<!-- bin/jquery.slider.min.css -->
<link rel="stylesheet" href="css/jslider.css" type="text/css">
<link rel="stylesheet" href="css/jslider.blue.css" type="text/css">
<link rel="stylesheet" href="css/jslider.plastic.css" type="text/css">
<link rel="stylesheet" href="css/jslider.round.css" type="text/css">
<link rel="stylesheet" href="css/jslider.round.plastic.css" type="text/css">
<!-- end -->
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<!-- bin/jquery.slider.min.js -->
<script type="text/javascript" src="js/jshashtable-2.1_src.js"></script>
<script type="text/javascript" src="js/jquery.numberformatter-1.2.3.js"></script>
<script type="text/javascript" src="js/tmpl.js"></script>
<script type="text/javascript" src="js/jquery.dependClass-0.1.js"></script>
<script type="text/javascript" src="js/draggable-0.1.js"></script>
<script type="text/javascript" src="js/jquery.slider.js"></script>
<!-- end -->
<style type="text/css" media="screen">
body { background: #EEF0F7; }
.layout { padding: 50px; font-family: Georgia, serif; }
.layout-slider { margin-bottom: 60px; width: 50%; }
.layout-slider-settings { font-size: 12px; padding-bottom: 10px; }
.layout-slider-settings pre { font-family: Courier; }
</style>
</head>
<body>
<div class="layout">
<div class="layout-slider" style="width: 100%">
Slider <span style="display: inline-block; width: 400px; padding: 0 5px;"><input id="Slider1" type="slider" name="price" value="30000.5;60000" /></span> in string
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider1").slider({ from: 1000, to: 100000, step: 500, smooth: true, round: 0, dimension: "&nbsp;$", skin: "plastic" });
</script>
<div class="layout-slider-settings">
<pre>{
from: 5,
to: 50,
step: 2.5,
round: 1,
format: { format: '##.0', locale: 'de' },
dimension: '&amp;nbsp;€'
}</pre>
</div>
<div class="layout-slider">
<input id="SliderSingle" type="slider" name="price" value="20" />
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#SliderSingle").slider({ from: 5, to: 50, step: 2.5, round: 1, format: { format: '##.0', locale: 'de' }, dimension: '&nbsp;€', skin: "round" });
</script>
<div class="layout-slider-settings">
<pre>{
from: 5000,
to: 150000,
heterogeneity: ['50/50000'],
step: 1000,
dimension: '&amp;nbsp;$'
}</pre>
</div>
<div class="layout-slider">
<input id="Slider2" type="slider" name="price" value="5000;50000" />
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider2").slider({ from: 5000, to: 150000, heterogeneity: ['50/50000'], step: 1000, dimension: '&nbsp;$' });
</script>
<div class="layout-slider-settings">
<pre>{
from: 0,
to: 500,
heterogeneity: ['50/100', '75/250'],
scale: [0, '|', 50, '|' , '100', '|', 250, '|', 500],
limits: false,
step: 1,
dimension: '&amp;nbsp;m&lt;small&gt;2&lt;/small&gt;'
}</pre>
</div>
<div class="layout-slider">
<input id="Slider3" type="slider" name="area" value="25;75" />
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider3").slider({ from: 0, to: 500, heterogeneity: ['50/100', '75/250'], scale: [0, '|', 50, '|', '100', '|', 250, '|', 500], limits: false, step: 1, dimension: '&nbsp;m<small>2</small>', skin: "round_plastic" });
</script>
<div class="layout-slider-settings">
<pre>{
from: 1,
to: 30,
heterogeneity: ['50/5', '75/15'],
scale: [1, '|', 3, '|', '5', '|', 15, '|', 30],
limits: false,
step: 1,
dimension: '',
skin: "blue"
}</pre>
</div>
<div class="layout-slider">
<input id="Slider4" type="slider" name="area" value="2;10" />
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider4").slider({ from: 1, to: 30, heterogeneity: ['50/5', '75/15'], scale: [1, '|', 3, '|', '5', '|', 15, '|', 30], limits: false, step: 1, dimension: '', skin: "blue", callback: function( value ){ console.dir( this ); } });
</script>
<div class="layout-slider-settings">
<pre>{
from: 480,
to: 1020,
step: 15,
dimension: '',
scale: ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00'],
limits: false,
calculate: function( value ){
var hours = Math.floor( value / 60 );
var mins = ( value - hours*60 );
return (hours &lt; 10 ? "0"+hours : hours) + ":" + ( mins == 0 ? "00" : mins );
},
onstatechange: function( value ){
console.dir( this );
}
}</pre>
</div>
<div class="layout-slider">
<input id="Slider5" type="slider" name="area" value="600;720" />
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider5").slider({ from: 480, to: 1020, step: 15, dimension: '', scale: ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00'], limits: false, calculate: function( value ){
var hours = Math.floor( value / 60 );
var mins = ( value - hours*60 );
return (hours < 10 ? "0"+hours : hours) + ":" + ( mins == 0 ? "00" : mins );
}})
</script>
</div>
</body>
</html>

View File

@ -0,0 +1,196 @@
/**
* draggable - Class allows to make any element draggable
*
* Written by
* Egor Khmelev (hmelyoff@gmail.com)
*
* Licensed under the MIT (MIT-LICENSE.txt).
*
* @author Egor Khmelev
* @version 0.1.0-BETA ($Id$)
*
**/
(function( $ ){
function Draggable(){
this._init.apply( this, arguments );
};
Draggable.prototype.oninit = function(){
};
Draggable.prototype.events = function(){
};
Draggable.prototype.onmousedown = function(){
this.ptr.css({ position: "absolute" });
};
Draggable.prototype.onmousemove = function( evt, x, y ){
this.ptr.css({ left: x, top: y });
};
Draggable.prototype.onmouseup = function(){
};
Draggable.prototype.isDefault = {
drag: false,
clicked: false,
toclick: true,
mouseup: false
};
Draggable.prototype._init = function(){
if( arguments.length > 0 ){
this.ptr = $(arguments[0]);
this.outer = $(".draggable-outer");
this.is = {};
$.extend( this.is, this.isDefault );
var _offset = this.ptr.offset();
this.d = {
left: _offset.left,
top: _offset.top,
width: this.ptr.width(),
height: this.ptr.height()
};
this.oninit.apply( this, arguments );
this._events();
}
};
Draggable.prototype._getPageCoords = function( event ){
if( event.targetTouches && event.targetTouches[0] ){
return { x: event.targetTouches[0].pageX, y: event.targetTouches[0].pageY };
} else
return { x: event.pageX, y: event.pageY };
};
Draggable.prototype._bindEvent = function( ptr, eventType, handler ){
var self = this;
if( this.supportTouches_ )
ptr.get(0).addEventListener( this.events_[ eventType ], handler, false );
else
ptr.bind( this.events_[ eventType ], handler );
};
Draggable.prototype._events = function(){
var self = this;
this.supportTouches_ = ( $.browser.webkit && navigator.userAgent.indexOf("Mobile") != -1 );
this.events_ = {
"click": this.supportTouches_ ? "touchstart" : "click",
"down": this.supportTouches_ ? "touchstart" : "mousedown",
"move": this.supportTouches_ ? "touchmove" : "mousemove",
"up" : this.supportTouches_ ? "touchend" : "mouseup"
};
this._bindEvent( $( document ), "move", function( event ){
if( self.is.drag ){
event.stopPropagation();
event.preventDefault();
self._mousemove( event );
}
});
this._bindEvent( $( document ), "down", function( event ){
if( self.is.drag ){
event.stopPropagation();
event.preventDefault();
}
});
this._bindEvent( $( document ), "up", function( event ){
self._mouseup( event );
});
this._bindEvent( this.ptr, "down", function( event ){
self._mousedown( event );
return false;
});
this._bindEvent( this.ptr, "up", function( event ){
self._mouseup( event );
});
this.ptr.find("a")
.click(function(){
self.is.clicked = true;
if( !self.is.toclick ){
self.is.toclick = true;
return false;
}
})
.mousedown(function( event ){
self._mousedown( event );
return false;
});
this.events();
};
Draggable.prototype._mousedown = function( evt ){
this.is.drag = true;
this.is.clicked = false;
this.is.mouseup = false;
var _offset = this.ptr.offset();
var coords = this._getPageCoords( evt );
this.cx = coords.x - _offset.left;
this.cy = coords.y - _offset.top;
$.extend(this.d, {
left: _offset.left,
top: _offset.top,
width: this.ptr.width(),
height: this.ptr.height()
});
if( this.outer && this.outer.get(0) ){
this.outer.css({ height: Math.max(this.outer.height(), $(document.body).height()), overflow: "hidden" });
}
this.onmousedown( evt );
};
Draggable.prototype._mousemove = function( evt ){
this.is.toclick = false;
var coords = this._getPageCoords( evt );
this.onmousemove( evt, coords.x - this.cx, coords.y - this.cy );
};
Draggable.prototype._mouseup = function( evt ){
var oThis = this;
if( this.is.drag ){
this.is.drag = false;
if( this.outer && this.outer.get(0) ){
if( $.browser.mozilla ){
this.outer.css({ overflow: "hidden" });
} else {
this.outer.css({ overflow: "visible" });
}
if( $.browser.msie && $.browser.version == '6.0' ){
this.outer.css({ height: "100%" });
} else {
this.outer.css({ height: "auto" });
}
}
this.onmouseup( evt );
}
};
window.Draggable = Draggable;
})( jQuery );

9266
library/jslider/js/jquery-1.7.1.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,56 @@
/**
* jquery.dependClass - Attach class based on first class in list of current element
*
* Written by
* Egor Khmelev (hmelyoff@gmail.com)
*
* Licensed under the MIT (MIT-LICENSE.txt).
*
* @author Egor Khmelev
* @version 0.1.0-BETA ($Id$)
*
**/
(function($) {
$.baseClass = function(obj){
obj = $(obj);
return obj.get(0).className.match(/([^ ]+)/)[1];
};
$.fn.addDependClass = function(className, delimiter){
var options = {
delimiter: delimiter ? delimiter : '-'
}
return this.each(function(){
var baseClass = $.baseClass(this);
if(baseClass)
$(this).addClass(baseClass + options.delimiter + className);
});
};
$.fn.removeDependClass = function(className, delimiter){
var options = {
delimiter: delimiter ? delimiter : '-'
}
return this.each(function(){
var baseClass = $.baseClass(this);
if(baseClass)
$(this).removeClass(baseClass + options.delimiter + className);
});
};
$.fn.toggleDependClass = function(className, delimiter){
var options = {
delimiter: delimiter ? delimiter : '-'
}
return this.each(function(){
var baseClass = $.baseClass(this);
if(baseClass)
if($(this).is("." + baseClass + options.delimiter + className))
$(this).removeClass(baseClass + options.delimiter + className);
else
$(this).addClass(baseClass + options.delimiter + className);
});
};
})(jQuery);

View File

@ -0,0 +1,510 @@
/**
* jquery.numberformatter - Formatting/Parsing Numbers in jQuery
*
* Written by
* Michael Abernethy (mike@abernethysoft.com),
* Andrew Parry (aparry0@gmail.com)
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* @author Michael Abernethy, Andrew Parry
* @version 1.2.3-SNAPSHOT ($Id$)
*
* Dependencies
*
* jQuery (http://jquery.com)
* jshashtable (http://www.timdown.co.uk/jshashtable)
*
* Notes & Thanks
*
* many thanks to advweb.nanasi.jp for his bug fixes
* jsHashtable is now used also, so thanks to the author for that excellent little class.
*
* This plugin can be used to format numbers as text and parse text as Numbers
* Because we live in an international world, we cannot assume that everyone
* uses "," to divide thousands, and "." as a decimal point.
*
* As of 1.2 the way this plugin works has changed slightly, parsing text to a number
* has 1 set of functions, formatting a number to text has it's own. Before things
* were a little confusing, so I wanted to separate the 2 out more.
*
*
* jQuery extension functions:
*
* formatNumber(options, writeBack, giveReturnValue) - Reads the value from the subject, parses to
* a Javascript Number object, then formats back to text using the passed options and write back to
* the subject.
*
* parseNumber(options) - Parses the value in the subject to a Number object using the passed options
* to decipher the actual number from the text, then writes the value as text back to the subject.
*
*
* Generic functions:
*
* formatNumber(numberString, options) - Takes a plain number as a string (e.g. '1002.0123') and returns
* a string of the given format options.
*
* parseNumber(numberString, options) - Takes a number as text that is formatted the same as the given
* options then and returns it as a plain Number object.
*
* To achieve the old way of combining parsing and formatting to keep say a input field always formatted
* to a given format after it has lost focus you'd simply use a combination of the functions.
*
* e.g.
* $("#salary").blur(function(){
* $(this).parseNumber({format:"#,###.00", locale:"us"});
* $(this).formatNumber({format:"#,###.00", locale:"us"});
* });
*
* The syntax for the formatting is:
* 0 = Digit
* # = Digit, zero shows as absent
* . = Decimal separator
* - = Negative sign
* , = Grouping Separator
* % = Percent (multiplies the number by 100)
*
* For example, a format of "#,###.00" and text of 4500.20 will
* display as "4.500,20" with a locale of "de", and "4,500.20" with a locale of "us"
*
*
* As of now, the only acceptable locales are
* Arab Emirates -> "ae"
* Australia -> "au"
* Austria -> "at"
* Brazil -> "br"
* Canada -> "ca"
* China -> "cn"
* Czech -> "cz"
* Denmark -> "dk"
* Egypt -> "eg"
* Finland -> "fi"
* France -> "fr"
* Germany -> "de"
* Greece -> "gr"
* Great Britain -> "gb"
* Hong Kong -> "hk"
* India -> "in"
* Israel -> "il"
* Japan -> "jp"
* Russia -> "ru"
* South Korea -> "kr"
* Spain -> "es"
* Sweden -> "se"
* Switzerland -> "ch"
* Taiwan -> "tw"
* Thailand -> "th"
* United States -> "us"
* Vietnam -> "vn"
**/
(function(jQuery) {
var nfLocales = new Hashtable();
var nfLocalesLikeUS = [ 'ae','au','ca','cn','eg','gb','hk','il','in','jp','sk','th','tw','us' ];
var nfLocalesLikeDE = [ 'at','br','de','dk','es','gr','it','nl','pt','tr','vn' ];
var nfLocalesLikeFR = [ 'cz','fi','fr','ru','se','pl' ];
var nfLocalesLikeCH = [ 'ch' ];
var nfLocaleFormatting = [ [".", ","], [",", "."], [",", " "], [".", "'"] ];
var nfAllLocales = [ nfLocalesLikeUS, nfLocalesLikeDE, nfLocalesLikeFR, nfLocalesLikeCH ]
function FormatData(dec, group, neg) {
this.dec = dec;
this.group = group;
this.neg = neg;
};
function init() {
// write the arrays into the hashtable
for (var localeGroupIdx = 0; localeGroupIdx < nfAllLocales.length; localeGroupIdx++) {
localeGroup = nfAllLocales[localeGroupIdx];
for (var i = 0; i < localeGroup.length; i++) {
nfLocales.put(localeGroup[i], localeGroupIdx);
}
}
};
function formatCodes(locale, isFullLocale) {
if (nfLocales.size() == 0)
init();
// default values
var dec = ".";
var group = ",";
var neg = "-";
if (isFullLocale == false) {
// Extract and convert to lower-case any language code from a real 'locale' formatted string, if not use as-is
// (To prevent locale format like : "fr_FR", "en_US", "de_DE", "fr_FR", "en-US", "de-DE")
if (locale.indexOf('_') != -1)
locale = locale.split('_')[1].toLowerCase();
else if (locale.indexOf('-') != -1)
locale = locale.split('-')[1].toLowerCase();
}
// hashtable lookup to match locale with codes
var codesIndex = nfLocales.get(locale);
if (codesIndex) {
var codes = nfLocaleFormatting[codesIndex];
if (codes) {
dec = codes[0];
group = codes[1];
}
}
return new FormatData(dec, group, neg);
};
/* Formatting Methods */
/**
* Formats anything containing a number in standard js number notation.
*
* @param {Object} options The formatting options to use
* @param {Boolean} writeBack (true) If the output value should be written back to the subject
* @param {Boolean} giveReturnValue (true) If the function should return the output string
*/
jQuery.fn.formatNumber = function(options, writeBack, giveReturnValue) {
return this.each(function() {
// enforce defaults
if (writeBack == null)
writeBack = true;
if (giveReturnValue == null)
giveReturnValue = true;
// get text
var text;
if (jQuery(this).is(":input"))
text = new String(jQuery(this).val());
else
text = new String(jQuery(this).text());
// format
var returnString = jQuery.formatNumber(text, options);
// set formatted string back, only if a success
// if (returnString) {
if (writeBack) {
if (jQuery(this).is(":input"))
jQuery(this).val(returnString);
else
jQuery(this).text(returnString);
}
if (giveReturnValue)
return returnString;
// }
// return '';
});
};
/**
* First parses a string and reformats it with the given options.
*
* @param {Object} numberString
* @param {Object} options
*/
jQuery.formatNumber = function(numberString, options){
var options = jQuery.extend({}, jQuery.fn.formatNumber.defaults, options);
var formatData = formatCodes(options.locale.toLowerCase(), options.isFullLocale);
var dec = formatData.dec;
var group = formatData.group;
var neg = formatData.neg;
var validFormat = "0#-,.";
// strip all the invalid characters at the beginning and the end
// of the format, and we'll stick them back on at the end
// make a special case for the negative sign "-" though, so
// we can have formats like -$23.32
var prefix = "";
var negativeInFront = false;
for (var i = 0; i < options.format.length; i++) {
if (validFormat.indexOf(options.format.charAt(i)) == -1)
prefix = prefix + options.format.charAt(i);
else
if (i == 0 && options.format.charAt(i) == '-') {
negativeInFront = true;
continue;
}
else
break;
}
var suffix = "";
for (var i = options.format.length - 1; i >= 0; i--) {
if (validFormat.indexOf(options.format.charAt(i)) == -1)
suffix = options.format.charAt(i) + suffix;
else
break;
}
options.format = options.format.substring(prefix.length);
options.format = options.format.substring(0, options.format.length - suffix.length);
// now we need to convert it into a number
//while (numberString.indexOf(group) > -1)
// numberString = numberString.replace(group, '');
//var number = new Number(numberString.replace(dec, ".").replace(neg, "-"));
var number = new Number(numberString);
return jQuery._formatNumber(number, options, suffix, prefix, negativeInFront);
};
/**
* Formats a Number object into a string, using the given formatting options
*
* @param {Object} numberString
* @param {Object} options
*/
jQuery._formatNumber = function(number, options, suffix, prefix, negativeInFront) {
var options = jQuery.extend({}, jQuery.fn.formatNumber.defaults, options);
var formatData = formatCodes(options.locale.toLowerCase(), options.isFullLocale);
var dec = formatData.dec;
var group = formatData.group;
var neg = formatData.neg;
var forcedToZero = false;
if (isNaN(number)) {
if (options.nanForceZero == true) {
number = 0;
forcedToZero = true;
} else
return null;
}
// special case for percentages
if (suffix == "%")
number = number * 100;
var returnString = "";
if (options.format.indexOf(".") > -1) {
var decimalPortion = dec;
var decimalFormat = options.format.substring(options.format.lastIndexOf(".") + 1);
// round or truncate number as needed
if (options.round == true)
number = new Number(number.toFixed(decimalFormat.length));
else {
var numStr = number.toString();
numStr = numStr.substring(0, numStr.lastIndexOf('.') + decimalFormat.length + 1);
number = new Number(numStr);
}
var decimalValue = number % 1;
var decimalString = new String(decimalValue.toFixed(decimalFormat.length));
decimalString = decimalString.substring(decimalString.lastIndexOf(".") + 1);
for (var i = 0; i < decimalFormat.length; i++) {
if (decimalFormat.charAt(i) == '#' && decimalString.charAt(i) != '0') {
decimalPortion += decimalString.charAt(i);
continue;
} else if (decimalFormat.charAt(i) == '#' && decimalString.charAt(i) == '0') {
var notParsed = decimalString.substring(i);
if (notParsed.match('[1-9]')) {
decimalPortion += decimalString.charAt(i);
continue;
} else
break;
} else if (decimalFormat.charAt(i) == "0")
decimalPortion += decimalString.charAt(i);
}
returnString += decimalPortion
} else
number = Math.round(number);
var ones = Math.floor(number);
if (number < 0)
ones = Math.ceil(number);
var onesFormat = "";
if (options.format.indexOf(".") == -1)
onesFormat = options.format;
else
onesFormat = options.format.substring(0, options.format.indexOf("."));
var onePortion = "";
if (!(ones == 0 && onesFormat.substr(onesFormat.length - 1) == '#') || forcedToZero) {
// find how many digits are in the group
var oneText = new String(Math.abs(ones));
var groupLength = 9999;
if (onesFormat.lastIndexOf(",") != -1)
groupLength = onesFormat.length - onesFormat.lastIndexOf(",") - 1;
var groupCount = 0;
for (var i = oneText.length - 1; i > -1; i--) {
onePortion = oneText.charAt(i) + onePortion;
groupCount++;
if (groupCount == groupLength && i != 0) {
onePortion = group + onePortion;
groupCount = 0;
}
}
// account for any pre-data padding
if (onesFormat.length > onePortion.length) {
var padStart = onesFormat.indexOf('0');
if (padStart != -1) {
var padLen = onesFormat.length - padStart;
// pad to left with 0's or group char
var pos = onesFormat.length - onePortion.length - 1;
while (onePortion.length < padLen) {
var padChar = onesFormat.charAt(pos);
// replace with real group char if needed
if (padChar == ',')
padChar = group;
onePortion = padChar + onePortion;
pos--;
}
}
}
}
if (!onePortion && onesFormat.indexOf('0', onesFormat.length - 1) !== -1)
onePortion = '0';
returnString = onePortion + returnString;
// handle special case where negative is in front of the invalid characters
if (number < 0 && negativeInFront && prefix.length > 0)
prefix = neg + prefix;
else if (number < 0)
returnString = neg + returnString;
if (!options.decimalSeparatorAlwaysShown) {
if (returnString.lastIndexOf(dec) == returnString.length - 1) {
returnString = returnString.substring(0, returnString.length - 1);
}
}
returnString = prefix + returnString + suffix;
return returnString;
};
/* Parsing Methods */
/**
* Parses a number of given format from the element and returns a Number object.
* @param {Object} options
*/
jQuery.fn.parseNumber = function(options, writeBack, giveReturnValue) {
// enforce defaults
if (writeBack == null)
writeBack = true;
if (giveReturnValue == null)
giveReturnValue = true;
// get text
var text;
if (jQuery(this).is(":input"))
text = new String(jQuery(this).val());
else
text = new String(jQuery(this).text());
// parse text
var number = jQuery.parseNumber(text, options);
if (number) {
if (writeBack) {
if (jQuery(this).is(":input"))
jQuery(this).val(number.toString());
else
jQuery(this).text(number.toString());
}
if (giveReturnValue)
return number;
}
};
/**
* Parses a string of given format into a Number object.
*
* @param {Object} string
* @param {Object} options
*/
jQuery.parseNumber = function(numberString, options) {
var options = jQuery.extend({}, jQuery.fn.parseNumber.defaults, options);
var formatData = formatCodes(options.locale.toLowerCase(), options.isFullLocale);
var dec = formatData.dec;
var group = formatData.group;
var neg = formatData.neg;
var valid = "1234567890.-";
// now we need to convert it into a number
while (numberString.indexOf(group)>-1)
numberString = numberString.replace(group,'');
numberString = numberString.replace(dec,".").replace(neg,"-");
var validText = "";
var hasPercent = false;
if (numberString.charAt(numberString.length - 1) == "%" || options.isPercentage == true)
hasPercent = true;
for (var i=0; i<numberString.length; i++) {
if (valid.indexOf(numberString.charAt(i))>-1)
validText = validText + numberString.charAt(i);
}
var number = new Number(validText);
if (hasPercent) {
number = number / 100;
var decimalPos = validText.indexOf('.');
if (decimalPos != -1) {
var decimalPoints = validText.length - decimalPos - 1;
number = number.toFixed(decimalPoints + 2);
} else {
number = number.toFixed(validText.length - 1);
}
}
return number;
};
jQuery.fn.parseNumber.defaults = {
locale: "us",
decimalSeparatorAlwaysShown: false,
isPercentage: false,
isFullLocale: false
};
jQuery.fn.formatNumber.defaults = {
format: "#,###.00",
locale: "us",
decimalSeparatorAlwaysShown: false,
nanForceZero: true,
round: true,
isFullLocale: false
};
Number.prototype.toFixed = function(precision) {
return jQuery._roundNumber(this, precision);
};
jQuery._roundNumber = function(number, decimalPlaces) {
var power = Math.pow(10, decimalPlaces || 0);
var value = String(Math.round(number * power) / power);
// ensure the decimal places are there
if (decimalPlaces > 0) {
var dp = value.indexOf(".");
if (dp == -1) {
value += '.';
dp = 0;
} else {
dp = value.length - (dp + 1);
}
while (dp < decimalPlaces) {
value += '0';
dp++;
}
}
return value;
};
})(jQuery);

View File

@ -0,0 +1,700 @@
/**
* jquery.slider - Slider ui control in jQuery
*
* Written by
* Egor Khmelev (hmelyoff@gmail.com)
*
* Licensed under the MIT (MIT-LICENSE.txt).
*
* @author Egor Khmelev
* @version 1.1.0-RELEASE ($Id$)
*
* Dependencies
*
* jQuery (http://jquery.com)
* jquery.numberformatter (http://code.google.com/p/jquery-numberformatter/)
* tmpl (http://ejohn.org/blog/javascript-micro-templating/)
* jquery.dependClass
* draggable
*
**/
(function( $ ) {
function isArray( value ){
if( typeof value == "undefined" ) return false;
if (value instanceof Array || (!(value instanceof Object) &&
(Object.prototype.toString.call((value)) == '[object Array]') ||
typeof value.length == 'number' &&
typeof value.splice != 'undefined' &&
typeof value.propertyIsEnumerable != 'undefined' &&
!value.propertyIsEnumerable('splice')
)) {
return true;
}
return false;
}
$.slider = function( node, settings ){
var jNode = $(node);
if( !jNode.data( "jslider" ) )
jNode.data( "jslider", new jSlider( node, settings ) );
return jNode.data( "jslider" );
};
$.fn.slider = function( action, opt_value ){
var returnValue, args = arguments;
function isDef( val ){
return val !== undefined;
};
function isDefAndNotNull( val ){
return val != null;
};
this.each(function(){
var self = $.slider( this, action );
// do actions
if( typeof action == "string" ){
switch( action ){
case "value":
if( isDef( args[ 1 ] ) && isDef( args[ 2 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0].set( args[ 1 ] );
pointers[0].setIndexOver();
}
if( isDefAndNotNull( pointers[1] ) && isDefAndNotNull( args[2] ) ){
pointers[1].set( args[ 2 ] );
pointers[1].setIndexOver();
}
}
else if( isDef( args[ 1 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0].set( args[ 1 ] );
pointers[0].setIndexOver();
}
}
else
returnValue = self.getValue();
break;
case "prc":
if( isDef( args[ 1 ] ) && isDef( args[ 2 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0]._set( args[ 1 ] );
pointers[0].setIndexOver();
}
if( isDefAndNotNull( pointers[1] ) && isDefAndNotNull( args[2] ) ){
pointers[1]._set( args[ 2 ] );
pointers[1].setIndexOver();
}
}
else if( isDef( args[ 1 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0]._set( args[ 1 ] );
pointers[0].setIndexOver();
}
}
else
returnValue = self.getPrcValue();
break;
case "calculatedValue":
var value = self.getValue().split(";");
returnValue = "";
for (var i=0; i < value.length; i++) {
returnValue += (i > 0 ? ";" : "") + self.nice( value[i] );
};
break;
case "skin":
self.setSkin( args[1] );
break;
};
}
// return actual object
else if( !action && !opt_value ){
if( !isArray( returnValue ) )
returnValue = [];
returnValue.push( self );
}
});
// flatten array just with one slider
if( isArray( returnValue ) && returnValue.length == 1 )
returnValue = returnValue[ 0 ];
return returnValue || this;
};
var OPTIONS = {
settings: {
from: 1,
to: 10,
step: 1,
smooth: true,
limits: true,
round: 0,
format: { format: "#,##0.##" },
value: "5;7",
dimension: ""
},
className: "jslider",
selector: ".jslider-",
template: tmpl(
'<span class="<%=className%>">' +
'<table><tr><td>' +
'<div class="<%=className%>-bg">' +
'<i class="l"></i><i class="r"></i>' +
'<i class="v"></i>' +
'</div>' +
'<div class="<%=className%>-pointer"></div>' +
'<div class="<%=className%>-pointer <%=className%>-pointer-to"></div>' +
'<div class="<%=className%>-label"><span><%=settings.from%></span></div>' +
'<div class="<%=className%>-label <%=className%>-label-to"><span><%=settings.to%></span><%=settings.dimension%></div>' +
'<div class="<%=className%>-value"><span></span><%=settings.dimension%></div>' +
'<div class="<%=className%>-value <%=className%>-value-to"><span></span><%=settings.dimension%></div>' +
'<div class="<%=className%>-scale"><%=scale%></div>'+
'</td></tr></table>' +
'</span>'
)
};
function jSlider(){
return this.init.apply( this, arguments );
};
jSlider.prototype.init = function( node, settings ){
this.settings = $.extend(true, {}, OPTIONS.settings, settings ? settings : {});
// obj.sliderHandler = this;
this.inputNode = $( node ).hide();
this.settings.interval = this.settings.to-this.settings.from;
this.settings.value = this.inputNode.attr("value");
if( this.settings.calculate && $.isFunction( this.settings.calculate ) )
this.nice = this.settings.calculate;
if( this.settings.onstatechange && $.isFunction( this.settings.onstatechange ) )
this.onstatechange = this.settings.onstatechange;
this.is = {
init: false
};
this.o = {};
this.create();
};
jSlider.prototype.onstatechange = function(){
};
jSlider.prototype.create = function(){
var $this = this;
this.domNode = $( OPTIONS.template({
className: OPTIONS.className,
settings: {
from: this.nice( this.settings.from ),
to: this.nice( this.settings.to ),
dimension: this.settings.dimension
},
scale: this.generateScale()
}) );
this.inputNode.after( this.domNode );
this.drawScale();
// set skin class
if( this.settings.skin && this.settings.skin.length > 0 )
this.setSkin( this.settings.skin );
this.sizes = {
domWidth: this.domNode.width(),
domOffset: this.domNode.offset()
};
// find some objects
$.extend(this.o, {
pointers: {},
labels: {
0: {
o: this.domNode.find(OPTIONS.selector + "value").not(OPTIONS.selector + "value-to")
},
1: {
o: this.domNode.find(OPTIONS.selector + "value").filter(OPTIONS.selector + "value-to")
}
},
limits: {
0: this.domNode.find(OPTIONS.selector + "label").not(OPTIONS.selector + "label-to"),
1: this.domNode.find(OPTIONS.selector + "label").filter(OPTIONS.selector + "label-to")
}
});
$.extend(this.o.labels[0], {
value: this.o.labels[0].o.find("span")
});
$.extend(this.o.labels[1], {
value: this.o.labels[1].o.find("span")
});
if( !$this.settings.value.split(";")[1] ){
this.settings.single = true;
this.domNode.addDependClass("single");
}
if( !$this.settings.limits )
this.domNode.addDependClass("limitless");
this.domNode.find(OPTIONS.selector + "pointer").each(function( i ){
var value = $this.settings.value.split(";")[i];
if( value ){
$this.o.pointers[i] = new jSliderPointer( this, i, $this );
var prev = $this.settings.value.split(";")[i-1];
if( prev && new Number(value) < new Number(prev) ) value = prev;
value = value < $this.settings.from ? $this.settings.from : value;
value = value > $this.settings.to ? $this.settings.to : value;
$this.o.pointers[i].set( value, true );
}
});
this.o.value = this.domNode.find(".v");
this.is.init = true;
$.each(this.o.pointers, function(i){
$this.redraw(this);
});
(function(self){
$(window).resize(function(){
self.onresize();
});
})(this);
};
jSlider.prototype.setSkin = function( skin ){
if( this.skin_ )
this.domNode.removeDependClass( this.skin_, "_" );
this.domNode.addDependClass( this.skin_ = skin, "_" );
};
jSlider.prototype.setPointersIndex = function( i ){
$.each(this.getPointers(), function(i){
this.index( i );
});
};
jSlider.prototype.getPointers = function(){
return this.o.pointers;
};
jSlider.prototype.generateScale = function(){
if( this.settings.scale && this.settings.scale.length > 0 ){
var str = "";
var s = this.settings.scale;
var prc = Math.round((100/(s.length-1))*10)/10;
for( var i=0; i < s.length; i++ ){
str += '<span style="left: ' + i*prc + '%">' + ( s[i] != '|' ? '<ins>' + s[i] + '</ins>' : '' ) + '</span>';
};
return str;
} else return "";
return "";
};
jSlider.prototype.drawScale = function(){
this.domNode.find(OPTIONS.selector + "scale span ins").each(function(){
$(this).css({ marginLeft: -$(this).outerWidth()/2 });
});
};
jSlider.prototype.onresize = function(){
var self = this;
this.sizes = {
domWidth: this.domNode.width(),
domOffset: this.domNode.offset()
};
$.each(this.o.pointers, function(i){
self.redraw(this);
});
};
jSlider.prototype.update = function(){
this.onresize();
this.drawScale();
};
jSlider.prototype.limits = function( x, pointer ){
// smooth
if( !this.settings.smooth ){
var step = this.settings.step*100 / ( this.settings.interval );
x = Math.round( x/step ) * step;
}
var another = this.o.pointers[1-pointer.uid];
if( another && pointer.uid && x < another.value.prc ) x = another.value.prc;
if( another && !pointer.uid && x > another.value.prc ) x = another.value.prc;
// base limit
if( x < 0 ) x = 0;
if( x > 100 ) x = 100;
return Math.round( x*10 ) / 10;
};
jSlider.prototype.redraw = function( pointer ){
if( !this.is.init ) return false;
this.setValue();
// redraw range line
if( this.o.pointers[0] && this.o.pointers[1] )
this.o.value.css({ left: this.o.pointers[0].value.prc + "%", width: ( this.o.pointers[1].value.prc - this.o.pointers[0].value.prc ) + "%" });
this.o.labels[pointer.uid].value.html(
this.nice(
pointer.value.origin
)
);
// redraw position of labels
this.redrawLabels( pointer );
};
jSlider.prototype.redrawLabels = function( pointer ){
function setPosition( label, sizes, prc ){
sizes.margin = -sizes.label/2;
// left limit
label_left = sizes.border + sizes.margin;
if( label_left < 0 )
sizes.margin -= label_left;
// right limit
if( sizes.border+sizes.label / 2 > self.sizes.domWidth ){
sizes.margin = 0;
sizes.right = true;
} else
sizes.right = false;
label.o.css({ left: prc + "%", marginLeft: sizes.margin, right: "auto" });
if( sizes.right ) label.o.css({ left: "auto", right: 0 });
return sizes;
}
var self = this;
var label = this.o.labels[pointer.uid];
var prc = pointer.value.prc;
var sizes = {
label: label.o.outerWidth(),
right: false,
border: ( prc * this.sizes.domWidth ) / 100
};
if( !this.settings.single ){
// glue if near;
var another = this.o.pointers[1-pointer.uid];
var another_label = this.o.labels[another.uid];
switch( pointer.uid ){
case 0:
if( sizes.border+sizes.label / 2 > another_label.o.offset().left-this.sizes.domOffset.left ){
another_label.o.css({ visibility: "hidden" });
another_label.value.html( this.nice( another.value.origin ) );
label.o.css({ visibility: "visible" });
prc = ( another.value.prc - prc ) / 2 + prc;
if( another.value.prc != pointer.value.prc ){
label.value.html( this.nice(pointer.value.origin) + "&nbsp;&ndash;&nbsp;" + this.nice(another.value.origin) );
sizes.label = label.o.outerWidth();
sizes.border = ( prc * this.sizes.domWidth ) / 100;
}
} else {
another_label.o.css({ visibility: "visible" });
}
break;
case 1:
if( sizes.border - sizes.label / 2 < another_label.o.offset().left - this.sizes.domOffset.left + another_label.o.outerWidth() ){
another_label.o.css({ visibility: "hidden" });
another_label.value.html( this.nice(another.value.origin) );
label.o.css({ visibility: "visible" });
prc = ( prc - another.value.prc ) / 2 + another.value.prc;
if( another.value.prc != pointer.value.prc ){
label.value.html( this.nice(another.value.origin) + "&nbsp;&ndash;&nbsp;" + this.nice(pointer.value.origin) );
sizes.label = label.o.outerWidth();
sizes.border = ( prc * this.sizes.domWidth ) / 100;
}
} else {
another_label.o.css({ visibility: "visible" });
}
break;
}
}
sizes = setPosition( label, sizes, prc );
/* draw second label */
if( another_label ){
var sizes = {
label: another_label.o.outerWidth(),
right: false,
border: ( another.value.prc * this.sizes.domWidth ) / 100
};
sizes = setPosition( another_label, sizes, another.value.prc );
}
this.redrawLimits();
};
jSlider.prototype.redrawLimits = function(){
if( this.settings.limits ){
var limits = [ true, true ];
for( key in this.o.pointers ){
if( !this.settings.single || key == 0 ){
var pointer = this.o.pointers[key];
var label = this.o.labels[pointer.uid];
var label_left = label.o.offset().left - this.sizes.domOffset.left;
var limit = this.o.limits[0];
if( label_left < limit.outerWidth() )
limits[0] = false;
var limit = this.o.limits[1];
if( label_left + label.o.outerWidth() > this.sizes.domWidth - limit.outerWidth() )
limits[1] = false;
}
};
for( var i=0; i < limits.length; i++ ){
if( limits[i] )
this.o.limits[i].fadeIn("fast");
else
this.o.limits[i].fadeOut("fast");
};
}
};
jSlider.prototype.setValue = function(){
var value = this.getValue();
this.inputNode.attr( "value", value );
this.onstatechange.call( this, value );
};
jSlider.prototype.getValue = function(){
if(!this.is.init) return false;
var $this = this;
var value = "";
$.each( this.o.pointers, function(i){
if( this.value.prc != undefined && !isNaN(this.value.prc) ) value += (i > 0 ? ";" : "") + $this.prcToValue( this.value.prc );
});
return value;
};
jSlider.prototype.getPrcValue = function(){
if(!this.is.init) return false;
var $this = this;
var value = "";
$.each( this.o.pointers, function(i){
if( this.value.prc != undefined && !isNaN(this.value.prc) ) value += (i > 0 ? ";" : "") + this.value.prc;
});
return value;
};
jSlider.prototype.prcToValue = function( prc ){
if( this.settings.heterogeneity && this.settings.heterogeneity.length > 0 ){
var h = this.settings.heterogeneity;
var _start = 0;
var _from = this.settings.from;
for( var i=0; i <= h.length; i++ ){
if( h[i] ) var v = h[i].split("/");
else var v = [100, this.settings.to];
v[0] = new Number(v[0]);
v[1] = new Number(v[1]);
if( prc >= _start && prc <= v[0] ) {
var value = _from + ( (prc-_start) * (v[1]-_from) ) / (v[0]-_start);
}
_start = v[0];
_from = v[1];
};
} else {
var value = this.settings.from + ( prc * this.settings.interval ) / 100;
}
return this.round( value );
};
jSlider.prototype.valueToPrc = function( value, pointer ){
if( this.settings.heterogeneity && this.settings.heterogeneity.length > 0 ){
var h = this.settings.heterogeneity;
var _start = 0;
var _from = this.settings.from;
for (var i=0; i <= h.length; i++) {
if(h[i]) var v = h[i].split("/");
else var v = [100, this.settings.to];
v[0] = new Number(v[0]); v[1] = new Number(v[1]);
if(value >= _from && value <= v[1]){
var prc = pointer.limits(_start + (value-_from)*(v[0]-_start)/(v[1]-_from));
}
_start = v[0]; _from = v[1];
};
} else {
var prc = pointer.limits((value-this.settings.from)*100/this.settings.interval);
}
return prc;
};
jSlider.prototype.round = function( value ){
value = Math.round( value / this.settings.step ) * this.settings.step;
if( this.settings.round ) value = Math.round( value * Math.pow(10, this.settings.round) ) / Math.pow(10, this.settings.round);
else value = Math.round( value );
return value;
};
jSlider.prototype.nice = function( value ){
value = value.toString().replace(/,/gi, ".").replace(/ /gi, "");;
if( $.formatNumber ){
return $.formatNumber( new Number(value), this.settings.format || {} ).replace( /-/gi, "&minus;" );
}
else {
return new Number(value);
}
};
function jSliderPointer(){
Draggable.apply( this, arguments );
}
jSliderPointer.prototype = new Draggable();
jSliderPointer.prototype.oninit = function( ptr, id, _constructor ){
this.uid = id;
this.parent = _constructor;
this.value = {};
this.settings = this.parent.settings;
};
jSliderPointer.prototype.onmousedown = function(evt){
this._parent = {
offset: this.parent.domNode.offset(),
width: this.parent.domNode.width()
};
this.ptr.addDependClass("hover");
this.setIndexOver();
};
jSliderPointer.prototype.onmousemove = function( evt, x ){
var coords = this._getPageCoords( evt );
this._set( this.calc( coords.x ) );
};
jSliderPointer.prototype.onmouseup = function( evt ){
if( this.parent.settings.callback && $.isFunction(this.parent.settings.callback) )
this.parent.settings.callback.call( this.parent, this.parent.getValue() );
this.ptr.removeDependClass("hover");
};
jSliderPointer.prototype.setIndexOver = function(){
this.parent.setPointersIndex( 1 );
this.index( 2 );
};
jSliderPointer.prototype.index = function( i ){
this.ptr.css({ zIndex: i });
};
jSliderPointer.prototype.limits = function( x ){
return this.parent.limits( x, this );
};
jSliderPointer.prototype.calc = function(coords){
var x = this.limits(((coords-this._parent.offset.left)*100)/this._parent.width);
return x;
};
jSliderPointer.prototype.set = function( value, opt_origin ){
this.value.origin = this.parent.round(value);
this._set( this.parent.valueToPrc( value, this ), opt_origin );
};
jSliderPointer.prototype._set = function( prc, opt_origin ){
if( !opt_origin )
this.value.origin = this.parent.prcToValue(prc);
this.value.prc = prc;
this.ptr.css({ left: prc + "%" });
this.parent.redraw(this);
};
})(jQuery);

View File

@ -0,0 +1,370 @@
/**
* Copyright 2010 Tim Down.
*
* 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.
*/
/**
* jshashtable
*
* jshashtable is a JavaScript implementation of a hash table. It creates a single constructor function called Hashtable
* in the global scope.
*
* Author: Tim Down <tim@timdown.co.uk>
* Version: 2.1
* Build date: 21 March 2010
* Website: http://www.timdown.co.uk/jshashtable
*/
var Hashtable = (function() {
var FUNCTION = "function";
var arrayRemoveAt = (typeof Array.prototype.splice == FUNCTION) ?
function(arr, idx) {
arr.splice(idx, 1);
} :
function(arr, idx) {
var itemsAfterDeleted, i, len;
if (idx === arr.length - 1) {
arr.length = idx;
} else {
itemsAfterDeleted = arr.slice(idx + 1);
arr.length = idx;
for (i = 0, len = itemsAfterDeleted.length; i < len; ++i) {
arr[idx + i] = itemsAfterDeleted[i];
}
}
};
function hashObject(obj) {
var hashCode;
if (typeof obj == "string") {
return obj;
} else if (typeof obj.hashCode == FUNCTION) {
// Check the hashCode method really has returned a string
hashCode = obj.hashCode();
return (typeof hashCode == "string") ? hashCode : hashObject(hashCode);
} else if (typeof obj.toString == FUNCTION) {
return obj.toString();
} else {
try {
return String(obj);
} catch (ex) {
// For host objects (such as ActiveObjects in IE) that have no toString() method and throw an error when
// passed to String()
return Object.prototype.toString.call(obj);
}
}
}
function equals_fixedValueHasEquals(fixedValue, variableValue) {
return fixedValue.equals(variableValue);
}
function equals_fixedValueNoEquals(fixedValue, variableValue) {
return (typeof variableValue.equals == FUNCTION) ?
variableValue.equals(fixedValue) : (fixedValue === variableValue);
}
function createKeyValCheck(kvStr) {
return function(kv) {
if (kv === null) {
throw new Error("null is not a valid " + kvStr);
} else if (typeof kv == "undefined") {
throw new Error(kvStr + " must not be undefined");
}
};
}
var checkKey = createKeyValCheck("key"), checkValue = createKeyValCheck("value");
/*----------------------------------------------------------------------------------------------------------------*/
function Bucket(hash, firstKey, firstValue, equalityFunction) {
this[0] = hash;
this.entries = [];
this.addEntry(firstKey, firstValue);
if (equalityFunction !== null) {
this.getEqualityFunction = function() {
return equalityFunction;
};
}
}
var EXISTENCE = 0, ENTRY = 1, ENTRY_INDEX_AND_VALUE = 2;
function createBucketSearcher(mode) {
return function(key) {
var i = this.entries.length, entry, equals = this.getEqualityFunction(key);
while (i--) {
entry = this.entries[i];
if ( equals(key, entry[0]) ) {
switch (mode) {
case EXISTENCE:
return true;
case ENTRY:
return entry;
case ENTRY_INDEX_AND_VALUE:
return [ i, entry[1] ];
}
}
}
return false;
};
}
function createBucketLister(entryProperty) {
return function(aggregatedArr) {
var startIndex = aggregatedArr.length;
for (var i = 0, len = this.entries.length; i < len; ++i) {
aggregatedArr[startIndex + i] = this.entries[i][entryProperty];
}
};
}
Bucket.prototype = {
getEqualityFunction: function(searchValue) {
return (typeof searchValue.equals == FUNCTION) ? equals_fixedValueHasEquals : equals_fixedValueNoEquals;
},
getEntryForKey: createBucketSearcher(ENTRY),
getEntryAndIndexForKey: createBucketSearcher(ENTRY_INDEX_AND_VALUE),
removeEntryForKey: function(key) {
var result = this.getEntryAndIndexForKey(key);
if (result) {
arrayRemoveAt(this.entries, result[0]);
return result[1];
}
return null;
},
addEntry: function(key, value) {
this.entries[this.entries.length] = [key, value];
},
keys: createBucketLister(0),
values: createBucketLister(1),
getEntries: function(entries) {
var startIndex = entries.length;
for (var i = 0, len = this.entries.length; i < len; ++i) {
// Clone the entry stored in the bucket before adding to array
entries[startIndex + i] = this.entries[i].slice(0);
}
},
containsKey: createBucketSearcher(EXISTENCE),
containsValue: function(value) {
var i = this.entries.length;
while (i--) {
if ( value === this.entries[i][1] ) {
return true;
}
}
return false;
}
};
/*----------------------------------------------------------------------------------------------------------------*/
// Supporting functions for searching hashtable buckets
function searchBuckets(buckets, hash) {
var i = buckets.length, bucket;
while (i--) {
bucket = buckets[i];
if (hash === bucket[0]) {
return i;
}
}
return null;
}
function getBucketForHash(bucketsByHash, hash) {
var bucket = bucketsByHash[hash];
// Check that this is a genuine bucket and not something inherited from the bucketsByHash's prototype
return ( bucket && (bucket instanceof Bucket) ) ? bucket : null;
}
/*----------------------------------------------------------------------------------------------------------------*/
function Hashtable(hashingFunctionParam, equalityFunctionParam) {
var that = this;
var buckets = [];
var bucketsByHash = {};
var hashingFunction = (typeof hashingFunctionParam == FUNCTION) ? hashingFunctionParam : hashObject;
var equalityFunction = (typeof equalityFunctionParam == FUNCTION) ? equalityFunctionParam : null;
this.put = function(key, value) {
checkKey(key);
checkValue(value);
var hash = hashingFunction(key), bucket, bucketEntry, oldValue = null;
// Check if a bucket exists for the bucket key
bucket = getBucketForHash(bucketsByHash, hash);
if (bucket) {
// Check this bucket to see if it already contains this key
bucketEntry = bucket.getEntryForKey(key);
if (bucketEntry) {
// This bucket entry is the current mapping of key to value, so replace old value and we're done.
oldValue = bucketEntry[1];
bucketEntry[1] = value;
} else {
// The bucket does not contain an entry for this key, so add one
bucket.addEntry(key, value);
}
} else {
// No bucket exists for the key, so create one and put our key/value mapping in
bucket = new Bucket(hash, key, value, equalityFunction);
buckets[buckets.length] = bucket;
bucketsByHash[hash] = bucket;
}
return oldValue;
};
this.get = function(key) {
checkKey(key);
var hash = hashingFunction(key);
// Check if a bucket exists for the bucket key
var bucket = getBucketForHash(bucketsByHash, hash);
if (bucket) {
// Check this bucket to see if it contains this key
var bucketEntry = bucket.getEntryForKey(key);
if (bucketEntry) {
// This bucket entry is the current mapping of key to value, so return the value.
return bucketEntry[1];
}
}
return null;
};
this.containsKey = function(key) {
checkKey(key);
var bucketKey = hashingFunction(key);
// Check if a bucket exists for the bucket key
var bucket = getBucketForHash(bucketsByHash, bucketKey);
return bucket ? bucket.containsKey(key) : false;
};
this.containsValue = function(value) {
checkValue(value);
var i = buckets.length;
while (i--) {
if (buckets[i].containsValue(value)) {
return true;
}
}
return false;
};
this.clear = function() {
buckets.length = 0;
bucketsByHash = {};
};
this.isEmpty = function() {
return !buckets.length;
};
var createBucketAggregator = function(bucketFuncName) {
return function() {
var aggregated = [], i = buckets.length;
while (i--) {
buckets[i][bucketFuncName](aggregated);
}
return aggregated;
};
};
this.keys = createBucketAggregator("keys");
this.values = createBucketAggregator("values");
this.entries = createBucketAggregator("getEntries");
this.remove = function(key) {
checkKey(key);
var hash = hashingFunction(key), bucketIndex, oldValue = null;
// Check if a bucket exists for the bucket key
var bucket = getBucketForHash(bucketsByHash, hash);
if (bucket) {
// Remove entry from this bucket for this key
oldValue = bucket.removeEntryForKey(key);
if (oldValue !== null) {
// Entry was removed, so check if bucket is empty
if (!bucket.entries.length) {
// Bucket is empty, so remove it from the bucket collections
bucketIndex = searchBuckets(buckets, hash);
arrayRemoveAt(buckets, bucketIndex);
delete bucketsByHash[hash];
}
}
}
return oldValue;
};
this.size = function() {
var total = 0, i = buckets.length;
while (i--) {
total += buckets[i].entries.length;
}
return total;
};
this.each = function(callback) {
var entries = that.entries(), i = entries.length, entry;
while (i--) {
entry = entries[i];
callback(entry[0], entry[1]);
}
};
this.putAll = function(hashtable, conflictCallback) {
var entries = hashtable.entries();
var entry, key, value, thisValue, i = entries.length;
var hasConflictCallback = (typeof conflictCallback == FUNCTION);
while (i--) {
entry = entries[i];
key = entry[0];
value = entry[1];
// Check for a conflict. The default behaviour is to overwrite the value for an existing key
if ( hasConflictCallback && (thisValue = that.get(key)) ) {
value = conflictCallback(key, thisValue, value);
}
that.put(key, value);
}
};
this.clone = function() {
var clone = new Hashtable(hashingFunctionParam, equalityFunctionParam);
clone.putAll(that);
return clone;
};
}
return Hashtable;
})();

View File

@ -0,0 +1,35 @@
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj",
"var p=[],print=function(){p.push.apply(p,arguments);};" +
// Introduce the data as local variables using with(){}
"with(obj){p.push('" +
// Convert the template into pure JavaScript
str
.replace(/[\r\t\n]/g, " ")
.split("<%").join("\t")
.replace(/((^|%>)[^\t]*)'/g, "$1\r")
.replace(/\t=(.*?)%>/g, "',$1,'")
.split("\t").join("');")
.split("%>").join("p.push('")
.split("\r").join("\\'")
+ "');}return p.join('');");
// Provide some basic currying to the user
return data ? fn( data ) : fn;
};
})();

Binary file not shown.

View File

@ -0,0 +1,53 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>jSlider Show/hide test</title>
<!-- bin/jquery.slider.min.css -->
<link rel="stylesheet" href="../css/jslider.css" type="text/css">
<link rel="stylesheet" href="../css/jslider.plastic.css" type="text/css">
<!-- end -->
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<!-- bin/jquery.slider.min.js -->
<script type="text/javascript" src="../js/jshashtable-2.1_src.js"></script>
<script type="text/javascript" src="../js/jquery.numberformatter-1.2.3.js"></script>
<script type="text/javascript" src="../js/tmpl.js"></script>
<script type="text/javascript" src="../js/jquery.dependClass-0.1.js"></script>
<script type="text/javascript" src="../js/draggable-0.1.js"></script>
<script type="text/javascript" src="../js/jquery.slider.js"></script>
<!-- end -->
<style type="text/css" media="screen">
body { background: #EEF0F7; }
.layout { padding: 50px; font-family: Georgia, serif; }
.layout-slider { margin-bottom: 60px; width: 50%; padding: 20px 0; }
</style>
</head>
<body>
<div class="layout">
<div class="layout-slider" style="width: 100%; display: none;">
Slider <span style="display: inline-block; width: 400px; padding: 0 5px;"><input id="Slider3" type="text" name="area" value="25;75" /></span> in string
</div>
<a href="#" id="trigger">Show/Hide</a>
<script type="text/javascript" charset="utf-8">
var layout = $(".layout-slider"),
trigger = $("#trigger");
jQuery("#Slider3").slider({ from: 0, to: 500, heterogeneity: ['50/100', '75/250'], scale: [0, '|', 50, '|', '100', '|', 250, '|', 500], limits: false, step: 1, dimension: '&nbsp;m<small>2</small>', skin: "plastic" });
$(trigger).click( function(){
layout.slideToggle("fast");
$("#Slider3").slider().update();
});
</script>
</div>
</body>
</html>

View File

@ -0,0 +1,64 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>jSlider Zero value test</title>
<!-- bin/jquery.slider.min.css -->
<link rel="stylesheet" href="../css/jslider.css" type="text/css">
<link rel="stylesheet" href="../css/jslider.plastic.css" type="text/css">
<!-- end -->
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<!-- bin/jquery.slider.min.js -->
<script type="text/javascript" src="../js/jshashtable-2.1_src.js"></script>
<script type="text/javascript" src="../js/jquery.numberformatter-1.2.3.js"></script>
<script type="text/javascript" src="../js/tmpl.js"></script>
<script type="text/javascript" src="../js/jquery.dependClass-0.1.js"></script>
<script type="text/javascript" src="../js/draggable-0.1.js"></script>
<script type="text/javascript" src="../js/jquery.slider.js"></script>
<!-- end -->
<style type="text/css" media="screen">
body { background: #EEF0F7; }
.layout { padding: 50px; font-family: Georgia, serif; }
.layout-slider { margin-bottom: 60px; width: 50%; }
</style>
</head>
<body>
<div class="layout">
<div class="layout-slider" style="width: 100%">
Slider <span style="display: inline-block; width: 400px; padding: 0 5px;"><input id="Slider1" type="slider" name="price" value="50" /></span> in string
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider1").slider({
from: -50,
to: 200,
step: 5,
dimension: '%',
skin: 'plastic',
scale: ['-50', '|', '0', '|', '50', '|', '100', '|', '150', '|', '200']
});
</script>
<div class="layout-slider" style="width: 100%">
Slider <span style="display: inline-block; width: 400px; padding: 0 5px;"><input id="Slider2" type="slider" name="price" value="-0.5;0.5" /></span> in string
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#Slider2").slider({
from: -1,
to: 1,
step: 0.1,
round: 1,
dimension: 'px',
skin: 'plastic'
});
</script>
</div>
</body>
</html>

Binary file not shown.

View File

@ -19,6 +19,12 @@ function babel_content(&$a) {
$o .= '<br /><br />';
$o .= '<form action="babel" method="post">';
$o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '<textarea name="d2bbtext" >' . htmlspecialchars($_REQUEST['d2bbtext']) .'</textarea>' . EOL;
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
if(x($_REQUEST,'text')) {
$text = trim($_REQUEST['text']);
@ -52,5 +58,18 @@ function babel_content(&$a) {
}
if(x($_REQUEST,'d2bbtext')) {
$d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= t("Source input (Diaspora format): ") . EOL. EOL;
$o .= visible_lf($d2bbtext) . EOL. EOL;
$bb = diaspora2bb($d2bbtext);
$o .= t("diaspora2bb: ") . EOL. EOL;
$o .= visible_lf($bb) . EOL. EOL;
}
return $o;
}

View File

@ -44,7 +44,7 @@ function group_post(&$a) {
intval(local_user())
);
if(! count($r)) {
notice( t('Group not found.') . EOL );
notice( t('Contact group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts');
return; // NOTREACHED
}
@ -57,7 +57,7 @@ function group_post(&$a) {
intval($group['id'])
);
if($r)
info( t('Group name changed.') . EOL );
info( t('Contact group name changed.') . EOL );
}
$a->page['aside'] = group_side();
@ -88,7 +88,7 @@ function group_content(&$a) {
return replace_macros($tpl, $context + array(
'$title' => t('Create a group of contacts/friends.'),
'$gname' => array('groupname',t('Group Name: '), '', ''),
'$gname' => array('groupname',t('Contact Group Name: '), '', ''),
'$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"),
));
@ -107,9 +107,9 @@ function group_content(&$a) {
if(count($r))
$result = group_rmv(local_user(),$r[0]['name']);
if($result)
info( t('Group removed.') . EOL);
info( t('Contact group removed.') . EOL);
else
notice( t('Unable to remove group.') . EOL);
notice( t('Unable to remove contact group.') . EOL);
}
goaway($a->get_baseurl() . '/group');
// NOTREACHED
@ -134,7 +134,7 @@ function group_content(&$a) {
intval(local_user())
);
if(! count($r)) {
notice( t('Group not found.') . EOL );
notice( t('Contact group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts');
}
$group = $r[0];
@ -173,8 +173,8 @@ function group_content(&$a) {
$context = $context + array(
'$title' => t('Group Editor'),
'$gname' => array('groupname',t('Group Name: '),$group['name'], ''),
'$title' => t('Contact Group Editor'),
'$gname' => array('groupname',t('Contact Group Name: '),$group['name'], ''),
'$gid' => $group['id'],
'$drop' => $drop_txt,
'$form_security_token' => get_form_security_token('group_edit'),

View File

@ -106,11 +106,12 @@ function like_content(&$a) {
$r = q("SELECT * FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s') LIMIT 1",
AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
dbesc($activity),
intval($contact['id']),
dbesc($item_id),
dbesc($item_id)
dbesc($item_id),
dbesc($item['uri'])
);
if(count($r)) {
$like_item = $r[0];

View File

@ -92,29 +92,17 @@ function network_init(&$a) {
);
}
$a->page['content'] .= '<div id="slider-range" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all">
<div class="ui-slider-range ui-widget-header" style="margin-left: 30px; margin-right: 30px;"></div>
<a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 0%;"></a>
<a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 100%;"></a>
</div>
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
});
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
</script>
';
$tpl = get_markup_template('main_slider.tpl');
$a->page['content'] .= replace_macros($tpl,array(
'$me' => t('Me'),
'$intimate' => t('Best Friends'),
'$friends' => t('Friends'),
'$coworkers' => t('Co-workers'),
'$oldfriends' => t('Former Friends'),
'$acquaintances' => t('Acquaintances'),
'$world' => t('Everybody')
));
// search terms header
if(x($_GET,'search')) {
$a->page['content'] .= '<h2>' . t('Search Results For:') . ' ' . htmlspecialchars($search) . '</h2>';

View File

@ -1,27 +1,22 @@
<?php
require_once("include/datetime.php");
require_once('include/bbcode.php');
function ping_init(&$a) {
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<result>";
$result = array();
$notifs = array();
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
header("content-type: application/json");
if(local_user()){
// Different login session than the page that is calling us.
if(intval($_GET['uid']) && intval($_GET['uid']) != local_user()) {
echo '<invalid>1</invalid></result>';
killme();
}
$firehose = intval(get_pconfig(local_user(),'system','notify_full'));
if((! local_user()) || ((intval($_GET['uid'])) && (intval($_GET['uid']) != local_user()))) {
$result[] = array('success' => false, 'message' => 'Authentication error');
echo json_encode($result);
killme();
}
if($a->argc > 1 && $a->argv[1] === 'notify') {
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_user())
);
@ -30,231 +25,121 @@ function ping_init(&$a) {
and seen = 0 order by date desc limit 0, 50",
intval(local_user())
);
$sysnotify = $t[0]['total'];
}
else {
$z1 = q("select * from notify where uid = %d
and seen = 0 order by date desc limit 0, 50",
intval(local_user())
);
$z2 = q("select * from notify where uid = %d
and seen = 1 order by date desc limit 0, %d",
intval(local_user()),
intval(50 - intval($t[0]['total']))
);
$z = array_merge($z1,$z2);
$sysnotify = 0; // we will update this in a moment
}
$tags = array();
$comments = array();
$likes = array();
$dislikes = array();
$friends = array();
$posts = array();
$home = 0;
$network = 0;
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
`item`.`deleted` = 0 AND `item`.`uid` = %d
ORDER BY `item`.`created` DESC",
intval(local_user())
);
if(count($r)) {
foreach ($r as $it) {
if($it['wall'])
$home ++;
else
$network ++;
switch($it['verb']){
case ACTIVITY_TAG:
$obj = parse_xml_string($xmlhead.$it['object']);
$it['tname'] = $obj->content;
$tags[] = $it;
break;
case ACTIVITY_LIKE:
$likes[] = $it;
break;
case ACTIVITY_DISLIKE:
$dislikes[] = $it;
break;
case ACTIVITY_FRIEND:
$obj = parse_xml_string($xmlhead.$it['object']);
$it['fname'] = $obj->title;
$friends[] = $it;
break;
default:
if ($it['parent']!=$it['id']) {
$comments[] = $it;
} else {
if(! $it['wall'])
$posts[] = $it;
}
}
if(count($z)) {
foreach($z as $zz) {
$notifs[] = array(
'notify_link' => $a->get_baseurl() . '/notify/view/' . $zz['id'],
'name' => $zz['name'],
'url' => $zz['url'],
'photo' => $zz['photo'],
'when' => relative_date($zz['date']),
'classs' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'),
'message' => strip_tags(bbcode($zz['msg']))
);
}
}
$intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
intval(local_user())
);
$intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
`contact`.`name`, `contact`.`url`, `contact`.`photo`
FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
intval(local_user())
);
$intro = count($intros1) + count($intros2);
$intros = $intros1+$intros2;
echo json_encode(array('notify' => $notifs));
killme();
$myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
$mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
intval(local_user()),
dbesc($myurl)
);
if($mails)
$mail = $mails[0]['total'];
if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
$regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
if($regs)
$register = $regs[0]['total'];
} else {
$register = "0";
}
function xmlize($href, $name, $url, $photo, $date, $seen, $message){
$data = array('href' => &$href, 'name' => &$name, 'url'=>&$url, 'photo'=>&$photo, 'date'=>&$date, 'seen'=>&$seen, 'messsage'=>&$message);
call_hooks('ping_xmlize', $data);
$notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" >%s</note>';
return sprintf ( $notsxml,
xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message)
);
}
echo "<intro>$intro</intro>
<mail>$mail</mail>
<net>$network</net>
<home>$home</home>";
if ($register!=0) echo "<register>$register</register>";
$tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
require_once('include/bbcode.php');
if($firehose) {
echo ' <notif count="'.$tot.'">';
}
else {
if(count($z) && (! $sysnotify)) {
foreach($z as $zz) {
if($zz['seen'] == 0)
$sysnotify ++;
}
}
echo ' <notif count="'. $sysnotify .'">';
if(count($z)) {
foreach($z as $zz) {
echo xmlize($a->get_baseurl() . '/notify/view/' . $zz['id'], $zz['name'],$zz['url'],$zz['photo'],relative_date($zz['date']), ($zz['seen'] ? 'notify-seen' : 'notify-unseen'), ($zz['seen'] ? '' : '&rarr; ') .strip_tags(bbcode($zz['msg'])));
}
}
}
if($firehose) {
if ($intro>0){
foreach ($intros as $i) {
echo xmlize( $a->get_baseurl().'/notifications/intros/'.$i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), 'notify-unseen',t("{0} wants to be your friend") );
};
}
if ($mail>0){
foreach ($mails as $i) {
echo xmlize( $a->get_baseurl().'/message/'.$i['id'], $i['from-name'], $i['from-url'], $i['from-photo'], relative_date($i['created']), 'notify-unseen',t("{0} sent you a message") );
};
}
if ($register>0){
foreach ($regs as $i) {
echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), 'notify-unseen',t("{0} requested registration") );
};
}
if (count($comments)){
foreach ($comments as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} commented %s's post"), $i['pname'] ) );
};
}
if (count($likes)){
foreach ($likes as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} liked %s's post"), $i['pname'] ) );
};
}
if (count($dislikes)){
foreach ($dislikes as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} disliked %s's post"), $i['pname'] ) );
};
}
if (count($friends)){
foreach ($friends as $i) {
echo xmlize($a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'],$i['author-name'],$i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} is now friends with %s"), $i['fname'] ) );
};
}
if (count($posts)){
foreach ($posts as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} posted") ) );
};
}
if (count($tags)){
foreach ($tags as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} tagged %s's post with #%s"), $i['pname'], $i['tname'] ) );
};
}
if (count($cit)){
foreach ($cit as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',t("{0} mentioned you in a post") );
};
}
}
echo " </notif>";
}
echo " <sysmsgs>";
$result['notify'] = 0;
$result['home'] = 0;
$result['network'] = 0;
$result['intros'] = 0;
$result['mail'] = 0;
$result['register'] = 0;
$result['notice'] = array();
$result['info'] = array();
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_user())
);
if($t)
$result['notify'] = intval($t[0]['total']);
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
`item`.`deleted` = 0 AND `item`.`uid` = %d
ORDER BY `item`.`created` DESC",
intval(local_user())
);
if(count($r)) {
foreach ($r as $it) {
if($it['wall'])
$result['home'] ++;
else
$result['network'] ++;
}
}
$intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
intval(local_user())
);
$intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
`contact`.`name`, `contact`.`url`, `contact`.`photo`
FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
intval(local_user())
);
$intro = count($intros1) + count($intros2);
$result['intros'] = intval($intros);
$myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
$mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
intval(local_user()),
dbesc($myurl)
);
if($mails)
$result['mail'] = intval($mails[0]['total']);
if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
$regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
if($regs)
$result['register'] = intval($regs[0]['total']);
}
if(x($_SESSION,'sysmsg')){
foreach ($_SESSION['sysmsg'] as $m){
echo "<notice>".xmlify($m)."</notice>";
$result['notice'][] = $m;
}
unset($_SESSION['sysmsg']);
}
if(x($_SESSION,'sysmsg_info')){
foreach ($_SESSION['sysmsg_info'] as $m){
echo "<info>".xmlify($m)."</info>";
$result['info'][] = $m;
}
unset($_SESSION['sysmsg_info']);
}
echo " </sysmsgs>";
echo"</result>
";
echo json_encode($result);
killme();
}

View File

@ -5,6 +5,7 @@
<link rel="stylesheet" href="$baseurl/library/tiptip/tipTip.css" type="text/css" media="screen" />
<link rel="stylesheet" href="$baseurl/library/jgrowl/jquery.jgrowl.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="$baseurl/library/jslider/bin/jquery.slider.min.css" />
<link rel="stylesheet" type="text/css" href="$stylesheet" media="all" />
<link rel="shortcut icon" href="$baseurl/images/friendica-32.png" />
@ -27,13 +28,7 @@
<script type="text/javascript" src="$baseurl/js/webtoolkit.base64.js" ></script>
<script type="text/javascript" src="$baseurl/js/main.js" ></script>
<link href="$baseurl/include/jquery_ui/development-bundle/themes/base/jquery.ui.all.css" rel="stylesheet">
<script src="$baseurl/include/jquery_ui/js/jquery-1.7.2.min.js"></script>
<script src="$baseurl/include/jquery_ui/development-bundle/ui/jquery.ui.core.js"></script>
<script src="$baseurl/include/jquery_ui/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="$baseurl/include/jquery_ui/development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="$baseurl/include/jquery_ui/development-bundle/ui/jquery.ui.slider.js"></script>
<script src="$baseurl/library/jslider/bin/jquery.slider.min.js"></script>
<script>
var updateInterval = $update_interval;

4
view/main_slider.tpl Normal file
View File

@ -0,0 +1,4 @@
<div id="slider" style="height: 32px; position: relative; left: 5%; width: 90%;"><input id="main-range" type="slider" name="closeness" value="0;99" /></div>
<script>
$("#main-range").slider({ from: 0, to: 99, step: 1, scale: ['$me', '$intimate', '|', '$friends', '|', '$coworkers', '|', '$oldfriends', '|', '$acquaintances', '|', '$world' ] });
</script>

View File

@ -220,3 +220,14 @@ nav #site-location {
-o-transform: rotate(4deg);
}
.jslider .jslider-scale ins {
color: #333;
font-size: 12px;
width: 100px;
text-align: center;
}
#slider {
margin-top: 10px;
margin-bottom: 15px;
}