code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function initParams(uri, options, callback) {
var params = uri
if (isFunction(options)) {
callback = options
if (typeof uri === "string") {
params = {uri:uri}
}
} else {
params = xtend(options, {uri: uri})
}
params.callback = callback
return params
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | initParams | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function createXHR(uri, options, callback) {
options = initParams(uri, options, callback)
return _createXHR(options)
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | createXHR | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function _createXHR(options) {
if(typeof options.callback === "undefined"){
throw new Error("callback argument missing")
}
var called = false
var callback = function cbOnce(err, response, body){
if(!called){
called = true
options.callback(err, response, body)
... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | _createXHR | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
callback = function cbOnce(err, response, body){
if(!called){
called = true
options.callback(err, response, body)
}
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | callback | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function readystatechange() {
if (xhr.readyState === 4) {
setTimeout(loadFunc, 0)
}
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | readystatechange | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function getBody() {
// Chrome with requestType=blob throws errors arround when even testing access to responseText
var body = undefined
if (xhr.response) {
body = xhr.response
} else {
body = xhr.responseText || getXml(xhr)
}
if (isJson) {
... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | getBody | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function errorFunc(evt) {
clearTimeout(timeoutTimer)
if(!(evt instanceof Error)){
evt = new Error("" + (evt || "Unknown XMLHttpRequest Error") )
}
evt.statusCode = 0
return callback(evt, failureResponse)
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | errorFunc | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function loadFunc() {
if (aborted) return
var status
clearTimeout(timeoutTimer)
if(options.useXDR && xhr.status===undefined) {
//IE8 CORS GET successful response doesn't have a status field, but body is fine
status = 200
} else {
status = (xhr.... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | loadFunc | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function getXml(xhr) {
// xhr.responseXML will throw Exception "InvalidStateError" or "DOMException"
// See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML.
try {
if (xhr.responseType === "document") {
return xhr.responseXML
}
var firefoxBugTak... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | getXml | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function extend() {
var target = {}
for (var i = 0; i < arguments.length; i++) {
var source = arguments[i]
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
target[key] = source[key]
}
}
}
return target
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | extend | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
OpenFrameIcon = function OpenFrameIcon(parent) {
var _this = this;
_classCallCheck(this, OpenFrameIcon);
this.parent = parent;
this.el = document.createElement('div');
this.el.setAttribute('class', 'glslGallery_openFrameIcon');
this.el.innerHTML = '[o]';
this.el.addEventListener('click', ... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | OpenFrameIcon | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function createOpenFrameArtwork(item, callback) {
var id = item.id;
var title = item.title || 'unknow';
var author = item.author || 'unknow';
var xhr = new XMLHttpRequest();
callback = callback || function () {};
// anywhere in the API that user {id} is needed, the alias 'current' can be used fo... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | createOpenFrameArtwork | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
successListener = function successListener(e) {
if (e.data === 'success') {
createOpenFrameArtwork(item, callback);
}
window.removeEventListener('message', successListener);
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | successListener | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function GalleryItem(id, main, options) {
var _this = this;
_classCallCheck(this, GalleryItem);
this.id = id;
this.main = main;
this.options = options;
// Construct Item
this.el = document.createElement('div');
this.el.setAttribute('class', 'glslGallery... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | GalleryItem | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function initCanvas() {
if (!window.glslGallery_canvas) {
var canvas = document.createElement('canvas');
canvas.setAttribute('class', 'glslGallery_canvas');
canvas.style.width = '250px';
canvas.style.height = '250px';
canvas.width = '250px';
canvas.height = '250px';
... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | initCanvas | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function onEnter(item) {
initCanvas();
if (item.getCode()) {
item.load(item.getCode());
} else {
var url = '';
if (item.id.match(/\d\d\/.*/)) {
url = 'https://thebookofshaders.com/' + item.id + '.frag';
} else {
url = 'https://thebookofshaders.com/log... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | onEnter | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function onLeave(item) {
initCanvas();
if (item.el.getElementsByClassName('glslGallery_canvas') > 0) {
// Remove glslCanvas instance from item
item.el.removeChild(window.glslGallery_canvas.canvas);
}
} | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | onLeave | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function GlslGallery(selector, options) {
_classCallCheck(this, GlslGallery);
if (typeof selector === 'object' && selector.nodeType && selector.nodeType === 1) {
this.container = selector;
} else if (typeof selector === 'string') {
this.container = document.querySelector... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | GlslGallery | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
function glslGalleryLoadAll() {
if (!window.GlslGallery) {
window.GlslGallery = GlslGallery;
}
var list = document.getElementsByClassName('glslGallery');
if (list.length > 0) {
window.glslGalleries = [];
for (var i = 0; i < list.length; i++) {
var gallery = new GlslG... | Loads a shader.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {function(string): void) opt_errorCallback callback for errors.
@return {!WebGLShader} The created shader. | glslGalleryLoadAll | javascript | patriciogonzalezvivo/glslGallery | build/glslGallery.js | https://github.com/patriciogonzalezvivo/glslGallery/blob/master/build/glslGallery.js | MIT |
Point = (x, y, r) => {
return {
x,
y,
radius: r
};
} | Tests for server/lib/util.js
This is mostly a regression suite, to make sure behavior
is preserved throughout changes to the server infrastructure. | Point | javascript | owenashurst/agar.io-clone | test/util.js | https://github.com/owenashurst/agar.io-clone/blob/master/test/util.js | MIT |
Point = (x, y, r) => {
return {
x,
y,
radius: r
};
} | Tests for server/lib/util.js
This is mostly a regression suite, to make sure behavior
is preserved throughout changes to the server infrastructure. | Point | javascript | owenashurst/agar.io-clone | test/util.js | https://github.com/owenashurst/agar.io-clone/blob/master/test/util.js | MIT |
function build () {
console.log('Installing node_modules...')
rimraf.sync(NODE_MODULES_PATH)
cp.execSync('npm ci', { stdio: 'inherit' })
console.log('Nuking dist/ and build/...')
rimraf.sync(DIST_PATH)
rimraf.sync(BUILD_PATH)
console.log('Build: Transpiling to ES5...')
cp.execSync('npm run build', { N... | Builds app binaries for Mac, Windows, and Linux. | build | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function buildDarwin (cb) {
const plist = require('plist')
console.log('Mac: Packaging electron...')
electronPackager(Object.assign({}, all, darwin)).then(function (buildPath) {
console.log('Mac: Packaged electron. ' + buildPath)
const appPath = path.join(buildPath[0], config.APP_NAME + '.app')
cons... | Builds app binaries for Mac, Windows, and Linux. | buildDarwin | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function signApp (cb) {
const sign = require('electron-osx-sign')
const { notarize } = require('electron-notarize')
/*
* Sign the app with Apple Developer ID certificates. We sign the app for 2 reasons:
* - So the auto-updater (Squirrrel.Mac) can check that app updates are signed by
... | Builds app binaries for Mac, Windows, and Linux. | signApp | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function pack (cb) {
packageZip() // always produce .zip file, used for automatic updates
if (argv.package === 'dmg' || argv.package === 'all') {
packageDmg(cb)
}
} | Builds app binaries for Mac, Windows, and Linux. | pack | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packageZip () {
// Create .zip file (used by the auto-updater)
console.log('Mac: Creating zip...')
const inPath = path.join(buildPath[0], config.APP_NAME + '.app')
const outPath = path.join(DIST_PATH, BUILD_NAME + '-darwin.zip')
zip.zipSync(inPath, outPath)
console.log('Ma... | Builds app binaries for Mac, Windows, and Linux. | packageZip | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packageDmg (cb) {
console.log('Mac: Creating dmg...')
const appDmg = require('appdmg')
const targetPath = path.join(DIST_PATH, BUILD_NAME + '.dmg')
rimraf.sync(targetPath)
// Create a .dmg (Mac disk image) file, for easy user installation.
const dmgOpts = {
basepa... | Builds app binaries for Mac, Windows, and Linux. | packageDmg | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function buildWin32 (cb) {
const installer = require('electron-winstaller')
console.log('Windows: Packaging electron...')
/*
* Path to folder with the following files:
* - Windows Authenticode private key and cert (authenticode.p12)
* - Windows Authenticode password file (authenticode.txt)
*/
l... | Builds app binaries for Mac, Windows, and Linux. | buildWin32 | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packageInstaller (filesPath, cb) {
console.log('Windows: Creating installer...')
installer.createWindowsInstaller({
appDirectory: filesPath,
authors: config.APP_TEAM,
description: config.APP_NAME,
exe: config.APP_NAME + '.exe',
iconUrl: config.GITHUB_URL_RAW... | Builds app binaries for Mac, Windows, and Linux. | packageInstaller | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packagePortable (filesPath, cb) {
console.log('Windows: Creating portable app...')
const portablePath = path.join(filesPath, 'Portable Settings')
fs.mkdirSync(portablePath, { recursive: true })
const downloadsPath = path.join(portablePath, 'Downloads')
fs.mkdirSync(downloadsPath... | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | packagePortable | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function buildLinux (cb) {
console.log('Linux: Packaging electron...')
electronPackager(Object.assign({}, all, linux)).then(function (buildPath) {
console.log('Linux: Packaged electron. ' + buildPath)
const tasks = []
buildPath.forEach(function (filesPath) {
const destArch = filesPath.split('-')... | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | buildLinux | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packageDeb (filesPath, destArch, cb) {
// Linux convention for Debian based 'x64' is 'amd64'
if (destArch === 'x64') {
destArch = 'amd64'
}
// Create .deb file for Debian-based platforms
console.log(`Linux: Creating ${destArch} deb...`)
const installer = require('electron-instal... | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | packageDeb | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packageRpm (filesPath, destArch, cb) {
// Linux convention for RedHat based 'x64' is 'x86_64'
if (destArch === 'x64') {
destArch = 'x86_64'
}
// Create .rpm file for RedHat-based platforms
console.log(`Linux: Creating ${destArch} rpm...`)
const installer = require('electron-inst... | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | packageRpm | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function packageZip (filesPath, destArch, cb) {
// Create .zip file for Linux
console.log(`Linux: Creating ${destArch} zip...`)
const inPath = path.join(DIST_PATH, path.basename(filesPath))
const outPath = path.join(DIST_PATH, `${BUILD_NAME}-linux-${destArch}.zip`)
zip.zipSync(inPath, outPath)
... | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | packageZip | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function printDone (err) {
if (err) console.error(err.message || err)
} | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | printDone | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function printWarning () {
console.log(fs.readFileSync(path.join(__dirname, 'warning.txt'), 'utf8'))
} | Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
versions of the app) | printWarning | javascript | webtorrent/webtorrent-desktop | bin/package.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/bin/package.js | MIT |
function init () {
const get = require('simple-get')
get.concat(ANNOUNCEMENT_URL, onResponse)
} | In certain situations, the WebTorrent team may need to show an announcement to
all WebTorrent Desktop users. For example: a security notice, or an update
notification (if the auto-updater stops working).
When there is an announcement, the `ANNOUNCEMENT_URL` endpoint should return an
HTTP 200 status code with a JSON ob... | init | javascript | webtorrent/webtorrent-desktop | src/main/announcement.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/announcement.js | MIT |
function onResponse (err, res, data) {
if (err) return log(`Failed to retrieve announcement: ${err.message}`)
if (res.statusCode !== 200) return log('No announcement available')
try {
data = JSON.parse(data.toString())
} catch (err) {
// Support plaintext announcement messages, using a default title.
... | In certain situations, the WebTorrent team may need to show an announcement to
all WebTorrent Desktop users. For example: a security notice, or an update
notification (if the auto-updater stops working).
When there is an announcement, the `ANNOUNCEMENT_URL` endpoint should return an
HTTP 200 status code with a JSON ob... | onResponse | javascript | webtorrent/webtorrent-desktop | src/main/announcement.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/announcement.js | MIT |
function openSeedFile () {
if (!windows.main.win) return
log('openSeedFile')
const opts = {
title: 'Select a file for the torrent.',
properties: ['openFile']
}
showOpenSeed(opts)
} | Show open dialog to create a single-file torrent. | openSeedFile | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function openSeedDirectory () {
if (!windows.main.win) return
log('openSeedDirectory')
const opts = process.platform === 'darwin'
? {
title: 'Select a file or folder for the torrent.',
properties: ['openFile', 'openDirectory']
}
: {
title: 'Select a folder for the torrent.',
... | Show open dialog to create a single-file torrent. | openSeedDirectory | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function openFiles () {
if (!windows.main.win) return
log('openFiles')
const opts = process.platform === 'darwin'
? {
title: 'Select a file or folder to add.',
properties: ['openFile', 'openDirectory']
}
: {
title: 'Select a file to add.',
properties: ['openFile']
... | Show open dialog to create a single-file torrent. | openFiles | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function openTorrentFile () {
if (!windows.main.win) return
log('openTorrentFile')
const opts = {
title: 'Select a .torrent file.',
filters: [{ name: 'Torrent Files', extensions: ['torrent'] }],
properties: ['openFile', 'multiSelections']
}
setTitle(opts.title)
const selectedPaths = dialog.showO... | Show open dialog to create a single-file torrent. | openTorrentFile | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function openTorrentAddress () {
log('openTorrentAddress')
windows.main.dispatch('openTorrentAddress')
} | Show open dialog to create a single-file torrent. | openTorrentAddress | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function setTitle (title) {
if (process.platform === 'darwin') {
windows.main.dispatch('setTitle', title)
}
} | Dialogs on do not show a title on Mac, so the window title is used instead. | setTitle | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function showOpenSeed (opts) {
setTitle(opts.title)
const selectedPaths = dialog.showOpenDialogSync(windows.main.win, opts)
resetTitle()
if (!Array.isArray(selectedPaths)) return
windows.main.dispatch('showCreateTorrent', selectedPaths)
} | Pops up an Open File dialog with the given options.
After the user selects files / folders, shows the Create Torrent page. | showOpenSeed | javascript | webtorrent/webtorrent-desktop | src/main/dialog.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dialog.js | MIT |
function init () {
if (!app.dock) return
const menu = Menu.buildFromTemplate(getMenuTemplate())
app.dock.setMenu(menu)
} | Add a right-click menu to the dock icon. (Mac) | init | javascript | webtorrent/webtorrent-desktop | src/main/dock.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dock.js | MIT |
function downloadFinished (path) {
if (!app.dock) return
log(`downloadFinished: ${path}`)
app.dock.downloadFinished(path)
} | Bounce the Downloads stack if `path` is inside the Downloads folder. (Mac) | downloadFinished | javascript | webtorrent/webtorrent-desktop | src/main/dock.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dock.js | MIT |
function setBadge (count) {
if (process.platform === 'darwin' ||
(process.platform === 'linux' && app.isUnityRunning())) {
log(`setBadge: ${count}`)
app.badgeCount = Number(count)
}
} | Display a counter badge for the app. (Mac, Linux) | setBadge | javascript | webtorrent/webtorrent-desktop | src/main/dock.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dock.js | MIT |
function getMenuTemplate () {
return [
{
label: 'Create New Torrent...',
accelerator: 'CmdOrCtrl+N',
click: () => dialog.openSeedDirectory()
},
{
label: 'Open Torrent File...',
accelerator: 'CmdOrCtrl+O',
click: () => dialog.openTorrentFile()
},
{
label: '... | Display a counter badge for the app. (Mac, Linux) | getMenuTemplate | javascript | webtorrent/webtorrent-desktop | src/main/dock.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/dock.js | MIT |
function registerProtocolHandlerWin32 (protocol, name, icon, command) {
const protocolKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: '\\Software\\Classes\\' + protocol
})
setProtocol()
function setProtocol (err) {
if (err) return log.error(err.message)
prot... | To add a protocol handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$PROTOCOL
(Default) = "$NAME"
URL Protocol = ""
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1"
Source: https://msdn.microsoft.com/en-us... | registerProtocolHandlerWin32 | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setProtocol (err) {
if (err) return log.error(err.message)
protocolKey.set('', Registry.REG_SZ, name, setURLProtocol)
} | To add a protocol handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$PROTOCOL
(Default) = "$NAME"
URL Protocol = ""
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1"
Source: https://msdn.microsoft.com/en-us... | setProtocol | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setURLProtocol (err) {
if (err) return log.error(err.message)
protocolKey.set('URL Protocol', Registry.REG_SZ, '', setIcon)
} | To add a protocol handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$PROTOCOL
(Default) = "$NAME"
URL Protocol = ""
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1"
Source: https://msdn.microsoft.com/en-us... | setURLProtocol | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setIcon (err) {
if (err) return log.error(err.message)
const iconKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${protocol}\\DefaultIcon`
})
iconKey.set('', Registry.REG_SZ, icon, setCommand)
} | To add a protocol handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$PROTOCOL
(Default) = "$NAME"
URL Protocol = ""
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1"
Source: https://msdn.microsoft.com/en-us... | setIcon | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setCommand (err) {
if (err) return log.error(err.message)
const commandKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${protocol}\\shell\\open\\command`
})
commandKey.set('', Registry.REG_SZ, `${commandToArgs(command)} "%1"`, done)
} | To add a protocol handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$PROTOCOL
(Default) = "$NAME"
URL Protocol = ""
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1"
Source: https://msdn.microsoft.com/en-us... | setCommand | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function done (err) {
if (err) return log.error(err.message)
} | To add a protocol handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$PROTOCOL
(Default) = "$NAME"
URL Protocol = ""
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1"
Source: https://msdn.microsoft.com/en-us... | done | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function registerFileHandlerWin32 (ext, id, name, icon, command) {
setExt()
function setExt () {
const extKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${ext}`
})
extKey.set('', Registry.REG_SZ, id, setId)
}
function setId (... | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | registerFileHandlerWin32 | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setExt () {
const extKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${ext}`
})
extKey.set('', Registry.REG_SZ, id, setId)
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | setExt | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setId (err) {
if (err) return log.error(err.message)
const idKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${id}`
})
idKey.set('', Registry.REG_SZ, name, setIcon)
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | setId | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setIcon (err) {
if (err) return log.error(err.message)
const iconKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${id}\\DefaultIcon`
})
iconKey.set('', Registry.REG_SZ, icon, setCommand)
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | setIcon | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function setCommand (err) {
if (err) return log.error(err.message)
const commandKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${id}\\shell\\open\\command`
})
commandKey.set('', Registry.REG_SZ, `${commandToArgs(command)} "%1"`, done)
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | setCommand | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function done (err) {
if (err) return log.error(err.message)
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | done | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function uninstallWin32 () {
const Registry = require('winreg')
unregisterProtocolHandlerWin32('magnet', EXEC_COMMAND)
unregisterProtocolHandlerWin32('stream-magnet', EXEC_COMMAND)
unregisterFileHandlerWin32('.torrent', 'io.webtorrent.torrent', EXEC_COMMAND)
function unregisterProtocolHandlerWin32 (protocol... | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | uninstallWin32 | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function unregisterProtocolHandlerWin32 (protocol, command) {
getCommand()
function getCommand () {
const commandKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${protocol}\\shell\\open\\command`
})
commandKey.get('', (err, item) => {
... | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | unregisterProtocolHandlerWin32 | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function getCommand () {
const commandKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${protocol}\\shell\\open\\command`
})
commandKey.get('', (err, item) => {
if (!err && item.value.indexOf(commandToArgs(command)) >= 0) {
des... | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | getCommand | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function destroyProtocol () {
const protocolKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${protocol}`
})
protocolKey.destroy(() => {})
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | destroyProtocol | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function unregisterFileHandlerWin32 (ext, id, command) {
eraseId()
function eraseId () {
const idKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${id}`
})
idKey.destroy(getExt)
}
function getExt () {
const extKey = new R... | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | unregisterFileHandlerWin32 | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function eraseId () {
const idKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${id}`
})
idKey.destroy(getExt)
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | eraseId | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function getExt () {
const extKey = new Registry({
hive: Registry.HKCU,
key: `\\Software\\Classes\\${ext}`
})
extKey.get('', (err, item) => {
if (!err && item.value === id) {
destroyExt()
}
})
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | getExt | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function destroyExt () {
const extKey = new Registry({
hive: Registry.HKCU, // HKEY_CURRENT_USER
key: `\\Software\\Classes\\${ext}`
})
extKey.destroy(() => {})
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | destroyExt | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function commandToArgs (command) {
return command.map((arg) => `"${arg}"`).join(' ')
} | To add a file handler, the following keys must be added to the Windows registry:
HKEY_CLASSES_ROOT
$EXTENSION
(Default) = "$EXTENSION_ID"
$EXTENSION_ID
(Default) = "$NAME"
DefaultIcon
(Default) = "$ICON"
shell
open
command
(Default) = "$COMMAND" "%1" | commandToArgs | javascript | webtorrent/webtorrent-desktop | src/main/handlers.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/handlers.js | MIT |
function log (...args) {
if (app.ipcReady) {
windows.main.send('log', ...args)
} else {
app.once('ipcReady', () => windows.main.send('log', ...args))
}
} | In the main electron process, we do not use console.log() statements because they do
not show up in a convenient location when running the packaged (i.e. production)
version of the app. Instead use this module, which sends the logs to the main window
where they can be viewed in Developer Tools. | log | javascript | webtorrent/webtorrent-desktop | src/main/log.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/log.js | MIT |
function error (...args) {
if (app.ipcReady) {
windows.main.send('error', ...args)
} else {
app.once('ipcReady', () => windows.main.send('error', ...args))
}
} | In the main electron process, we do not use console.log() statements because they do
not show up in a convenient location when running the packaged (i.e. production)
version of the app. Instead use this module, which sends the logs to the main window
where they can be viewed in Developer Tools. | error | javascript | webtorrent/webtorrent-desktop | src/main/log.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/log.js | MIT |
function enable () {
if (powerSaveBlocker.isStarted(blockId)) {
// If a power saver block already exists, do nothing.
return
}
blockId = powerSaveBlocker.start('prevent-display-sleep')
log(`powerSaveBlocker.enable: ${blockId}`)
} | Block the system from entering low-power (sleep) mode or turning off the
display. | enable | javascript | webtorrent/webtorrent-desktop | src/main/power-save-blocker.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/power-save-blocker.js | MIT |
function disable () {
if (!powerSaveBlocker.isStarted(blockId)) {
// If a power saver block does not exist, do nothing.
return
}
powerSaveBlocker.stop(blockId)
log(`powerSaveBlocker.disable: ${blockId}`)
} | Stop blocking the system from entering low-power mode. | disable | javascript | webtorrent/webtorrent-desktop | src/main/power-save-blocker.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/power-save-blocker.js | MIT |
function showItemInFolder (path) {
log(`showItemInFolder: ${path}`)
shell.showItemInFolder(path)
} | Show the given file in a file manager. If possible, select the file. | showItemInFolder | javascript | webtorrent/webtorrent-desktop | src/main/shell.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/shell.js | MIT |
function moveItemToTrash (path) {
log(`moveItemToTrash: ${path}`)
shell.trashItem(path)
} | Move the given file to trash and returns a boolean status for the operation. | moveItemToTrash | javascript | webtorrent/webtorrent-desktop | src/main/shell.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/shell.js | MIT |
function enable () {
buttons = [
{
tooltip: 'Previous Track',
icon: PREV_ICON,
click: () => windows.main.dispatch('previousTrack')
},
{
tooltip: 'Pause',
icon: PAUSE_ICON,
click: () => windows.main.dispatch('playPause')
},
{
tooltip: 'Next Track',
ic... | Show the Windows thumbnail toolbar buttons. | enable | javascript | webtorrent/webtorrent-desktop | src/main/thumbar.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/thumbar.js | MIT |
function disable () {
buttons = []
update()
} | Hide the Windows thumbnail toolbar buttons. | disable | javascript | webtorrent/webtorrent-desktop | src/main/thumbar.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/thumbar.js | MIT |
function onPlayerPause () {
if (!isEnabled()) return
buttons[PLAY_PAUSE].tooltip = 'Play'
buttons[PLAY_PAUSE].icon = PLAY_ICON
update()
} | Hide the Windows thumbnail toolbar buttons. | onPlayerPause | javascript | webtorrent/webtorrent-desktop | src/main/thumbar.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/thumbar.js | MIT |
function onPlayerPlay () {
if (!isEnabled()) return
buttons[PLAY_PAUSE].tooltip = 'Pause'
buttons[PLAY_PAUSE].icon = PAUSE_ICON
update()
} | Hide the Windows thumbnail toolbar buttons. | onPlayerPlay | javascript | webtorrent/webtorrent-desktop | src/main/thumbar.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/thumbar.js | MIT |
function onPlayerUpdate (state) {
if (!isEnabled()) return
buttons[PREV].flags = [state.hasPrevious ? 'enabled' : 'disabled']
buttons[NEXT].flags = [state.hasNext ? 'enabled' : 'disabled']
update()
} | Hide the Windows thumbnail toolbar buttons. | onPlayerUpdate | javascript | webtorrent/webtorrent-desktop | src/main/thumbar.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/thumbar.js | MIT |
function isEnabled () {
return buttons.length > 0
} | Hide the Windows thumbnail toolbar buttons. | isEnabled | javascript | webtorrent/webtorrent-desktop | src/main/thumbar.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/thumbar.js | MIT |
function hasTray () {
return !!tray
} | Returns true if there a tray icon is active. | hasTray | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function setWindowFocus (flag) {
if (!tray) return
updateTrayMenu()
} | Returns true if there a tray icon is active. | setWindowFocus | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function initLinux () {
checkLinuxTraySupport(err => {
if (!err) createTray()
})
} | Returns true if there a tray icon is active. | initLinux | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function checkLinuxTraySupport (cb) {
const cp = require('child_process')
// Check that libappindicator libraries are installed in system.
cp.exec('ldconfig -p | grep libappindicator', (err, stdout) => {
if (err) return cb(err)
cb(null)
})
} | Check for libappindicator support before creating tray icon. | checkLinuxTraySupport | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function createTray () {
tray = new Tray(getIconPath())
// On Windows, left click opens the app, right click opens the context menu.
// On Linux, any click (left or right) opens the context menu.
tray.on('click', () => windows.main.show())
// Show the tray context menu, and keep the available commands up to... | Check for libappindicator support before creating tray icon. | createTray | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function updateTrayMenu () {
const contextMenu = Menu.buildFromTemplate(getMenuTemplate())
tray.setContextMenu(contextMenu)
} | Check for libappindicator support before creating tray icon. | updateTrayMenu | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function getMenuTemplate () {
return [
getToggleItem(),
{
label: 'Quit',
click: () => app.quit()
}
]
function getToggleItem () {
if (windows.main.win.isVisible()) {
return {
label: 'Hide to tray',
click: () => windows.main.hide()
}
} else {
return... | Check for libappindicator support before creating tray icon. | getMenuTemplate | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function getToggleItem () {
if (windows.main.win.isVisible()) {
return {
label: 'Hide to tray',
click: () => windows.main.hide()
}
} else {
return {
label: 'Show WebTorrent',
click: () => windows.main.show()
}
}
} | Check for libappindicator support before creating tray icon. | getToggleItem | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function getIconPath () {
return process.platform === 'win32'
? config.APP_ICON + '.ico'
: config.APP_ICON + '.png'
} | Check for libappindicator support before creating tray icon. | getIconPath | javascript | webtorrent/webtorrent-desktop | src/main/tray.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/tray.js | MIT |
function init () {
if (process.platform !== 'win32') return
app.setUserTasks(getUserTasks())
} | Add a user task menu to the app icon on right-click. (Windows) | init | javascript | webtorrent/webtorrent-desktop | src/main/user-tasks.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/user-tasks.js | MIT |
function getUserTasks () {
return [
{
arguments: '-n',
title: 'Create New Torrent...',
description: 'Create a new torrent'
},
{
arguments: '-o',
title: 'Open Torrent File...',
description: 'Open a .torrent file'
},
{
arguments: '-u',
title: 'Open Tor... | Add a user task menu to the app icon on right-click. (Windows) | getUserTasks | javascript | webtorrent/webtorrent-desktop | src/main/user-tasks.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/user-tasks.js | MIT |
function getUserTasksItem (item) {
return Object.assign(item, {
program: process.execPath,
iconPath: process.execPath,
iconIndex: 0
})
} | Add a user task menu to the app icon on right-click. (Windows) | getUserTasksItem | javascript | webtorrent/webtorrent-desktop | src/main/user-tasks.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/user-tasks.js | MIT |
function setAspectRatio (aspectRatio) {
if (!main.win) return
main.win.setAspectRatio(aspectRatio)
} | Enforce window aspect ratio. Remove with 0. (Mac) | setAspectRatio | javascript | webtorrent/webtorrent-desktop | src/main/windows/main.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/windows/main.js | MIT |
function setBounds (bounds, maximize) {
// Do nothing in fullscreen
if (!main.win || main.win.isFullScreen()) {
log('setBounds: not setting bounds because already in full screen mode')
return
}
// Maximize or minimize, if the second argument is present
if (maximize === true && !main.win.isMaximized()... | Change the size of the window.
TODO: Clean this up? Seems overly complicated. | setBounds | javascript | webtorrent/webtorrent-desktop | src/main/windows/main.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/windows/main.js | MIT |
function setProgress (progress) {
if (!main.win) return
main.win.setProgressBar(progress)
} | Set progress bar to [0, 1]. Indeterminate when > 1. Remove with < 0. | setProgress | javascript | webtorrent/webtorrent-desktop | src/main/windows/main.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/windows/main.js | MIT |
function setTitle (title) {
if (!main.win) return
main.win.setTitle(title)
} | Set progress bar to [0, 1]. Indeterminate when > 1. Remove with < 0. | setTitle | javascript | webtorrent/webtorrent-desktop | src/main/windows/main.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/windows/main.js | MIT |
function show () {
if (!main.win) return
main.win.show()
} | Set progress bar to [0, 1]. Indeterminate when > 1. Remove with < 0. | show | javascript | webtorrent/webtorrent-desktop | src/main/windows/main.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/windows/main.js | MIT |
function toggleAlwaysOnTop (flag) {
if (!main.win) return
if (flag == null) {
flag = !main.win.isAlwaysOnTop()
}
log(`toggleAlwaysOnTop ${flag}`)
main.win.setAlwaysOnTop(flag)
menu.onToggleAlwaysOnTop(flag)
} | Set progress bar to [0, 1]. Indeterminate when > 1. Remove with < 0. | toggleAlwaysOnTop | javascript | webtorrent/webtorrent-desktop | src/main/windows/main.js | https://github.com/webtorrent/webtorrent-desktop/blob/master/src/main/windows/main.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.