From 0afa7e17cfce3bdb911a1bf840313636fc917b12 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 22 Feb 2012 08:12:12 -0800 Subject: [PATCH] New: Hide Downloaded option added to Upcoming, state is saved in a cookie. --- NzbDrone.Web/NzbDrone.Web.csproj | 1 + NzbDrone.Web/Scripts/jquery.cookie.js | 96 ++++++++++++++++++ .../Views/Shared/_ReferenceLayout.cshtml | 1 + NzbDrone.Web/Views/Upcoming/Index.cshtml | 53 ++++++++++ NzbDrone.Web/packages.config | 1 + .../content/Scripts/jquery.cookie.js | 96 ++++++++++++++++++ .../jquery.cookie.1.0/jquery.cookie.1.0.nupkg | Bin 0 -> 4508 bytes 7 files changed, 248 insertions(+) create mode 100644 NzbDrone.Web/Scripts/jquery.cookie.js create mode 100644 packages/jquery.cookie.1.0/content/Scripts/jquery.cookie.js create mode 100644 packages/jquery.cookie.1.0/jquery.cookie.1.0.nupkg diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 0e0e50b35..c26dc5494 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -338,6 +338,7 @@ + diff --git a/NzbDrone.Web/Scripts/jquery.cookie.js b/NzbDrone.Web/Scripts/jquery.cookie.js new file mode 100644 index 000000000..6df1faca2 --- /dev/null +++ b/NzbDrone.Web/Scripts/jquery.cookie.js @@ -0,0 +1,96 @@ +/** + * Cookie plugin + * + * Copyright (c) 2006 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + +/** + * Create a cookie with the given name and value and other optional parameters. + * + * @example $.cookie('the_cookie', 'the_value'); + * @desc Set the value of a cookie. + * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); + * @desc Create a cookie with all available options. + * @example $.cookie('the_cookie', 'the_value'); + * @desc Create a session cookie. + * @example $.cookie('the_cookie', null); + * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain + * used when the cookie was set. + * + * @param String name The name of the cookie. + * @param String value The value of the cookie. + * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. + * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. + * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. + * If set to null or omitted, the cookie will be a session cookie and will not be retained + * when the the browser exits. + * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). + * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). + * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will + * require a secure protocol (like HTTPS). + * @type undefined + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ + +/** + * Get the value of a cookie with the given name. + * + * @example $.cookie('the_cookie'); + * @desc Get the value of a cookie. + * + * @param String name The name of the cookie. + * @return The value of the cookie. + * @type String + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ +jQuery.cookie = function(name, value, options) { + if (typeof value != 'undefined') { // name and value given, set cookie + options = options || {}; + if (value === null) { + value = ''; + options.expires = -1; + } + var expires = ''; + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { + var date; + if (typeof options.expires == 'number') { + date = new Date(); + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); + } else { + date = options.expires; + } + expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE + } + // CAUTION: Needed to parenthesize options.path and options.domain + // in the following expressions, otherwise they evaluate to undefined + // in the packed version for some reason... + var path = options.path ? '; path=' + (options.path) : ''; + var domain = options.domain ? '; domain=' + (options.domain) : ''; + var secure = options.secure ? '; secure' : ''; + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); + } else { // only name given, get cookie + var cookieValue = null; + if (document.cookie && document.cookie != '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) == (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } +}; \ No newline at end of file diff --git a/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml b/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml index 1c58cb17e..7331ccf19 100644 --- a/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml +++ b/NzbDrone.Web/Views/Shared/_ReferenceLayout.cshtml @@ -30,6 +30,7 @@ @Html.IncludeScript("jquery.hotkeys.js") @Html.IncludeScript("jquery.signalR.min.js") @Html.IncludeScript("jquery.validate.min.js") + @Html.IncludeScript("jquery.cookie.js") @Html.IncludeScript("doTimeout.js") @Html.IncludeScript("NzbDrone/localSearch.js") diff --git a/NzbDrone.Web/Views/Upcoming/Index.cshtml b/NzbDrone.Web/Views/Upcoming/Index.cshtml index f519509ab..c06bb12d8 100644 --- a/NzbDrone.Web/Views/Upcoming/Index.cshtml +++ b/NzbDrone.Web/Views/Upcoming/Index.cshtml @@ -5,6 +5,13 @@ @section HeaderContent { @Html.IncludeCss("Grid.css") + + } @section ActionMenu{ } +
+@Html.CheckBox("hideDownloaded") Hide Downloaded +
+ @@ -117,5 +128,47 @@
@section Scripts{ + } \ No newline at end of file diff --git a/NzbDrone.Web/packages.config b/NzbDrone.Web/packages.config index 40a7b1b26..4c065e51e 100644 --- a/NzbDrone.Web/packages.config +++ b/NzbDrone.Web/packages.config @@ -5,6 +5,7 @@ + diff --git a/packages/jquery.cookie.1.0/content/Scripts/jquery.cookie.js b/packages/jquery.cookie.1.0/content/Scripts/jquery.cookie.js new file mode 100644 index 000000000..6df1faca2 --- /dev/null +++ b/packages/jquery.cookie.1.0/content/Scripts/jquery.cookie.js @@ -0,0 +1,96 @@ +/** + * Cookie plugin + * + * Copyright (c) 2006 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + +/** + * Create a cookie with the given name and value and other optional parameters. + * + * @example $.cookie('the_cookie', 'the_value'); + * @desc Set the value of a cookie. + * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); + * @desc Create a cookie with all available options. + * @example $.cookie('the_cookie', 'the_value'); + * @desc Create a session cookie. + * @example $.cookie('the_cookie', null); + * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain + * used when the cookie was set. + * + * @param String name The name of the cookie. + * @param String value The value of the cookie. + * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. + * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. + * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. + * If set to null or omitted, the cookie will be a session cookie and will not be retained + * when the the browser exits. + * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). + * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). + * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will + * require a secure protocol (like HTTPS). + * @type undefined + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ + +/** + * Get the value of a cookie with the given name. + * + * @example $.cookie('the_cookie'); + * @desc Get the value of a cookie. + * + * @param String name The name of the cookie. + * @return The value of the cookie. + * @type String + * + * @name $.cookie + * @cat Plugins/Cookie + * @author Klaus Hartl/klaus.hartl@stilbuero.de + */ +jQuery.cookie = function(name, value, options) { + if (typeof value != 'undefined') { // name and value given, set cookie + options = options || {}; + if (value === null) { + value = ''; + options.expires = -1; + } + var expires = ''; + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { + var date; + if (typeof options.expires == 'number') { + date = new Date(); + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); + } else { + date = options.expires; + } + expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE + } + // CAUTION: Needed to parenthesize options.path and options.domain + // in the following expressions, otherwise they evaluate to undefined + // in the packed version for some reason... + var path = options.path ? '; path=' + (options.path) : ''; + var domain = options.domain ? '; domain=' + (options.domain) : ''; + var secure = options.secure ? '; secure' : ''; + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); + } else { // only name given, get cookie + var cookieValue = null; + if (document.cookie && document.cookie != '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) == (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } +}; \ No newline at end of file diff --git a/packages/jquery.cookie.1.0/jquery.cookie.1.0.nupkg b/packages/jquery.cookie.1.0/jquery.cookie.1.0.nupkg new file mode 100644 index 0000000000000000000000000000000000000000..1e0df8dafbc58d7ba954fdd1edce194c9ce9a6dc GIT binary patch literal 4508 zcmchb2Ut_d7RMttRz*<|*S5s0YoX*)LNz3^HjpN|pi&LV4F=N4O+qKStF9|PP;hC| zK~d^TC<+3WRiuhWVF3XblwPEX1SIb!AOcT)`}W)Kh40SCWagYXGjnF{|Ca+M^A{{Z zh(D&@|H7@@`-(m=4}lOrOA#9ojx3N00cdfFjQ<+3EmmIAb#Bp@UxdYb(5Of*$bu*g zx&cZZt%gE^bRvU9p*tI(IBc@2E((vs9t5cbHrxX`PGLew*n|!lppLWIOnm@=h{r)1 z0YWpFARTTYGgveN8?LgP0VaXyN^k}N4K+1w0FLIP57ca*$R9kJ;D30eQHU%C#2~ZL zL8=wFeHx9`1g!?mGDIl88ftVl>g)}A^ zpbiqWwe+0Sopkl|Ks}5eK^KJt{z?%4)3g8@$R>~oYyv=Jus~HN3$|vlDIhc>#1D%C zfh;bC2tuE=0SM|C9S}nXwbjX57z~IZ5S-N2)U@4qz zx;@h9-B&PKJ^lusp>P_25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