first commit
[osm/LW-UI.git] / static / src / adminlte_session_storage.js
1 /*
2 Copyright 2017 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 function setCookie(cname, cvalue, exdays) {
18 var d = new Date();
19 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
20 var expires = "expires=" + d.toUTCString();
21 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
22 }
23
24 function getCookie(cname) {
25 var name = cname + "=";
26 var ca = document.cookie.split(';');
27 for (var i = 0; i < ca.length; i++) {
28 var c = ca[i];
29 while (c.charAt(0) == ' ') {
30 c = c.substring(1);
31 }
32 if (c.indexOf(name) == 0) {
33 return c.substring(name.length, c.length);
34 }
35 }
36 return "";
37 }
38
39
40 $(document).ready(function () {
41
42 //event section
43
44 // save if sidebar is collapsed or not
45 $('.sidebar-toggle').click(function (event) {
46 event.preventDefault();
47 var cookie = getCookie("collapsed_sidebar");
48 if (cookie != "") {
49 setCookie("collapsed_sidebar", "")
50 } else {
51 setCookie("collapsed_sidebar", "1")
52 }
53 });
54
55 });