PageSourceSearch

https://www.1pondo.tv/vendor/videojs-persistvolume-0.1.2/videojs.persistvolume.js

js 1pondo.tv collected 2026-10-08 11:49:48 UTC 3,629 bytes, 123 lines download raw bytes

1"use strict";
2(function(factory){
3  /*!
4   * Custom Universal Module Definition (UMD)
5   *
6   * Video.js will never be a non-browser lib so we can simplify UMD a bunch and
7   * still support requirejs and browserify. This also needs to be closure
8   * compiler compatible, so string keys are used.
9   */
10  if (typeof define === 'function' && define['amd']) {
11    define(['./video'], function(vjs){ factory(window, document, vjs) });
12  // checking that module is an object too because of umdjs/umd#35
13  } else if (typeof exports === 'object' && typeof module === 'object') {
14    factory(window, document, require('video.js'));
15  } else {
16    factory(window, document, videojs);
17  }
18
19})(function(window, document, vjs) {
20  //cookie functions from https://developer.mozilla.org/en-US/docs/DOM/document.cookie
21  var
22  getCookieItem = function(sKey) {
23    if (!sKey || !hasCookieItem(sKey)) { return null; }
24    var reg_ex = new RegExp(
25      "(?:^|.*;\\s*)" +
26      window.escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") +
27      "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"
28    );
29    return window.unescape(document.cookie.replace(reg_ex,"$1"));
30  },
31
32  setCookieItem = function(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
33    if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return; }
34    var sExpires = "";
35    if (vEnd) {
36      switch (vEnd.constructor) {
37        case Number:
38          sExpires = vEnd === Infinity ? "; expires=Tue, 19 Jan 2038 03:14:07 GMT" : "; max-age=" + vEnd;
39          break;
40        case String:
41          sExpires = "; expires=" + vEnd;
42          break;
43        case Date:
44          sExpires = "; expires=" + vEnd.toGMTString();
45          break;
46      }
47    }
48    document.cookie =
49      window.escape(sKey) + "=" +
50      window.escape(sValue) +
51      sExpires +
52      (sDomain ? "; domain=" + sDomain : "") +
53      (sPath ? "; path=" + sPath : "") +
54      (bSecure ? "; secure" : "");
55  },
56
57  hasCookieItem = function(sKey) {
58    return (new RegExp(
59      "(?:^|;\\s*)" +
60      window.escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") +
61      "\\s*\\=")
62    ).test(document.cookie);
63  },
64
65  hasLocalStorage = function() {
66    try {
67      window.localStorage.setItem('persistVolume', 'persistVolume');
68      window.localStorage.removeItem('persistVolume');
69      return true;
70    } catch(e) {
71      return false;
72    }
73  },
74  getStorageItem = function(key) {
75    return hasLocalStorage() ? window.localStorage.getItem(key) : getCookieItem(key);
76  },
77  setStorageItem = function(key, value) {
78    return hasLocalStorage() ? window.localStorage.setItem(key, value) : setCookieItem(key, value, Infinity, '/');
79  },
80
81  extend = function(obj) {
82    var arg, i, k;
83    for (i = 1; i < arguments.length; i++) {
84      arg = arguments[i];
85      for (k in arg) {
86        if (arg.hasOwnProperty(k)) {
87          obj[k] = arg[k];
88        }
89      }
90    }
91    return obj;
92  },
93
94  defaults = {
95    namespace: ""
96  },
97
98  volumePersister = function(options) {
99    var player = this;
100    var settings = extend({}, defaults, options || {});
101
102    var key = settings.namespace + '-' + 'volume';
103    var muteKey = settings.namespace + '-' + 'mute';
104
105    player.on("volumechange", function() {
106      setStorageItem(key, player.volume());
107      setStorageItem(muteKey, player.muted());
108    });
109
110    var persistedVolume = getStorageItem(key);
111    if(persistedVolume !== null){
112      player.volume(persistedVolume);
113    }
114
115    var persistedMute = getStorageItem(muteKey);
116    if(persistedMute !== null){
117      player.muted('true' === persistedMute);
118    }
119  };
120
121  vjs.registerPlugin("persistvolume", volumePersister);
122
123});

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.