background color api and setting
This commit is contained in:
parent
5e8512f12d
commit
d6c2ee383c
|
@ -10,7 +10,7 @@
|
|||
|
||||
* lib/apiaction.php
|
||||
|
||||
- add urls to larger avatars, groupcount and linkcolor field
|
||||
- add urls to larger avatars, groupcount, linkcolor and backgroundcolor fields
|
||||
|
||||
~LINE 213
|
||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||
|
@ -24,7 +24,8 @@
|
|||
Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||
|
||||
$twitter_user['groups_count'] = $profile->getGroups(0, null)->N;
|
||||
$twitter_user['linkcolor'] = $user->linkcolor;
|
||||
$twitter_user['linkcolor'] = $user->linkcolor;
|
||||
$twitter_user['backgroundcolor'] = $user->backgroundcolor;
|
||||
|
||||
|
||||
- add the uri-field
|
||||
|
@ -91,6 +92,9 @@
|
|||
$m->connect('api/account/update_link_color.json',
|
||||
array('action' => 'ApiAccountUpdateLinkColor'));
|
||||
|
||||
$m->connect('api/account/update_background_color.json',
|
||||
array('action' => 'ApiAccountUpdateBackgroundColor'));
|
||||
|
||||
|
||||
- also, tags need regexp to work with unicode charachters, e.g. farsi and arabic:
|
||||
|
||||
|
@ -182,8 +186,10 @@
|
|||
|
||||
* classes/User.php
|
||||
|
||||
- add field "linkcolor" to user table (do this is the db too!)
|
||||
- add fields "linkcolor" and "background_image_url" to user table (do this is the db too!)
|
||||
|
||||
~ line 64 public $linkcolor; // varchar(6)
|
||||
public $background_image_url; // varchar(255)
|
||||
~ line 105 'linkcolor' => array('type' => 'varchar', 'length' => 6, 'description' => 'hex link color'),
|
||||
'background_image_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'url to profile image'),
|
||||
|
||||
|
|
108
api-changes-1.1.1/actions/apiaccountupdatebackgroundcolor.php
Normal file
108
api-changes-1.1.1/actions/apiaccountupdatebackgroundcolor.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Update a user's background color
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Hannes Mannerheim <h@nnesmannerhe.im>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/lib/apiauth.php';
|
||||
|
||||
|
||||
class ApiAccountUpdateBackgroundColorAction extends ApiAuthAction
|
||||
{
|
||||
var $backgroundcolor = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
$this->user = $this->auth_user;
|
||||
|
||||
$this->backgroundcolor = $this->trimmed('backgroundcolor');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the request
|
||||
*
|
||||
* Try to save the user's colors in her design. Create a new design
|
||||
* if the user doesn't already have one.
|
||||
*
|
||||
* @param array $args $_REQUEST data (unused)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$validhex = preg_match('/^[a-f0-9]{6}$/i',$this->backgroundcolor);
|
||||
if($validhex === false || $validhex == 0) {
|
||||
$this->clientError(_('Not a valid hex color.'),404,'json');
|
||||
return;
|
||||
}
|
||||
|
||||
// save the new color
|
||||
$original = clone($this->user);
|
||||
$this->user->backgroundcolor = $this->backgroundcolor;
|
||||
if (!$this->user->update($original)) {
|
||||
$this->clientError(_('Error updating user.'),404,'json');
|
||||
return;
|
||||
}
|
||||
|
||||
$profile = $this->user->getProfile();
|
||||
|
||||
if (empty($profile)) {
|
||||
$this->clientError(_('User has no profile.'),'json');
|
||||
return;
|
||||
}
|
||||
|
||||
$twitter_user = $this->twitterUserArray($profile, true);
|
||||
|
||||
$this->initDocument('json');
|
||||
$this->showJsonObjects($twitter_user);
|
||||
$this->endDocument('json');
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -63,6 +63,7 @@ class User extends Managed_DataObject
|
|||
public $inboxed; // tinyint(1)
|
||||
public $linkcolor; // varchar(6)
|
||||
public $background_image_url; // varchar(255)
|
||||
public $backgroundcolor; // varchar(6)
|
||||
public $private_stream; // tinyint(1) default_0
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
@ -104,6 +105,7 @@ class User extends Managed_DataObject
|
|||
'inboxed' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'has an inbox been created for this user?'),
|
||||
'linkcolor' => array('type' => 'varchar', 'length' => 6, 'description' => 'hex link color'),
|
||||
'background_image_url' => array('type' => 'varchar', 'length' => 255, 'description' => 'url to profile image'),
|
||||
'backgroundcolor' => array('type' => 'varchar', 'length' => 6, 'description' => 'hex background color'),
|
||||
'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'),
|
||||
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
|
|
|
@ -221,7 +221,8 @@ class ApiAction extends Action
|
|||
Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||
|
||||
$twitter_user['groups_count'] = $profile->getGroups(0, null)->N;
|
||||
$twitter_user['linkcolor'] = $user->linkcolor;
|
||||
$twitter_user['linkcolor'] = $user->linkcolor;
|
||||
$twitter_user['backgroundcolor'] = $user->backgroundcolor;
|
||||
|
||||
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
||||
$twitter_user['protected'] = (!empty($user) && $user->private_stream) ? true : false;
|
||||
|
|
|
@ -488,6 +488,9 @@ class Router
|
|||
$m->connect('api/account/update_link_color.json',
|
||||
array('action' => 'ApiAccountUpdateLinkColor'));
|
||||
|
||||
$m->connect('api/account/update_background_color.json',
|
||||
array('action' => 'ApiAccountUpdateBackgroundColor'));
|
||||
|
||||
// users
|
||||
|
||||
$m->connect('api/users/show/:id.:format',
|
||||
|
|
12
css/1.css
12
css/1.css
|
@ -33,7 +33,6 @@
|
|||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
|
||||
body {
|
||||
background-color:#fff;
|
||||
background-size:100% auto;
|
||||
background-attachment:fixed;
|
||||
margin:0;
|
||||
|
@ -321,7 +320,11 @@ button.icon.nav-search span {
|
|||
width: 125px;
|
||||
position: relative;
|
||||
display: block;
|
||||
}
|
||||
text-align:left;
|
||||
}
|
||||
body.rtl .dropdown-menu li:not(.dropdown-caret) {
|
||||
text-align:right;
|
||||
}
|
||||
.dropdown-menu li:not(.dropdown-caret) a {
|
||||
clear: both;
|
||||
color: #333333;
|
||||
|
@ -752,7 +755,10 @@ button#submit-login:hover {
|
|||
}
|
||||
|
||||
#settings-container {
|
||||
padding:10px 10px 300px 10px;
|
||||
padding:10px 10px 150px 10px;
|
||||
}
|
||||
#settings-container > div {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
#settings-container label {
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
window.fullUrlToThisQvitterApp = '<?php print $qvitterpath; ?>';
|
||||
window.siteRootDomain = '<?php print $siterootdomain; ?>';
|
||||
window.useHistoryPushState = <?php if($usehistorypushstate) print 'true'; else print 'false'; ?>;
|
||||
window.defaultLinkColor = '<?php print $defaultlinkcolor; ?>';
|
||||
window.defaultBackgroundColor = '<?php print $defaultbackgroundcolor; ?>';
|
||||
</script>
|
||||
<style>
|
||||
a, a:visited, a:active,
|
||||
|
@ -72,7 +74,7 @@
|
|||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body style="background-color:<?php print $defaultbackgroundcolor; ?>">
|
||||
<div class="topbar">
|
||||
<a href="<?php print strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,strpos( $_SERVER["SERVER_PROTOCOL"],'/'))).'://'.$siterootdomain; ?>"><div id="logo"></div></a>
|
||||
<a id="settingslink">
|
||||
|
|
|
@ -179,11 +179,40 @@ function postNewLinkColor(newLinkColor) {
|
|||
},
|
||||
dataType:"json",
|
||||
error: function(data){ console.log(data); },
|
||||
success: function(data) { console.log(data);}
|
||||
success: function(data) {
|
||||
window.userLinkColor = newLinkColor;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Post new background color
|
||||
·
|
||||
· @param newBackgroundColor: the new background color in hex without #
|
||||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
function postNewBackgroundColor(newBackgroundColor) {
|
||||
$.ajax({ url: 'API.php',
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'account/update_background_color.json',
|
||||
backgroundcolor: newBackgroundColor,
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ console.log(data); },
|
||||
success: function(data) {
|
||||
window.userBackgroundColor = newBackgroundColor;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
|
@ -298,31 +327,6 @@ function postActionToAPI(action, actionOnSuccess) {
|
|||
success: function(data) { actionOnSuccess(data);}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Generic POST-action
|
||||
·
|
||||
· @param action: the api action, e.q. 'statuses/retweet/1.json'
|
||||
· @param actionOnSuccess: callback function, false on error, data on success
|
||||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
function postActionToAPI(action, actionOnSuccess) {
|
||||
$.ajax({ url: window.fullUrlToThisQvitterApp + 'API.php',
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: action,
|
||||
source: 'Qvitter',
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ actionOnSuccess(false); console.log(data); },
|
||||
success: function(data) { actionOnSuccess(data);}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* ·
|
||||
|
|
|
@ -178,13 +178,8 @@ function profileCardFromFirstObject(data,screen_name) {
|
|||
var followButton = '<div class="user-actions"><button data-follow-user-id="' + first.user.id + '" data-follow-user="' + first.user.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
|
||||
}
|
||||
|
||||
// change link color if set
|
||||
if(first.user.linkcolor.length == 6) {
|
||||
changeLinkColor('#' + first.user.linkcolor);
|
||||
}
|
||||
else {
|
||||
changeLinkColor('#0084B4');
|
||||
}
|
||||
// change design
|
||||
changeDesign(first.user);
|
||||
|
||||
$('#feed').before('<div class="profile-card"><div class="profile-header-inner" style="background-image:url(' + first.user.profile_image_url_original + ')"><div class="profile-header-inner-overlay"></div><a class="profile-picture" href="' + first.user.profile_image_url_original + '"><img src="' + first.user.profile_image_url_profile_size + '" /></a><div class="profile-card-inner"><h1 class="fullname">' + first.user.name + '<span></span></h1><h2 class="username"><span class="screen-name">@' + first.user.screen_name + '</span><span class="follow-status"></span></h2><div class="bio-container"><p>' + first.user.description + '</p></div><p class="location-and-url"><span class="location">' + first.user.location + '</span><span class="divider"> · </span><span class="url"><a href="' + first.user.url + '">' + first.user.url.replace('http://','').replace('https://','') + '</a></span></p></div></div><div class="profile-banner-footer"><ul class="stats"><li><a class="tweet-stats"><strong>' + first.user.statuses_count + '</strong>' + window.sL.notices + '</a></li><li><a class="following-stats"><strong>' + first.user.friends_count + '</strong>' + window.sL.following + '</a></li><li><a class="follower-stats"><strong>' + first.user.followers_count + '</strong>' + window.sL.followers + '</a></li><li><a class="groups-stats"><strong>' + first.user.groups_count + '</strong>' + window.sL.groups + '</a></li></ul>' + followButton + '<div class="clearfix"></div></div></div>');
|
||||
}
|
||||
|
@ -216,13 +211,8 @@ function profileCardFromFirstObject(data,screen_name) {
|
|||
var followButton = '<div class="user-actions"><button data-follow-user-id="' + data.id + '" data-follow-user="' + data.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
|
||||
}
|
||||
|
||||
// change link color
|
||||
if(data.linkcolor.length == 6) {
|
||||
changeLinkColor('#' + data.linkcolor);
|
||||
}
|
||||
else {
|
||||
changeLinkColor('#0084B4');
|
||||
}
|
||||
// change design
|
||||
changeDesign(data);
|
||||
|
||||
$('#feed').before('<div class="profile-card"><div class="profile-header-inner" style="background-image:url(' + data.profile_image_url_original + ')"><div class="profile-header-inner-overlay"></div><a class="profile-picture" href="' + data.profile_image_url_original + '"><img src="' + data.profile_image_url_profile_size + '" /></a><div class="profile-card-inner"><h1 class="fullname">' + data.name + '<span></span></h1><h2 class="username"><span class="screen-name">@' + data.screen_name + '</span><span class="follow-status"></span></h2><div class="bio-container"><p>' + data.description + '</p></div><p class="location-and-url"><span class="location">' + data.location + '</span><span class="divider"> · </span><span class="url"><a href="' + data.url + '">' + data.url.replace('http://','').replace('https://','') + '</a></span></p></div></div><div class="profile-banner-footer"><ul class="stats"><li><a class="tweet-stats"><strong>' + data.statuses_count + '</strong>' + window.sL.notices + '</a></li><li><a class="following-stats"><strong>' + data.friends_count + '</strong>' + window.sL.following + '</a></li><li><a class="follower-stats"><strong>' + data.followers_count + '</strong>' + window.sL.followers + '</a></li><li><a class="groups-stats"><strong>' + data.groups_count + '</strong>' + window.sL.groups + '</a></li></ul>' + followButton + '<div class="clearfix"></div></div></div>');
|
||||
}});
|
||||
|
@ -412,15 +402,8 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
// while waiting for this data user might have changed stream, so only proceed if current stream still is this one
|
||||
if(window.currentStream == stream) {
|
||||
|
||||
// change link color
|
||||
if(typeof window.userLinkColor != 'undefined') {
|
||||
if(window.userLinkColor.length == 6) {
|
||||
changeLinkColor('#' + window.userLinkColor);
|
||||
}
|
||||
else {
|
||||
changeLinkColor('#0084B4');
|
||||
}
|
||||
}
|
||||
// change design
|
||||
changeDesign(window);
|
||||
|
||||
// get screen name from stream, if not found, this is me
|
||||
if(stream.indexOf('screen_name=')>-1) {
|
||||
|
@ -453,15 +436,8 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
// while waiting for this data user might have changed stream, so only proceed if current stream still is this one
|
||||
if(window.currentStream == stream) {
|
||||
|
||||
// change link color
|
||||
if(typeof window.userLinkColor != 'undefined') {
|
||||
if(window.userLinkColor.length == 6) {
|
||||
changeLinkColor('#' + window.userLinkColor);
|
||||
}
|
||||
else {
|
||||
changeLinkColor('#0084B4');
|
||||
}
|
||||
}
|
||||
// change design
|
||||
changeDesign(window);
|
||||
|
||||
// show profile card if this is a user's queet stream
|
||||
if(stream.substring(0,27) == 'statuses/user_timeline.json') {
|
||||
|
|
11
js/lan-1.js
11
js/lan-1.js
|
@ -125,7 +125,7 @@ window.l.es.adminCount = 'Administradores';
|
|||
window.l.es.settings = 'Configuración';
|
||||
window.l.es.saveChanges = 'Guardar cambios';
|
||||
window.l.es.linkColor = 'Color del enlace';
|
||||
|
||||
window.l.es.backgroundColor = 'Color de fondo';
|
||||
|
||||
// french
|
||||
window.l.fr = new Object();
|
||||
|
@ -214,7 +214,8 @@ window.l.fr.memberCount = 'Membres';
|
|||
window.l.fr.adminCount = 'Administrateurs';
|
||||
window.l.fr.settings = 'Paramètres';
|
||||
window.l.fr.saveChanges = 'Sauvegarder les modifications';
|
||||
window.l.fr.linkColor = ' Couleur des liens';
|
||||
window.l.fr.linkColor = 'Couleur des liens';
|
||||
window.l.fr.backgroundColor = 'Couleur de l\'arrière-plan';
|
||||
|
||||
|
||||
// deutsch
|
||||
|
@ -305,6 +306,7 @@ window.l.de.adminCount = 'Administratoren';
|
|||
window.l.de.settings = 'Einstellungen';
|
||||
window.l.de.saveChanges = 'Änderungen speichern';
|
||||
window.l.de.linkColor = 'Linkfarbe';
|
||||
window.l.de.backgroundColor = 'Hintergrundfarbe';
|
||||
|
||||
|
||||
|
||||
|
@ -396,6 +398,7 @@ window.l.en.adminCount = 'Admins';
|
|||
window.l.en.settings = 'Settings';
|
||||
window.l.en.saveChanges = 'Save changes';
|
||||
window.l.en.linkColor = 'Link color';
|
||||
window.l.en.backgroundColor = 'Background color';
|
||||
|
||||
|
||||
// svenska
|
||||
|
@ -486,6 +489,7 @@ window.l.sv.adminCount = 'Administratörer';
|
|||
window.l.sv.settings = 'Inställningar';
|
||||
window.l.sv.saveChanges = 'Spara ändringarna';
|
||||
window.l.sv.linkColor = 'Länkfärg';
|
||||
window.l.sv.backgroundColor = 'Bakgrundsfärg';
|
||||
|
||||
|
||||
|
||||
|
@ -577,7 +581,7 @@ window.l.fa.adminCount = 'مدیران';
|
|||
window.l.fa.settings = 'تنظیمات';
|
||||
window.l.fa.saveChanges = 'ذخیره تغییرات';
|
||||
window.l.fa.linkColor = 'رنگ پیوند';
|
||||
|
||||
window.l.fa.backgroundColor = 'رنگ پسزمینه';
|
||||
|
||||
|
||||
// arabic
|
||||
|
@ -668,6 +672,7 @@ window.l.ar.adminCount = 'الإداريين';
|
|||
window.l.ar.settings = 'الإعدادات';
|
||||
window.l.ar.saveChanges = 'حفظ التغييرات';
|
||||
window.l.ar.linkColor = 'لون الرابط';
|
||||
window.l.ar.backgroundColor = 'لون الخلفيّة';
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,68 @@ function localStorageIsEnabled() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Change profile design
|
||||
·
|
||||
· @param obj: user object that _might_ contain colors, or window object, that _might_ contain user settings
|
||||
·
|
||||
· · · · · · · · · */
|
||||
|
||||
function changeDesign(obj) {
|
||||
|
||||
// user object that might contains other user's colors
|
||||
if(typeof obj.linkcolor != 'undefined' &&
|
||||
typeof obj.backgroundcolor != 'undefined') {
|
||||
if(obj.linkcolor == null) {
|
||||
changeLinkColor(window.defaultLinkColor);
|
||||
}
|
||||
else if(obj.linkcolor.length == 6) {
|
||||
changeLinkColor('#' + obj.linkcolor);
|
||||
}
|
||||
else {
|
||||
changeLinkColor(window.defaultLinkColor);
|
||||
}
|
||||
if(obj.backgroundcolor == null) {
|
||||
$('body').css('background-color',window.defaultBackgroundColor);
|
||||
}
|
||||
else if(obj.backgroundcolor.length == 6) {
|
||||
$('body').css('background-color','#' + obj.backgroundcolor);
|
||||
}
|
||||
else {
|
||||
$('body').css('background-color',window.defaultBackgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
// window object that might contain my colors
|
||||
else if(typeof obj.userLinkColor != 'undefined' &&
|
||||
typeof obj.userBackgroundColor != 'undefined') {
|
||||
if(obj.userLinkColor == null) {
|
||||
changeLinkColor(window.defaultLinkColor);
|
||||
}
|
||||
else if(obj.userLinkColor.length == 6) {
|
||||
changeLinkColor('#' + obj.userLinkColor);
|
||||
}
|
||||
else {
|
||||
changeLinkColor(window.defaultLinkColor);
|
||||
}
|
||||
if(obj.userBackgroundColor == null) {
|
||||
$('body').css('background-color',window.defaultBackgroundColor);
|
||||
}
|
||||
else if(obj.userBackgroundColor.length == 6) {
|
||||
$('body').css('background-color','#' + obj.userBackgroundColor);
|
||||
}
|
||||
else {
|
||||
$('body').css('background-color',window.defaultBackgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO BACKGROUND IMAGE!
|
||||
$('body').css('background-image','none');
|
||||
}
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
|
@ -272,7 +334,7 @@ function placeCaretAtEnd(el) {
|
|||
function updateHistoryLocalStorage() {
|
||||
if(localStorageIsEnabled()) {
|
||||
var i=0;
|
||||
var localStorageName = window.username + '-history-container';
|
||||
var localStorageName = window.loginUsername + '-history-container';
|
||||
var historyContainer = new Object();
|
||||
$.each($('#history-container .stream-selection'), function(key,obj) {
|
||||
historyContainer[i] = new Object();
|
||||
|
@ -301,7 +363,7 @@ function updateHistoryLocalStorage() {
|
|||
|
||||
function loadHistoryFromLocalStorage() {
|
||||
if(localStorageIsEnabled()) {
|
||||
var localStorageName = window.username + '-history-container';
|
||||
var localStorageName = window.loginUsername + '-history-container';
|
||||
if(typeof localStorage[localStorageName] != "undefined") {
|
||||
$('#history-container').css('display','block');
|
||||
$('#history-container').html('');
|
||||
|
|
|
@ -59,8 +59,7 @@ if(window.useHistoryPushState) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
$('#submit-login').removeAttr('disabled'); // might be remebered by browser...
|
||||
$('<img/>').attr('src', window.fullUrlToThisQvitterApp + 'img/ekan4.jpg').load(function() {
|
||||
$('body').css('background-image', 'url(' + window.fullUrlToThisQvitterApp + 'img/ekan4.jpg)');
|
||||
$(window).load(function() {
|
||||
|
||||
$('#user-container').css('display','block');
|
||||
$('#feed').css('display','block');
|
||||
|
@ -87,7 +86,6 @@ $('<img/>').attr('src', window.fullUrlToThisQvitterApp + 'img/ekan4.jpg').load(f
|
|||
$('#submit-login').trigger('click');
|
||||
}
|
||||
else {
|
||||
|
||||
display_spinner();
|
||||
window.currentStream = ''; // force reload stream
|
||||
setNewCurrentStream(getStreamFromUrl(),function(){
|
||||
|
@ -118,7 +116,21 @@ $('#submit-login').click(function () {
|
|||
// store credentials in global var
|
||||
window.loginUsername = user.screen_name;
|
||||
window.loginPassword = $('input#password').val();
|
||||
window.userLinkColor = user.linkcolor;
|
||||
|
||||
// set colors if the api supports it
|
||||
if(typeof user.linkcolor != 'undefined' &&
|
||||
typeof user.backgroundcolor != 'undefined') {
|
||||
user.linkcolor = user.linkcolor || ''; // no null value
|
||||
user.backgroundcolor = user.backgroundcolor || ''; // no null value
|
||||
window.userLinkColor = user.linkcolor;
|
||||
window.userBackgroundColor = user.backgroundcolor;
|
||||
if(window.userLinkColor.length != 6) {
|
||||
window.userLinkColor = window.defaultLinkColor;
|
||||
}
|
||||
if(window.userBackgroundColor.length != 6) {
|
||||
window.userBackgroundColor = window.defaultBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
// add user data to DOM, show search form, remeber user id, show the feed
|
||||
$('#user-avatar').attr('src', user.profile_image_url);
|
||||
|
@ -224,13 +236,20 @@ $('#logout').click(function(){
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
$('#settings').click(function(){
|
||||
popUpAction('popup-settings', window.sL.settings,'<div id="settings-container"><label for="link-color-selection">' + window.sL.linkColor + '</label><input id="link-color-selection" type="text" value="#' + window.userLinkColor + '" /></div>','<div class="right"><button class="close">' + window.sL.cancelVerb + '</button><button class="primary">' + window.sL.saveChanges + '</button></div>');
|
||||
// buttons to add later: '<div class="right"><button class="close">' + window.sL.cancelVerb + '</button><button class="primary disabled">' + window.sL.saveChanges + '</button></div>'
|
||||
popUpAction('popup-settings', window.sL.settings,'<div id="settings-container"><div><label for="link-color-selection">' + window.sL.linkColor + '</label><input id="link-color-selection" type="text" value="#' + window.userLinkColor + '" /></div><div><label for="link-color-selection">' + window.sL.backgroundColor + '</label><input id="background-color-selection" type="text" value="#' + window.userBackgroundColor + '" /></div></div>',false);
|
||||
$('#link-color-selection').minicolors({
|
||||
change: function(hex) {
|
||||
changeLinkColor(hex);
|
||||
postNewLinkColor(hex.substring(1));
|
||||
}
|
||||
});
|
||||
$('#background-color-selection').minicolors({
|
||||
change: function(hex) {
|
||||
$('body').css('background-color',hex);
|
||||
postNewBackgroundColor(hex.substring(1));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
@ -244,34 +263,40 @@ $('#settings').click(function(){
|
|||
|
||||
function logoutWithoutReload(doShake) {
|
||||
|
||||
$('#submit-login').removeAttr('disabled');
|
||||
|
||||
// delete any locally stored credentials
|
||||
if(localStorageIsEnabled()) {
|
||||
delete localStorage.autologinUsername;
|
||||
delete localStorage.autologinPassword;
|
||||
}
|
||||
|
||||
$('#user-header').animate({opacity:'0'},800);
|
||||
$('#user-body').animate({opacity:'0'},800);
|
||||
$('#user-footer').animate({opacity:'0'},800);
|
||||
$('.menu-container').animate({opacity:'0'},800);
|
||||
$('#settingslink').fadeOut('slow');
|
||||
$('#search').fadeOut('slow');
|
||||
$('input#username').focus();
|
||||
if(doShake) {
|
||||
$('input#username').css('background-color','pink');
|
||||
$('input#password').css('background-color','pink');
|
||||
}
|
||||
$('#login-content').animate({opacity:'1'},800, function(){
|
||||
if(doShake) {
|
||||
$('#login-content').effect('shake',{distance:5,times:2},function(){
|
||||
$('input#username').animate({backgroundColor:'#fff'},1000);
|
||||
$('input#password').animate({backgroundColor:'#fff'},1000);
|
||||
});
|
||||
// preload default background
|
||||
$('<img/>').attr('src', window.fullUrlToThisQvitterApp + 'img/ekan4.jpg').load(function() {
|
||||
$('body').css('background-image', 'url(' + window.fullUrlToThisQvitterApp + 'img/ekan4.jpg)');
|
||||
|
||||
$('#submit-login').removeAttr('disabled');
|
||||
|
||||
// delete any locally stored credentials
|
||||
if(localStorageIsEnabled()) {
|
||||
delete localStorage.autologinUsername;
|
||||
delete localStorage.autologinPassword;
|
||||
}
|
||||
});
|
||||
$('#page-container').animate({opacity:'1'},200);
|
||||
|
||||
$('#user-header').animate({opacity:'0'},200);
|
||||
$('#user-body').animate({opacity:'0'},200);
|
||||
$('#user-footer').animate({opacity:'0'},200);
|
||||
$('.menu-container').animate({opacity:'0'},200);
|
||||
$('#settingslink').fadeOut('slow');
|
||||
$('#search').fadeOut('slow');
|
||||
$('input#username').focus();
|
||||
if(doShake) {
|
||||
$('input#username').css('background-color','pink');
|
||||
$('input#password').css('background-color','pink');
|
||||
}
|
||||
$('#login-content').animate({opacity:'1'},200, function(){
|
||||
if(doShake) {
|
||||
$('#login-content').effect('shake',{distance:5,times:2},function(){
|
||||
$('input#username').animate({backgroundColor:'#fff'},1000);
|
||||
$('input#password').animate({backgroundColor:'#fff'},1000);
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#page-container').animate({opacity:'1'},200);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,12 @@ $siterootdomain = 'quitter.se'; // no http:// or https:// and no ending slash
|
|||
// API ROOT
|
||||
$apiroot = 'http://quitter.se/api/';
|
||||
|
||||
// DEFAULT BACKGROUND COLOR
|
||||
$defaultbackgroundcolor = '#f4f4f4';
|
||||
|
||||
// DEFAULT LINK COLOR
|
||||
$defaultlinkcolor = '#0084B4';
|
||||
|
||||
// TIME BETWEEN POLLING
|
||||
$timebetweenpolling = 5000; // ms
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user