1 // Handle .hide-if-no-js and .hide-if-js styles
\r
2 $(document).ready(function(){
\r
3 $('.hide-if-no-js').removeClass('hide-if-no-js');
\r
4 $('.hide-if-js').hide();
\r
7 // Change an element text an revert in a smooth pulse. el is an element id like '#copybox h2'
\r
8 function html_pulse( el, newtext ){
\r
9 var oldtext = $(el).html();
\r
10 // Fast pulse to "Copied" and revert
\r
19 "slow", 1, // this fades from 1 to 1: just a 'sleep(1)' actually
\r
21 $(el).fadeTo("normal", 0.01, function(){$(el).html( oldtext ).css('opacity', 1)});
\r
30 // Update feedback message
\r
31 function feedback(msg, type, delay) {
\r
32 close = ( type == 'fail' || type == 'error' ) ? true : false;
\r
33 delay = delay || ( close == true ? 10000 : 3500 );
\r
35 html: '<span>'+msg+'</span>',
\r
37 animationSpeed: "normal",
\r
49 data: {action:'logout'},
\r
50 success: function() {
\r
51 window.parent.location.href = window.parent.location.href;
\r
56 // Begin the spinning animation & disable a button
\r
57 function add_loading(el) {
\r
58 $(el).attr("disabled", "disabled").addClass('disabled').addClass('loading');
\r
61 // End spinning animation
\r
62 function end_loading(el) {
\r
63 $(el).removeClass('loading');
\r
66 // Un-disable an element
\r
67 function end_disable(el) {
\r
68 $(el).removeAttr("disabled").removeClass('disabled');
\r
72 function trim_long_string( string, length) {
\r
73 var newstring = string;
\r
74 length = length || 60;
\r
75 if ( newstring.length > length ) {
\r
76 newstring = newstring.substr(0, (length - 5) ) + '[...]';
\r
81 // Get the var=xxx from a query string
\r
82 function get_var_from_query( url, varname, default_val ) {
\r
83 if( varname == undefined ) {
\r
86 if( default_val == undefined ) {
\r
91 url = url.split('?')[1].split('&').reverse().filter(function(e){
\r
92 var pair = e.split('=');
\r
93 return( pair[0] == varname );
\r
94 })[0].split('=')[1];
\r
96 // split the query string on '&', reverse to check last pairs first so that ?ozh=1&ozh=2 matches ozh=2 first
\r
97 // then filter on each pair to find the matching 'varname=something',
\r
98 // which is then returned in a one element array that we split on '=' and take second part. woot!
\r
100 return default_val;
\r
107 * Jquery Cookie plugin
\r
108 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
\r
109 * Dual licensed under the MIT and GPL licenses:
\r
110 * http://www.opensource.org/licenses/mit-license.php
\r
111 * http://www.gnu.org/licenses/gpl.html
\r
112 * Available at http://plugins.jquery.com/files/jquery.cookie.js.txt
\r
114 jQuery.cookie = function(name, value, options) {
\r
115 if (typeof value != 'undefined') { // name and value given, set cookie
\r
116 options = options || {};
\r
117 if (value === null) {
\r
119 options.expires = -1;
\r
122 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
\r
124 if (typeof options.expires == 'number') {
\r
126 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
\r
128 date = options.expires;
\r
130 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
\r
132 // CAUTION: Needed to parenthesize options.path and options.domain
\r
133 // in the following expressions, otherwise they evaluate to undefined
\r
134 // in the packed version for some reason...
\r
135 var path = options.path ? '; path=' + (options.path) : '';
\r
136 var domain = options.domain ? '; domain=' + (options.domain) : '';
\r
137 var secure = options.secure ? '; secure' : '';
\r
138 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
\r
139 } else { // only name given, get cookie
\r
140 var cookieValue = null;
\r
141 if (document.cookie && document.cookie != '') {
\r
142 var cookies = document.cookie.split(';');
\r
143 for (var i = 0; i < cookies.length; i++) {
\r
144 var cookie = jQuery.trim(cookies[i]);
\r
145 // Does this cookie string begin with the name we want?
\r
146 if (cookie.substring(0, name.length + 1) == (name + '=')) {
\r
147 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
\r
152 return cookieValue;
\r