1 // Change an element text an revert in a smooth pulse. el is an element id like '#copybox h2'
\r
2 function html_pulse( el, newtext ){
\r
3 var oldtext = $(el).html();
\r
4 // Fast pulse to "Copied" and revert
\r
13 "slow", 1, // this fades from 1 to 1: just a 'sleep(1)' actually
\r
15 $(el).fadeTo("normal", 0.01, function(){$(el).html( oldtext ).css('opacity', 1)});
\r
24 // Update feedback message
\r
25 function feedback(msg, type, delay) {
\r
26 close = ( type == 'fail' || type == 'error' ) ? true : false;
\r
27 delay = delay || ( close == true ? 10000 : 3500 );
\r
29 html: '<span>'+msg+'</span>',
\r
31 animationSpeed: "normal",
\r
43 data: {action:'logout'},
\r
44 success: function() {
\r
45 window.parent.location.href = window.parent.location.href;
\r
50 // Begin the spinning animation & disable a button
\r
51 function add_loading(el) {
\r
52 $(el).attr("disabled", "disabled").addClass('disabled').addClass('loading');
\r
55 // End spinning animation
\r
56 function end_loading(el) {
\r
57 $(el).removeClass('loading');
\r
60 // Un-disable an element
\r
61 function end_disable(el) {
\r
62 $(el).removeAttr("disabled").removeClass('disabled');
\r
66 function trim_long_string( string, length) {
\r
67 var newstring = string;
\r
68 length = length || 60;
\r
69 if ( newstring.length > length ) {
\r
70 newstring = newstring.substr(0, (length - 5) ) + '[...]';
\r
75 // Get the var=xxx from a query string
\r
76 function get_var_from_query( url, varname, default_val ) {
\r
77 if( varname == undefined ) {
\r
80 if( default_val == undefined ) {
\r
85 url = url.split('?')[1].split('&').reverse().filter(function(e){
\r
86 var pair = e.split('=');
\r
87 return( pair[0] == varname );
\r
88 })[0].split('=')[1];
\r
90 // split the query string on '&', reverse to check last pairs first so that ?ozh=1&ozh=2 matches ozh=2 first
\r
91 // then filter on each pair to find the matching 'varname=something',
\r
92 // which is then returned in a one element array that we split on '=' and take second part. woot!
\r
101 * Jquery Cookie plugin
\r
102 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
\r
103 * Dual licensed under the MIT and GPL licenses:
\r
104 * http://www.opensource.org/licenses/mit-license.php
\r
105 * http://www.gnu.org/licenses/gpl.html
\r
106 * Available at http://plugins.jquery.com/files/jquery.cookie.js.txt
\r
108 jQuery.cookie = function(name, value, options) {
\r
109 if (typeof value != 'undefined') { // name and value given, set cookie
\r
110 options = options || {};
\r
111 if (value === null) {
\r
113 options.expires = -1;
\r
116 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
\r
118 if (typeof options.expires == 'number') {
\r
120 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
\r
122 date = options.expires;
\r
124 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
\r
126 // CAUTION: Needed to parenthesize options.path and options.domain
\r
127 // in the following expressions, otherwise they evaluate to undefined
\r
128 // in the packed version for some reason...
\r
129 var path = options.path ? '; path=' + (options.path) : '';
\r
130 var domain = options.domain ? '; domain=' + (options.domain) : '';
\r
131 var secure = options.secure ? '; secure' : '';
\r
132 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
\r
133 } else { // only name given, get cookie
\r
134 var cookieValue = null;
\r
135 if (document.cookie && document.cookie != '') {
\r
136 var cookies = document.cookie.split(';');
\r
137 for (var i = 0; i < cookies.length; i++) {
\r
138 var cookie = jQuery.trim(cookies[i]);
\r
139 // Does this cookie string begin with the name we want?
\r
140 if (cookie.substring(0, name.length + 1) == (name + '=')) {
\r
141 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
\r
146 return cookieValue;
\r