Merge pull request #876 from codenift/js_cookie
Updated jquery.cookie to js.cookie
This commit is contained in:
commit
cbbb148d2b
|
@ -91,7 +91,7 @@ class PageLayoutInitPlugin extends Zend_Controller_Plugin_Abstract
|
|||
$userType = "";
|
||||
}
|
||||
$view->headScript()->appendScript("var userType = '$userType';");
|
||||
|
||||
|
||||
// Dropzone also accept file extensions and doesn't correctly extract certain mimetypes (eg. FLAC - try it),
|
||||
// so we append the file extensions to the list of mimetypes and that makes it work.
|
||||
$mimeTypes = FileDataHelper::getAudioMimeTypeArray();
|
||||
|
@ -181,7 +181,7 @@ class PageLayoutInitPlugin extends Zend_Controller_Plugin_Abstract
|
|||
->appendFile($baseUrl . 'js/qtip/jquery.qtip.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/jplayer/jquery.jplayer.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/sprintf/sprintf-0.7-beta1.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/cookie/jquery.cookie.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/cookie/js.cookie.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/i18n/jquery.i18n.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'locale/general-translation-table?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'locale/datatables-translation-table?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
|
|
|
@ -41,7 +41,7 @@ var nextSongPrepare = true;
|
|||
var nextShowPrepare = true;
|
||||
|
||||
function secondsTimer(){
|
||||
/* This function constantly calls itself every 'uiUpdateInterval'
|
||||
/* This function constantly calls itself every 'uiUpdateInterval'
|
||||
* micro-seconds and is responsible for updating the UI. */
|
||||
if (localRemoteTimeOffset !== null){
|
||||
var date = new Date();
|
||||
|
@ -59,7 +59,7 @@ function newSongStart(){
|
|||
if (nextSong.type == 'track') {
|
||||
currentSong = nextSong;
|
||||
nextSong = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nextShowStart(){
|
||||
|
@ -83,13 +83,13 @@ function updateProgressBarValue(){
|
|||
var songPercentDone = 0;
|
||||
var scheduled_play_div = $("#scheduled_play_div");
|
||||
var scheduled_play_line_to_switch = scheduled_play_div.parent().find(".line-to-switch");
|
||||
|
||||
|
||||
if (currentSong !== null){
|
||||
var songElapsedTime = 0;
|
||||
songPercentDone = (approximateServerTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100;
|
||||
songElapsedTime = approximateServerTime - currentSong.songStartPosixTime;
|
||||
if (songPercentDone < 0) {
|
||||
songPercentDone = 0;
|
||||
songPercentDone = 0;
|
||||
//currentSong = null;
|
||||
} else if (songPercentDone > 100) {
|
||||
songPercentDone = 100;
|
||||
|
@ -211,12 +211,12 @@ function calculateTimeToNextSong() {
|
|||
if (approximateServerTime === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (newSongTimeoutId !== null) {
|
||||
/* We have a previous timeout set, let's unset it */
|
||||
clearTimeout(newSongTimeoutId);
|
||||
newSongTimeoutId = null;
|
||||
}
|
||||
}
|
||||
|
||||
var diff = nextSong.songStartPosixTime - approximateServerTime;
|
||||
if (diff < 0) diff=0;
|
||||
|
@ -233,7 +233,7 @@ function calculateTimeToNextShow() {
|
|||
/* We have a previous timeout set, let's unset it */
|
||||
clearTimeout(newShowTimeoutId);
|
||||
newShowTimeoutId = null;
|
||||
}
|
||||
}
|
||||
|
||||
var diff = nextShow[0].showStartPosixTime - approximateServerTime;
|
||||
if (diff < 0) diff=0;
|
||||
|
@ -256,7 +256,7 @@ function parseItems(obj){
|
|||
calcAdditionalData(nextSong);
|
||||
calculateTimeToNextSong();
|
||||
}
|
||||
|
||||
|
||||
currentShow = new Array();
|
||||
if (obj.currentShow.length > 0) {
|
||||
calcAdditionalShowData(obj.currentShow);
|
||||
|
@ -269,7 +269,7 @@ function parseItems(obj){
|
|||
nextShow = obj.nextShow;
|
||||
calculateTimeToNextShow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
|
||||
var date = new Date();
|
||||
|
@ -281,7 +281,7 @@ function parseSourceStatus(obj){
|
|||
var master_div = $("#master_dj_div");
|
||||
var live_li = live_div.parent();
|
||||
var master_li = master_div.parent();
|
||||
|
||||
|
||||
if(obj.live_dj_source == false){
|
||||
live_li.find(".line-to-switch").attr("class", "line-to-switch off");
|
||||
live_div.removeClass("ready");
|
||||
|
@ -289,7 +289,7 @@ function parseSourceStatus(obj){
|
|||
live_li.find(".line-to-switch").attr("class", "line-to-switch on");
|
||||
live_div.addClass("ready");
|
||||
}
|
||||
|
||||
|
||||
if(obj.master_dj_source == false){
|
||||
master_li.find(".line-to-switch").attr("class", "line-to-switch off");
|
||||
master_div.removeClass("ready");
|
||||
|
@ -300,43 +300,43 @@ function parseSourceStatus(obj){
|
|||
}
|
||||
|
||||
function parseSwitchStatus(obj){
|
||||
|
||||
|
||||
if(obj.live_dj_source == "on"){
|
||||
live_dj_on_air = true;
|
||||
}else{
|
||||
live_dj_on_air = false;
|
||||
}
|
||||
|
||||
|
||||
if(obj.master_dj_source == "on"){
|
||||
master_dj_on_air = true;
|
||||
}else{
|
||||
master_dj_on_air = false;
|
||||
}
|
||||
|
||||
|
||||
if(obj.scheduled_play == "on"){
|
||||
scheduled_play_on_air = true;
|
||||
}else{
|
||||
scheduled_play_on_air = false;
|
||||
}
|
||||
|
||||
|
||||
var scheduled_play_switch = $("#scheduled_play.source-switch-button");
|
||||
var live_dj_switch = $("#live_dj.source-switch-button");
|
||||
var master_dj_switch = $("#master_dj.source-switch-button");
|
||||
|
||||
|
||||
scheduled_play_switch.find("span").html(obj.scheduled_play);
|
||||
if(scheduled_play_on_air){
|
||||
scheduled_play_switch.addClass("active");
|
||||
}else{
|
||||
scheduled_play_switch.removeClass("active");
|
||||
}
|
||||
|
||||
|
||||
live_dj_switch.find("span").html(obj.live_dj_source);
|
||||
if(live_dj_on_air){
|
||||
live_dj_switch.addClass("active");
|
||||
}else{
|
||||
live_dj_switch.removeClass("active");
|
||||
}
|
||||
|
||||
|
||||
master_dj_switch.find("span").html(obj.master_dj_source)
|
||||
if(master_dj_on_air){
|
||||
master_dj_switch.addClass("active");
|
||||
|
@ -351,7 +351,7 @@ function controlOnAirLight(){
|
|||
onAirOffIterations = 0;
|
||||
} else if (onAirOffIterations < 20) {
|
||||
//if less than 4 seconds have gone by (< 20 executions of this function)
|
||||
//then keep the ON-AIR light on. Only after at least 3 seconds have gone by,
|
||||
//then keep the ON-AIR light on. Only after at least 3 seconds have gone by,
|
||||
//should we be allowed to turn it off. This is to stop the light from temporarily turning
|
||||
//off between tracks: CC-3725
|
||||
onAirOffIterations++;
|
||||
|
@ -364,7 +364,7 @@ function controlSwitchLight(){
|
|||
var live_li= $("#live_dj_div").parent();
|
||||
var master_li = $("#master_dj_div").parent();
|
||||
var scheduled_play_li = $("#scheduled_play_div").parent();
|
||||
|
||||
|
||||
if((scheduled_play_on_air && scheduled_play_source) && !live_dj_on_air && !master_dj_on_air){
|
||||
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
|
@ -385,8 +385,8 @@ function controlSwitchLight(){
|
|||
}
|
||||
|
||||
function getScheduleFromServer(){
|
||||
$.ajax({ url: baseUrl+"Schedule/get-current-playlist/format/json",
|
||||
dataType:"json",
|
||||
$.ajax({ url: baseUrl+"Schedule/get-current-playlist/format/json",
|
||||
dataType:"json",
|
||||
success:function(data){
|
||||
parseItems(data.entries);
|
||||
parseSourceStatus(data.source_status);
|
||||
|
@ -440,7 +440,7 @@ function setSwitchListener(ele){
|
|||
|
||||
function kickSource(ele){
|
||||
var sourcename = $(ele).attr('id');
|
||||
|
||||
|
||||
$.get(baseUrl+"Dashboard/disconnect-source/format/json/sourcename/"+sourcename, function(data){
|
||||
if(data.error){
|
||||
alert(data.error);
|
||||
|
@ -458,7 +458,7 @@ function init() {
|
|||
secondsTimer();
|
||||
|
||||
setupQtip();
|
||||
|
||||
|
||||
$('.listen-control-button').click(function() {
|
||||
if (stream_window == null || stream_window.closed)
|
||||
stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=158');
|
||||
|
@ -490,15 +490,15 @@ $(document).ready(function() {
|
|||
if ($('.errors').length === 0) {
|
||||
setCurrentUserPseudoPassword();
|
||||
}
|
||||
|
||||
|
||||
$('body').on('click','#current-user', function() {
|
||||
$.ajax({
|
||||
url: baseUrl+'user/edit-user/format/json'
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('body').on('click', '#cu_save_user', function() {
|
||||
$.cookie("airtime_locale", $('#cu_locale').val(), {path: '/'});
|
||||
Cookies.set('airtime_locale', $('#cu_locale').val(), {path: '/'});
|
||||
});
|
||||
|
||||
// When the 'Listen' button is clicked we set the width
|
||||
|
|
|
@ -4,6 +4,6 @@ $(window).load(function() {
|
|||
|
||||
$(document).ready(function() {
|
||||
$("#submit").click(function() {
|
||||
$.cookie("airtime_locale", $("#locale").val(), {path: '/'});
|
||||
Cookies.set('airtime_locale', $('#locale').val(), {path: '/'});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/*!
|
||||
* jQuery Cookie Plugin v1.3
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2011, Klaus Hartl
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.opensource.org/licenses/GPL-2.0
|
||||
*/
|
||||
(function ($, document, undefined) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function raw(s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
function decoded(s) {
|
||||
return decodeURIComponent(s.replace(pluses, ' '));
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// write
|
||||
if (value !== undefined) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (value === null) {
|
||||
options.expires = -1;
|
||||
}
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setDate(t.getDate() + days);
|
||||
}
|
||||
|
||||
value = config.json ? JSON.stringify(value) : String(value);
|
||||
|
||||
return (document.cookie = [
|
||||
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// read
|
||||
var decode = config.raw ? raw : decoded;
|
||||
var cookies = document.cookie.split('; ');
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
if (decode(parts.shift()) === key) {
|
||||
var cookie = decode(parts.join('='));
|
||||
return config.json ? JSON.parse(cookie) : cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) !== null) {
|
||||
$.cookie(key, null, options);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
})(jQuery, document);
|
|
@ -0,0 +1,163 @@
|
|||
/*!
|
||||
* JavaScript Cookie v2.2.1
|
||||
* https://github.com/js-cookie/js-cookie
|
||||
*
|
||||
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
||||
* Released under the MIT license
|
||||
*/
|
||||
;(function (factory) {
|
||||
var registeredInModuleLoader;
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(factory);
|
||||
registeredInModuleLoader = true;
|
||||
}
|
||||
if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
registeredInModuleLoader = true;
|
||||
}
|
||||
if (!registeredInModuleLoader) {
|
||||
var OldCookies = window.Cookies;
|
||||
var api = window.Cookies = factory();
|
||||
api.noConflict = function () {
|
||||
window.Cookies = OldCookies;
|
||||
return api;
|
||||
};
|
||||
}
|
||||
}(function () {
|
||||
function extend () {
|
||||
var i = 0;
|
||||
var result = {};
|
||||
for (; i < arguments.length; i++) {
|
||||
var attributes = arguments[ i ];
|
||||
for (var key in attributes) {
|
||||
result[key] = attributes[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function decode (s) {
|
||||
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
||||
}
|
||||
|
||||
function init (converter) {
|
||||
function api() {}
|
||||
|
||||
function set (key, value, attributes) {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
attributes = extend({
|
||||
path: '/'
|
||||
}, api.defaults, attributes);
|
||||
|
||||
if (typeof attributes.expires === 'number') {
|
||||
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
|
||||
}
|
||||
|
||||
// We're using "expires" because "max-age" is not supported by IE
|
||||
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
||||
|
||||
try {
|
||||
var result = JSON.stringify(value);
|
||||
if (/^[\{\[]/.test(result)) {
|
||||
value = result;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
value = converter.write ?
|
||||
converter.write(value, key) :
|
||||
encodeURIComponent(String(value))
|
||||
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
||||
|
||||
key = encodeURIComponent(String(key))
|
||||
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
|
||||
.replace(/[\(\)]/g, escape);
|
||||
|
||||
var stringifiedAttributes = '';
|
||||
for (var attributeName in attributes) {
|
||||
if (!attributes[attributeName]) {
|
||||
continue;
|
||||
}
|
||||
stringifiedAttributes += '; ' + attributeName;
|
||||
if (attributes[attributeName] === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Considers RFC 6265 section 5.2:
|
||||
// ...
|
||||
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
||||
// character:
|
||||
// Consume the characters of the unparsed-attributes up to,
|
||||
// not including, the first %x3B (";") character.
|
||||
// ...
|
||||
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
||||
}
|
||||
|
||||
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
||||
}
|
||||
|
||||
function get (key, json) {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var jar = {};
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all.
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
var i = 0;
|
||||
|
||||
for (; i < cookies.length; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var cookie = parts.slice(1).join('=');
|
||||
|
||||
if (!json && cookie.charAt(0) === '"') {
|
||||
cookie = cookie.slice(1, -1);
|
||||
}
|
||||
|
||||
try {
|
||||
var name = decode(parts[0]);
|
||||
cookie = (converter.read || converter)(cookie, name) ||
|
||||
decode(cookie);
|
||||
|
||||
if (json) {
|
||||
try {
|
||||
cookie = JSON.parse(cookie);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
jar[name] = cookie;
|
||||
|
||||
if (key === name) {
|
||||
break;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return key ? jar[key] : jar;
|
||||
}
|
||||
|
||||
api.set = set;
|
||||
api.get = function (key) {
|
||||
return get(key, false /* read as raw */);
|
||||
};
|
||||
api.getJSON = function (key) {
|
||||
return get(key, true /* read as json */);
|
||||
};
|
||||
api.remove = function (key, attributes) {
|
||||
set(key, '', extend(attributes, {
|
||||
expires: -1
|
||||
}));
|
||||
};
|
||||
|
||||
api.defaults = {};
|
||||
|
||||
api.withConverter = init;
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
return init(function () {});
|
||||
}));
|
Loading…
Reference in New Issue