1/*! 2 3 * ihavecookies - jQuery plugin for displaying cookie/privacy message 4 5 * 6 7 * Copyright (c) 2018 Ketan Mistry (https://iamketan.com.au) 8 9 * 10 11 * Licensed under the MIT license: 12 13 * http://www.opensource.org/licenses/mit-license.php 14 15 * 16 17 * Version: 0.3 18 19 * 20 21 */ 22 23(function($) { 24 25 26 27 /* 28 29 |-------------------------------------------------------------------------- 30 31 | Cookie Message 32 33 |-------------------------------------------------------------------------- 34 35 | 36 37 | Displays the cookie message on first visit or 30 days after their 38 39 | last visit. 40 41 | 42 43 | Options: 44 45 | - title : Title for the popup 46 47 | - message : Message to display within the popup 48 49 | - link : Link to privacy page 50 51 | - delay : Time before the popup is displayed after page load 52 53 | - expires : Days for the cookie to expire 54 55 | - onAccept : Optional callback function when 'Accept' button is clicked 56 57 | - uncheckBoxes : Unchecks all checkboxes on page load that have class 58 59 | .ihavecookies applied to them. Set to true to turn this 60 61 | option on 62 63 | - moreInfoLabel : Label for the link to privacy policy 64 65 | - acceptBtnLabel : Label for the accept cookies button 66 67 | - cookieTypes : Array of cookie types to list with checkboxes 68 69 | 70 71 */ 72 73 $.fn.ihavecookies = function(options) { 74 75 76 77 var $element = $(this); 78 79 80 81 // Set defaults 82 83 var settings = $.extend({ 84 85 cookieTypes: [ 86 { 87 type: 'Yangilangan Markaz va Bo\'limlar', 88 // value: 'preferences', 89 // description: 'Ushbu cookie-lar sayt sozlamalaringiz bilan bog\'liq, masalan, foydalanuvchi nomingizni yoki sayt ranglarini eslab qolish.' 90 }, 91 { 92 type: 'Yangiliklar va E\'lonlar', 93 // value: 'preferences', 94 // description: 'Ushbu cookie-lar sayt sozlamalaringiz bilan bog\'liq, masalan, foydalanuvchi nomingizni yoki sayt ranglarini eslab qolish.' 95 }, 96 { 97 type: 'Yangilangan Fakultetlar', 98 // value: 'analytics', 99 // description: 'Saytga tashriflar, brauzer turlari va boshqa statistik ma\'lumotlar bilan bog\'liq cookie-lar.' 100 }, 101 { 102 type: 'Yangi yo\'nalishlar', 103 // value: 'marketing', 104 // description: 'Marketing bilan bog\'liq cookie-lar, masalan, yangiliklar, ijtimoiy tarmoqlar va boshqalar.' 105 }, 106 { 107 type: "Ko'pgina o'zgarishlar", 108 // value: 'changes', 109 // description: 'Saytdagi eng so\'nggi o\'zgarishlar va yangilanishlar.' 110 }, 111 { 112 type: "Yangilangan Kafedralar", 113 // value: 'departments', 114 // description: 'Kafedralar va ularning yangiliklari bilan bog\'liq cookie-lar.' 115 }, 116 117 { 118 type: "Saytni mobil qurulmalar uchun moslash", 119 // value: 'departments', 120 // description: 'Kafedralar va ularning yangiliklari bilan bog\'liq cookie-lar.' 121 } 122 ], 123 124 title: 'Cookie-lar va Maxfiylik', 125 message: 'Cookie-lar savatdan foydalanish va saytda shaxsiy tajribangizni shakllantirish imkonini beradi. Ular bizga qaysi sahifalarga tashrif buyurilganligini, reklamalar va qidiruvlarning samaradorligini o\'lchashga yordam beradi, shuningdek, foydalanuvchilar xatti-harakatlarini tahlil qilish orqali mahsulot va xizmatlarimizni yaxshilash imkoniyatini beradi.', 126 link: '/privacy/', 127 delay: 2000, 128 expires: 30, 129 moreInfoLabel: 'Batafsil ma\'lumot', 130 acceptBtnLabel: 'Cookie-larni qabul qilish', 131 advancedBtnLabel: "Qanday o'zgarishlar bo'ldi?", 132 onAccept: function(){}, 133 uncheckBoxes: false 134 135 }, options); 136 137 138 var myCookie = getCookie('cookieControl'); 139 140 var myCookiePrefs = getCookie('cookieControlPrefs'); 141 142 if (!myCookie || !myCookiePrefs) { 143 144 145 146 // Set the 'necessary' cookie type checkbox which can not be unchecked 147 var cookieTypes = '<li class="d-flex align-items-center p-2 mb-2 rounded w-100" style="background-color: #952441; color: white;">' + 148 '<input type="checkbox" class="me-2" name="gdpr[]" value="necessary" checked="checked" disabled="disabled">' + 149 '<label class="mb-0 text-white" title="Saytning asosiy ishlashi uchun zarur bo\'lgan tizim scriptlari">' + 150 'Yangilangan Sistema</label></li>'; 151 152 // Generate list of cookie type checkboxes 153 154 $.each(settings.cookieTypes, function(index, field) { 155 156 if (field.type !== '' && field.value !== '') { 157 158 var cookieTypeDescription = ''; 159 160 if (field.description !== false) { 161 162 cookieTypeDescription = ' title="' + field.description + '"'; 163 164 } 165 166 cookieTypes += '<li class="d-flex align-items-center p-2 mb-2 rounded w-100" style="background-color: #103b93; color: white;">' + 167 '<input type="checkbox" class="me-2" id="gdpr-cookietype-' + field.value + 168 '" name="gdpr[]" value="' + field.value + '" data-auto="on">' + 169 '<label class="mb-0 text-white" for="gdpr-cookietype-' + field.value + '"' + 170 cookieTypeDescription + '>
170' + field.type + '</label></li>'; 171 } 172 173 }); 174 175 176 177 // Display cookie message on page 178 179 var cookieMessage = '<div id="gdpr-cookie-message"><h4>' + settings.title + '</h4><p>' + settings.message + ' <a href="' + settings.link + '">' + settings.moreInfoLabel + '</a><div id="gdpr-cookie-types" style="display:none;"><h5>O\'zgarishlar haqida qisqacha</h5><ul>' + cookieTypes + '</ul></div><p><button id="gdpr-cookie-accept" type="button">' + settings.acceptBtnLabel + '</button><button id="gdpr-cookie-advanced" type="button">' + settings.advancedBtnLabel + '</button></p></div>'; 180 181 setTimeout(function(){ 182 183 $($element).append(cookieMessage); 184 185 $('#gdpr-cookie-message').hide().fadeIn('slow'); 186 187 }, settings.delay); 188 189 190 191 // When accept button is clicked drop cookie 192 193 $('body').on('click','#gdpr-cookie-accept', function(){ 194 195 // Set cookie 196 197 dropCookie(true, settings.expires); 198 199 200 201 // If 'data-auto' is set to ON, tick all checkboxes because 202 203 // the user hasn't clicked the customise cookies button 204 205 $('input[name="gdpr[]"][data-auto="on"]').prop('checked', true); 206 207 208 209 // Save users cookie preferences (in a cookie!) 210 211 var prefs = []; 212 213 $.each($('input[name="gdpr[]"]').serializeArray(), function(i, field){ 214 215 prefs.push(field.value); 216 217 }); 218 219 setCookie('cookieControlPrefs', JSON.stringify(prefs), 365); 220 221 222 223 // Run callback function 224 225 settings.onAccept.call(this); 226 227 }); 228 229 230 231 // Toggle advanced cookie options 232 233 $('body').on('click', '#gdpr-cookie-advanced', function(){ 234 235 // Uncheck all checkboxes except for the disabled 'necessary' 236 237 // one and set 'data-auto' to OFF for all. The user can now 238 239 // select the cookies they want to accept. 240 241 $('input[name="gdpr[]"]:not(:disabled)').attr('data-auto', 'off').prop('checked', false); 242 243 $('#gdpr-cookie-types').slideDown('fast', function(){ 244 245 $('#gdpr-cookie-advanced').prop('disabled', true); 246 247 }); 248 249 }); 250 251 252 253 } else { 254 255 var cookieVal = true; 256 257 if (myCookie == 'false') { 258 259 cookieVal = false; 260 261 } 262 263 dropCookie(cookieVal, settings.expires); 264 265 } 266 267 268 269 // Uncheck any checkboxes on page load 270 271 if (settings.uncheckBoxes === true) { 272 273 $('input[type="checkbox"].ihavecookies').prop('checked', false); 274 275 } 276 277 278 279 }; 280 281 282 283 // Method to get cookie value 284 285 $.fn.ihavecookies.cookie = function() { 286 287 var preferences = getCookie('cookieControlPrefs'); 288 289 return JSON.parse(preferences); 290 291 }; 292 293 294 295 // Method to check if user cookie preference exists 296 297 $.fn.ihavecookies.preference = function(cookieTypeValue) { 298 299 var control = getCookie('cookieControl'); 300 301 var preferences = getCookie('cookieControlPrefs'); 302 303 preferences = JSON.parse(preferences); 304 305 if (control === false) { 306 307 return false; 308 309 } 310 311 if (preferences === false || preferences.indexOf(cookieTypeValue) === -1) { 312 313 return false; 314 315 } 316 317 return true; 318 319 }; 320 321 322 323 /* 324 325 |-------------------------------------------------------------------------- 326 327 | Drop Cookie 328 329 |-------------------------------------------------------------------------- 330 331 | 332 333 | Function to drop the cookie with a boolean value of true. 334 335 | 336 337 */ 338 339 var dropCookie = function(value, expiryDays) { 340 341 setCookie('cookieControl', value, expiryDays); 342 343 $('#gdpr-cookie-message').fadeOut('fast', function() { 344 345 $(this).remove(); 346 347 }); 348 349 }; 350 351 352 353 /* 354 355 |-------------------------------------------------------------------------- 356 357 | Set Cookie 358 359 |-------------------------------------------------------------------------- 360 361 | 362 363 | Sets cookie with 'name' and value of 'value' for 'expiry_days'. 364 365 | 366 367 */ 368 369 var setCookie = function(name, value, expiry_days) { 370 371 var d = new Date(); 372 373 d.setTime(d.getTime() + (expiry_days*24*60*60*1000)); 374 375 var expires = "expires=" + d.toUTCString(); 376 377 document.cookie = name + "=" + value + ";" + expires + ";path=/"; 378 379 return getCookie(name); 380 381 }; 382 383 384 385 /* 386 387 |-------------------------------------------------------------------------- 388 389 | Get Cookie 390 391 |-------------------------------------------------------------------------- 392 393 | 394
395 | Gets cookie called 'name'. 396 397 | 398 399 */ 400 401 var getCookie = function(name) { 402 403 var cookie_name = name + "="; 404 405 var decodedCookie = decodeURIComponent(document.cookie); 406 407 var ca = decodedCookie.split(';'); 408 409 for (var i = 0; i < ca.length; i++) { 410 411 var c = ca[i]; 412 413 while (c.charAt(0) == ' ') { 414 415 c = c.substring(1); 416 417 } 418 419 if (c.indexOf(cookie_name) === 0) { 420 421 return c.substring(cookie_name.length, c.length); 422 423 } 424 425 } 426 427 return false; 428 429 }; 430 431 432 433}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.