Search completed in 1.52 seconds.
849 results for "sample":
Your results are loading. Please wait...
NSS Sample Code Sample_1_Hashing
nss sample code 1: hashing a file.
... sample code 1 /* nspr headers */ #include <prprf.h> #include <prtypes.h> #include <plgetopt.h> #include <prio.h> /* nss headers */ #include <secoid.h> #include <secmodt.h> #include <sechash.h> typedef struct { const char *hashname; secoidtag oid; } nametagpair; /* the hash algorithms supported */ static const nametagpair hash_names[] = { { "md2", sec_oid_md2 }, { "md5", sec_oid_md5 }, { "sha1", sec_oid_sha1 }, { "sha256", sec_oid_sha256 }, { "sha384", sec_oid_sha384 }, { "sha512", sec_oid_sha512 } }; /* * maps a hash name to a secoidtag.
... */ printashex(outfile, digest, len); } while (0); /* cleanup */ if (hashcontext != null) hash_destroy(hashcontext); return secsuccess; } /* * this sample computes the hash of a file and saves it * to another file.
NSS Sample Code Sample1
nss sample code 1: key generation and transport between servers.
...sample code #include <iostream.h> #include "pk11pub.h" #include "keyhi.h" #include "nss.h" // key management for keys share among multiple hosts // // this example shows how to use nss functions to create and // distribute keys that need to be shared among multiple servers // or hosts.
NSS Sample Code Sample_2_Initialization of NSS
nss sample code 2: initializing nss this example program demonstrates how to initialize the nss database.
... sample code 1 /* nspr headers */ #include <prthread.h> #include <plgetopt.h> #include <prprf.h> /* nss headers */ #include <nss.h> #include <pk11func.h> #include "util.h" /* print a usage message and exit */ static void usage(const char *progname) { fprintf(stderr, "\nusage: %s -d <dbdirpath> [-p <plainpasswc>]" " [-f <passwdffile>]\n\n", progname); fprintf(stderr, "%-15s specify a db directory path\n\n", "-d <dbdirpath>"); fprintf(stderr, "%-15s specify a plaintext password\n\n", "-p <plainpasswc>"); fprintf(stderr, "%-15s specify a password file\n\n", "-f <plainpasswc>"); exit(-1); } /* initialize the slot password */ char *initslotpassword(pk1...
NSS Sample Code Sample_3_Basic Encryption and MACing
nss sample code 3: basic encryption and macing this example program demonstrates how to encrypt and mac a file.
... sample code 3 /* nspr headers */ #include <prthread.h> #include <plgetopt.h> #include <prerror.h> #include <prinit.h> #include <prlog.h> #include <prtypes.h> #include <plstr.h> /* nss headers */ #include <keyhi.h> #include <pk11priv.h> /* our samples utilities */ #include "util.h" #define buffersize 80 #define digestsize 16 #define ptext_mac_buffer_size 96 #define ciphersize 96 #define blocksize 32 #define cipher_header "-----begin cipher-----" #define cipher_trailer "-----end cipher-----" #define enckey_header "-----begin aeskey ckaid-----" #define enckey_trailer "-----end aeskey ckaid-----" #define mackey_header "-----begin mackey ckaid-----" #define mackey_trailer "-----end mackey ckaid-----" #de...
NSS Sample Code sample2
nss sample code 2: symmetric encryption /* example code to illustrate des enccryption/decryption using nss.
...mode, ivitem.data and ivitem.len can be 0, or you * can simply pass null for the iv parameter in pk11_paramfromiv func */ ivitem.type = sibuffer; ivitem.data = giv; ivitem.len = sizeof(giv); secparam = pk11_paramfromiv(ciphermech, &ivitem); if (secparam == null) { fprintf(stderr, "failure to set up pkcs11 param (err %d)\n", pr_geterror()); goto out; } /* sample data we'll encrypt and decrypt */ strcpy(data, "encrypt me!"); fprintf(stderr, "clear data: %s\n", data); /* ========================= start section ============================= */ /* if using the the same key and iv over and over, stuff before this */ /* section and after this section needs to be done only once */ /* encrypt data into buf1.
NSS Sample Code sample3
sample code 3: hashing, mac /* * demonstration program for hashing and macs */ #include <iostream.h> #include "pk11pub.h" #include "nss.h" static void printdigest(unsigned char *digest, unsigned int len) { int i; cout << "length: " << len << endl; for(i = 0;i < len;i++) printf("%02x ", digest[i]); cout << endl; } /* * main */ int main(int argc, const char *argv[]) { int status = 0; pk11slotinfo *slot = 0; pk11symkey *key = 0; pk11context *context = 0; unsigned char data[80]; unsigned char digest[20]; /*is there a way to tell how large the output is?*/ unsigned int len; secstatus s; /* initialize nss * if your application code has already initialized nss, you can skip it * here.
NSS Sample Code sample4
nss sample code 4: pki encryption /* example code to illustrate pki crypto ops (encrypt with public key, * decrypt with private key) * * code assumes that you have set up a nss database with a certificate * and a private key.
NSS Sample Code sample5
nss sample code 5: pki encryption with a raw public & private key in der format /* example code to illustrate pki crypto ops (encrypt with public key, * decrypt with private key) * * no nss db needed.
NSS Sample Code sample6
nss sample code 6: persistent symmetric keys in nss database /* example code to illustrate generation of a secret symmetric key ring * that persists in the nss database.
MediaTrackSettings.sampleSize - Web APIs
the mediatracksettings dictionary's samplesize property is an integer indicating the linear sample size (in bits per sample) the mediastreamtrack is currently configured for.
... this lets you determine what value was selected to comply with your specified constraints for this property's value as described in the mediatrackconstraints.samplesize property you provided when calling either getusermedia() or mediastreamtrack.applyconstraints().
... if needed, you can determine whether or not this constraint is supported by checking the value of mediatracksupportedconstraints.samplesize as returned by a call to mediadevices.getsupportedconstraints().
...And 7 more matches
WaveShaperNode.oversample - Web APIs
the oversample property of the waveshapernode interface is an enumerated value indicating if oversampling must be used.
... oversampling is a technique for creating more samples (up-sampling) before applying a distortion effect to the audio signal.
... once applied, the number of samples is reduced to its initial numbers.
...And 6 more matches
AudioContextOptions.sampleRate - Web APIs
the audiocontextoptions dictionary (used when instantiating an audiocontext) may contain a property named samplerate, which indicates the sample rate to use for the new context.
... the value must be a floating-point value indicating the sample rate, in samples per second, for which to configure the new context; additionally, the value must be one which is supported by audiobuffer.samplerate.
... syntax audiocontextoptions.samplerate = 44100; var samplerate = audiocontextoptions.samplerate; value the desired sample rate for the audiocontext, specified in samples per second.
...And 4 more matches
WebGL2RenderingContext.isSampler() - Web APIs
the webgl2renderingcontext.issampler() method of the webgl 2 api returns true if the passed object is a valid webglsampler object.
... syntax glboolean gl.issampler(sampler); parameters sampler a webglsampler object to test.
... return value a glboolean indicating whether the given object is a valid webglsampler object (true) or not (false).
...And 4 more matches
Samples and Test Cases - Archive of obsolete content
npapi plugin samples collections of npapi plugin samples can be found in the seamonkey source code at /modules/plugin/sdk/samples.
... the samples may not build any more on all platforms.
... there are plans to clean up the sample plugin situation - better organization, updated build systems, get them building on all platforms.
...And 3 more matches
sample2
rs */ #include <prthread.h> #include <plgetopt.h> #include <prerror.h> #include <prinit.h> #include <prlog.h> #include <prtypes.h> #include <plstr.h> /* nss headers */ #include <cryptohi.h> #include <keyhi.h> #include <pk11priv.h> #include <cert.h> #include <base64.h> #include <secerr.h> #include <secport.h> #include <secoid.h> #include <secmodt.h> #include <secoidt.h> #include <sechash.h> /* our samples utilities */ #include "util.h" /* constants */ #define blocksize 32 #define modblocksize 128 #define default_key_bits 1024 /* header file constants */ #define enckey_header "-----begin wrapped enckey-----" #define enckey_trailer "-----end wrapped enckey-----" #define mackey_header "-----begin wrapped mackey-----" #define mackey_trailer "-----end wrapped mackey-----" #define iv_header "-----begin...
...*/ #ifndef port_errortostring #define port_errortostring(err) pr_errortostring((err), pr_language_i_default) #endif /* sample 6 commands */ typedef enum { generate_csr, add_cert_to_db, save_cert_to_header, encrypt, decrypt, sign, verify, unknown } commandtype; typedef enum { symkey = 0, mackey = 1, iv = 2, mac = 3, pad = 4, pubkey = 5, lab = 6, certenc= 7, certvfy= 8, sig = 9 } headertype; /* * print usage message and exit */ static void usage(const char *progname) { fprintf(stderr, "\nusage: %s %s %s %s %s %s %s %s %s ...
...* finds the matching private key, decrypts and write to external file * * how this sample is different from sample 5 ?
...And 3 more matches
MediaTrackConstraints.sampleSize - Web APIs
the mediatrackconstraints dictionary's samplesize property is a constrainlong describing the requested or mandatory constraints placed upon the value of the samplesize constrainable property.
... if needed, you can determine whether or not this constraint is supported by checking the value of mediatracksupportedconstraints.samplesize as returned by a call to mediadevices.getsupportedconstraints().
... syntax var constraintsobject = { samplesize: constraint }; constraintsobject.samplesize = constraint; value if this value is a number, the user agent will attempt to obtain media whose sample size (in bits per linear sample) is as close as possible to this number given the capabilities of the hardware and the other constraints specified.
...And 3 more matches
MediaTrackSettings.sampleRate - Web APIs
the mediatracksettings dictionary's samplerate property is an integer indicating how many audio samples per second the mediastreamtrack is currently configured for.
... this lets you determine what value was selected to comply with your specified constraints for this property's value as described in the mediatrackconstraints.samplerate property you provided when calling either getusermedia() or mediastreamtrack.applyconstraints().
... if needed, you can determine whether or not this constraint is supported by checking the value of mediatracksupportedconstraints.samplerate as returned by a call to mediadevices.getsupportedconstraints().
...And 3 more matches
WebGL2RenderingContext.createSampler() - Web APIs
the webgl2renderingcontext.createsampler() method of the webgl 2 api creates and initializes webglsampler objects.
... syntax webglsampler gl.createsampler(); parameters none.
... return value a webglsampler object.
...And 3 more matches
WebGL2RenderingContext.deleteSampler() - Web APIs
the webgl2renderingcontext.deletesampler() method of the webgl 2 api deletes a given webglsampler object.
... syntax void gl.deletesampler(sampler); parameters sampler a webglsampler object to delete.
...webglsampler objects are not available in webgl 1.
...And 3 more matches
WebGLRenderingContext.sampleCoverage() - Web APIs
the webglrenderingcontext.samplecoverage() method of the webgl api specifies multi-sample coverage parameters for anti-aliasing effects.
... syntax void gl.samplecoverage(value, invert); parameters value a glclampf which sets a single floating-point coverage value clamped to the range [0,1].
...to enable or disable multi-sampling, use the enable() and disable() methods with the argument gl.sample_coverage and gl.sample_alpha_to_coverage.
...And 3 more matches
BaseAudioContext.sampleRate - Web APIs
the samplerate property of the baseaudiocontext interface returns a floating point number representing the sample rate, in samples per second, used by all nodes in this audio context.
... this limitation means that sample-rate converters are not supported.
... syntax baseaudiocontext.samplerate; value a floating point number indicating the audio context's sample rate, in samples per second.
...And 2 more matches
MediaTrackConstraints.sampleRate - Web APIs
the mediatrackconstraints dictionary's samplerate property is a constrainlong describing the requested or mandatory constraints placed upon the value of the samplerate constrainable property.
... if needed, you can determine whether or not this constraint is supported by checking the value of mediatracksupportedconstraints.samplerate as returned by a call to mediadevices.getsupportedconstraints().
... syntax var constraintsobject = { samplerate: constraint }; constraintsobject.samplerate = constraint; value if this value is a number, the user agent will attempt to obtain media whose sample rate is as close as possible to this number given the capabilities of the hardware and the other constraints specified.
...And 2 more matches
WebGL2RenderingContext.bindSampler() - Web APIs
the webgl2renderingcontext.bindsampler() method of the webgl 2 api binds a passed webglsampler object to the texture unit at the passed index.
... syntax void gl.bindsampler(unit, sampler); parameters unit a gluint specifying the index of the texture unit to which to bind the sampler to.
... sampler a webglsampler object to bind.
...And 2 more matches
WebGL2RenderingContext.renderbufferStorageMultisample() - Web APIs
the webgl2renderingcontext.renderbufferstoragemultisample() method of the webgl 2 api returns creates and initializes a renderbuffer object's data store and allows specifying a number of samples to be used.
... syntax void gl.renderbufferstoragemultisample(target, samples, internalformat, width, height); parameters target a glenum specifying the target renderbuffer object.
... samples a glsizei specifying the number of samples to be used for the renderbuffer storage.
...And 2 more matches
WebGL2RenderingContext.samplerParameter[if]() - Web APIs
the webgl2renderingcontext.samplerparameter[if]() methods of the webgl 2 api set webglsampler parameters.
... syntax void gl.samplerparameteri(sampler, pname, param); void gl.samplerparameterf(sampler, pname, param); parameters sampler a webglsampler object.
... param a glint (samplerparameteri) or a glfloat (samplerparameterf) specifying a value for pname.
...And 2 more matches
<samp>: The Sample Output element - HTML: Hypertext Markup Language
WebHTMLElementsamp
the html sample element (<samp>) is used to enclose inline text which represents sample (or quoted) output from a computer program.
...found <em>n</em> results.</samp> you can then proceed to the next step.</p> the resulting output looks like this: sample output including user input you can nest the <kbd> element within a <samp> block to present an example that includes text entered by the user.
...presenting a transcript of a linux (or macos) console session: html <pre> <samp><span class="prompt">mike@interwebz:~$</span> <kbd>md5 -s "hello world"</kbd> md5 ("hello world") = 3e25960a79dbc69b674cd4ec67a72c62 <span class="prompt">mike@interwebz:~$</span> <span class="cursor">█</span></samp></pre> note the use of <span> to allow customization of the appearance of specific portions of the sample text such as the shell prompts and the cursor.
...And 2 more matches
NSS Sample Code
nss sample code the collection of sample code here demonstrates how nss can be used for cryptographic operations, certificate handling, ssl, etc.
... old samples in the process of being replaced.
... sample code 1: key generation and transport between servers sample code 2: symmetric encryption sample code 3: hashing, mac sample code 4: pki encryption sample code 5: pki encryption with a raw public & private key in der format sample code 6: persistent symmetric keys in nss database these are very old examples in need of replacement.
... see https://bugzilla.mozilla.org/show_bug.cgi?id=490238 you are welcome to download the new samples via: hg clone https://hg.mozilla.org/projects/nss; cd nss; hg update samples_branch the new samples: /docs/mozilla/projects/nss/new_nss_samples ...
AudioBuffer.sampleRate - Web APIs
the samplerate property of the audiobuffer interface returns a float representing the sample rate, in samples per second, of the pcm data stored in the buffer.
... syntax var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); myarraybuffer.samplerate; value a floating-point value indicating the current sample rate of the buffers data, in samples per second.
... example // stereo var channels = 2; // create an empty two second stereo buffer at the // sample rate of the audiocontext var framecount = audioctx.samplerate * 2.0; var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; // just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuffering = myarraybuffer.getchanneldata(channel); for (var i = 0; i < framecount; i++) { // math.random() is in [0; 1.0] // audio needs to be in [-1.0; 1.0] nowbuffering[i] = math.random() * 2 - 1; } } console.log(myarraybuffer.samplerate); } specification specifi...
...cation status comment web audio apithe definition of 'samplerate' in that specification.
SecurityPolicyViolationEvent.sample - Web APIs
the sample read-only property of the securitypolicyviolationevent interface is a domstring representing a sample of the resource that caused the violation.
... syntax let sample = violationeventinstance.sample; value a domstring containing a sample of the resource that caused the violation, usually the first 40 characters.
... this will only be populated if the resource is an inline script, event handler, or style — external resources causing a violation will not generate a sample.
... example document.addeventlistener("securitypolicyviolation", (e) => { console.log(e.sample); }); specifications specification status comment content security policy level 3the definition of 'sample' in that specification.
WebGL2RenderingContext.getSamplerParameter() - Web APIs
the webgl2renderingcontext.getsamplerparameter() method of the webgl 2 api returns parameter information of a webglsampler object.
... syntax any gl.getsamplerparameter(sampler, pname); parameters sampler a webglsampler object.
... examples var sampler = gl.createsampler(); gl.getsamplerparameter(sampler, gl.texture_compare_func); specifications specification status comment webgl 2.0the definition of 'getsamplerparameter' in that specification.
... opengl es 3.0the definition of 'glgetsamplerparameter' in that specification.
WebGLSampler - Web APIs
the webglsampler interface is part of the webgl 2 api and stores sampling parameters for webgltexture access inside of a shader.
... when working with webglsampler objects, the following methods of the webgl2renderingcontext are useful: webgl2renderingcontext.createsampler() webgl2renderingcontext.deletesampler() webgl2renderingcontext.issampler() webgl2renderingcontext.bindsampler() webgl2renderingcontext.getsamplerparameter() examples creating a webglsampler object in this example, gl must be a webgl2renderingcontext.
... webglsampler objects are not available in webgl 1.
... var sampler = gl.createsampler(); specifications specification status comment webgl 2.0the definition of 'webglsample' in that specification.
MediaTrackSupportedConstraints.sampleRate - Web APIs
the mediatracksupportedconstraints dictionary's samplerate property is a read-only boolean value which is present (and set to true) in the object returned by mediadevices.getsupportedconstraints() if and only if the user agent supports the samplerate constraint.
... syntax samplerateconstraintsupported = supportedconstraintsdictionary.samplerate; value this property is present in the dictionary (and its value is always true) if the user agent supports the samplerate constraint.
... example html content <div id="result"> </div> css content #result { font: 14px "arial", sans-serif; } javascript content let result = document.getelementbyid("result"); if (navigator.mediadevices.getsupportedconstraints().samplerate) { result.innerhtml = "supported!"; } else { result.innerhtml = "not supported!"; } result specifications specification status comment media capture and streamsthe definition of 'samplerate' in that specification.
MediaTrackSupportedConstraints.sampleSize - Web APIs
the mediatracksupportedconstraints dictionary's samplesize property is a read-only boolean value which is present (and set to true) in the object returned by mediadevices.getsupportedconstraints() if and only if the user agent supports the samplesize constraint.
... syntax samplesizeconstraintsupported = supportedconstraintsdictionary.samplesize; value this property is present in the dictionary (and its value is always true) if the user agent supports the samplesize constraint.
... example html content <div id="result"> </div> css content #result { font: 14px "arial", sans-serif; } javascript content let result = document.getelementbyid("result"); if (navigator.mediadevices.getsupportedconstraints().samplesize) { result.innerhtml = "supported!"; } else { result.innerhtml = "not supported!"; } result specifications specification status comment media capture and streamsthe definition of 'samplesize' in that specification.
Compiling The npruntime Sample Plugin in Visual Studio - Archive of obsolete content
again note that the resulting dll filename must start with "np", so either call your project like this or rename the file later delete the .cpp and .h and readme files from the project and disk (if you did not create an empty project) copy the npruntime sample plugin source code into the dir of the new vs project and add the files to the project using the vs gui (.cpp files to "source files", .h files to "header files", .rc file to "resource files").
... samples can be obtained from: https://developer.mozilla.org/en/plugins/samples_and_test_cases get the npapi sdk.
Code Samples - Archive of obsolete content
this page contains sample code that you can use with the custom toolbar button tutorial.
... the samples here are designed to work in firefox, thunderbird, sunbird and seamonkey, except where the text says otherwise.
Displaying a graphic with audio samples - Archive of obsolete content
the following example shows how to take samples from an audio stream and display them behind an image (in this case, the mozilla logo), giving the impression that the image is built from the samples.
...ight="200"></canvas></div> <img id="mozlogo" style="display:none" src="mozilla2.png"></img> <script> var canvas = document.getelementbyid('fft'), ctx = canvas.getcontext('2d'), channels, rate, framebufferlength, fft; function loadedmetadata() { channels = audio.mozchannels; rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; fft = new fft(framebufferlength / channels, rate); } function audioavailable(event) { var fb = event.framebuffer, t = event.time, /* unused, but it's there */ signal = new float32array(fb.length / channels), magnitude; for (var i = 0, fbl = framebufferle...
NSS Sample Code Utilities_1
nss sample code common: utilities this is a library of utilities used by many of the samples.
... this code shows the following: extract seed from noise file read der encoding from a file extract the password from a text file get the module password print as ascii or hexadecimal sample code #include <prlog.h> #include <termios.h> #include <base64.h> #include <unistd.h> #include <sys/stat.h> #include <prprf.h> #include "util.h" /* * these utility functions are adapted from those found in * the sectool library used by the nss security tools and * other nss test applications.
Hashing - sample 1
nss sample code 1: hashing.
... */ printashex(outfile, digest, len); } while (0); /* cleanup */ if (hashcontext != null) hash_destroy(hashcontext); return secsuccess; } /* * this sample computes the hash of a file and saves it * to another file.
Initialize NSS database - sample 2
nss sample code 2: initialize the nss database.
... the nss sample code below demonstrates how to initialize the nss database.
EncDecMAC using token object - sample 3
encdecmac using token object example: <h2 id="nss_sample_code_3_hashing.">nss sample code 3: enc/dec/mac using token object id.</h2> <p class="summary">computes the hash of a file and saves it to another file, illustrates the use of nss message apis.</p> <pre class="brush: cpp"> /* this source code form is subject to the terms of the mozilla public * license, v.
...*/ /* nspr headers */ #include #include #include #include #include #include #include /* nss headers */ #include #include /* our samples utilities */ #include "util.h" #define buffersize 80 #define digestsize 16 #define ptext_mac_buffer_size 96 #define ciphersize 96 #define blocksize 32 #define cipher_header "-----begin cipher-----" #define cipher_trailer "-----end cipher-----" #define enckey_header "-----begin aeskey ckaid-----" #define enckey_trailer "-----end aeskey ckaid-----" #define mackey_header "-----begin mackey ckaid-----" #define mackey_trailer "-----end mackey ckaid-----" #define iv_header "-----begin iv-----" #define iv_trailer "-----end iv-----" #define mac_header "---...
New NSS Samples
new nss sample code this collection of sample code demonstrates how nss can be used for cryptographic operations, certificate handling, ssl, etc.
...see https://bugzilla.mozilla.org/show_bug.cgi?id=490238 how to download the samples: hg clone https://hg.mozilla.org/projects/nss; cd nss; hg update samples_branch samples list: sample code 1: hashing sample code 2: init nss database sample code 3: encrypt/decrypt and mac using token sample code 4: encrypt/decrypt and mac using session objects sample code 5: encrypt/decrypt/mac output public key as a csr sample code 6: encrypt/decrypt/mac generating a pkcs#11 csr common code used by these samples: sample code 0: utilities thanks are due to shailendra jain, mozilla community member, who is the principal author of these samples.
Utilities for nss samples
nss sample code 0: utilities.
sample1
*/ printashex(outfile, digest, len); } while (0); /* cleanup */ if (hashcontext != null) hash_destroy(hashcontext); return secsuccess; } /* * this sample computes the hash of a file and saves it to another file.
Index - Web APIs
WebAPIIndex
53 analysernode.fftsize api, analysernode, property, reference, web audio api, fftsize the fftsize property of the analysernode interface is an unsigned long value and represents the window size in samples that is used when performing a fast fourier transform (fft) to get frequency domain data.
... 105 audiobuffer.copyfromchannel() api, audio, audiobuffer, copying, frames, method, reference, samples, web audio, web audio api, copy, copyfromchannel, sound the copyfromchannel() method of the audiobuffer interface copies the audio sample data from the specified channel of the audiobuffer to a specified float32array.
... 106 audiobuffer.copytochannel() api, audio, audiobuffer, method, reference, web audio api, copytochannel the copytochannel() method of the audiobuffer interface copies the samples to the specified channel of the audiobuffer, from the source array.
...And 43 more matches
Digital audio concepts - Web media technologies
each of these captured moments is a sample.
... by chaining all the samples together, you can approximately represent the original wave, as seen in the diagram below.
... in this example, the blue line represents the samples taken from the audio waveform, which is black.
...And 38 more matches
Color picker tool - CSS: Cascading Style Sheets
cker tool html <div id="container"> <div id="palette" class="block"> <div id="color-palette"></div> <div id="color-info"> <div class="title"> css color </div> </div> </div> <div id="picker" class="block"> <div class="ui-color-picker" data-topic="picker" data-mode="hsl"></div> <div id="picker-samples" sample-id="master"></div> <div id="controls"> <div id="delete"> <div id="trash-can"></div> </div> <div id="void-sample" class="icon"></div> </div> </div> <div id="canvas" data-tutorial="drop"> <div id="zindex" class="ui-input-slider" data-topic="z-index" data-info="z-index" ...
... -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; display: table; } /** * picker zone */ #picker { padding: 10px; width: 980px; } .ui-color-picker { padding: 3px 5px; float: left; border-color: #fff; } .ui-color-picker .switch_mode { display: none; } .ui-color-picker .preview-color:hover { cursor: move; } /** * picker container */ #picker-samples { width: 375px; height: 114px; max-height: 218px; margin: 0 10px 0 30px; overflow: hidden; position: relative; float: left; transition: all 0.2s; } #picker-samples .sample { width: 40px; height: 40px; margin: 5px; border: 1px solid #ddd; position: absolute; float: left; transition: all 0.2s; } #picker-samples .sample:hover { cursor: pointer; border-color: #bbb; transform: sc...
...ale(1.15); border-radius: 3px; } #picker-samples .sample[data-active='true'] { border-color: #999; } #picker-samples .sample[data-active='true']:after { content: ""; position: absolute; background: url('https://mdn.mozillademos.org/files/6065/arrow.png') center no-repeat; width: 100%; height: 12px; top: -12px; z-index: 2; } #picker-samples #add-icon { width: 100%; height: 100%; position: relative; box-shadow: inset 0px 0px 2px 0px #ddd; } #picker-samples #add-icon:hover { cursor: pointer; border-color: #ddd; box-shadow: inset 0px 0px 5px 0px #ccc; } #picker-samples #add-icon:before, #picker-samples #add-icon:after { content: ""; position: absolute; background-color: #eee; box-shadow: 0 0 1px 0 #eee; } #picker-samples #add-icon:before { width: 70%; height: 16%; top: 4...
...And 31 more matches
Web audio codec guide - Web media technologies
for each factor that affects the encoded audio, there is a simple rule that is nearly always true: because the fidelity of digital audio is determined by the granularity and precision of the samples taken to convert it into a data stream, the more data used to represent the digital version of the audio, the more closely the sampled sound will match the source material.
... the effect of source audio format on encoded audio output because encoded audio inherently uses fewer bits to represent each sample, the source audio format may actually have less impact on the encoded audio size than one might expect.
... sample rate the more samples available per second, the higher the resulting encoded audio fidelity is likely to be.
...And 23 more matches
Introducing the Audio API extension - Archive of obsolete content
this event has the following attributes: mozchannels: number of channels mozsamplerate: sample rate per second mozframebufferlength: number of samples collected in all channels this information is needed later to decode the audio data stream.
...tracts the data from an audio element: <!doctype html> <html> <head> <title>javascript metadata example</title> </head> <body> <audio id="audio-element" src="song.ogg" controls="true" style="width: 512px;"> </audio> <script> function loadedmetadata() { channels = audio.mozchannels; rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; } var audio = document.getelementbyid('audio-element'); audio.addeventlistener('loadedmetadata', loadedmetadata, false); </script> </body> </html> the mozaudioavailable event as the audio is played, sample data is made available to the audio layer and the audio buffer (size defined in mozframebufferlength) ge...
...ts filled with those samples.
...And 21 more matches
MathML Torture Test
pagella</option> <option value="texgyreschola">tex gyre schola</option> <option value="texgyretermes">tex gyre termes</option> <option value="xits">xits</option> </select> <br/> </p> <table> <tr> <td></td> <th scope="col">as rendered by tex</th> <th scope="col">as rendered by your browser</th></tr> <tr> <td>1</td> <td><img src="https://udn.realityripple.com/samples/45/d5a0dbbca3.png" width="38" height="22" alt="texbook, 16.2-16.3" /></td> <td> <math display="block"> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <msup> <mi>y</mi> <mn>2</mn> </msup> </mrow> </math> </td></tr> <tr> <td>2</td> <td><img src="https://udn.
...realityripple.com/samples/b8/da4a50ea34.png" width="30" height="17" alt="texbook, 16.2-16.3" /></td> <td> <math display="block"> <!-- <mrow> <msub><mi></mi><mn>2</mn></msub> <msub><mi>f</mi><mn>3</mn></msub> </mrow> --> <mrow> <mmultiscripts> <mi>f</mi> <mn>3</mn><none/> <mprescripts/> <mn>2</mn><none/> </mmultiscripts> </mrow> </math> </td></tr> <tr> <td>3</td> <td><img src="https://udn.realityripple.com/samples/8a/1d0e6e073c.png" width="58" height="47" alt="texbook, 17-17.1" /></td> <td> <math display="block"> <mrow> <mfrac> <mrow> <mi>x</mi> <mo...
...>+</mo> <msup> <mi>y</mi> <mn>2</mn> </msup> </mrow> <mrow> <mi>k</mi> <mo>+</mo> <mn>1</mn> </mrow> </mfrac> </mrow> </math> </td></tr> <tr> <td>4</td> <td><img src="https://udn.realityripple.com/samples/a7/27acbeabcf.png" width="76" height="25" alt="texbook, 17-17.1" /></td> <td> <math display="block"> <mrow> <mi>x</mi> <mo>+</mo> <msup> <mi>y</mi> <mfrac> <mn>2</mn> <mrow> <mi>k</mi> <mo>+</mo> <mn>1</mn> </mrow> </mfrac> </msup> </m...
...And 21 more matches
Modularization techniques - Archive of obsolete content
this sample code should be updated to reflect this, but it gives you a good basic understanding of com from the c++ perspective.
... file nsisample.h nsisample.h defines an extremely simple interface and its interface id (iid).
... #include "nsisupports.h" // {57ecad90-ae1a-11d1-b66c-00805f8a2676} #define ns_isample_iid \ {0x57ecad90, 0xae1a, 0x11d1, \ {0xb6, 0x6c, 0x00, 0x80, 0x5f, 0x8a, 0x26, 0x76}} /* * nsisample interface declaration */ class nsisample: public nsisupports { public: ns_imethod hello() = 0; }; file nssample.h nssample.h defines the class id (cid) for our sample class.
...And 20 more matches
Index
9 encrypt decrypt mac keys as session objects decrypt, encryption, example, nss, sample code generates encryption/mac keys and uses session objects.
... 13 getting started with nss samples wip network security services (nss) is a base library for cryptographic algorithms and secure network protocols used by mozilla software.
... 169 nss sample code example the collection of sample code here demonstrates how nss can be used for cryptographic operations, certificate handling, ssl, etc.
...And 20 more matches
Call Tree - Firefox Developer Tools
it periodically samples the state of the javascript engine and records the stack for the code executing at the time.
... statistically, the number of samples taken in which we were executing a particular function corresponds to the amount of time the browser spent executing it.
...each row represents a function in which at least one sample was taken, and the rows are ordered by the number of samples taken while in that function, highest to lowest.
...And 15 more matches
Creating the Component Code
static const nsiid kimoduleiid = ns_imodule_iid; static const nsiid kifactoryiid = ns_ifactory_iid; static const nsiid kisupportsiid = ns_isupports_iid; static const nsiid kicomponentregistrariid = ns_icomponentregistrar_iid; // generate unique id here with uuidgen #define sample_cid \ { 0x777f7150, 0x4a2b, 0x4301, \ { 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}} static const nscid ksamplecid = sample_cid; nsimodule.h and nsifactory.h are required to build your module successfully.
...the variable kifactoryiid, for example, provides methods like equals() that can be used to facilitate comparisons in the code, as in the following example from the mozilla source: using class methods to handle identifiers if (aiid.equals(ns_get_iid(nsisupports))) { *ainstanceptr = (void*)(nsisupports*)this; ns_addref_this(); return ns_ok; } finally, sample_cid is an example of a cid that uniquely identifies the component.
...the code to register such an object is simple: ns_imethodimp samplemodule::registerself(nsicomponentmanager *acompmgr, nsifile* apath, const char* registrylocation, const char* componenttype) { printf("hello mozilla registration!\n\n"); nsicomponentregistrar* compreg = nsnull; nsresult rv = acompmgr->queryinterface(kicomponentregistrariid,(void**)& compreg); if ...
...And 14 more matches
Advanced techniques: Creating and sequencing audio - Web APIs
we're going to introduce sample loading, envelopes, filters, wavetables, and frequency modulation.
...the techniques we are using are: name of voice technique associated web audio api feature "sweep" oscillator, periodic wave oscillatornode, periodicwave "pulse" multiple oscillators oscillatornode "noise" random noise buffer, biquad filter audiobuffer, audiobuffersourcenode, biquadfilternode "dial up" loading a sound sample to play audiocontext.decodeaudiodata(), audiobuffersourcenode note: this instrument was not created to sound good, it was created to provide demonstration code and represents a very simplified version of such an instrument.
...we can use the baseaudiocontext.samplerate property for this: const buffersize = audioctx.samplerate * noiselength; const buffer = audioctx.createbuffer(1, buffersize, audioctx.samplerate); now we can fill it with random numbers between -1 and 1: let data = buffer.getchanneldata(0); // get data // fill the buffer with noise for (let i = 0; i < buffersize; i++) { data[i] = math.random() * 2 - 1; } note: why -1 to 1?
...And 14 more matches
Creating a status bar extension - Archive of obsolete content
some of the samples in this series may be similar to samples you've seen elsewhere, but the goal of this series of articles is to help compile information for new extension developers into one place to make it easy to jump in and get started.
...this sample will add a static text string to the status bar at the bottom of firefox browser windows.
...however, this sample will be expanded upon in later articles in the series.
...And 13 more matches
Index - Archive of obsolete content
32 porting the library detector add-on sdk, add-ons, example, extensions, sample code, tutorial no summary!
... 237 extension samples no summary!
... 312 adding preferences to an extension add-ons, extensions, preferences system, xul this article takes the creating a dynamic status bar extension sample to the next level, adding a popup menu that lets you quickly switch between multiple stocks to watch.
...And 13 more matches
Basic concepts behind Web Audio API - Web APIs
audio data: what's in a sample when an audio signal is processed, sampling means the conversion of a continuous signal to a discrete signal; or put another way, a continuous sound wave, such as a band playing live, is converted to a sequence of samples (a discrete-time signal) that allow a computer to handle the audio in distinct blocks.
... audio buffers: frames, samples and channels an audiobuffer takes as its parameters a number of channels (1 for mono, 2 for stereo, etc), a length, meaning the number of sample frames inside the buffer, and a sample rate, which is the number of sample frames played per second.
... a sample is a single float32 value that represents the value of the audio stream at each specific point in time, in a specific channel (left or right, if in the case of stereo).
...And 12 more matches
Applying styles and colors - Web APIs
lementbyid('canvas').getcontext('2d'); for (var i = 0; i < 6; i++) { for (var j = 0; j < 6; j++) { ctx.fillstyle = 'rgb(' + math.floor(255 - 42.5 * i) + ', ' + math.floor(255 - 42.5 * j) + ', 0)'; ctx.fillrect(j * 25, i * 25, 25, 25); } } } <canvas id="canvas" width="150" height="150"></canvas> draw(); the result looks like this: screenshotlive sample a strokestyle example this example is similar to the one above, but uses the strokestyle property to change the colors of the shapes' outlines.
...; j < 6; j++) { ctx.strokestyle = 'rgb(0, ' + math.floor(255 - 42.5 * i) + ', ' + math.floor(255 - 42.5 * j) + ')'; ctx.beginpath(); ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, math.pi * 2, true); ctx.stroke(); } } } <canvas id="canvas" width="150" height="150"></canvas> draw(); the result looks like this: screenshotlive sample transparency in addition to drawing opaque shapes to the canvas, we can also draw semi-transparent (or translucent) shapes.
...5, 75, 75); ctx.fillstyle = '#f30'; ctx.fillrect(75, 75, 75, 75); ctx.fillstyle = '#fff'; // set transparency value ctx.globalalpha = 0.2; // draw semi transparent circles for (var i = 0; i < 7; i++) { ctx.beginpath(); ctx.arc(75, 75, 10 + 10 * i, 0, math.pi * 2, true); ctx.fill(); } } <canvas id="canvas" width="150" height="150"></canvas> draw(); screenshotlive sample an example using rgba() in this second example, we do something similar to the one above, but instead of drawing circles on top of each other, i've drawn small rectangles with increasing opacity.
...And 11 more matches
Creating a dynamic status bar extension - Archive of obsolete content
specifically, this sample displays a stock quote in the status bar, and, when you mouse over it, displays a tooltip containing more detailed information about the stock.
... concepts covered in the previous sample won't be reiterated here; instead, refer to the downloadable sample code or to the previous sample for further details.
... download the sample you can download a copy of this sample to look over, or to use as the basis for your own extension.
...And 10 more matches
powermetrics
the following command encompasses the most useful ones: sudo powermetrics --samplers tasks --show-process-coalition --show-process-gpu -n 1 -i 5000 --samplers tasks tells it to just do per-process measurements.
... -n 1 tells it to take one sample and then stop.
... -i 5000 tells it to use a sample length of 5 seconds (5000 ms).
...And 10 more matches
Digital video concepts - Web media technologies
there are two primary methods used to represent rgb samples: using integer components and using floating-point components.
... blue-difference (u or cb) the blue-difference component of the chroma, or color, of the color sample.
... red-difference (v or cr) the red-difference component of the chroma of the color sample.
...And 9 more matches
Profiling with the Firefox Profiler
call tree the call tree shows the samples organized by 'running time' which will show the data by wall clock time.
...you can see the samples in the timeline get darker as you select different functions in the call tree; these are samples that were taken when the selected function was running.
...thgis requires the following command: $ xpcshell -m -i -n -e ' const ci = components.interfaces; const cc = components.classes; var profiler = cc["@mozilla.org/tools/profiler;1"].getservice(ci.nsiprofiler); profiler.startprofiler( 10000000 /* = profiler memory */, 1 /* = sample rate: 100µs with patch, 1ms without */, ["stackwalk", "js"], 2 /* = features, and number of features.
...And 8 more matches
BaseAudioContext.createBuffer() - Web APIs
note: createbuffer() used to be able to take compressed data and give back decoded samples, but this ability was removed from the spec, because all the decoding was done on the main thread, therefore createbuffer() was blocking other code execution.
... syntax var buffer = baseaudiocontext.createbuffer(numofchannels, length, samplerate); parameters note: for an in-depth explanation of how audio buffers work, and what these parameters mean, read audio buffers: frames, samples and channels from our basic concepts guide.
... length an integer representing the size of the buffer in sample-frames (where each sample-frame is the size of a sample in bytes multiplied by numofchannels).
...And 8 more matches
Gecko Profiler FAQ
similarly it also can’t show you instruction level information about where each sample was captured (this is why there is no support for line-level sampling for native code either.) at this point the granularity of each sample it displays is a native function.
...you need deterministic profiles that can be compared meaningfully, you need to gather enough data / samples, and you need a way to compare profiles.
...to stop the profiler from gathering more samples after the “startup end” marker that you’re interested in, you can call services.profiler.pause(); or you can insert a marker with a special string and then write a script that filters out all samples that were gathered after your marker.
...And 7 more matches
Creating a Web based tone generator - Archive of obsolete content
the function requestsounddata() produces the samples to be played.
...the function mozwriteaudio() is called to write those samples produced in the audio stream.
... in order to always have samples to play, a buffer of 500 ms is created.
...And 6 more matches
Debugging a hang on OS X (Archived)
below are steps you can use to attach so-called "samples" to bug reports.
... creating the sample on mac os x 10.5 (xcode < 4.2) when the application is still hung, open up spin control.app (it’s in your <tt>/developer/applications/performance tools/</tt> folder; if it is missing, install the latest computer hardware understanding development (chud) tools from apple).
... when it's done parsing the data, click the "show text report" button; a new window will open with a couple of rows with stacktraces for all the threads in the sampled application.
...And 6 more matches
Drawing shapes with canvas - Web APIs
screenshotlive sample the fillrect() function draws a large black square 100 pixels on each side.
...<body onload="draw();"> <canvas id="canvas" width="100" height="100"></canvas> </body> </html> function draw() { var canvas = document.getelementbyid('canvas'); if (canvas.getcontext) { var ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(75, 50); ctx.lineto(100, 75); ctx.lineto(100, 25); ctx.fill(); } } the result looks like this: screenshotlive sample moving the pen one very useful function, which doesn't actually draw anything but becomes part of the path list described above, is the moveto() function.
...npath(); ctx.arc(75, 75, 50, 0, math.pi * 2, true); // outer circle ctx.moveto(110, 75); ctx.arc(75, 75, 35, 0, math.pi, false); // mouth (clockwise) ctx.moveto(65, 65); ctx.arc(60, 65, 5, 0, math.pi * 2, true); // left eye ctx.moveto(95, 65); ctx.arc(90, 65, 5, 0, math.pi * 2, true); // right eye ctx.stroke(); } } the result looks like this: screenshotlive sample if you'd like to see the connecting lines, you can remove the lines that call moveto().
...And 6 more matches
Traversing an HTML table with JavaScript and DOM Interfaces - Web APIs
example: creating an html table dynamically (sample1.html) html <input type="button" value="generate a table." onclick="generate_table()"> javascript function generate_table() { // get the reference for the body var body = document.getelementsbytagname("body")[0]; // creates a <table> element and a <tbody> element var tbl = document.createelement("table"); var tblbody = document.createelement("tbody"); // creating all cells fo...
... myp.appendchild(mytextnode); after testing this sample, note that the words hello and world are together: helloworld.
... mynewptagnode.appendchild(mytextnode); the final state for the modified object tree looks like this: creating a table dynamically (back to sample1.html) for the rest of this article we will continue working with sample1.html.
...And 6 more matches
The "codecs" parameter in common media types - Web media technologies
if both of those are 1, the third is the value of chroma_sample_position; otherwise, the third digit is always 0.
... subsampling_y monochrome flag chroma subsampling format 0 0 0 yuv 4:4:4 1 0 0 yuv 4:2:2 1 1 0 yuv 4:2:0 1 1 1 yuv 4:0:0 (monochrome) the third digit in ccc indicates the chroma sample position, with a value of 0 indicating that the position is unknown and must be separately provided during decoding; a value of 1 indicating that the sample position is horizontally colocated with the (0, 0) luma sample; and a value of 2 indicating that the sample position is colocated with (0, 0) luma.
...also includes support for up to 14 bits per color sample and efficient lossless region coding.
...And 6 more matches
Audio for Web games - Game development
to prime audio like this we want to play a part of it; for this reason it is useful to include a moment of silence at the end of your audio sample.
... var myaudio = document.createelement("audio"); myaudio.src = "mysprite.mp3"; myaudio.play(); myaudio.pause(); you'll need to sample the current time to know when to stop.
... here's an example of an audio sprite player — first let's set up the user interface in html: <audio id="myaudio" src="https://udn.realityripple.com/samples/f0/2909c16512.mp3"></audio> <button data-start="18" data-stop="19">0</button> <button data-start="16" data-stop="17">1</button> <button data-start="14" data-stop="15">2</button> <button data-start="12" data-stop="13">3</button> <button data-start="10" data-stop="11">4</button> <button data-start="8" data-stop="9">5</button> <button data-start="6" data-stop="7">6</button> <button data-start="4" data-stop="5">7</...
...And 5 more matches
How do you host your website on Google App Engine? - Learn web development
for this tutorial, the following values are used: project name: gae sample site project id: gaesamplesite click the create button to create your project.
... we'll need a sample application to publish.
... if you've not got one to use, download and unzip this sample app.
...And 5 more matches
nss tech note5
using nss to perform miscellaneous cryptographic operations nss technical note: 5 nss project info is at http://www.mozilla.org/projects/security/pki/nss/ you can browse the nss source online at http://lxr.mozilla.org/mozilla/source/security/nss/ and http://lxr.mozilla.org/security/ be sure to look for sample code first for things you need to do.
... you can also look at a sample program illustrating encryption hash / digest include headers #include "nss.h" #include "pk11pub.h" make sure nss is initialized.the simplest init function, in case you don't need a nss database is nss_nodb_init(".") <big>create digest context</big>.
...d_md5); <big>digest the data</big> <big>secstatus s = pk11_digestbegin(digestcontext); s = pk11_digestop(digestcontext, data, sizeof data); s = pk11_digestfinal(digestcontext, digest, &len, sizeof digest); /* now, digest contains the 'digest', and len contains the length of the digest */</big> clean up pk11_destroycontext(digestcontext, pr_true); you can also look at a sample program illustrating this hash / digest with secret key included include headers #include "nss.h" #include "pk11pub.h" make sure nss is initialized.the simplest init function, in case you don't need a nss database is nss_nodb_init(".") choose a digest mechanism.
...And 5 more matches
nsIDOMHTMLAudioElement
last changed in gecko 2.0 (firefox 4 / thunderbird 3.3 / seamonkey 2.1) inherits from: nsidomhtmlmediaelement method overview unsigned long long mozcurrentsampleoffset(); void mozsetup(in pruint32 channels, in pruint32 rate); [implicit_jscontext] unsigned long mozwriteaudio(in jsval data); methods mozcurrentsampleoffset() non-standard this feature is non-standard and is not on a standards track.
... returns the current offset of the audio stream, specified as the number of samples that have played since the beginning of the stream.
... unsigned long long mozcurrentsampleoffset(); parameters none.
...And 5 more matches
WebGL constants - Web APIs
0d3a subpixel_bits 0x0d50 red_bits 0x0d52 green_bits 0x0d53 blue_bits 0x0d54 alpha_bits 0x0d55 depth_bits 0x0d56 stencil_bits 0x0d57 polygon_offset_units 0x2a00 polygon_offset_factor 0x8038 texture_binding_2d 0x8069 sample_buffers 0x80a8 samples 0x80a9 sample_coverage_value 0x80aa sample_coverage_invert 0x80ab compressed_texture_formats 0x86a3 vendor 0x1f00 renderer 0x1f01 version 0x1f02 implementation_color_read_type 0x8b9a implementation_color_read_format 0x8b...
... sample_alpha_to_coverage 0x809e passed to enable/disable to turn on/off the alpha to coverage.
... sample_coverage 0x80a0 passed to enable/disable to turn on/off the sample coverage.
...And 5 more matches
Background audio processing using AudioWorklet - Web APIs
fundamentally, the audio for a single audio channel (such as the left speaker or the subwoofer, for example) is represented as a float32array whose values are the individual audio samples.
... by specification, each block of audio your process() function receives contains 128 frames (that is, 128 samples for each channel), but it is planned that this value will change in the future, and may in fact vary depending on circumstances, so you should always check the array's length rather than assuming a particular size.
...each input may have a different number of channels, and each channel has its own array of samples.
...And 5 more matches
Image file type and format guide - Web media technologies
greyscale with alpha 8 and 16 each pixel is represented by two d-bit values: the intensity of the greyscale pixel and an alpha sample, indicating how opaque the pixel is.
... true color with alpha 8 and 16 each pixel is comprised of four d-pixel color components: red, green, blue, and the alpha sample indicating how opaque the pixel is.
... greyscale with alpha 8 and 16 each pixel is represented by two d-bit values: the intensity of the greyscale pixel and an alpha sample, indicating how opaque the pixel is.
...And 5 more matches
Inner-browsing extending the browser navigation paradigm - Archive of obsolete content
note this article is the version from 2003 with slight modifications (no images and no links to samples).
...this sample was made using iframes to illustrate a possible implementation.
...we've separated this sample in two main components following the model.
...And 4 more matches
Examples - Archive of obsolete content
</p> <dl> <dt>mozilla 1.1+/opera 7</dt> <dd>do not apply css or execute the javascript.</dd> <dt>netscape 7.0x/mozilla 1.0.x</dt> <dd>do not apply css but does execute the javascript.</dd> <dt>internet explorer 5.5+</dt> <dd>can not display the document.</dd> </dl> <p> <a href="http://validator.w3.org/check/referer"><img src="https://udn.realityripple.com/samples/8a/9e64asf935.png" alt="valid xhtml 1.0!" height="31" width="88" /></a> </p> </body> </html> back to the article problem 3 <!-- this file should have a .xhtml extension and will generate an error when parsed.
... </p> <p> <a href="http://validator.w3.org/check/referer"><img src="https://udn.realityripple.com/samples/8a/9e64asf935.png" alt="valid xhtml 1.0!" height="31" width="88" /></a> </p> </body> </html> back to the article example 2 <!-- this file should have a .xml extension --> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <title>example...
... </p> <p> <a href="http://validator.w3.org/check/referer"><img src="https://udn.realityripple.com/samples/8a/9e64asf935.png" alt="valid xhtml 1.0!" height="31" width="88" /></a> </p> </body> </html> back to the article example 3 <!-- this file should have a .xhtml extension --> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <title>examp...
...And 4 more matches
Understanding client-side JavaScript frameworks - Learn web development
if you need to check your code against our version, you can find a finished version of the sample react app code in our todo-react repository.
... if you need to check your code against our version, you can find a finished version of the sample ember app code in the ember-todomvc-tutorial repository.
...getting started with ember in our first ember article we will look at how ember works and what it's useful for, install the ember toolchain locally, create a sample app, and then do some initial setup to get it ready for development.
...And 4 more matches
Enc Dec MAC Output Public Key as CSR
nss sample code 5: encryption/decryption and mac and output public as a csr.
...*/ /* nspr headers */ #include #include #include #include #include #include #include /* nss headers */ #include #include #include #include #include #include #include #include #include #include #include #include /* our samples utilities */ #include "util.h" #define buffersize 80 #define digestsize 16 #define ptext_mac_buffer_size 96 #define ciphersize 96 #define blocksize 32 #define default_key_bits 1024 #define cipher_header "-----begin cipher-----" #define cipher_trailer "-----end cipher-----" #define enckey_header "-----begin wrapped enckey...
... * fixme: samples should determine the version of nss that's available and refuse * to run if not 3.13 or higher.
...And 4 more matches
Enc Dec MAC Using Key Wrap CertReq PKCS10 CSR
nss sample code 6: encryption/decryption and mac and output public as a pkcs 11 csr.
...*/ /* nspr headers */ #include <prthread.h> #include <plgetopt.h> #include <prerror.h> #include <prinit.h> #include <prlog.h> #include <prtypes.h> #include <plstr.h> /* nss headers */ #include <keyhi.h> #include <pk11priv.h> /* our samples utilities */ #include "util.h" /* constants */ #define blocksize 32 #define modblocksize 128 #define default_key_bits 1024 /* header file constants */ #define enckey_header "-----begin wrapped enckey-----" #define enckey_trailer "-----end wrapped enckey-----" #define mackey_header "-----begin wrapped mackey-----" #define mackey_trailer ...
...rt_vfy_header "-----begin certificate for signature verification-----" #define ns_cert_vfy_trailer "-----end certificate for signature verification-----" #define ns_sig_header "-----begin signature-----" #define ns_sig_trailer "-----end signature-----" #define ns_cert_header "-----begin certificate-----" #define ns_cert_trailer "-----end certificate-----" /* sample 6 commands */ typedef enum { generate_csr, add_cert_to_db, save_cert_to_header, encrypt, decrypt, sign, verify, unknown } commandtype; typedef enum { symkey = 0, mackey = 1, iv = 2, mac = 3, pad = 4, pubkey = 5, lab = 6, certenc= 7, certvfy= 8, sig = 9 } headertype; /* * print usage message an...
...And 4 more matches
Allocations - Firefox Developer Tools
then record a profile as usual, and you will see a new tab labeled "allocations" in the toolbar: anatomy of the allocations view the allocations view looks something like this: the allocations view periodically samples allocations that are made over the recording.
... each row represents a function in which at least one allocation-sample was taken during the recording.
... it includes the following columns: self count: the number of allocation-samples that were taken in this function (also shown as a percentage of the total) self bytes: the total number of bytes allocated in the allocation-samples in this function (also shown as a percentage of the total) rows are sorted by the "self bytes" column.
...And 4 more matches
AudioWorkletProcessor.process - Web APIs
important: currently, audio data blocks are always 128 frames long—that is, they contain 128 32-bit floating-point samples for each of the inputs' channels.
...therefore, you must always check the size of the sample array rather than assuming a particular size.
... this size may even be allowed to change over time, so you mustn't look at just the first block and assume the sample buffers will always be the same size.
...And 4 more matches
OfflineAudioContext.OfflineAudioContext() - Web APIs
syntax var offlineaudioctx = new offlineaudiocontext(numberofchannels, length, samplerate); var offlineaudioctx = new offlineaudiocontext(options); parameters you can specify the parameters for the offlineaudiocontext() constructor as either the same set of parameters as are inputs into the audiocontext.createbuffer() method, or by passing those parameters in an options object.
... length an integer specifying the size of the buffer to create for the audio context, in sample-frames, where one sample-frame is a unit that can contain a single sample of audio data for every channel in the audio data.
... for example, a 5-second buffer with a samplerate of 48000hz would have a length of 5 * 48000 = 240000 sample-frames.
...And 4 more matches
WebGL2RenderingContext - Web APIs
webgl2renderingcontext.renderbufferstoragemultisample() creates and initializes a renderbuffer object's data store and allows specifying the number of samples to be used.
... sampler objects webgl2renderingcontext.createsampler() creates a new webglsampler object.
... webgl2renderingcontext.deletesampler() deletes a given webglsampler object.
...And 4 more matches
Using textures in WebGL - Web APIs
« previousnext » now that our sample program has a rotating 3d cube, let's map a texture onto it instead of having its faces be solid colors.
...our sample loads a copy from a cdn in our html's <head>.
...without performing the above configuration, webgl requires all samples of npot textures to fail by returning transparent black: rgba(0,0,0,0).
...And 4 more matches
WebGL best practices - Web APIs
don't assume you can use thirty texture samplers per shader just because it works on your machine!
...(works on desktop, not on android) if you have a float texture, ios requires that you use highp sampler2d foo;, or it will very painfully give you lowp texture samples!
... (+/-2.0 max is probably not good enough for you) implicit defaults the vertex language has the following predeclared globally scoped default precision statements: precision highp float; precision highp int; precision lowp sampler2d; precision lowp samplercube; the fragment language has the following predeclared globally scoped default precision statements: precision mediump int; precision lowp sampler2d; precision lowp samplercube; in webgl 1, "highp float" support is optional in fragment shaders using highp precision unconditionally in fragment shaders will prevent your content from working on some older mobile hardware.
...And 4 more matches
Standalone XPCOM - Archive of obsolete content
building standalone xpcom here are the instructions for building the standalone xpcom on unix or windows: step 1 : pull the sources cvs -z 3 co mozilla/client.mk cd mozilla gmake -f client.mk pull_all build_modules=xpcom step 2 : build xpcom standalone ./configure --enable-standalone-modules=xpcom --enable-application=standalone gmake testing standalone xpcom xpcom/sample contains a sample application and a component.
... nstestsample is the sample application.
... libsample.so (unix) is the sample component implementation that the sample application will try to instantiate.
...And 3 more matches
Accessing Files - Archive of obsolete content
the following example will retrieve a reference to a file named sample.txt located in the profile directory.
... var file = io.getfile("profile", "sample.txt"); the nsiscriptableio object is a global object always available within an application or extension which provides a number of useful functions for dealing with files.
...the second argument to nsiscriptableio.getfile() is the filename to locate, which, here, is 'sample.txt'.
...And 3 more matches
tools/power/rapl
once sampling is finished — either because the user interrupted it, or because the requested number of samples has been taken — the following summary data is shown: 10 samples taken over a period of 10.000 seconds distribution of 'total' values: mean = 8.85 w std dev = 3.50 w 0th percentile = 5.17 w (min) 5th percentile = 5.17 w 25th percentile = 5.17 w 50th percentile = 8.13 w 75th percentile = 11.16 w 95th percentile = 14.63 w 100th percentile = 14.63 w (max) the...
... distribution data is omitted if there was zero or one samples taken.
... options -i --sample-interval.
...And 3 more matches
nsIDOMMozNetworkStatsManager
you can test for the presence of the service as follows, for example: if ("moznetworkstats" in navigator) { /* networkstats is available */ } else { alert("i'm sorry, but networkstats services are not supported."); } method overview nsidomdomrequest getsamples(in nsisupports network, in jsval start, in jsval end, [optional] in jsval options /* networkstatsgetoptions */); nsidomdomrequest addalarm(in nsisupports network, in long threshold, [optional] in jsval options /* networkstatsalarmopt...
...est getallalarms([optional] in nsisupports network); nsidomdomrequest removealarms([optional] in long alarmid); nsidomdomrequest clearstats(in nsisupports network); nsidomdomrequest clearallstats(); nsidomdomrequest getavailablenetworks(); nsidomdomrequest getavailableservicetypes(); attributes attribute type description samplerate long minimum time in milliseconds between samples stored in the database.
...all samples older than maxstorageage from now are deleted.
...And 3 more matches
Activity Manager examples
for xbl samples please see activity.xml and activitybinding.css files.
... showing a user-defined activity in the activity manager window the following sample will show a process and an event for junk processing in the activity manager window.
...older.prettiestname + " is processed", null, "no junk found", process.starttime, // start time date.now()); // completion time event.contexttype = process.contexttype; // optional event.contextobj = process.contextobj; // optional gactivitymanager.addactivity(event); showing a user-defined activity with cancel capability (javascript) this sample improves the previous one by providing an nsiactivitycancelhandler to allow the user to cancel the process.
...And 3 more matches
AudioBuffer() - Web APIs
options options are as follows: length: the size of the audio buffer in sample-frames.
... to determine the length to use for a specific number of seconds of audio, use numseconds * samplerate.
... samplerate: the sample rate in hz for the buffer.
...And 3 more matches
AudioBuffer.copyFromChannel() - Web APIs
the copyfromchannel() method of the audiobuffer interface copies the audio sample data from the specified channel of the audiobuffer to a specified float32array.
... syntax myarraybuffer.copyfromchannel(destination, channelnumber, startinchannel); parameters destination a float32array to copy the channel's samples to.
... startinchannel optional an optional offset into the source channel's buffer from which to begin copying samples.
...And 3 more matches
AudioBuffer - Web APIs
the buffer contains data in the following format: non-interleaved ieee754 32-bit linear pcm with a nominal range between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0.
... properties audiobuffer.samplerate read only returns a float representing the sample rate, in samples per second, of the pcm data stored in the buffer.
... audiobuffer.length read only returns an integer representing the length, in sample-frames, of the pcm data stored in the buffer.
...And 3 more matches
BaseAudioContext.createScriptProcessor() - Web APIs
syntax var scriptprocessor = audioctx.createscriptprocessor(buffersize, numberofinputchannels, numberofoutputchannels); parameters buffersize the buffer size in units of sample-frames.
... this value controls how frequently the audioprocess event is dispatched and how many sample-frames need to be processed each call.
... example the following example shows basic usage of a scriptprocessornode to take a track loaded via audiocontext.decodeaudiodata(), process it, adding a bit of white noise to each audio sample of the input track (buffer) and play it through the audiodestinationnode.
...And 3 more matches
Using images - Web APIs
ocument.getelementbyid('canvas').getcontext('2d'); var img = new image(); img.onload = function() { ctx.drawimage(img, 0, 0); ctx.beginpath(); ctx.moveto(30, 96); ctx.lineto(70, 66); ctx.lineto(103, 76); ctx.lineto(170, 15); ctx.stroke(); }; img.src = 'https://mdn.mozillademos.org/files/5395/backdrop.png'; } the resulting graph looks like this: screenshotlive sample scaling the second variant of the drawimage() method adds two new parameters and lets us place scaled images on the canvas.
..."> <canvas id="canvas" width="150" height="150"></canvas> </body> </html> function draw() { var ctx = document.getelementbyid('canvas').getcontext('2d'); var img = new image(); img.onload = function() { for (var i = 0; i < 4; i++) { for (var j = 0; j < 3; j++) { ctx.drawimage(img, j * 50, i * 38, 50, 38); } } }; img.src = 'https://udn.realityripple.com/samples/db/f374e9c6fc.jpg'; } the resulting canvas looks like this: screenshotlive sample slicing the third and last variant of the drawimage() method has eight parameters in addition to the image source.
... <html> <body onload="draw();"> <canvas id="canvas" width="150" height="150"></canvas> <div style="display:none;"> <img id="source" src="https://udn.realityripple.com/samples/db/f374e9c6fc.jpg" width="300" height="227"> <img id="frame" src="https://udn.realityripple.com/samples/57/952c634159.png" width="132" height="150"> </div> </body> </html> function draw() { var canvas = document.getelementbyid('canvas'); var ctx = canvas.getcontext('2d'); // draw slice ctx.drawimage(document.getelementbyid('source'), 33, 71, 104, 124, 21, 20, ...
...And 3 more matches
Codecs used by WebRTC - Web media technologies
g.711 g.711 defines the format for pulse code modulation (pcm) audio as a series of 8-bit integer samples taken at a sample rate of 8,000 hz, yielding a bit rate of 64 kbps.
... webrtc requires that g.711 use 8-bit samples at the standard 64 kbps rate, even though g.711 supports some other variations.
... due to its low sample rate and sample size, g.711 audio quality is generally considered poor by modern standards, even though it's roughly equivalent to what a landline telephone sounds like.
...And 3 more matches
Chapter 3: Introduction to XUL—How to build a more intuitive UI - Archive of obsolete content
for example, there is the mozilla amazon browser, which helps with shopping at amazon, and the presentation method in xul, a tool for writing and displaying presentations to try out the code samples in this chapter, save them as text files with .xul extensions and drag and drop them into the firefox browser window.
...but for the samples in this chapter, please include them.
...please be aware that if you attempt to open this sample directly in firefox, it will not run correctly.
...And 2 more matches
Localizing an extension - Archive of obsolete content
« previousnext » this article expands upon the previous samples on extension writing by adding localization support to our stock watcher extension.
...if you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series: creating a status bar extension creating a dynamic status bar extension adding preferences to an extension download the sample you can download this article's sample code so you can look at it side-by-side with the article, or to use it as a basis for your own extension.
... download the sample localizing strings in xul files create the needed locale files each xul file that comprises the user interface for your extension should have a locale file in its locale directory.
...And 2 more matches
How to implement a custom XUL query processor component - Archive of obsolete content
we are not really using the datasources in our sample component, so we set it to a dummy value.
... here is our sample javascript xpcom query processor: components.utils.import("resource://gre/modules/xpcomutils.jsm"); // basic wrapper for nsixultemplateresult function templateresult(adata) { this._data = adata; // just make a random number for the id this._id = math.random(100000).tostring(); } templateresult.prototype = { queryinterface: xpcomutils.generateqi([components.interfaces.nsixultemplateresult]), // private storage _data: null, // right now our results are flat lists, so no co...
...rown", eye: "brown"}, {name: "bill", age: 25, hair: "red", eye: "black"}, {name: "joe", age: 15, hair: "blond", eye: "blue"}, {name: "jimmy", age: 65, hair: "gray", eye: "dull"} ]; } templatequeryprocessor.prototype = { queryinterface: xpcomutils.generateqi([components.interfaces.nsixultemplatequeryprocessor]), classdescription: "sample xul template query processor", classid: components.id("{282cc4ea-a49c-44fc-81f4-1f03cbb7825f}"), contractid: "@mozilla.org/xul/xul-query-processor;1?name=simpledata", getdatasource: function(adatasources, arootnode, aistrusted, abuilder, ashoulddelaybuilding) { // todo: parse the adatasources variable // for now, ignore everything and let's just signal that we have data return ...
...And 2 more matches
Writing a plugin for Mac OS X - Archive of obsolete content
before you go on reading this article, you may wish to grab the sample code located here, as it will be referenced during this tutorial.
... the sample is posted under a bsd-style license that means you can use it for anything, even if you don't plan to release your source code.
... to install the plugin, just copy it into one of these two locations: /library/internet plugins/ ~/library/internet plugins/ from this point, you can simply modify the sample plugin to do whatever you want.
...And 2 more matches
Building a Theme - Archive of obsolete content
create the install manifest open the file called install.rdf that you created at the top of your extension's folder hierarchy and put this inside: <?xml version="1.0"?> <rdf xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <description about="urn:mozilla:install-manifest"> <em:id>sample@example.net</em:id> <em:version>1.0</em:version> <em:type>4</em:type> <!-- target application this theme can install into, with minimum and maximum supported versions.
... --> <em:targetapplication> <description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minversion>29.0</em:minversion> <em:maxversion>39.*</em:maxversion> </description> </em:targetapplication> <!-- front end metadata --> <em:name>my theme</em:name> <em:internalname>sample</em:internalname> <em:description>a test extension</em:description> <em:creator>your name here</em:creator> <em:homepageurl>http://www.example.com/</em:homepageurl> </description> </rdf> sample@example.net - the id of the extension.
... add in this code: skin browser sample chrome/browser/ skin communicator sample chrome/communicator/ skin global sample chrome/global/ skin mozapps sample chrome/mozapps/ don't forget the trailing slash, "/"!
...And 2 more matches
Positioning - Learn web development
overflowing inline elements <span>wrap onto a new line if possible — like this one containing text</span>, or just go on to a new line if not, much like this image will do: <img src="https://udn.realityripple.com/samples/9e/6ff6af6fd4.jpg"></p> body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: relative; background: yellow; top: 30px; left: 30px; } cool, huh?
...overflowing inline elements <span>wrap onto a new line if possible — like this one containing text</span>, or just go on to a new line if not, much like this image will do: <img src="https://udn.realityripple.com/samples/9e/6ff6af6fd4.jpg"></p> body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; } first of all, note that the gap where the positioned element should be in the document flow is n...
...overflowing inline elements <span>wrap onto a new line if possible — like this one containing text</span>, or just go on to a new line if not, much like this image will do: <img src="https://udn.realityripple.com/samples/9e/6ff6af6fd4.jpg"></p> body { width: 500px; margin: 0 auto; position: relative; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; } the positioned element now sits relative to the <body> element.
...And 2 more matches
Index - Learn web development
we've got to the point where we can start build up our sample todomvc app in ember.
...we now have sample data in place, and a loop that takes each bit of data and renders it inside a todoitem in our app.
... 296 styling vue components with css beginner, css, frameworks, javascript, learn, styling, client-side, vue our work is done on the styling of our sample app.
...And 2 more matches
mozIStorageStatement
see the sample code for more details.
... sample code var statement = dbconn.createstatement( "select * " + "from table_name " + "where column_name like :userinput escape '/'" ); statement.params.userinput = statement.escapestringforlike(someuserinput, "/"); binding functions these functions are discussed in more detail with sample code in the overview document.
... execution functions these functions are discussed in more detail with sample code in the overview document.
...And 2 more matches
AudioContext() - Web APIs
samplerate optional the samplerate to be used by the audiocontext, specified in samples per second.
...if not specified, the preferred sample rate for the context's output device is used by default.
... exceptions notsupportederror the specified samplerate isn't supported by the context.
...And 2 more matches
Transformations - Web APIs
screenshotlive sample translating the first of the transformation methods we'll look at is translate().
...etelementbyid('canvas').getcontext('2d'); for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { ctx.save(); ctx.fillstyle = 'rgb(' + (51 * i) + ', ' + (255 - 51 * i) + ', 255)'; ctx.translate(10 + j * 50, 10 + i * 50); ctx.fillrect(0, 0, 25, 25); ctx.restore(); } } } <canvas id="canvas" width="150" height="150"></canvas> draw(); screenshotlive sample rotating the second transformation method is rotate().
... <canvas id="canvas" width="300" height="200"></canvas> draw(); screenshotlive sample scaling the next transformation method is scaling.
...And 2 more matches
ScriptProcessorNode.bufferSize - Web APIs
the buffersize property of the scriptprocessornode interface returns an integer representing both the input and output buffer size, in sample-frames.
... example the following example shows basic usage of a scriptprocessornode to take a track loaded via audiocontext.decodeaudiodata(), process it, adding a bit of white noise to each audio sample of the input track (buffer) and play it through the audiodestinationnode.
... for each channel and each sample frame, the scriptnode.onaudioprocess function takes the associated audioprocessingevent and uses it to loop through each channel of the input buffer, and each sample in each channel, and add a small amount of white noise, before setting that result to be the output sample in each case.
...And 2 more matches
Web video codec guide - Web media technologies
ed bit rates unrestricted, but typically below 64 kbps supported frame rates any compression lossy dct-based algorithm supported frame sizes up to 1408 x 1152 pixels[2] supported color modes ycbcr; each picture format (sub-qcif, qcif, cif, 4cif, or 16cif) defines the frame size in pixels as well as how many rows each of luminance and chrominance samples are used for each frame hdr support no variable frame rate (vfr) support no browser compatibility feature chrome edge firefox internet explorer opera safari h.263 support no no no[1] no no no containe...
... for example, each coding tree unit (ctu)—similar to the macroblock used in previous codecs—consists of a tree of luma values for each sample as well as a tree of chroma values for each chroma sample used in the same coding tree unit, as well as any required syntax elements.
...instead of having the luma samples (representing the image's pixels in grayscale) and the cb and cr samples (indicating how to alter the grays to create color pixels), the three channels are instead treated as three monochrome images, one for each color, which are then combined during rendering to produce a full-color image.
...And 2 more matches
HTML to DOM - Archive of obsolete content
the returned <body> object is of type element here is a sample that counts the number of paragraphs in a string: var dompars = htmlparser('<p>foo</p><p>bar</p>'); alert(dompars.getelementsbytagname('p').length); if htmlparser() returns the element name html (instead of body), you have all document object with its complete functions list, therefore you can retrieve info within div tag like this: var dompars = htmlparser("<div id='userinfo'>john was a medi...
...t the dom into which we'll insert our newly-retrieved html: var doc = document.implementation.createhtmldocument("example"); doc.documentelement.innerhtml = request.responsetext; after this any manipulation that we might want to do will be something as simple as the following: doc.body.textcontent = "this is inside the body!"; using a hidden iframe element to parse html to a window's dom sample code may need more work.
... var frame = document.getelementbyid("sample-frame"); if (!frame) { // create frame frame = document.createelement("iframe"); // iframe (or browser on older firefox) frame.setattribute("id", "sample-frame"); frame.setattribute("name", "sample-frame"); frame.setattribute("type", "content"); frame.setattribute("collapsed", "true"); document.getelementbyid("main-window").appendchild(frame); // or // document.documentelement.appendchild(frame); // set restrictions as needed frame.webnavigation.allowauth = false; frame.webnavigation.allowimages = false; frame.webnavigation.allowjavascript = false; frame.webnavigation.allowmetaredirects = true; frame.webnavigation.allowplugins = false; frame.webnavigation.al...
...{ // the document of the html in the dom var doc = event.originaltarget; // skip blank page or frame if (doc.location.href == "about:blank" || doc.defaultview.frameelement) return; // do something with the dom of doc alert(doc.location.href); // when done remove frame or set location "about:blank" settimeout(function (){ var frame = document.getelementbyid("sample-frame"); // remove frame // frame.destroy(); // if using browser element instead of iframe frame.parentnode.removechild(frame); // or set location "about:blank" // frame.contentdocument.location.href = "about:blank"; },10); }, true); } // load a page frame.contentdocument.location.href = "http://www.mozilla.org/"; // or // frame.webnavigation.loaduri("h...
Adding preferences to an extension - Archive of obsolete content
« previousnext » this article takes the creating a dynamic status bar extension sample to the next level, adding a popup menu that lets you quickly switch between multiple stocks to watch.
... download the sample you can download a copy of this sample to look over, or to use as the basis for your own extension.
... get the code here: download the sample update the manifests the install manifest and chrome manifest need to be updated.
... refreshinformation: function() { // because we may be called as a callback, we can't rely on // "this" referring to the right object, so we need to reference // it by its full name var symbol = stockwatcher.tickersymbol; var fullurl = "http://quote.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=" + symbol; function inforeceived() { var samplepanel = document.getelementbyid('stockwatcher2'); var output = httprequest.responsetext; if (output.length) { // remove any whitespace from the end of the string output = output.replace(/\w*$/, ""); // build the tooltip string var fieldarray = output.split(","); samplepanel.label = symbol + ": " + fieldarray[1]; samplepanel.tool...
Index of archived content - Archive of obsolete content
stom about: urls default preferences deploying a plugin as an extension developing add-ons displaying web content in an extension without security issues downloading json and javascript in extensions enhanced extension installation extension etiquette extension library extension packaging extension samples extension theming guidelines extension versioning, update and compatibility extensions support in seamonkey 2 firefox addons developer guide hiding browser chrome hotfix extension how to convert an overlay extension to restartless inline options install manifests installing extensions and themes f...
...config settings other mozilla customization pages protecting mozilla's registry.dat file automatically handle failed asserts in debug builds blackconnect blackwood bonsai bookmark keywords build building transformiix standalone chromeless compiling the npruntime sample plugin in visual studio creating a firefox sidebar extension creating a microsummary creating a mozilla extension adding the structure conclusion enabling the behavior - retrieving tinderbox status enabling the behavior - updating the status bar panel enabling the behavior - updating ...
...struct nprect npregion npsaveddata npsetwindowcallbackstruct npstream npstring nputf8 npvariant npvarianttype npwindow np_getmimedescription np_getvalue np_initialize np_port np_shutdown samples and test cases shipping a plugin as a toolkit bundle supporting private browsing in plugins the first install problem writing a plugin for mac os x xembed extension for mozilla plugins sax security digital signatures encryption and decryption introduction to publ...
...eferences summary of changes using the w3c dom using workers in extensions web standards choosing standards compliance over proprietary practices community correctly using titles with external stylesheets describing microformats in javascript displaying a graphic with audio samples fixing incorrectly sized list item markers fixing table inheritance in quirks mode issues arising from arbitrary-element hover mozilla's doctype sniffing parsing microformats in javascript popup window controls rdf in fifty words or less rdf in mozilla faq styling abbreviations and acronyms the bu...
Install.js - Archive of obsolete content
there is a different sample install.js template located at http://downloads.mozdev.org/xsidebar/mods/.
...it assumes the following structure of your xpi file: sampleext.xpi chrome\ sampleext.jar content\ sampleext\ locale\ (optional) en-us\ sampleext\ ...
... skin\ (optional) classic\ sampleext\ ...
... install.js install.rdf (optional -- see above) code // install.js // xpiinstaller // by pike (heavily inspired by code from henrik gemal and stephen clavering) var xpiinstaller = { // --- editable items begin --- extfullname: 'sample extension', // the name displayed to the user (don't include the version) extshortname: 'sampleext', // the leafname of the jar file (without the .jar part) extversion: '1.0', extauthor: 'insert-your-name-here', extlocalenames: null, // e.g.
Reading from Files - Archive of obsolete content
var file = io.getfile("home", "sample.txt"); var stream = io.newinputstream(file, "text"); this example first retrieves a file object using nsiscriptableio.getfile().
... in this case, the file 'sample.txt' within the user's home directory is retrieved.
...var file = io.getfile("home", "sample.txt"); var stream = io.newinputstream(file, "text"); var str = stream.readstring(20); stream.close(); in this example, a text input stream is created for the file 'sample.txt'.
...you can use the available method to check if data is available for reading: var file = io.getfile("home", "sample.txt"); var stream = io.newinputstream(file, "text"); var str = stream.readstring(stream.available()); stream.close(); in this example, the available method is called to determine the number of available bytes for reading.
Menus - Archive of obsolete content
<menubar id="sample-menubar"> <menu id="file-menu" label="file"> <menupopup id="file-popup"> <menuitem label="new"/> <menuitem label="open"/> <menuitem label="save"/> <menuseparator/> <menuitem label="exit"/> </menupopup> </menu> </menubar> there are five tags used in this example, described briefly here: menubar a row of menus that appears along the top of the window ...
... <menubar id="sample-menubar"> <menu id="file-menu" label="file"> ...
... <menubar id="sample-menubar"> <menu id="file-menu" label="file"> ...
... <menubar id="sample-menubar"> <menu id="view-menu" label="view"> <menupopup> <menuitem label="toolbar"/> <menuitem label="status bar"/> <menuseparator/> <menu label="sort" accesskey="s"> <menupopup> <menuitem label="by name"/> <menuitem label="by date"/> </menupopup> </menu> </menupopup> </menu> </menubar> in this example, a top level ...
Skinning XUL Files by Hand - Archive of obsolete content
loading stylesheets in xul for your custom skin, let's assume you want to skin the xul file, xulnote_sample1.xul.
... to work with this xul file, save it locally and rename itsample1.xul.
...when the xul file is a stand-alone, as in this example, where the stylesheet is external and sitting in the same directory, the processing instruction at the top of the file is as follows: <?xml-stylesheet href="sample.css" type="text/css"?> a xul file may actually have any number of stylesheet processing instructions: one for each stylesheet that the xul wants to load.
... <?xml-stylesheet href="sample.css" type="text/css"?> create a new text file called sample.css.
Archive of obsolete content
adding preferences to an extension this article takes the creating a dynamic status bar extension sample to the next level, adding a popup menu that lets you quickly switch between multiple stocks to watch.
... case sensitivity in class and id names creating a dynamic status bar extension concepts covered in the previous sample won't be reiterated here; instead, refer to the downloadable sample code or to the previous sample for further details.
... index of archived content inner-browsing extending the browser navigation paradigm this article is the version from 2003 with slight modifications (no images and no links to samples).
... localizing an extension this article expands upon the previous samples on extension writing by adding localization support to our stock watcher extension.
HTML Cheatsheet - Learn web development
usage code snippet result a simple link <a href="https://realityripple.com/">a link to realityripple</a> a link to realityripple a simple image <img src="https://udn.realityripple.com/samples/6e/d6ed76c6c7.png" width="25" /> a generic inline container <p>p its used to <span style="color:blue">style and group</span> particular elements </p> p its used to style and group particular elements another inline container <p>span its used to differentiate a part <span style="color:blue">of the content</span> that we will work on differently </p> ...
... embedded audio <audio controls="controls" src="https://udn.realityripple.com/samples/b7/193cb038d0.mp3">your browser does not support the html5 audio element.</audio> your browser does not support the html5 audio element.
... embedded audio with alternative sources <audio controls="controls"><source src="https://udn.realityripple.com/samples/b7/193cb038d0.mp3" type="audio/mpeg"><source src="https://udn.realityripple.com/samples/f7/14a4179ee6.ogg" type="audio/ogg"> your browser does not support audio.
... embedded video <video controls src="https://udn.realityripple.com/samples/1f/6cc66528b8.mp4">the <code>video</code> element is unsupported.</video> the video element is unsupported.
Creating a Login Manager storage module
sample javascript implementation the following code snippet is a javascript component that implements a dummy nsiloginmanagerstorage interface.
... const cc = components.classes; const ci = components.interfaces; components.utils.import("resource://gre/modules/xpcomutils.jsm"); function sampleloginmanagerstorage() {} sampleloginmanagerstorage.prototype = { classdescription: "sample nsiloginmanagerstorage implementation", contractid: "@example.com/login-manager/storage/sample;1", classid: components.id("{364a118c-747a-4f6d-ac63-2d2998e5a5c1}"), queryinterface: xpcomutils.generateqi([ci.nsiloginmanagerstorage]), // this registers the category for overriding the built-in nsiloginmanagerstorage _xpcom_categories: [ { category: "login-manager-storage", entry: "nsiloginmanagerstorage" } ], // console logging se...
... getservice(ci.nsiconsoleservice); return this.__logservice; }, log: function (message) { dump("sampleloginmanager: " + message + "\n"); this._logservice.logstringmessage("sampleloginmanager: " + message); }, // logs function name and arguments for debugging stub: function(arguments) { var args = []; for (let i = 0; i < arguments.length; i++) args.push(arguments[i]) this.log("called " + arguments.callee.name + "(" + args.join(",") + ")"); }, init: function slms_init() { this.stub(arguments); }, initwithfile: function slms_initwithfile(ainputfile, aoutputfil...
...ingenabled: function slms_setloginsavingenabled(hostname, enabled) { this.stub(arguments); }, findlogins: function slms_findlogins(count, hostname, formsubmiturl, httprealm) { this.stub(arguments); }, countlogins: function slms_countlogins(ahostname, aformsubmiturl, ahttprealm) { this.stub(arguments); } }; function nsgetmodule(compmgr, filespec) xpcomutils.generatemodule([sampleloginmanagerstorage]); sample c++ implementation bug 309807 contains a complete example.
TimerFirings logging
the following sample shows the basics of this output.
...there are also timers for settimer or setinterval calls in javascript code, as the following sample shows.
... cat out | grep timer | sort | uniq -c | sort -r -n the following is sample output from this command.
... sed 's/^[^:]\+: //' # strip thread ids sed 's/\[[0-9]\+\] //' # strip process ids sed 's/ \+[0-9]\+ ms//' # strip timer periods the following is the previous sample output with all three of these commands added into the pipeline.
Getting Started With NSS
you could contribute by organizing it in a better way.) nss sample code a good place to start learning how to write nss applications are the command line tools that are maintained by the nss developers.
... you can find them in subdirectory mozilla/security/nss/cmd or have a look at some basic nss sample code.
... a new set of samples is currently under development and review, see create new nss samples.
... you are welcome to download the samples via: hg clone https://hg.mozilla.org/projects/nss; cd nss; hg update samples_branch how to contribute ...
JSS FAQ
MozillaProjectsNSSJSSJSS FAQ
is there any sample code and documentation?
... is there any sample code and documentation?
... jss example code is essentially developer test code; with that understanding, the best directory to look for sample code is in the org/mozilla/jss/tests directory: http://lxr.mozilla.org/mozilla/source/security/jss/org/mozilla/jss/tests org/mozilla/jss/tests/closedbs.java org/mozilla/jss/tests/keyfactorytest.java org/mozilla/jss/tests/digesttest.java org/mozilla/jss/tests/jcasigtest.java org/mozilla/jss/tests/keywrapping.java org/mozilla/jss/tests/listcerts.java org/mozilla/jss/tests/pk10gen.java org/mozilla/jss/tests/sdr.java org/mozilla/jss/tests/selftest.java org/mozilla/jss/tests/setupdbs.java ...
...ix/cert/certificate.java org/mozilla/jss/pkix/cmmf/certrepcontent.java org/mozilla/jss/pkix/crmf/certreqmsg.java org/mozilla/jss/pkix/crmf/certtemplate.java org/mozilla/jss/pkix/primitive/name.java org/mozilla/jss/provider/javax/crypto/jsssecretkeyfactoryspi.java org/mozilla/jss/util/utf8converter.java org/mozilla/jss/util/base64inputstream.java jss/samples/pqggen.java jss/samples/pkcs12.java if i don't call setcipherpolicy, is the domestic policy used by default?
How to embed the JavaScript engine
a bare bones tutorial hello world sample embedding application the following code is a very simple application that shows how to embed spidermonkey and run a simple javascript script.
... see the instructions for building and running the sample below the code.
...here are sample mac and linux command lines (where <objdir> is the directory where spidermonkey was built): # if you're using debug build of spidermonkey, you need -ddebug in addition to the command below.
...to get a copy of the code sample without line numbers, hover over the sample near the top until buttons appear.
An Overview of XPCOM
the nsisupports interface is shown below: the nsisupports interface class sample: public nsisupports { private: nsrefcnt mrefcnt; public: sample(); virtual ~sample(); ns_imethod queryinterface(const nsiid &aiid, void **aresult); ns_imethod_(nsrefcnt) addref(void); ns_imethod_(nsrefcnt) release(void); }; the various types used in the interface are described in the xpcom types section below.
... implementation of nsisupports interface // initialize the reference count to 0 sample::sample() : mrefcnt(0) { } sample::~sample() { } // typical, generic implementation of qi ns_imethodimp sample::queryinterface(const nsiid &aiid, void **aresult) { if (!aresult) { return ns_error_null_pointer; } *aresult = null; if (aiid.equals(kisupportsiid)) { *aresult = (void *) this; } if (!*aresult) { return ns_error_no_interface; } // add a reference addref(); return ns_ok; } ns_imethodimp_(nsrefcnt) sample::addref() { return ++mrefcnt; } ns_imethodimp_(nsrefcnt) sample::release...
...the cid for nsisupports looks like this: 00000000-0000-0000-c000-000000000046 the length of a cid can make it cumbersome to deal with in the code, so very often you see #defines for cids and other identifiers being used, as in this example: #define sample_cid \ { 0x777f7150, 0x4a2b, 0x4301, \ { 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}} you also see ns_define_cid used a lot.
... xpcom types there are many xpcom declared types and simple macros that we will use in the following samples.
Setting up the Gecko SDK
(this example uses "samplegeckoproject" as the project name and c:\ as its location.).
... building the sample built sample in d:\projects\sample the idl this step is fairly straight forward.
...cialthing.obj: $(cc) $(ccparms) /c cspecialthing.cpp cspecialthingmodule.obj: $(cc) $(ccparms) /c cspecialthingmodule.cpp link: link.exe /dll /out:"cspecialthing.dll" /implib:"cspecialthing.lib" /machine:i386 xpcom.lib xpcomglue_s.lib nspr4.lib "cspecialthing.obj" "cspecialthingmodule.obj" clean: del *.lib *.dll *.obj *.exp please note, this makefile is only for compiling the sample, you will probably have more .lib files if you are linking against winapi functions like kernel32.lib, user32.lib, etc.
... sample makefile for the gecko sdk module = mozshim # change this to point at your gecko sdk directory.
Using XPCOM Utilities to Make Things Easier
#include "nsigenericfactory.h" static const nsmodulecomponentinfo components[] = { { "pretty class name", sample_cid, "@company.com/sample", sampleconstructor } } ns_impl_nsgetmodule(nssamplemodule, components) most of the components in the mozilla browser client use this approach.
... weblock2.cpp the listing below shows the generic module code from weblock1.cpp using the macros described in this chapter: weblock2.cpp #include "nsigenericfactory.h" #include "nsisupportsutils.h" #define sample_cid \ { 0x777f7150, 0x4a2b, 0x4301, \ { 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}} class sample: public nsisupports { public: sample(); virtual ~sample(); ns_decl_isupports }; sample::sample() { // note: in newer versions of gecko (1.3 or later) // you don't have to do this: ns_init_isupports(); } sample::~sample() { } ns_impl_isupports1(sample, nsisupports); ns_ge...
...neric_factory_constructor(sample); static const nsmodulecomponentinfo components[] = { { "pretty class name", sample_cid, "@company.com/sample", sampleconstructor } }; ns_impl_nsgetmodule(nssamplemodule, components) string classes in xpcom strings are usually thought of as linear sequences of characters.
...although we haven't formally introduced these two interfaces, the next code sample shows how simple it is to switch between these two interfaces: someclass::dosomething(nsifile* afile) { if (!afile) return ns_error_null_pointer; nsresult rv; nscomptr<nsilocalfile> localfile = do_queryinterface(afile, &rv); // ...
Index - Firefox Developer Tools
64 examine and edit the box model guide, tools with the select element button pressed, if you hover over an element in the page, the box model for the element is shown overlaid on the page: 65 inspect and select colors guide, inspector, tools in the css pane's rules view, if a rule contains a color value, you'll see a sample of the color next to the value: 66 open the inspector guide, inspector, tools there are two main ways to open the inspector: 67 reposition elements in the page starting in firefox 48 you can move absolutely positioned elements by dragging them around the page.
...it periodically samples the state of the javascript engine and records the stack for the code executing at the time.
... statistically, the number of samples taken in which we were executing a particular function corresponds to the amount of time the browser spent executing it.
... 87 flame chart the call tree and the flame chart are both used to analyze your site's javascript, and they both use the same data: a sample of the javascript engine's stack, taken periodically during the recording.
Edit fonts - Firefox Developer Tools
a text sample, to give you an idea of what the font looks like when rendered.
... the default text for the sample is "abc" but the preview text can be edited by clicking on the input field at the top of the section and entering a new value.
... once entered, all of the sample text will be set to the same custom value.
... if you hover over the font-family property in the rules view, a tooltip shows a sample of the font: you'll also notice in the above screenshot that the font in the font-family font stack that is actually applied to the inspected element is underlined.
AudioBufferSourceNode - Web APIs
if there's no buffer set—that is, if buffer is null—the output contains a single channel of silence (every sample is 0).
... audiobuffersourcenode.buffer an audiobuffer that defines the audio asset to be played, or when set to the value null, defines a single channel of silence (in which every sample is 0.0).
...since no pitch correction is applied on the output, this can be used to change the pitch of the sample.
... var audioctx = new (window.audiocontext || window.webkitaudiocontext)(); // create an empty three-second stereo buffer at the sample rate of the audiocontext var myarraybuffer = audioctx.createbuffer(2, audioctx.samplerate * 3, audioctx.samplerate); // fill the buffer with white noise; //just random values between -1.0 and 1.0 for (var channel = 0; channel < myarraybuffer.numberofchannels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuffering = myarraybuffer.getchanneldata(channel); ...
AudioContextOptions - Web APIs
samplerate optional the samplerate to be used by the audiocontext, specified in samples per second.
...if not specified, the preferred sample rate for the context's output device is used by default.
... example this example instantiates an audio context for music playback (optimized for power consumption over latency), with the sample rate 48,000 hz.
... let musiccontext = new audiocontext({ latencyhint: "playback", samplerate: 48000 }); specifications specification status comment web audio apithe definition of 'audiocontextoptions' in that specification.
AudioProcessingEvent - Web APIs
example the following example shows basic usage of a scriptprocessornode to take a track loaded via audiocontext.decodeaudiodata(), process it, adding a bit of white noise to each audio sample of the input track (buffer) and play it through the audiodestinationnode.
... for each channel and each sample frame, the scriptnode.onaudioprocess function takes the associated audioprocessingevent and uses it to loop through each channel of the input buffer, and each sample in each channel, and add a small amount of white noise, before setting that result to be the output sample in each case.
... mybuffer = buffer; source.buffer = mybuffer; }, function(e){"error with decoding audio data" + e.err}); } request.send(); } // give the node a function to process audio events scriptnode.onaudioprocess = function(audioprocessingevent) { // the input buffer is the song we loaded earlier var inputbuffer = audioprocessingevent.inputbuffer; // the output buffer contains the samples that will be modified and played var outputbuffer = audioprocessingevent.outputbuffer; // loop through the output channels (in this case there is only one) for (var channel = 0; channel < outputbuffer.numberofchannels; channel++) { var inputdata = inputbuffer.getchanneldata(channel); var outputdata = outputbuffer.getchanneldata(channel); // loop through the 4096 samples f...
...or (var sample = 0; sample < inputbuffer.length; sample++) { // make output equal to the same as the input outputdata[sample] = inputdata[sample]; // add noise to each output sample outputdata[sample] += ((math.random() * 2) - 1) * 0.2; } } } getdata(); // wire up play button playbutton.onclick = function() { source.connect(scriptnode); scriptnode.connect(audioctx.destination); source.start(); } // when the buffer source stops playing, disconnect everything source.onended = function() { source.disconnect(scriptnode); scriptnode.disconnect(audioctx.destination); } ...
AudioWorkletGlobalScope - Web APIs
properties currentframe read only returns an integer that represents the ever-increasing current sample-frame of the audio block being processed.
... samplerate read only returns a float that represents the sample rate of the associated baseaudiocontext.
... // test-processor.js class testprocessor extends audioworkletprocessor { constructor () { super() // current sample-frame and time at the moment of instantiation // to see values change, you can put these two lines in process method console.log(currentframe) console.log(currenttime) } // the process method is required - simply output silence, // which the outputs are already filled with process (inputs, outputs, parameters) { return true } } // the sample rate is not going to change ...
...ever, // because it's a read-only property of a baseaudiocontext // and is set only during its instantiation console.log(samplerate) // you can declare any variables and use them in your processors // for example it may be an arraybuffer with a wavetable const usefulvariable = 42 console.log(usefulvariable) registerprocessor('test-processor', testprocessor) next, in our main scripts file we'll load the processor, create an instance of audioworkletnode — passing the name of the processor to it — and connect the node to an audio graph.
Introduction to the DOM - Web APIs
document.getelementbyid(id) document.getelementsbytagname(name) document.createelement(name) parentnode.appendchild(node) element.innerhtml element.style.left element.setattribute() element.getattribute() element.addeventlistener() window.content window.onload window.scrollto() testing the dom api this document provides samples for every interface that you can use in your own web development.
... in some cases, the samples are complete html pages, with the dom access in a <script> element, the interface (e.g, buttons) necessary to fire up the script in a form, and the html elements upon which the dom operates listed as well.
...ion value="white">white</option> <option value="lightgrey">gray</option> </select> <p><b><tt>link</tt></b></p> <select onchange="setbodyattr('link', this.options[this.selectedindex].value);"> <option value="blue">blue</option> <option value="green">green</option> </select> <small> <a href="http://some.website.tld/page.html" id="sample"> (sample link) </a> </small><br /> <input type="button" value="version" onclick="ver()" /> </form> </div> </body> </html> to test a lot of interfaces in a single page—for example, a "suite" of properties that affect the colors of a web page—you can create a similar test page with a whole console of buttons, textfields, and other html elements.
... figure 0.1 sample dom test page in this example, the drop-down menus dynamically update such dom—accessible aspects of the web page as its background color (bgcolor), the color of the hyperlinks (alink), and color of the text (text).
HTMLMediaElement - Web APIs
htmlmediaelement.mozframebufferlength is a unsigned long that indicates the number of samples that will be returned in the framebuffer of each mozaudioavailable event.
... this number is a total for all channels, and by default is set to be the number of channels * 1024 (e.g., 2 channels * 1024 samples = 2048 total).
... htmlmediaelement.mozsamplerate read only returns a double representing the number of samples per second that will be played.
... for example, 44100 samples per second is the sample rate used by cd audio.
MediaTrackSettings - Web APIs
channelcount a long integer value indicating the current value of the channelcount property, specifying the number of audio channels present on the track (therefore indicating how many audio samples exist in each audio frame).
... samplerate a long integer value indicating the current value of the samplerate property, specifying the sample rate in samples per second of the audio data.
... standard cd-quality audio, for example, has a sample rate of 41,000 samples per second.
... samplesize a long integer value indicating the current value of the samplesize property, specifying the linear size, in bits, of each audio sample.
Transcoding assets for Media Source Extensions - Web APIs
sample media if you're looking to follow the steps listed here, but don't have any media to experiment with, you can grab the trailer to big buck bunny [0] here.
... sample media should be placed in the bento4 utils directory and worked here.
... to convert our sample media from a quicktime mov container to an mp4 container, we can use ffmpeg.
... run the following commands (shown with sample output): $ python mp4-dash-encode.py -b 5 -v bunny_fragmented.mp4 encoding 5 bitrates, min bitrate = 500.0 max bitrate = 2000.0 media source: video: resolution=640x360 encoding bitrate: 500, resolution: 256x144 encoding bitrate: 875, resolution: 384x216 encoding bitrate: 1250, resolution: 480x270 encoding bitrate: 1625, resolution: 560x316 encoding bitrate: 2000, resolution: 640x360 $ python mp...
ScriptProcessorNode.onaudioprocess - Web APIs
} example the following example shows basic usage of a scriptprocessornode to take a track loaded via audiocontext.decodeaudiodata(), process it, adding a bit of white noise to each audio sample of the input track (buffer) and play it through the audiodestinationnode.
... for each channel and each sample frame, the scriptnode.onaudioprocess function takes the associated audioprocessingevent and uses it to loop through each channel of the input buffer, and each sample in each channel, and add a small amount of white noise, before setting that result to be the output sample in each case.
... mybuffer = buffer; source.buffer = mybuffer; }, function(e){"error with decoding audio data" + e.err}); } request.send(); } // give the node a function to process audio events scriptnode.onaudioprocess = function(audioprocessingevent) { // the input buffer is the song we loaded earlier var inputbuffer = audioprocessingevent.inputbuffer; // the output buffer contains the samples that will be modified and played var outputbuffer = audioprocessingevent.outputbuffer; // loop through the output channels (in this case there is only one) for (var channel = 0; channel < outputbuffer.numberofchannels; channel++) { var inputdata = inputbuffer.getchanneldata(channel); var outputdata = outputbuffer.getchanneldata(channel); // loop through the 4096 samples f...
...or (var sample = 0; sample < inputbuffer.length; sample++) { // make output equal to the same as the input outputdata[sample] = inputdata[sample]; // add noise to each output sample outputdata[sample] += ((math.random() * 2) - 1) * 0.2; } } } getdata(); // wire up play button playbutton.onclick = function() { source.connect(scriptnode); scriptnode.connect(audioctx.destination); source.start(); } // when the buffer source stops playing, disconnect everything source.onended = function() { source.disconnect(scriptnode); scriptnode.disconnect(audioctx.destination); } specifications specification status comment web audio apithe definition of 'onaudioprocess' in that specification.
ScriptProcessorNode - Web APIs
examples the following example shows basic usage of a scriptprocessornode to take a track loaded via audiocontext.decodeaudiodata(), process it, adding a bit of white noise to each audio sample of the input track (buffer) and play it through the audiodestinationnode.
... for each channel and each sample frame, the scriptnode.onaudioprocess function takes the associated audioprocessingevent and uses it to loop through each channel of the input buffer, and each sample in each channel, and add a small amount of white noise, before setting that result to be the output sample in each case.
... mybuffer = buffer; source.buffer = mybuffer; }, function(e){"error with decoding audio data" + e.err}); } request.send(); } // give the node a function to process audio events scriptnode.onaudioprocess = function(audioprocessingevent) { // the input buffer is the song we loaded earlier var inputbuffer = audioprocessingevent.inputbuffer; // the output buffer contains the samples that will be modified and played var outputbuffer = audioprocessingevent.outputbuffer; // loop through the output channels (in this case there is only one) for (var channel = 0; channel < outputbuffer.numberofchannels; channel++) { var inputdata = inputbuffer.getchanneldata(channel); var outputdata = outputbuffer.getchanneldata(channel); // loop through the 4096 samples f...
...or (var sample = 0; sample < inputbuffer.length; sample++) { // make output equal to the same as the input outputdata[sample] = inputdata[sample]; // add noise to each output sample outputdata[sample] += ((math.random() * 2) - 1) * 0.2; } } } getdata(); // wire up play button playbutton.onclick = function() { source.connect(scriptnode); scriptnode.connect(audioctx.destination); source.start(); } // when the buffer source stops playing, disconnect everything source.onended = function() { source.disconnect(scriptnode); scriptnode.disconnect(audioctx.destination); } specifications specification status comment web audio apithe definition of 'scriptprocessornode' in that specification.
WaveShaperNode - Web APIs
waveshapernode.oversample is an enumerated value indicating if oversampling must be used.
... oversampling is a technique for creating more samples (up-sampling) before applying the distortion effect to the audio signal.
...amount : 50, n_samples = 44100, curve = new float32array(n_samples), deg = math.pi / 180, i = 0, x; for ( ; i < n_samples; ++i ) { x = i * 2 / n_samples - 1; curve[i] = ( 3 + k ) * x * 20 * deg / ( math.pi + k * math.abs(x) ); } return curve; }; ...
... distortion.curve = makedistortioncurve(400); distortion.oversample = '4x'; specifications specification status comment web audio apithe definition of 'waveshapernode' in that specification.
WebGL2RenderingContext.endQuery() - Web APIs
possible values: gl.any_samples_passed: specifies an occlusion query: these queries detect whether an object is visible (whether the scoped drawing commands pass the depth test and if so, how many samples pass).
... gl.any_samples_passed_conservative: same as above above, but less accurate and faster version.
... examples var query = gl.createquery(); gl.beginquery(gl.any_samples_passed, query); // ...
... gl.endquery(gl.any_samples_passed); specifications specification status comment webgl 2.0the definition of 'endquery' in that specification.
WebGL: 2D and 3D graphics for the web - Web APIs
WebAPIWebGL API
reference standard interfaces webglrenderingcontext webgl2renderingcontext webglactiveinfo webglbuffer webglcontextevent webglframebuffer webglprogram webglquery webglrenderbuffer webglsampler webglshader webglshaderprecisionformat webglsync webgltexture webgltransformfeedback webgluniformlocation webglvertexarrayobject extensions angle_instanced_arrays ext_blend_minmax ext_color_buffer_float ext_color_buffer_half_float ext_disjoint_timer_query ext_float_blend ext_frag_depth ext_srgb ext_shader_texture_lod ext_texture_compression_bptc ext_texture_compression_...
...it is based on opengl es 3.0 and new features include: 3d textures, sampler objects, uniform buffer objects, sync objects, query objects, transform feedback objects, promoted extensions that are now core to webgl 2: vertex array objects, instancing, multiple render targets, fragment depth.
... see also the blog post "webgl 2 lands in firefox" and webglsamples.org/webgl2samples for a few demos.
... webgl by example a series of live samples with short explanations that showcase webgl concepts and capabilities.
Movement, orientation, and motion: A WebXR example - Web APIs
tattriblocation(shaderprogram, 'avertexnormal'), texturecoord: gl.getattriblocation(shaderprogram, 'atexturecoord'), }, uniformlocations: { projectionmatrix: gl.getuniformlocation(shaderprogram, 'uprojectionmatrix'), modelviewmatrix: gl.getuniformlocation(shaderprogram, 'umodelviewmatrix'), normalmatrix: gl.getuniformlocation(shaderprogram, 'unormalmatrix'), usampler: gl.getuniformlocation(shaderprogram, 'usampler') }, }; buffers = initbuffers(gl); texture = loadtexture(gl, 'https://cdn.glitch.com/a9381af1-18a9-495e-ad01-afddfd15d000%2ffirefox-logo-solid.png?v=1575659351244'); xrsession.updaterenderstate({ baselayer: new xrwebgllayer(xrsession, gl) }); if (session_type == "immersive-vr") { refspacetype = "local"; } else { ref...
...this is all taken directly from the webgl sample code, so refer to lighting in webgl and its preceding articles creating 3d objects using webgl and using textures in webgl.
...projectionmatrix, false, view.projectionmatrix); gl.uniformmatrix4fv( programinfo.uniformlocations.modelviewmatrix, false, modelviewmatrix); gl.uniformmatrix4fv( programinfo.uniformlocations.normalmatrix, false, normalmatrix); gl.activetexture(gl.texture0); gl.bindtexture(gl.texture_2d, texture); gl.uniform1i(programinfo.uniformlocations.usampler, 0); { const vertexcount = 36; const type = gl.unsigned_short; const offset = 0; gl.drawelements(gl.triangles, vertexcount, type, offset); } } renderscene() begins by calculating how much rotation should occur around each of the three axes in the amount of time that has elapsed since the previous frame was rendered.
...the remainder of the function is identical or essentially identical to the older webgl sample from which this code is derived.
Web Audio API - Web APIs
sources provide arrays of sound intensities (samples) at very small timeslices, often tens of thousands of them per second.
... outputs of these nodes could be linked to inputs of others, which mix or modify these streams of sound samples into different streams.
... a common modification is multiplying the samples by a value to make them louder or quieter (as is the case with gainnode).
... timing is controlled with high precision and low latency, allowing developers to write code that responds accurately to events and is able to target specific samples, even at a high sample rate.
filter - CSS: Cascading Style Sheets
WebCSSfilter
the value of angle defines the number of degrees around the color circle the input samples will be adjusted.
... td { padding: 5px; border: 1px solid rgb(204, 204, 204); text-align: left; vertical-align: top; width:25%; height:auto; } #img3 { height:100%; } <svg style="position: absolute; top: -999999px" xmlns="http://www.w3.org/2000/svg"> <filter id="svghuerotate" > <fecolormatrix type="huerotate" values="[angle]" /> <filter /> </svg> invert() the invert() function inverts the samples in the input image.
... 1px solid rgb(187, 187, 187); padding: 0px 5px; background: none repeat scroll 0% 0% rgb(238, 238, 238); text-align: left; font-weight: bold; } table.standard-table td { padding: 5px; border: 1px solid rgb(204, 204, 204); text-align: left; vertical-align: top; width:25%; height:auto; } #img3 { height:100%; } opacity() the opacity() function applies transparency to the samples in the input image.
...this is equivalent to multiplying the input image samples by amount.
vertical-align - CSS: Cascading Style Sheets
for example, it could be used to vertically position an <img> in a line of text: <p> top:<img style="vertical-align:top" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> middle:<img style="vertical-align:middle" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> bottom:<img style="vertical-align:bottom" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> super:<img style="vertical-align:super" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> sub:<img style="vertical-align:sub" src="https://udn.realityr...
...ipple.com/samples/16/ed9c61c3b6.png"/> </p> <p> text-top:<img style="vertical-align:text-top" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> text-bottom:<img style="vertical-align:text-bottom" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> 0.2em:<img style="vertical-align:0.2em" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> -1em:<img style="vertical-align:-1em" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> 20%:<img style="vertical-align:20%" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> -100%:<img style="vertical-align:-100%" src="https://udn.realityripple.com/samples/16/ed9c61c3b6.png"/> </p> #* { box-sizing: border-box; } img { margin-right: 0.5em; } p { height: 3em; padding: 0 .5em; font-...
...:first-line.inheritednopercentagesrefer to the line-height of the element itselfcomputed valuefor percentage and length values, the absolute length, otherwise the keyword as specifiedanimation typea length formal syntax baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length> examples basic example html <div>an <img src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a default alignment.</div> <div>an <img class="top" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a text-top alignment.</div> <div>an <img class="bottom" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a t...
...ext-bottom alignment.</div> <div>an <img class="middle" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a middle alignment.</div> css img.top { vertical-align: text-top; } img.bottom { vertical-align: text-bottom; } img.middle { vertical-align: middle; } result specifications specification status comment css level 2 (revision 1)the definition of 'vertical-align' in that specification.
Gradients in SVG - SVG: Scalable Vector Graphics
"><![cdata[ #rect1 { fill: url(#gradient1); } .stop1 { stop-color: red; } .stop2 { stop-color: black; stop-opacity: 0; } .stop3 { stop-color: blue; } ]]></style> </defs> <rect id="rect1" x="10" y="10" rx="15" ry="15" width="100" height="100"/> <rect x="10" y="120" rx="15" ry="15" width="100" height="100" fill="url(#gradient2)"/> </svg> screenshotlive sample above is an example of a linear gradient being applied to a <rect> element.
...radient id="radialgradient2" cx="0.25" cy="0.25" r="0.25"> <stop offset="0%" stop-color="red"/> <stop offset="100%" stop-color="blue"/> </radialgradient> </defs> <rect x="10" y="10" rx="15" ry="15" width="100" height="100" fill="url(#radialgradient1)"/> <rect x="10" y="120" rx="15" ry="15" width="100" height="100" fill="url(#radialgradient2)"/> </svg> screenshotlive sample the stops used here are the same as before, but now the object will be red in the center, and in all directions gradually change to blue at the edge.
...cy="60" r="50" fill="transparent" stroke="white" stroke-width="2"/> <circle cx="35" cy="35" r="2" fill="white" stroke="white"/> <circle cx="60" cy="60" r="2" fill="white" stroke="white"/> <text x="38" y="40" fill="white" font-family="sans-serif" font-size="10pt">(fx,fy)</text> <text x="63" y="63" fill="white" font-family="sans-serif" font-size="10pt">(cx,cy)</text> </svg> screenshotlive sample if the focal point is moved outside the circle described earlier, it's impossible for the gradient to be rendered correctly, so the spot will be assumed to be within the edge of the circle.
...)"/> <rect x="120" y="120" rx="15" ry="15" width="100" height="100" fill="url(#gradientreflect)"/> <text x="15" y="30" fill="white" font-family="sans-serif" font-size="12pt">pad</text> <text x="15" y="140" fill="white" font-family="sans-serif" font-size="12pt">repeat</text> <text x="125" y="140" fill="white" font-family="sans-serif" font-size="12pt">reflect</text> </svg> screenshotlive sample both gradients also have an attribute named gradientunits, which describes the unit system you're going to use when you describe the size or orientation of the gradient.
File I/O - Archive of obsolete content
this sample code uses netutil.jsm.
...}); writing to a file write a string this sample uses netutil.jsm and fileutils.jsm.
...stream); fstream.init(file, -1, 0, 0); cstream.init(fstream, "utf-8", 0, 0); // you can use another encoding here if you wish let (str = {}) { let read = 0; do { read = cstream.readstring(0xffffffff, str); // read as much as we can and put it in str.value data += str.value; } while (read != 0); } cstream.close(); // this closes fstream alert(data); reading line by line note: the sample code below does not handle text with non-ascii characters.
JavaScript Daemons Management - Archive of obsolete content
sample usage: var mydaemon = daemon.buildaround({ "create": function () { [custom code] }, // optional "prepare": function () { [custom code] }, // optional "perform": function () { [custom code] }, // required "customproperty": [custom value], "mycustommethod": function () { [custom code] }, "anothercustomproperty": [custom value], "etc.": "etc." }, 200, 30); daemon.incorporate(function...
... |*| |*| sample usage: |*| |*| var mydaemon = daemon.buildaround({ |*| "customproperty": [custom value], |*| "mycustommethod": function () { [custom code] }, |*| "anothercustomproperty": [custom value], |*| "etc.": "etc." |*| "create": function () { [custom code] }, // optional |*| "prepare": function () { [custom code] }, // optional |*| "perform"...
... |*| |*| sample usage: |*| |*| var mydaemon = daemon.safe.buildaround({ |*| "customproperty": [custom value], |*| "mycustommethod": function () { [custom code] }, |*| "anothercustomproperty": [custom value], |*| "etc.": "etc." |*| "create": function () { [custom code] }, // optional |*| "prepare": function () { [custom code] }, // optional |*| "per...
Chapter 4: Using XPCOM—Implementing advanced processes - Archive of obsolete content
because ordinary web pages and local files don't have privileges, it's impossible to actually try out the sample code in this chapter.
...you should be able to get the gist of how xpcom is used by looking at the sample code.
... you can paste almost all the sample code in this chapter into your existing test.xul file to try it out.
MozAudioAvailable - Archive of obsolete content
the mozaudioavailable event is fired when the audio buffer is full and the corresponding raw samples are available.
... framebuffer read only framebuffer (array) the decoded audio sample data (i.e., floats).
... time read only float timestamp for these samples measured from the start in seconds.
Visualizing an audio spectrum - Archive of obsolete content
the function handling the loadedmetadata event stores the metadata of the audio element in global variables; the function for the mozaudioavailable event does an fft of the samples and displays them in a canvas.
...idth: 512px;"> </audio> <div><canvas id="fft" width="512" height="200"></canvas></div> <script> var canvas = document.getelementbyid('fft'), ctx = canvas.getcontext('2d'), channels, rate, framebufferlength, fft; function loadedmetadata() { channels = audio.mozchannels; rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; fft = new fft(framebufferlength / channels, rate); } function audioavailable(event) { var fb = event.framebuffer, t = event.time, /* unused, but it's there */ signal = new float32array(fb.length / channels), magnitude; for (var i = 0, fbl = framebufferlength / 2...
...aw rectangle bars for each frequency bin ctx.fillrect(i * 4, canvas.height, 3, -magnitude); } } var audio = document.getelementbyid('audio-element'); audio.addeventlistener('mozaudioavailable', audioavailable, false); audio.addeventlistener('loadedmetadata', loadedmetadata, false); // fft from dsp.js, see below var fft = function(buffersize, samplerate) { this.buffersize = buffersize; this.samplerate = samplerate; this.spectrum = new float32array(buffersize/2); this.real = new float32array(buffersize); this.imag = new float32array(buffersize); this.reversetable = new uint32array(buffersize); this.sintable = new float32array(buffersize); this.costable...
JavaScript Client API - Archive of obsolete content
the skeleton of a sample record implementation: function foorecord(collection, id) { cryptowrapper.call(this, collection, id); } foorecord.prototype = { __proto__: cryptowrapper.prototype, _logname: "record.foo", ttl: foo_ttl, // optional get bar() this.cleartext.bar, set bar(value) { this.cleartext.bar = value; }, get baz() this.cleartext.baz, set baz(value) { this.cleartext.baz = value; }...
... example here's the skeleton of a sample tracker class.
... a sample engine class: function fooengine() { weave.syncengine.call(this, "foo"); } fooengine.prototype = { __proto__: weave.syncengine.prototype, _recordobj: foorecord, _storeobj: foostore, _trackerobj: footracker }; as you can see, there isn't actually any new code here at all; the prototype simply defines some metadata such as the store and tracker classes to use, and the human-readable nam...
Introduction - Archive of obsolete content
here is an example: <vbox datasources="http://www.xulplanet.com/ds/sample.rdf" querytype="rdf"> this example specifies the datasource 'http://www.xulplanet.com/ds/sample.rdf', using the datasource type rdf as indicated by the querytype attribute'.
...for example: <listbox datasources="http://www.xulplanet.com/ds/sample.xml" querytype="xml"> <template> <listitem label="?name"/> </template> </listbox> this template uses an xml datasource to generate a listbox.
...<vbox datasources="rdf:bookmarks http://www.xulplanet.com/ds/sample.rdf"> in addition, when using the rdf type for chrome xul (such as in extensions), the datasource rdf:local-store is always included in the composite.
Keyboard Shortcuts - Archive of obsolete content
example 1 : source view <menubar id="sample-menubar"> <menu id="file-menu" label="file" accesskey="f"> <menupopup id="file-popup"> <menuitem id="close-command" label="close" accesskey="c"/> </menupopup> </menu> </menubar> you can also use the accesskey attribute on buttons.
...an example is shown below: <keyset> <key id="sample-key" modifiers="shift" key="r"/> </keyset> this sample defines a keyboard shortcut that is activated when the user presses the shift key and r.
... example 2 : source view <keyset> <key id="paste-key" modifiers="accel" key="v" oncommand="alert('paste invoked')"/> </keyset> <menubar id="sample-menubar"> <menu id="edit-menu" label="edit" accesskey="e"> <menupopup id="edit-popup"> <menuitem id="paste-command" accesskey="p" key="paste-key" label="paste" oncommand="alert('paste invoked')"/> </menupopup> </menu> </menubar> the menuitem's key attribute, which here is paste-key is equal to the id of the defined key.
Getting started with XULRunner - Archive of obsolete content
hint: skip ahead and download the sample application, you can experiment with it while following this tutorial.
... you can download the sample application from https://github.com/matthewkastor/xulrunner-examples.
...most xul applications will include some external javascript, so the sample application does too, just to show how to include it into the xul file.
-ms-filter - Archive of obsolete content
code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/filter_8.htm -ms-filter: 'progid:dximagetransform.microsoft.motionblur(strength=50), progid:dximagetransform.microsoft.basicimage(mirror=1)'; the following example shows how to use an inline style sheet to set the filter on an image.
... code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/filter_h.htm <img style="filter:progid:dximagetransform.microsoft.motionblur(strength=50) progid:dximagetransform.microsoft.basicimage(mirror=1)" src="/workshop/samples/author/dhtml/graphics/cone.jpg" height="80px" width="80px" alt="cone"> the following example shows how to use scripting to set the filter on an image.
... code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/filter_s.htm <body> <p>click the image to start the filter.</p> // call the function.
Back to the Server: Server-Side JavaScript On The Rise - Archive of obsolete content
the code in listing 1 is a sample javascript script which incorporates java classes to handle the database query.
...sample output is shown in listing 2.
...the sample script in listing 1 could be factored out to it’s own function to retrieve the set of employee information, or abstracted further into a more generic data handler class.
Windows Media in Netscape - Archive of obsolete content
instead of doing that, this is the recommendation and workaround for netscape 7.1: <script for="player" event="scriptcommand(type, param)"> if (type == "text") { var cap = document.getelementbyid("captext"); cap.innerhtml = param; } </script> more detailed examples are available in the final section on examples and sample code.
... examples of usage in netscape 7.1 and ie all these samples consist of one page of markup (and script) that works in both ie and netscape 7.1.
... the min-object-usage.html sample shows a minimalist control manipulated by scripting and html buttons.
Getting started with HTML - Learn web development
for example, the <img> element embeds an image file onto a page: <img src="https://udn.realityripple.com/samples/d5/2be21e0477.png"> this would output the following: note: empty elements are sometimes called void elements.
...initially the page looks like this: in this exercise, you can edit the code locally on your computer, as described previously, or you can edit it in the sample window below (the editable sample window represents just the contents of the <body> element, in this case).
...one of my favorite drummers is neal peart, who\ plays in the band <a href="https://en.wikipedia.org/wiki/rush_%28band%29" title="rush wikipedia article">rush</a>.\ my favourite rush album is currently <a href="http://www.deezer.com/album/942295">moving pictures</a>.</p>\ <img src="https://udn.realityripple.com/samples/4b/9bb5edda5d.jpg">'; var solutionentry = htmlsolution; textarea.addeventlistener('input', updatecode); window.addeventlistener('load', updatecode); // stop tab key tabbing out of textarea and // make it write a tab at the caret position instead textarea.onkeydown = function(e){ if (e.keycode === 9) { e.preventdefault(); insertatcaret('\t'); } if (e.keycode === 27) { textar...
Images in HTML - Learn web development
you are provided with a basic <img> tag; we'd like you to embed the image located at the following url: https://udn.realityripple.com/samples/ec/5a13bd14f6.jpg earlier we said to never hotlink to images on other servers, but this is just for learning purposes, so we'll let you off this one time.
...mlsolution; solution.value = 'show solution'; updatecode(); }); solution.addeventlistener('click', function() { if(solution.value === 'show solution') { textarea.value = solutionentry; solution.value = 'hide solution'; } else { textarea.value = userentry; solution.value = 'show solution'; } updatecode(); }); var htmlsolution = '<img src="https://udn.realityripple.com/samples/ec/5a13bd14f6.jpg"\n alt="the head and torso of a dinosaur skeleton; it has a large head with long sharp teeth"\n width="200"\n height="171"\n title="a t-rex on display in the manchester university museum">'; var solutionentry = htmlsolution; textarea.addeventlistener('input', updatecode); window.addeventlistener('load', updatecode); // stop tab key tabbing out of textarea and // make it write...
... solution.value = 'show solution'; updatecode(); }); solution.addeventlistener('click', function() { if(solution.value === 'show solution') { textarea.value = solutionentry; solution.value = 'hide solution'; } else { textarea.value = userentry; solution.value = 'show solution'; } updatecode(); }); var htmlsolution = '<figure>\n <img src="https://udn.realityripple.com/samples/ec/5a13bd14f6.jpg"\n alt="the head and torso of a dinosaur skeleton; it has a large head with long sharp teeth"\n width="200"\n height="171">\n <figcaption>a t-rex on display in the manchester university museum</figcaption>\n</figure>'; var solutionentry = htmlsolution; textarea.addeventlistener('input', updatecode); window.addeventlistener('load', updatecode); // stop tab key tabbing out of t...
Video and audio content - Learn web development
we have provided you with sample audio and video files and example code for your own experimentation, in case you are unable to get hold of your own.
... if you are unable to source any video or audio, then you can feel free to use our sample audio and video files to carry out this exercise.
... you can also use our sample code for reference.
Getting started with Ember - Learn web development
previous overview: client-side javascript frameworks next in our first ember article we will look at how ember works and what it's useful for, install the ember toolchain locally, create a sample app, and then do some initial setup to get it ready for development.
... getting started the rest of the ember material you'll find here consists of a multi-part tutorial, in which we'll make a version of the classic todomvc sample app, teaching you how to use the essentials of the ember framework along the way.
...we've got to the point where we can start build up our sample todomvc app in ember.
Getting started with Vue - Learn web development
initializing a new project to explore various features of vue, we will be building up a sample todo list app.
...follow the steps below: in terminal, cd to where you'd like to create your sample app, then run vue create moz-todo-vue.
... with a basic introduction out of the way, we'll now go further and build up our sample app, a basic todo list application that allows us to store a list of items, check them off when done, and filter the list by all, complete, and incomplete todos.
Roll your own browser: An embedding how-to
included is the sample test application (gtkembed or winembed).
...the sections marked 'mozilla examples' refer to clients and sample code to be found within the mozilla source tree.
... mozilla examples ppembed: standard mozilla sample application implemented with metroworks' powerplant.
Localization and Plurals
additionally, there is a brief description of each plural form, followed by some sample numbers that fall into that particular form.
...selecting a table entry will populate the bottom box with sample uses of the word for some numbers.
... chrome://mozapps/locale/downloads/do...tes,hours,days chrome://mozapps/locale/downloads/do...dstitlepercent chrome://browser/locale/browser.prop...auseddownloads version history 0.1: initial version with pluralrule check, properties input loading, table generation, sample output display 0.2: use pluralform.numforms() to get the number of forms instead of figuring out locally to better support future rules - requires build from 2007/01/27 or later 0.3: generate a list of what numbers fall into which plural form to minimize the sample output to at most 3 of each form developing with pluralform the functionality for getting the correct plural forms is provided by...
Introduction to NSPR
this chapter introduces key nspr programming concepts and illustrates them with sample code.
... nspr sample code the documents linked here present two sample programs, including detailed annotations: layer.html and switch.html.
... in addition to these annotated html versions, the same samples are available in pure source form.
OLD SSL Reference
chapter 2, "getting started with ssl" illustrates their use in sample client and server applications.
... initialization initializing caches configuration communication functions used by callbacks cleanup chapter 2 getting started with ssl this chapter describes how to set up your environment, including certificate and key databases, to run the nss sample code.
... the sample code and makefiles are available via lxr in the sslsamples directory.
gtstd.html
before running the sample programs, it's important to understand the relationships between the ssl interface, the pkcs #11 interface, pkcs #11 modules, and the default netscape security databases.
... setting up the certificate and key databases before you can run the sample programs (server.c and client.c) that come with nss, you must set up certificate, key, and security module databases for both the client and the server and populate them with valid ca, client ssl, and server ssl certificates.
... if you create your own makefiles, be sure to include the libraries in the same order that they are listed in the sample makefiles.
NSS Tools modutil
sample script for example, the pkcs #11 installer script could be in the file pk11install.
... if so, the metainfo file for the netscape signing tool would include a line such as this: + pkcs11_install_script: pk11install the sample script file could contain the following: forwardcompatible { irix:6.2:mips sunos:5.5.1:sparc }platforms { winnt::x86 { modulename { "fortezza module" } modulefile { win32/fort32.dll } defaultmechanismflags{0x0001} defaultcipherflags{0x0001} files { win32/setup.exe { executable relativepath { %temp%/setup.exe } } win32/setup.hlp { relativepath { %temp%/setup.hlp } } win32/setup.cab { relativepath { %temp%/setup.cab } } } } win95::x86 { equivalentplatform {winnt::x86} } sunos:5.5.1:sparc { modulename { "fortezza unix mo...
...c:\modutil> installing a cryptographic module from a jar file this example installs a cryptographic module from the following sample installation script.
Starting WebLock
the sample component you've built up so far doesn't do anything.
... in order to be started up or notified when some event happens, the sample component has to hook into mozilla, which it can do either by overriding an existing component or by registering for some event that will cause it to start up.
...the ns_decl_iweblock declaration macro expands into the following: ns_imethod lock(void); ns_imethod unlock(void); ns_imethod addsite(const char *url); ns_imethod removesite(const char *url); ns_imethod getsites(nsisimpleenumerator * *asites); ns_imethod setsites(nsisimpleenumerator *asites); representing return values in xpcom the code sample above is the c++ version of the iweblock interface methods.
How to build a binary XPCOM component using Visual Studio
this tutorial uses microsoft’s free visual c++ express and the sample project in the next paragraph.
...recap: use the right gecko sdk for your xulrunner release use a microsoft compiler use pre-built glib-1.2.dll & libidl-0.6.dll libraries from wintools.zip download the sample project here is what the folder structure looks like: create a vc++ project visual studio project and file templates (or wizards) for creating xpcom modules and components do not currently exist.
...i put this together from some samples i found on the mdc site: #include "nsigenericfactory.h" #include "comp-impl.h" ns_generic_factory_constructor(cspecialthing) static nsmodulecomponentinfo components[] = { { specialthing_classname, specialthing_cid, specialthing_contractid, cspecialthingconstructor, } }; ns_impl_nsgetmodule("specialthingsmodule", components) assuming you have the right sdk...
imgIContainer
flag_clamp: extend the image to the fill area by clamping image sample coordinates instead of by tiling.
...when aflags includes flag_clamp, the image will be extended to this area by clamping image sample coordinates.
... asubimage the area of the image, in pixels, that we are allowed to sample from.
nsIDOMMozNetworkStats
data nsidommoznetworkstatsdata array stats samples.
... start date start date of the stats samples.
... end date end date of the stats samples.
Inspect and select colors - Firefox Developer Tools
in the css pane's rules view, if a rule contains a color value, you'll see a sample of the color next to the value: a color sample is also shown for css custom properties (variables) that represent colors.
... if you click on the color sample, you'll see a color picker popup, enabling you to change the color: if the color is a foreground color, the color picker tells you whether its contrast with the background color meets accessibility guidelines.
... the color picker includes an eyedropper icon: clicking this icon enables you to use the eyedropper to select a new color for the element from the page: clicking the color sample while holding down the shift key changes the color format: ...
AnalyserNode.getByteFrequencyData() - Web APIs
the frequencies are spread linearly from 0 to 1/2 of the sample rate.
... for example, for 48000 sample rate, the last item of the array will represent the decibel value for 24000 hz.
...for any sample which is silent, the value is -infinity.
AnalyserNode.getFloatFrequencyData() - Web APIs
the frequencies are spread linearly from 0 to 1/2 of the sample rate.
... for example, for 48000 sample rate, the last item of the array will represent the decibel value for 24000 hz.
...for any sample which is silent, the value is -infinity.
AudioBuffer.length - Web APIs
the length property of the audiobuffer interface returns an integer representing the length, in sample-frames, of the pcm data stored in the buffer.
... syntax var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); myarraybuffer.length; value an integer.
... example // stereo var channels = 2; // create an empty two second stereo buffer at the // sample rate of the audiocontext var framecount = audioctx.samplerate * 2.0; var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; // just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuffering = myarraybuffer.getchanneldata(channel); for (var i = 0; i < framecount; i++) { // math.random() is in [0; 1.0] // audio needs to be in [-1.0; 1.0] nowbuffering[i] = math.random() * 2 - 1; } } console.log(myarraybuffer.length); } specification specificati...
AudioBufferSourceNode.AudioBufferSourceNode() - Web APIs
the sample frames, comprising the loop, run from the values loopstart to loopend-(1/samplerate).
...this attribute is converted to an exact sample frame offset within the buffer, by multiplying by the buffer's sample rate and rounding to the nearest integer value.
...this attribute is converted to an exact sample frame offset within the buffer, by multiplying by the buffer's sample rate and rounding to the nearest integer value.
AudioParam - Web APIs
there are two kinds of audioparam, a-rate and k-rate parameters: an a-rate audioparam takes the current audio parameter value for each sample frame of the audio signal.
... a k-rate audioparam uses the same initial audio parameter value for the whole block processed, that is 128 sample frames.
...gain is an example of an a-rate audioparam, as the value can potentially be set differently for each sample frame of the audio.
BaseAudioContext - Web APIs
baseaudiocontext.samplerate read only returns a float representing the sample rate (in samples per second) used by all nodes in this context.
... the sample-rate of an audiocontext cannot be changed.
... baseaudiocontext.createconstantsource() creates a constantsourcenode object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value.
BiquadFilterNode.getFrequencyResponse() - Web APIs
for any frequency in frequencyarray whose value is outside the range 0.0 to samplerate/2 (where samplerate is the sample rate of the audiocontext), the corresponding value in this array is nan.
...for any frequency in frequencyarray whose value is outside the range 0.0 to samplerate/2 (where samplerate is the sample rate of the audiocontext), the corresponding value in this array is nan.
... example in the following example we are using a biquad filter on a media stream (for the full demo, see our stream-source-buffer demo live, or read the source.) as part of this demo, we get the frequency responses for this biquad filter, for five sample frequencies.
MediaConfiguration - Web APIs
if the media is an audio file, the audio configuration must include a valid audio mime type as contenttype, the number of channels, the bitrate, and the sample rate.
... samplerate: number of audio samples making up one second of the audio file.
... } }; const audioencoderconfig = { type : 'file', // 'record', 'transmission', or 'media-source' audio : { contenttype : "audio/ogg", // valid content type channels : 2, // audio channels used by the track bitrate : 132700, // number of bits used to encode 1s of audio samplerate : 5200 // number of audio samples making up that 1s.
Web-based protocol handlers - Web APIs
example <!doctype html public "-//w3c//dtd html 4.01//en"> <html lang="en"> <head> <title>web protocol handler sample - register</title> <script type="text/javascript"> navigator.registerprotocolhandler("web+burger", "http://www.google.co.uk/?uri=%s", "burger handler"); </script> </head> <body> <h1>web protocol handler sample</h1> <p>this web page will install a web protocol handler for the <code>web+burger:</code> protocol.</p> </bo...
... example <!doctype html public "-//w3c//dtd html 4.01//en"> <html lang="en"> <head> <title>web protocol handler sample - test</title> </head> <body> <p>hey have you seen <a href="web+burger:cheeseburger">this</a> before?</p> </body> </html> handling the next phase is handling the action.
... example <?php $value = ""; if ( isset ( $_get["value"] ) ) { $value = $_get["value"]; } ?> <!doctype html public "-//w3c//dtd html 4.01//en"> <html lang="en"> <head> <title>web protocol handler sample</title> </head> <body> <h1>web protocol handler sample - handler</h1> <p>this web page is called when handling a <code>web+burger:</code> protocol action.
NotifyAudioAvailableEvent - Web APIs
the data is a series of audio samples, each sample containing one 32-bit value per audio channel.
... all audio frames are normalized to contain 1024 samples by default, but could be any length between 512 and 16384 samples if the user has set a different length using the mozframebufferlength attribute.
... time a floating-point value indicating the time in seconds at which the first sample in the framebuffer occurs, relative to the start of the audio track.
VTTCue - Web APIs
WebAPIVTTCue
example html <video controls src="https://udn.realityripple.com/samples/c6/f8a3489533.webm"></video> css video { width: 320px; height: 180px; } javascript let video = document.queryselector('video'); video.addeventlistener('loadedmetadata', () => { const track = video.addtexttrack("captions", "简体中文subtitles", "zh_cn"); track.mode = "showing"; const cuecn = new vttcue(0, 2.500, '字幕会在0至2.5秒间显示'); track.addcue(cuecn); const...
... cueen = new vttcue(2.6, 4, 'subtitles will display between 2.6 and 4 seconds'); track.addcue(cueen); }); result chrome: please open in jsfiddle to view the live sample.
... embed live sample can not show subtitles in chrome.
WebGL2RenderingContext.beginQuery() - Web APIs
possible values: gl.any_samples_passed: specifies an occlusion query: these queries detect whether an object is visible (whether the scoped drawing commands pass the depth test and if so, how many samples pass).
... gl.any_samples_passed_conservative: same as above above, but less accurate and faster version.
... examples var query = gl.createquery(); gl.beginquery(gl.any_samples_passed, query); // ...
WebGL2RenderingContext.getInternalformatParameter() - Web APIs
possible values: gl.samples: returns a int32array containing sample counts supported for internalformat in descending order.
...it is an int32array if pname is gl.samples.
... examples var samples = gl.getinternalformatparameter(gl.renderbuffer, gl.rgba8, gl.samples); specifications specification status comment webgl 2.0the definition of 'getinternalformatparameter' in that specification.
WebGL2RenderingContext.getQuery() - Web APIs
possible values: gl.any_samples_passed: specifies an occlusion query: these queries detect whether an object is visible (whether the scoped drawing commands pass the depth test and if so, how many samples pass).
... gl.any_samples_passed_conservative: same as above above, but less accurate and faster version.
... examples var currentquery = gl.getquery(gl.any_samples_passed, gl.current_query); specifications specification status comment webgl 2.0the definition of 'getquery' in that specification.
WebGLRenderingContext.disable() - Web APIs
gl.sample_alpha_to_coverage deactivates the computation of a temporary coverage value determined by the alpha value.
... gl.sample_coverage deactivates anding the fragment's coverage with the temporary coverage value.
... see webglrenderingcontext.samplecoverage().
WebGLRenderingContext.enable() - Web APIs
gl.sample_alpha_to_coverage activates the computation of a temporary coverage value determined by the alpha value.
... gl.sample_coverage activates anding the fragment's coverage with the temporary coverage value.
... see webglrenderingcontext.samplecoverage().
WebGLRenderingContext.getParameter() - Web APIs
gl.renderer domstring gl.sample_buffers glint gl.sample_coverage_invert glboolean gl.sample_coverage_value glfloat gl.samples glint gl.scissor_box int32array (with 4 elements) gl.scissor_test glboolean gl.shading_language_version domstring gl.stencil_back_fail glenum gl.stencil_back_func glenum ...
....max_draw_buffers glint gl.max_element_index glint64 gl.max_elements_indices glint gl.max_elements_vertices glint gl.max_fragment_input_components glint gl.max_fragment_uniform_blocks glint gl.max_fragment_uniform_components glint gl.max_program_texel_offset glint gl.max_samples glint gl.max_server_wait_timeout glint64 gl.max_texture_lod_bias glfloat gl.max_transform_feedback_interleaved_components glint gl.max_transform_feedback_separate_attribs glint gl.max_transform_feedback_separate_components glint gl.max_uniform_block_size glint64 gl.max_uniform_buffer_b...
... gl.sample_alpha_to_coverage glboolean gl.sample_coverage glboolean gl.sampler_binding webglsampler or null see bindsampler.
WebGLRenderingContext.isEnabled() - Web APIs
gl.sample_alpha_to_coverage computation of a temporary coverage value determined by the alpha value.
... gl.sample_coverage anding the fragment's coverage with the temporary coverage value.
... see webglrenderingcontext.samplecoverage().
Lighting in WebGL - Web APIs
our sample loads a copy from a cdn in our html's <head>.
... the fragment shader the fragment shader now needs to be updated to take into account the lighting value computed by the vertex shader: const fssource = ` varying highp vec2 vtexturecoord; varying highp vec3 vlighting; uniform sampler2d usampler; void main(void) { highp vec4 texelcolor = texture2d(usampler, vtexturecoord); gl_fragcolor = vec4(texelcolor.rgb * vlighting, texelcolor.a); } `; here we fetch the color of the texel, just like we did in the previous example, but before setting the color of the fragment, we multiply the texel's color by the lighting value to adjust the texel's color to take ...
...tattriblocation(shaderprogram, 'avertexnormal'), texturecoord: gl.getattriblocation(shaderprogram, 'atexturecoord'), }, uniformlocations: { projectionmatrix: gl.getuniformlocation(shaderprogram, 'uprojectionmatrix'), modelviewmatrix: gl.getuniformlocation(shaderprogram, 'umodelviewmatrix'), normalmatrix: gl.getuniformlocation(shaderprogram, 'unormalmatrix'), usampler: gl.getuniformlocation(shaderprogram, 'usampler'), }, }; and that's it!
Window: storage event - Web APIs
bubbles no cancelable no interface storageevent event handler property onstorage examples log the samplelist item to the console when the storage event fires: window.addeventlistener('storage', () => { // when local storage changes, dump the list to // the console.
... console.log(json.parse(window.localstorage.getitem('samplelist'))); }); the same action can be achieved using the onstorage event handler property: window.onstorage = () => { // when local storage changes, dump the list to // the console.
... console.log(json.parse(window.localstorage.getitem('samplelist'))); }; specifications specification status html living standardthe definition of 'storage' in that specification.
Border-image generator - CSS: Cascading Style Sheets
border image generator html content <div id="container"> <div id="gallery"> <div id="image-gallery"> <img class="image" src="https://udn.realityripple.com/samples/2c/fa0192d18e.png" data-stateid="border1"/> <img class="image" src="https://udn.realityripple.com/samples/b8/dacdd63e77.png" data-stateid="border2"/> <img class="image" src="https://udn.realityripple.com/samples/07/1fcc357205.png" data-stateid="border3"/> <img class="image" src="https://udn.realityripple.com/samples/7b/dd37c1d691.png" data-stateid="border4"/> <img class="image" src="https://udn.realityripple.com/samples/a9/b9fff72dab.png" data-stateid="border5"/...
...> <img class="image" src="https://udn.realityripple.com/samples/fb/c0b285d3da.svg" data-stateid="border6"/> </div> </div> <div id="load-actions" class="group section"> <div id="toggle-gallery" data-action="hide"> </div> <div id="load-image" class="button"> upload image </div> <input id="remote-url" type="text" placeholder="load an image from url"/> <div id="load-remote" class="button"> </div> </div> <div id="general-controls" class="group section"> <div class="name"> control box </div> <div class="separator"></div> <div class="property"> <div class="name">scale</div> <div class="ui-input-slider" data-topic="scale" ...
...listener('click', function(){ loadremoteimage(remote.value); }); browse.addeventlistener('click', imagereader.load); gallery.addeventlistener('click', pickimage); imgsource.addeventlistener('load', update); inputslidermanager.subscribe('scale', setscale); inputslidermanager.setvalue('scale', scale); imgstate = 'border1'; loadremoteimage('https://udn.realityripple.com/samples/2c/fa0192d18e.png'); togglegallery(); }; return { init: init, getscale : getscale, loadremoteimage: loadremoteimage }; })(); var guideline = function guideline(node) { var topic = node.getattribute('data-topic'); var axis = node.getattribute('data-axis'); this.node = node; this.topic = topic; this.axis = axis; this.info = topic.split('-')[1]; this.position ...
border-image-slice - CSS: Cascading Style Sheets
however, we have also provided two sliders to allow you to dynamically change the values of the above two properties, allowing you to appreciate the effect they have: border-image-slice changes the size of the image slice sampled for use in each border and border corner (and the content area, if the fill keyword is used) — varying this away from 30 causes the border to look somewhat irregular, but can have some interesting effects.
...the sampled image size is scaled to fit inside the border, which means that if the width is bigger than the slice, the image can start to look somewhat pixellated (unless of course you use an svg image).
...t> </li> <li> <label for="slice">slide to adjust <code>border-image-slice</code></label> <input type="range" min="10" max="45" id="slice"> <output id="slice-output">30</output> </li> </ul> css .wrapper { width: 400px; height: 300px; } div > div { width: 300px; height: 200px; border-width: 30px; border-style: solid; border-image: url(https://udn.realityripple.com/samples/56/bb98f533ef.png); border-image-slice: 30; border-image-repeat: round; } li { display: flex; place-content: center; } javascript const widthslider = document.getelementbyid('width'); const sliceslider = document.getelementbyid('slice'); const widthoutput = document.getelementbyid('width-output'); const sliceoutput = document.getelementbyid('slice-output'); const divelem = document.qu...
font-style - CSS: Cascading Style Sheets
html <header> <input type="range" id="slant" name="slant" min="-90" max="90" /> <label for="slant">slant</label> </header> <div class="container"> <p class="sample">...it would not be wonderful to meet a megalosaurus, forty feet long or so, waddling like an elephantine lizard up holborn hill.</p> </div> css /* amstelvaralpha-vf is created by david berlow (https://github.com/typenetwork/amstelvar) and is used here under the terms of its license: https://github.com/typenetwork/amstelvar/blob/master/ofl.txt */ @font-face { src: url('https://mdn.mozillade...
...mos.org/files/16044/amstelvaralpha-vf.ttf'); font-family:'amstelvaralpha'; font-style: normal; } label { font: 1rem monospace; } .container { max-height: 150px; overflow: scroll; } .sample { font: 2rem 'amstelvaralpha', sans-serif; } html, body { max-height: 100vh; max-width: 100vw; overflow: hidden; } body { display: flex; flex-direction: column; } header { margin-bottom: 1.5rem; } .container { flex-grow: 1; } .container > p { margin-top: 0; margin-bottom: 0; } javascript let slantlabel = document.queryselector('label[for="slant"]'); let slantinput = document.queryselector('#slant'); let sampletext = document.queryselector('.sample'); function update() { let slant = `oblique ${slantinput.value}deg`; slantlabel.textcontent = `font-style: ${slant}...
...;`; sampletext.style.fontstyle = slant; } slantinput.addeventlistener('input', update); update(); accessibility concerns large sections of text set with a font-style value of italic may be difficult for people with cognitive concerns such as dyslexia to read.
font-weight - CSS: Cascading Style Sheets
html <header> <input type="range" id="weight" name="weight" min="1" max="1000" /> <label for="weight">weight</label> </header> <div class="container"> <p class="sample">...it would not be wonderful to meet a megalosaurus, forty feet long or so, waddling like an elephantine lizard up holborn hill.</p> </div> css /* mutator sans is created by letterror (https://github.com/letterror/mutatorsans) and is used here under the terms of its license: https://github.com/letterror/mutatorsans/blob/master/license */ @font-face { src: url('https://mdn.mozillademos.org/...
...files/16011/mutatorsans.ttf'); font-family:'mutatorsans'; font-style: normal; } label { font: 1rem monospace; white-space: nowrap; } .container { max-height: 150px; overflow-y: auto; } .sample { text-transform: uppercase; font: 1.5rem 'mutatorsans', sans-serif; } html, body { max-height: 100vh; max-width: 100vw; overflow: hidden; } body { display: flex; flex-direction: column; } header { margin-bottom: 1.5rem; } .container { flex-grow: 1; } .container > p { margin-top: 0; margin-bottom: 0; } javascript let weightlabel = document.queryselector('label[for="weight"]'); let weightinput = document.queryselector('#weight'); let sampletext = document.queryselector('.sample'); function update() { weightlabel.textcontent = `font-weight: ${weightinput.val...
...ue};`; sampletext.style.fontweight = weightinput.value; } weightinput.addeventlistener('input', update); update(); accessibility concerns people experiencing low vision conditions may have difficulty reading text set with a font-weight value of 100 (thin/hairline) or 200 (extra light), especially if the font has a low contrast color ratio.
Audio and video manipulation - Developer guides
html we can set up our video player and <canvas> element like this: <video id="my-video" controls="true" width="480" height="270" crossorigin="anonymous"> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type="video/webm"> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type="video/mp4"> </video> <canvas id="my-canvas" width="480" height="270"></canvas> javascript this code handles altering the frames.
... html <video id="my-video" controls src="https://udn.realityripple.com/samples/6f/08625b424a.m4v"> </video> javascript var myvideo = document.getelementbyid('my-video'); myvideo.playbackrate = 2; playable code <video id="my-video" controls="true" width="480" height="270"> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type="video/webm"> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type="video/mp4"> </video> <div cla...
...e(document.getelementbyid("my-video")), filter = context.createbiquadfilter(); audiosource.connect(filter); filter.connect(context.destination); // configure filter filter.type = "lowshelf"; filter.frequency.value = 1000; filter.gain.value = 25; playable code <video id="my-video" controls="true" width="480" height="270" crossorigin="anonymous"> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type="video/webm"> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type="video/mp4"> </video> <div class="playable-buttons"> <input id="edit" type="button" value="edit" /> <input id="reset" type="button" value="reset" /> </div> <textarea id="code" class="playable-code"> filter.type = "lowshelf"; filter.frequency.value = 1000; filter.gain.value = 25...
<img>: The Image Embed element - HTML: Hypertext Markup Language
WebHTMLElementimg
<img src="https://udn.realityripple.com/samples/6c/98485e5d8a.png" alt="mdn logo"> image link this example builds upon the previous one, showing how to turn the image into a link.
... <a href="https://developer.mozilla.org"> <img src="https://udn.realityripple.com/samples/6c/98485e5d8a.png" alt="visit the mdn site"> </a> using the srcset attribute in this example we include a srcset attribute with a reference to a high-resolution version of the logo; this will be loaded instead of the src image on high-resolution devices.
... <img src="https://udn.realityripple.com/samples/61/869e27c81e.png" alt="mdn logo" srcset="/static/external/6c/6c98485e5d8acac9fecd7824ce30c9587f0d8548b946ee9fb1293d2eccdb6cf1.png 2x"> using the srcset and sizes attributes the src attribute is ignored in user agents that support srcset when w descriptors are included.
<input type="range"> - HTML: Hypertext Markup Language
WebHTMLElementinputrange
consider this range control: <input type="range" id="volume" min="0" max="11" value="7" step="1"> screenshotlive sample this control is horizontal (at least on most if not all major browers; others might vary).
... standards according to the specification, making it vertical requires adding css to change the dimensions of the control so that it's taller than it is wide, like this: css #volume { height: 150px; width: 50px; } html <input type="range" id="volume" min="0" max="11" value="7" step="1"> result screenshotlive sample unfortunately, no major browsers currently support vertical range controls directly.
... screenshotlive sample appearance property the appearance property has a non-standard value of slider-vertical that, well, makes sliders vertical.
Media - Progressive web apps (PWAs)
body> <tr> <td><button class="green-button" disabled>click me</button></td> <td><button class="green-button">click me</button></td> <td><button class="green-button active">click me</button></td> </tr> <tr style="line-height:25%;"> <td>&nbsp;</td> </tr> <tr style="font-style:italic;"> <td>disabled</td> <td>normal</td> <td>active</td> </tr> </tbody> </table> live sample a fully functional button also has a dark outline around the entire button when it is the default, and a dotted outline on the face of the button when it has keyboard focus.
...copy and paste the content from here: <!doctype html> <html> <head> <title>print sample</title> <link rel="stylesheet" href="style4.css"> </head> <body> <h1>section a</h1> <p>this is the first section...</p> <h1>section b</h1> <p>this is the second section...</p> <div id="print-head"> heading for paged media </div> <div id="print-foot"> page: </div> </body> </html> make a new stylesheet, style4.css.
... copy and paste the content from here: /*** print sample ***/ /* defaults for screen */ #print-head, #print-foot { display: none; } /* print only */ @media print { h1 { page-break-before: always; padding-top: 2em; } h1:first-child { page-break-before: avoid; counter-reset: page; } #print-head { display: block; position: fixed; top: 0pt; left:0pt; right: 0pt; font-size: 200%; text-align: center; } #print-foot { display: block; position: fixed; bottom: 0pt; right: 0pt; font-size: 200%; } #print-foot:after { content: counter(page); counter-increment: page; } } /* end print only */ view this document in your browser.
Mobile first - Progressive web apps (PWAs)
to make my simple example i created a sample app structure from a mozilla mortar template.
... i installed the volo automation tool by running the following on the command line sudo npm install -g volo (you'll also need to get node.js too if you don't already have it) i then created my sample project using volo create myapp mozilla/mortar-app-stub this creates a sample project inside a directory called myapp.
...in this sample app, i have used a couple of the built-in features to: include an install button that works for firefox os, firefox aurora, chrome and ios app installs (as explained on the install github page).
Clipping and masking - SVG: Scalable Vector Graphics
since the rectangle covers only the upper half of the circle, the lower half of the circle will vanish: screenshotlive sample we now have a semicircle without having to deal with arcs in path elements.
...as a result the pixels of the red rectangle use the luminance value of the mask content as the alpha value (the transparency), and we see a green-to-red gradient as a result: screenshotlive sample transparency with opacity there is a simple possibility to set the transparency for a whole element.
...shine through on half of the stroke, while on the other half the background will appear: <svg width="200" height="200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <rect x="0" y="0" width="200" height="200" fill="blue" /> <circle cx="100" cy="100" r="50" stroke="yellow" stroke-width="40" stroke-opacity=".5" fill="red" /> </svg> screenshotlive sample you see in this example the red circle on blue background.
2015 MDN Fellowship Program - Archive of obsolete content
in 2015, mdn will expand the impact of this content by developing kits of key learning materials, including such elements as code samples, videos and other elements being finalized.
... activities and deliverables act as lead curator for technical curriculum addressing a key web technology, developing code samples, videos, interactive exercises and other components to be determined.
Code snippets - Archive of obsolete content
this is a quick list of useful code snippets (small code samples) available for developers of extensions for the various mozilla applications.
... many of these samples can also be used in xulrunner applications, as well as in actual mozilla code itself.
Using Dependent Libraries In Extension Components - Archive of obsolete content
sample code is below, and can be built by placing the two files in extensions/stub and configuring with --enable-extensions=stub extension file structure using the stub slightly changes how components are packaged in the extension directory structure.
...static void* lookupsymbol(const mach_header* alib, const char* asymbolname) { nssymbol sym = nsnull; if (alib) { sym = nslookupsymbolinimage(alib, asymbolname, nslookupsymbolinimage_option_bind | nslookupsymbolinimage_option_return_on_error); } if (!sym) return nsnull; return nsaddressofsymbol(sym); } notes code samples are licensed under the mit license.
JXON - Archive of obsolete content
conversion snippets now imagine you have this sample xml document: example.xml <?xml version="1.0"?> <!doctype catalog system "catalog.dtd"> <catalog> <product description="cardigan sweater"> <catalog_item gender="men's"> <item_number>qwz5671</item_number> <price>39.95</price> <size description="medium"> <color_swatch image="red_cardigan.jpg">red</color_swatch> <color_swatch image="burgundy_cardigan.jpg">burgundy...
... sample usage: var myobject = jxon.build(doc); // we got our javascript object!
Repackaging Firefox - Archive of obsolete content
sample dex the best way to get started is probably to look at a simple dex and modify it for your own purposes.
... download the sample.
Creating a Help Content Pack - Archive of obsolete content
the sample page chrome://help/locale/welcome.xhtml has a section on searching which may be a useful link to use here.
...let's start with a brief sample rdf file with a single level: <?xml version="1.0"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:nc="http://home.netscape.com/nc-rdf#"> <rdf:description rdf:about="urn:root"> <nc:subheadings> <rdf:seq> <rdf:li><rdf:description nc:link="foo.html" nc:title="foo"/></rdf:li> <rdf:li><rdf:description nc:link="baz.html" nc:title="baz"/><...
XML in Mozilla - Archive of obsolete content
see the testing and qa section for samples.
...see the testing and qa section for samples.
Using XPInstall to Install Plugins - Archive of obsolete content
there is also a sample registry entry created by an imaginary company that is illustrative of what is discussed in the specification for these registry keys.
...) has already been called // using the install object's execute method to block on a native installer execute("setup.exe", "-s", true); // in the above sample, assume that running "setup -s" from the // command prompt runs the setup executable, and that "-s" is some // invocation parameter defined by the setup.exe file, perhaps to force // the installer to run silently.
IO - Archive of obsolete content
ArchiveMozillaXULFileGuideIO
the following example will retrieve a reference to a file located in the profile directory named sample.txt.
... var file = io.getfile("profile", "sample.txt"); the nsiscriptableio object is a global object always available within an application or extension.
Actions - Archive of obsolete content
<vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a"> <template> <query> <content uri="?start"/> <triple subject="?start" predicate="http://www.xulplanet.com/rdf/relateditem" object="?relateditem"/> </query> <action> <button uri="?relateditem" label="?relateditem"/> </action> </template> </vbox> in this example, we omit the <xul:rul...
...after all the results have been examined, the dom tree will look like the following: <vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a"> <template> <query> <content uri="?start"/> <triple subject="?start" predicate="http://www.xulplanet.com/rdf/relateditem" object="?relateditem"/> </query> <action> <button uri="?relateditem" label="?relateditem"/> </action> </template> <button id="http://www.xulplanet.com/rdf/b" ...
Rule Compilation - Archive of obsolete content
<vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a" flex="1"> <template> <query> -- query content goes here -- </query> <rule> -- rule content goes here -- </rule> <rule> -- rule content goes here -- </rule> </template> </vbox> query/rule compilation and lazy content generation when the template builder starts processing, and after it has started the ...
...for instance, consider the example below: <vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a" hidden="true"> <template> ...
SeaMonkey - making custom toolbar (SM ver. 1.x) - Archive of obsolete content
you can use the sample code provided here to make buttons that do various useful things.
...for a selection of code samples that you can copy and paste, and customize without any knowledge of programming, see this page: code samples your changes take effect when you restart the application.
Custom toolbar button - Archive of obsolete content
you can use the sample code provided here to make buttons that do various useful things.
... for a selection of code samples that you can copy and paste, and customize without any knowledge of programming, see this page: code samples your changes take effect when you restart the application.
Introduction to RDF - Archive of obsolete content
the sample below shows a simple rdf template.
...rdf/xml file example below, a sample rdf/xml file is shown, listing a table with three records and three fields.
Deploying XULRunner - Archive of obsolete content
here's a sample one: <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple computer//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>cfbundledevelopmentregion</key> <string>english</string> <key>cfbundleexecutable</key> <string>xulrunner</string> <key>cfbundlegetinfostring</key> <string>1.0</string> <key>cfbundleiconfile</key> <str...
...only useful if your app handle urls--> <key>cfbundleurltypes</key> <array> <dict> <key>cfbundleurliconfile</key> <string>app_icon.icns</string> <key>cfbundleurlname</key> <string>yourapp entity</string> <key>cfbundleurlschemes</key> <array> <string>chrome</string> </array> </dict> </array> <key>cfbundleversion</key> <string>1.0</string> </dict> </plist> here's a sample of the pkginfo file aapl????
How to enable locale switching in a XULRunner application - Archive of obsolete content
screenshot of sample locale switching control 3.
...sample chrome/chrome.manifest content localeswitchdemo content/ locale localeswitchdemo de-de locale/de-de/ locale localeswitchdemo en-gb locale/en-gb/ locale localeswitchdemo fr-fr locale/fr-fr/ how are you going to populate the xul listbox?
Create Your Own Firefox Background Theme - Archive of obsolete content
view a sample theme header here.
... view a sample theme footer here.
Updating an extension to support multiple Mozilla applications - Archive of obsolete content
if you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series: creating a status bar extension creating a dynamic status bar extension adding preferences to an extension localizing an extension download the sample you can download this article's sample code so you can look at it side-by-side with the article, or to use it as a basis for your own extension.
... download the sample updating the install manifest the first step is to revise the extension's install manifest to indicate that it can be installed in thunderbird and sunbird.
GetObject - Archive of obsolete content
for example: var myobject; myobject = getobject("c:\\drawings\\sample.drw", "figment.drawing"); in the preceding example, figment is the name of a drawing application and drawing is one of the object types it supports.
...for example: myobject.line(9, 90); myobject.inserttext(9, 100, "hello, world."); myobject.saveas("c:\\drawings\\sample.drw"); note: use the getobject function when there is a current instance of the object, or if you want to create the object with a file already loaded.
Reference - Archive of obsolete content
once that is done, the various code samples should be updated to reflect current practices and code if they cannot be written in a "version-neutral" manner.
...--maian 05:10, 22 september 2005 (pdt) if the examples are there specifically to show the differences between two versions of js, and if we have a section in the reference that is dedicated to discussing these differences, i would think that those samples should be included in that section of the reference.
XForms Custom Controls - Archive of obsolete content
it is bound to <xf:output mediatype="image/*"/> mimicking the current xforms 1.1 draft: <?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>custom image control sample</title> <bindings id="xformsbindings" xmlns="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml"> <binding id="output-image" extends="chrome://xforms/content/xforms.xml#xformswidget-base"> <content> <html:div> <html:img anonid="content"/> </html:div> </content> <implementation implements="nsixformsuiwidget"> <method name="refre...
...p://www.mozilla.org/images/p-bugz.gif</img> <img label="mozilla">http://www.mozilla.org/images/mozhead-80x64.gif</img> </data> </xf:instance> </xf:model> <style type="text/css"> @namespace xf url(http://www.w3.org/2002/xforms); xf|output[mediatype="image/*"] { -moz-binding: url('#output-image'); } </style> </head> <body> <h1>custom control sample</h1> <xf:select1 ref="curimg"> <xf:label>select image to display: </xf:label> <xf:itemset nodeset="../img"> <xf:label ref="@label"/> <xf:value ref="."/> </xf:itemset> </xf:select1> <xf:output ref="curimg" mediatype="image/*"/> </body> </html> ...
Obsolete: XPCOM-based scripting for NPAPI plugins - Archive of obsolete content
related sources the full sample plugin code can be found in the mozilla source tree under modules/plugin/samples/4x-scriptable/ ibm developer works has published a good article on xpcom.
...sample .idl file #include "nsisupports.idl" [scriptable, uuid(bedb0778-2ee0-11d5-9cf8-0060b0fbd8ac)] interface nsitestplugin : nsisupports { void nativemethod(); }; example 2.
Vendor Prefix - MDN Web Docs Glossary: Definitions of Web-related terms
css prefixes the major browsers use the following prefixes: -webkit- (chrome, safari, newer versions of opera, almost all ios browsers including firefox for ios; basically, any webkit based browser) -moz- (firefox) -o- (old pre-webkit versions of opera) -ms- (internet explorer and microsoft edge) sample usage: -webkit-transition: all 4s ease; -moz-transition: all 4s ease; -ms-transition: all 4s ease; -o-transition: all 4s ease; transition: all 4s ease; api prefixes historically, vendors have also used prefixes for experimental apis.
...webkit, versions of opera) ms (internet explorer and microsoft edge) property and method prefixes the prefixes for properties and methods are lower-case: webkit (chrome, safari, newer versions of opera, almost all ios browsers (including firefox for ios); basically, any webkit based browser) moz (firefox) o (old, pre-webkit, versions of opera) ms (internet explorer and microsoft edge) sample usage: var requestanimationframe = window.requestanimationframe || window.mozrequestanimationframe || window.webkitrequestanimationframe || window.orequestanimationframe || window.msrequestanimationframe; learn more general knowledge vendor prefix on wikipedia ...
XInclude - MDN Web Docs Glossary: Definitions of Web-related terms
when used in conjunction with xpointer (firefox supports a subset of it, and is used in the code sample below), xinclude can also target just specific portions of a document for inclusion.
... code sample the following code aims to let <xi:include> and <xi:fallback> tags (the two elements in the language) with all of the attributes of <xi:include> be included in an xml document so as to be resolvable into a single xml document.
Fundamental text and font styling - Learn web development
in this example we'll apply some different css properties to the same html sample, which looks like this: <h1>tommy the cat</h1> <p>well i remember it as though it were a meal ago...</p> <p>said tommy the cat as he reeled back to clear whatever foreign matter may have nestled its way into his mighty throat.
... playable code <div class="body-wrapper" style="font-family: 'open sans light',helvetica,arial,sans-serif;"> <h2>html input</h2> <textarea id="code" class="html-input" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"> <p>some sample text for your delight</p> </textarea> <h2>css input</h2> <textarea id="code" class="css-input" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"> p { } </textarea> <h2>output</h2> <div class="output" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"></div> <div class="controls"> <input id="reset" type="button" value="reset" style="m...
Advanced text formatting - Learn web development
you can use our sample below, or replace it with one of your own.
...you should try having a play with these (try grabbing a copy of our other-semantics.html sample file): <pre><code>var para = document.queryselector('p'); para.onclick = function() { alert('owww, stop poking me!'); }</code></pre> <p>you shouldn't use presentational elements like <code>&lt;font&gt;</code> and <code>&lt;center&gt;</code>.</p> <p>in the above javascript example, <var>para</var> represents a paragraph element.</p> <p>select all the text with <kbd>ctrl</kbd>/<kbd>cmd</kbd...
Debugging HTML - Learn web development
active learning: validating an html document let's try this with our sample document.
... copy all of the sample document's code (not just the body) and paste it into the large text area shown in the markup validation service.
HTML text fundamentals - Learn web development
milk eggs bread hummus every unordered list starts off with a <ul> element—this wraps around all the list items: <ul> milk eggs bread hummus </ul> the last step is to wrap each list item in a <li> (list item) element: <ul> <li>milk</li> <li>eggs</li> <li>bread</li> <li>hummus</li> </ul> active learning: marking up an unordered list try editing the live sample below to create your very own html unordered list.
...dered lists, except that you have to wrap the list items in an <ol> element, rather than <ul>: <ol> <li>drive to the end of the road</li> <li>turn right</li> <li>go straight across the first two roundabouts</li> <li>turn left at the third roundabout</li> <li>the school is on your right, 300 meters up the road</li> </ol> active learning: marking up an ordered list try editing the live sample below to create your very own html ordered list.
What is JavaScript? - Learn web development
people are doing some amazing things using these web technologies —see chrome experiments and webglsamples.
... first, create a new file in the same directory as your sample html file.
Starting our Svelte Todo list app - Learn web development
for example, if we add an <img> element to our todos.svelte component without its corresponding alt prop: <h1>svelte to-do list</h1> <img height="32" width="88" src="https://udn.realityripple.com/samples/b0/98dase3c7d.png"> the compiler will issue the following warning: (!) plugin svelte: a11y: <img> element should have an alt attribute src/components/todos.svelte 1: <h1>svelte to-do list</h1> 2: 3: <img height="32" width="88" src="https://udn.realityripple.com/samples/b0/98dase3c7d.png"> ^ created public/build/bundle.js in 220ms [2020-07-15 04:07:43] waiting for changes...
... moreover, our editor can display this warning even before calling the compiler: you can tell svelte to ignore this warning for the next block of markup with a comment beginning with svelte-ignore, like this: <!-- svelte-ignore a11y-missing-attribute --> <img height="32" width="88" src="https://udn.realityripple.com/samples/b0/98dase3c7d.png"> note: with vscode you can automatically add this ignore comment by clicking on the quick fix...
Rendering a list of Vue components - Learn web development
add a few sample to-do items, along the lines of those seen below.
...we now have sample data in place, and a loop that takes each bit of data and renders it inside a todoitem in our app.
Deploying our app - Learn web development
previous overview: understanding client-side tools in the final article in our series, we take the example toolchain we built up in the previous article and add to it so that we can deploy our sample app.
... summary that's it for our sample case study, and for the module!
Introducing a complete toolchain - Learn web development
previous overview: understanding client-side tools next in the final couple of articles in the series we will solidify your tooling knowledge by walking you through the process of building up a sample case study toolchain.
... for our sample project, we'll be using a toolchain specifically designed to aid our software development and support the technical choices made during the software design phase.
Understanding client-side web development tools - Learn web development
introducing a complete toolchain in the final couple of articles in the series we will solidify your tooling knowledge by walking you through the process of building up a sample case study toolchain.
...deploying our app in the final article in our series, we take the example toolchain we built up in the previous article and add to it so that we can deploy our sample app.
Obsolete Build Caveats and Tips
you may choose not to install the sample code and documentation to save space and download time.
... for all sdks, you may choose not to install sample code and documentation to save space and download time.
Internationalized Domain Names (IDN) Support in Mozilla Browsers
for example, most sample links on the following test pages can be used without any further setting: http://www.nunames.nu/eu-lang-test.htm (domain names with latin 1 accented characters) http://www.nunames.nu/lldemo/default.htm (domain names in other languages) on july 10, 2003 and thereafter, you can access a large number of japanese domain name sites under the .jp top domain with no further setting on netscape 7.
...you should succeed in reaching the sample sites.
Interfacing with the Add-on Repository
this article provides some sample code that queries the recommended add-ons list on amo and lets the user click a button to install an add-on from the list.
... installing the add-on the shownotification() routine displays a notification box offering to install the recommended add-on, if one was found, or reports an error if the search failed: shownotification: function(prompt, button, installobj) { this.install = installobj; var box = popupnotifications.show(gbrowser.selectedbrowser, "sample-popup", prompt, null, /* anchor id */ { label: button, accesskey: "i", callback: function() { if (popupnotifications.install) { popupnotifications.install.install(); } else { popupnotifications.remove(box); } } }, null /* seco...
Creating localizable web applications
bad: <?= _("view a sample persona header <b><a href=\"/static/img/persona_header_labs.jpg\">here</a></b>.");?> snippet 2.
... good: <?php printf(_("view a sample persona header <b><a href=\"%s\">here</a></b>."), '/static/img/persona_header_labs.jpg'); ?> snippet 3.
BloatView
here's a sample of the bloatview output.
...the following sample code shows what must be done: mytype::mytype() { moz_count_ctor(mytype); ...
Power profiling overview
for example, the gecko profiler takes samples at 1000hz using a timer.
... each of these samples can trigger a wakeup, which consumes power and obscures firefox's natural wakeup patterns.
javascript.options.strict
example : <html> <head> <title>sample</title> </head> <body> <label id="name">enter you first name</label> <p id ="sample"></p> <script> "use strict" name1= "john" ; // this will cause and an error as variable not declared .
... var name2= "peter"; document.getelementbyid("sample").innerhtml = name1; </script> </body> </html> possible values and their effects: true: show javascript errors and warnings.
Encrypt Decrypt MAC Keys As Session Objects
nss sample code 4: encryption/decryption and mac keys using session.
...*/ /* nspr headers */ #include #include #include #include #include #include #include /* nss headers */ #include #include /* our samples utilities */ #include "util.h" #define buffersize 80 #define digestsize 16 #define ptext_mac_buffer_size 96 #define ciphersize 96 #define blocksize 32 #define cipher_header "-----begin cipher-----" #define cipher_trailer "-----end cipher-----" #define enckey_header "-----begin aeskey ckaid-----" #define enckey_trailer "-----end...
Encrypt and decrypt MAC using token
nss sample code 3: encryption/decryption and mac using token object.
...*/ /* nspr headers */ #include #include #include #include #include #include #include /* nss headers */ #include #include /* our samples utilities */ #include "util.h" #define buffersize 80 #define digestsize 16 #define ptext_mac_buffer_size 96 #define ciphersize 96 #define blocksize 32 #define cipher_header "-----begin cipher-----" #define cipher_trailer "-----end cipher-----" #define enckey_header "-----begin aeskey ckaid-----" #define enckey_trailer "-----e...
Encrypt Decrypt_MAC_Using Token
nss sample code 3: encryption/decryption and mac using token object.
...*/ /* nspr headers */ #include #include #include #include #include #include #include /* nss headers */ #include #include /* our samples utilities */ #include "util.h" #define buffersize 80 #define digestsize 16 #define ptext_mac_buffer_size 96 #define ciphersize 96 #define blocksize 32 #define cipher_header "-----begin cipher-----" #define cipher_trailer "-----end cipher-----" #define enckey_header "-----begin aeskey ckaid-----" #define enckey_trailer "-----e...
nss tech note7
here is the asn.1 type definition: rsapublickey ::= sequence { modulus integer, -- n publicexponent integer -- e } the following sample code (error handling omitted for brevity) encodes a rsapublickey from a modulus and a public exponent and imports the public key into nss.
... sample code sample code 4: pki encryption references rsa labs pkcs #1 web site rfc 3447: rsa pkcs #1 v2.1 poupou's blog: common question: how to encrypt using rsa ...
Rhino Examples
sample scripts the unique.js script allows printing unique lines from a file.
... the liveconnect.js script shows a sample usage of liveconnect (java-to-javascript connectivity).
JSAPI User Guide
*/ js_clearpendingexception(cx); return false; more sample code the following examples illustrate how to achieve a few different effects using the jsapi.
...more jsapi code samples appear in the jsapi phrasebook.
Animated PNG graphics
MozillaTechAPNG
note that the second variation of the sample code is applicable.
...he first frame can be hidden and it is signaled with a missing fctl idat, fctl and fdat are no longer required to have no other chunks in between them from 0.8 removed crcs for ihdr and plte from actl the actl fctl and adat are now not copy safe, renamed them to actl, fctl and adat from 0.9 split render_op into dispose_op and blend_op from 0.10 no changes test encoder and sample images sample images are available from the apng implementation page at http://littlesvr.ca/apng/ an encoder (open source) is available in versions of the gecko engine starting with version 1.9 alpha 4.
AT APIs Support
if you seriously need to understand msaa, you'll need to read the docs on msdn and play with the sample apps and code that come with msaa sdk 1.3.
...if you seriously need to understand at-spi, you'll need to read the docs on gnome.org and play with the available sample apps and code, such as at-poke.
Frecency algorithm
points for each sampled visit = (bonus / 100.0) * weight final frecency score for visited uri = ceiling(total visit count * sum of points for sampled visits / number of sampled visits) example this is an example of a frecency calculation for a uri that is bookmarked and has been visited twice recently (once yesterday, and once last week by clicking a link), and two other times more than 90 d...
...140 100 * (140/100.0) - first bucket weight and bookmarked bonus +84 70 * (120/100.0) - second bucket weight and followed-link bonus +14 10 * (140/100.0) - fifth bucket weight and bookmarked bonus +14 10 * (140/100.0) - fifth bucket weight and bookmarked bonus -- 252 (4 * 252 / 4) - final frecency score notes the number of sampled visits is min(10 most recent visits pref, total visit counts).
Places Developer Guide
it provides code samples for many common use-cases, such as crud operations, searching, and observing.
...tartdate = enddate - (7 * 86400 * 1000 * 1000); // one week ago, in microseconds browserhistory.removepagesbytimeframe(startdate, enddate); // remove all pages for a given host var entiredomain = true; // will delete from all hosts from the given domain browserhistory.removepagesfromhost("mozilla.com", true); // remove all history visits browserhistory.removeallpages(); querying history the code sample below queries the browser history for the ten most visited urls in the browser history.
Bundling multiple binary components
the real components are not in the "components" folder, but are in a side folder ("libraries" in the sample).
... the real components are manually loaded and registered using the stub ("krealcomponent" in the sample).
Creating a Python XPCOM component
for example: % cd c:\mozilla\bin\python\xpcom % python xpt.py nsisample class nsisample: _com_interfaces_ = xpcom.components.interfaces.nsisample # if this object needs to be registered, the following 2 are also needed.
...the problem with this one is that the sample code they give is slightly broken (it ends with a "retu" which shouldn't be there.
XPCOM changes in Gecko 2.0
for an up-to-date example of implementing a dynamic modules, see nssamplemodule.cpp.
...see nssamplemodule.cpp for more details.
mozIStorageConnection
see mozistorageaggregatefunction for sample code and more details.
...see mozistoragefunction for sample code and more details.
Setting HTTP request headers
below is some sample code where we set an http header.
... data) { if (topic == "http-on-modify-request") { var httpchannel = subject.queryinterface(ci.nsihttpchannel); httpchannel.setrequestheader("x-hello", "world", false); } } }; note: the above code was changed to reflect that in a firefox add-on one can not directly access components.interfaces und components.classes anymore but must use the require line introduced to the sample code above.
Xray vision
that includes the code samples in this article.
...that includes the code samples in this article.
Mail composition back end
pizzarro <rhp@netscape.com> contents overview sending messages nsimsgsend sending listener interfaces nsimsgsendlistener nsimsgcopyservicelistener copy operations copy to sent folder drafts templates "send later" sending unsent messages sending unsent messages listener quoting sample programs overview i've done considerable work in the past few weeks reorganizing the mail composition back end, so i thought it would be helpful to put together a small doc on the new interfaces and how one can use them.
... ns_imethod quotemessage( const prunichar *msguri, - the uri of the message to be quoted nsioutputstream *outstream) = 0; - the consumer output stream for the quoted data sample programs the mozilla/mailnews/compose/tests/ directory contains sample test programs for all of the above described interfaces.
Mail event system
sample control flow here is an example of a possible flow of control when a new message is added to a folder.
...hanged onitemintpropertychanged notifyitemboolpropertychanged onitemboolpropertychanged notifyitemunicharpropertychanged onitemunicharpropertychanged notifyitempropertyflagchanged onitempropertyflagchanged notifyitemevent onitemevent notifyfolderloaded onfolderloaded notifydeleteormovemessages ondeleteormovemessages sample code in this example, a listener will be set up to be notified when the message count changes in a folder: // our variable to know if the listener fired var listenerhasfired = false; var totalmessageslistenerhasfired = false; // the listening function that will react to changes function myonintpropertychanged(item, property, oldvalue, newvalue) { listenerhasfired=true; var propertystring...
libmime content type handlers
pizzarro <rhp@netscape.com> contents overview api's plugin location/installation sample content type handler plugin overview the libmime module implements a general-purpose mime parser and one of the primary methods provided by the parser is the ability to emit an html representation of an input stream.
... sample content type handler plugin to see an example of a content type handler plugin, the source for the handler of the content type "text/calendar" can be viewed at the following link: calendar plugin note: this plugin simply creates a blue table in the output stream to identify the fact that it is operational, but the basic constructs of what is needed to build a functional content type handler can ...
Using popup notifications
then you can create the popup notification at the appropriate time like this: popupnotifications.show(gbrowser.selectedbrowser, "sample-popup", "this is a sample popup notification.", null, /* anchor id */ { label: "do something", accesskey: "d", callback: function() { alert("doing something awesome!"); } }, null /* secondary action */ ); in this case, we aren't providing any secondary actions; that is, actions provided to the u...
...you can use this to style the icon, like this: .popup-notification-icon[popupid="sample-popup"] { list-style-image: url("chrome://popupnotifications/skin/mozlogo.png"); } with this css in place, the result is the look we want: adding secondary options to provide options in the drop-down menu, add an array of notification actions to the call to the show() method, like this: popupnotifications.show(gbrowser.selectedbrowser, "sample-popup", "this is a sample popup noti...
Flame Chart - Firefox Developer Tools
the call tree and the flame chart are both used to analyze your site's javascript, and they both use the same data: a sample of the javascript engine's stack, taken periodically during the recording.
...in the call tree page, we figured out that the program call graph in that profile, and the associated sample count, looked like this: sortall() // 8 -> sort() // 37 -> bubblesort() // 1345 -> swap() // 252 -> selectionsort() // 190 -> swap() // 1 -> quicksort() // 103 -> partition() // 12 first, we'll just select the ...
UI Tour - Firefox Developer Tools
it periodically samples the state of the javascript engine, and records the stack for the code executing at the time the sample was taken.
... statistically, the number of samples taken in which we were executing a particular function corresponds to the amount of time the browser is spending executing it, so you can identify bottlenecks in your code.
AnalyserNode.fftSize - Web APIs
the fftsize property of the analysernode interface is an unsigned long value and represents the window size in samples that is used when performing a fast fourier transform (fft) to get frequency domain data.
... syntax var curvalue = analysernode.fftsize; analysernode.fftsize = newvalue; value an unsigned integer, representing the window size of the fft, given in number of samples.
AudioBuffer.copyToChannel() - Web APIs
the copytochannel() method of the audiobuffer interface copies the samples to the specified channel of the audiobuffer, from the source array.
... example var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); var anotherarray = new float32array; // copy channel data from second channel of myarraybuffer.
AudioBuffer.duration - Web APIs
syntax var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); myarraybuffer.duration; value a double.
... example // stereo var channels = 2; // create an empty two second stereo buffer at the // sample rate of the audiocontext var framecount = audioctx.samplerate * 2.0; var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; // just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuffering = myarraybuffer.getchanneldata(channel); for (var i = 0; i < framecount; i++) { // math.random() is in [0; 1.0] // audio needs to be in [-1.0; 1.0] nowbuffering[i] = math.random() * 2 - 1; } } console.log(myarraybuffer.duration); } specification specific...
AudioBuffer.getChannelData() - Web APIs
syntax var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); var nowbuffering = myarraybuffer.getchanneldata(channel); parameters channel the channel property is an index representing the particular channel to get data for.
... var audioctx = new (window.audiocontext || window.webkitaudiocontext)(); var button = document.queryselector('button'); var pre = document.queryselector('pre'); var myscript = document.queryselector('script'); pre.innerhtml = myscript.innerhtml; // stereo var channels = 2; // create an empty two second stereo buffer at the // sample rate of the audiocontext var framecount = audioctx.samplerate * 2.0; var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; //just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuf...
AudioBuffer.numberOfChannels - Web APIs
syntax var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); myarraybuffer.numberofchannels; value an integer.
... example // stereo var channels = 2; // create an empty two second stereo buffer at the // sample rate of the audiocontext var framecount = audioctx.samplerate * 2.0; var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; // just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuffering = myarraybuffer.getchanneldata(channel); for (var i = 0; i < framecount; i++) { // math.random() is in [0; 1.0] // audio needs to be in [-1.0; 1.0] nowbuffering[i] = math.random() * 2 - 1; } } console.log(myarraybuffer.numberofchannels); } specification s...
AudioBufferSourceNode.buffer - Web APIs
if the buffer property is set to the value null, the node generates a single channel containing silence (that is, every sample is 0).
... var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; //just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuffering = myarraybuffer.getchanneldata(channel); for (var i = 0; i < framecount; i++) { // math.random() is in [0; 1.0] // audio needs to be in [-1.0; 1.0] nowbuffering[i] = math.random() * 2 - 1; } } // get an a...
AudioBufferSourceNode.playbackRate - Web APIs
when set to another value, the audiobuffersourcenode resamples the audio before sending it to the output.
... consider a sound buffer containing audio sampled at 44.1 khz (44,100 samples per second).
AudioConfiguration - Web APIs
samplerate: the number of audio samples making up one second of the audio file.
... examples //create media configuration to be tested const mediaconfig = { type : 'file', // 'record', 'transmission', or 'media-source' audio : { contenttype : "audio/ogg", // valid content type channels : 2, // audio channels used by the track bitrate : 132700, // number of bits used to encode 1s of audio samplerate : 5200 // number of audio samples making up that 1s.
AudioContext.createJavaScriptNode() - Web APIs
syntax var jsnode = audioctx.createjavascriptnode(buffersize, numinputchannels, numoutputchannels); parameters buffersize the buffer size must be in units of sample frames, i.e., one of: 256, 512, 1024, 2048, 4096, 8192, or 16384.
... example the following script illustrates the use of createjavascriptnode(): var sinewave = function(context) { var that = this; this.x = 0; // initial sample number this.context = context; this.node = context.createjavascriptnode(1024, 1, 1); this.node.onaudioprocess = function(e) { that.process(e) }; } sinewave.prototype.process = function(e) { var data = e.outputbuffer.getchanneldata(0); for (var i = 0; i < data.length; ++i) { data[i] = math.sin(this.x++); } } sinewave.prototype.play = function() { this.node.connect(this.context.
AudioContext.getOutputTimestamp() - Web APIs
the two values are as follows: audiotimestamp.contexttime: the time of the sample frame currently being rendered by the audio output device (i.e., output audio stream position), in the same units and origin as the context's audiocontext.currenttime.
... audiotimestamp.performancetime: an estimation of the moment when the sample frame corresponding to the stored contexttime value was rendered by the audio output device, in the same units and origin as performance.now().
BaseAudioContext.createConvolver() - Web APIs
the basic premise is that you create an audiobuffer containing a sound sample to be used as an ambience to shape the convolution (called the impulse response,) and apply that to the convolver.
... the example below uses a short sample of a concert hall crowd, so the reverb effect applied is really deep and echoey.
BaseAudioContext.createWaveShaper() - Web APIs
amount : 50, n_samples = 44100, curve = new float32array(n_samples), deg = math.pi / 180, i = 0, x; for ( ; i < n_samples; ++i ) { x = i * 2 / n_samples - 1; curve[i] = ( 3 + k ) * x * 20 * deg / ( math.pi + k * math.abs(x) ); } return curve; }; ...
... distortion.curve = makedistortioncurve(400); distortion.oversample = '4x'; specifications specification status comment web audio apithe definition of 'createwaveshaper()' in that specification.
CanvasRenderingContext2D.drawImage() - Web APIs
html <canvas id="canvas"></canvas> <div style="display:none;"> <img id="source" src="https://udn.realityripple.com/samples/db/f374e9c6fc.jpg" width="300" height="227"> </div> javascript the source image is taken from the coordinates (33, 71), with a width of 104 and a height of 124.
... html <canvas id="canvas"></canvas> javascript const canvas = document.getelementbyid('canvas'); const ctx = canvas.getcontext('2d'); const image = new image(60, 45); // using optional size for image image.onload = drawimageactualsize; // draw when image has loaded // load an image of intrinsic size 300x227 in css pixels image.src = 'https://udn.realityripple.com/samples/db/f374e9c6fc.jpg'; function drawimageactualsize() { // use the intrinsic size of image in css pixels for the canvas element canvas.width = this.naturalwidth; canvas.height = this.naturalheight; // will draw the image as 300x227, ignoring the custom size of 60x45 // given in the constructor ctx.drawimage(this, 0, 0); // to use the custom size we'll have to specify the scale para...
Basic animations - Web APIs
.pi) / 6000) * time.getmilliseconds()); ctx.translate(0, 28.5); ctx.drawimage(moon, -3.5, -3.5); ctx.restore(); ctx.restore(); ctx.beginpath(); ctx.arc(150, 150, 105, 0, math.pi * 2, false); // earth orbit ctx.stroke(); ctx.drawimage(sun, 0, 0, 300, 300); window.requestanimationframe(draw); } init(); <canvas id="canvas" width="300" height="300"></canvas> screenshotlive sample an animated clock this example draws an animated clock, showing your current time.
...= 'rgba(0, 0, 0, 0)'; ctx.arc(0, 0, 3, 0, math.pi * 2, true); ctx.fill(); ctx.restore(); ctx.beginpath(); ctx.linewidth = 14; ctx.strokestyle = '#325fa2'; ctx.arc(0, 0, 142, 0, math.pi * 2, true); ctx.stroke(); ctx.restore(); window.requestanimationframe(clock); } window.requestanimationframe(clock); <canvas id="canvas" width="150" height="150"></canvas> screenshotlive sample a looping panorama in this example, a panorama is scrolled left-to-right.
ConstantSourceNode.offset - Web APIs
the read-only offset property of the constantsourcenode interface returns a audioparam object indicating the numeric a-rate value which is always returned by the source when asked for the next sample.
...so you can change the value of offset by setting the value of constantsourcenode.offset.value: myconstantsourcenode.offset.value = newvalue; syntax let offsetparameter = constantaudionode.offset; let offset = constantsourcenode.offset.value; constantsourcenode.offset.value = newvalue; value an audioparam object indicating the a-rate value returned for every sample by this node.
Document.cookie - Web APIs
WebAPIDocumentcookie
examples example #1: simple usage document.cookie = "name=oeschger"; document.cookie = "favorite_food=tripe"; function alertcookie() { alert(document.cookie); } <button onclick="alertcookie()">show cookies</button> example #2: get a sample cookie named test2 document.cookie = "test1=hello"; document.cookie = "test2=world"; const cookievalue = document.cookie .split('; ') .find(row => row.startswith('test2')) .split('=')[1]; function alertcookievalue() { alert(cookievalue); } <button onclick="alertcookievalue()">show cookie value</button> example #3: do something only once in order to use the following code, please ...
...s, which differs from other client-client storage methods (like, for instance, localstorage): the server tells the client to store a cookie http/1.0 200 ok content-type: text/html set-cookie: cookie_name1=cookie_value1 set-cookie: cookie_name2=cookie_value2; expires=sun, 16 jul 3567 06:23:41 gmt [content of the page here] the client sends back to the server its cookies previously stored get /sample_page.html http/1.1 host: www.example.org cookie: cookie_name1=cookie_value1; cookie_name2=cookie_value2 accept: */* specifications specification status comment document object model (dom) level 2 html specificationthe definition of 'document.cookie' in that specification.
EXT_shader_texture_lod - Web APIs
glsl built-in functions the following new functions can be used in glsl shader code, if this extension is enabled: vec4 texture2dlodext(sampler2d sampler, vec2 coord, float lod) vec4 texture2dprojlodext(sampler2d sampler, vec3 coord, float lod) vec4 texture2dprojlodext(sampler2d sampler, vec4 coord, float lod) vec4 texturecubelodext(samplercube sampler, vec3 coord, float lod) vec4 texture2dgradext(sampler2d sampler, vec2 p, vec2 dpdx, vec2 dpdy) vec4 texture2dprojgradext(sampler2d sampler, vec3 p, vec2 dpdx, vec2 dpdy) vec4 texture2dpro...
...jgradext(sampler2d sampler, vec4 p, vec2 dpdx, vec2 dpdy) vec4 texturecubegradext(samplercube sampler, vec3 p, vec3 dpdx, vec3 dpdy) examples enabling the extensions: gl.getextension('ext_shader_texture_lod'); shader code that avoids artifacts when wrapping texture coordinates: <script type="x-shader/x-fragment"> #extension gl_ext_shader_texture_lod : enable #extension gl_oes_standard_derivatives : enable uniform sampler2d mytexture; varying vec2 texcoord; void main(){ gl_fragcolor = texture2dgradext(mytexture, mod(texcoord, vec2(0.1, 0.5)), dfdx(texcoord), dfdy(texcoord)); } </script> specifications specification status comment ext_shader_texture_lodthe definition of 'ext_shader_texture_lod' in that specification.
Introduction to the File and Directory Entries API - Web APIs
for examples of features you can create with this app, see the sample use cases section.
... sample use cases the following are just a few examples of how you can use the file and directory entries api: apps with persistent uploader when a file or directory is selected for upload, you can copy the file into a local sandbox and upload a chunk at a time.
HTMLAudioElement - Web APIs
mozcurrentsampleoffset() returns the number of samples form the beginning of the stream that have been written so far into the audio stream created by calling mozwriteaudio().
... mozsetup() sets up the audio stream to allow writing, given the number of audio channels (1 or 2) and the sample rate in khz.
HTMLMediaElement: loadedmetadata event - Web APIs
mozsamplerate read only int the sample rate per second.
... mozframebufferlength read only int the number of samples collected in all channels.
HTMLMedia​Element​.textTracks - Web APIs
examples we start with a <video> that has several <track> children <video controls poster="/images/sample.gif"> <source src="sample.mp4" type="video/mp4"> <source src="sample.ogv" type="video/ogv"> <track kind="captions" src="samplecaptions.vtt" srclang="en"> <track kind="descriptions" src="sampledescriptions.vtt" srclang="en"> <track kind="chapters" src="samplechapters.vtt" srclang="en"> <track kind="subtitles" src="samplesubtitles_de.vtt" srclang="de"> <track kind="subtitles" src="sam...
...plesubtitles_en.vtt" srclang="en"> <track kind="subtitles" src="samplesubtitles_ja.vtt" srclang="ja"> <track kind="subtitles" src="samplesubtitles_oz.vtt" srclang="oz"> <track kind="metadata" src="keystage1.vtt" srclang="en" label="key stage 1"> <track kind="metadata" src="keystage2.vtt" srclang="en" label="key stage 2"> <track kind="metadata" src="keystage3.vtt" srclang="en" label="key stage 3"> </video> the htmlmediaelement.texttracks returns a texttrackslist thru which we can iterate.
Recommended Drag Types - Web APIs
for example, this sample text/uri-list data contains two links and a comment: http://www.mozilla.org #a second link http://www.example.com when retrieving a dropped link, ensure you handle when multiple links are dragged, including any comments.
...the following sample offers an overview of this advanced case: // currentevent is an existing drag operation event currentevent.datatransfer.setdata("text/x-moz-url", url); currentevent.datatransfer.setdata("application/x-moz-file-promise-url", url); currentevent.datatransfer.setdata("application/x-moz-file-promise-dest-filename", leafname); currentevent.datatransfer.mozsetdataat('application/x-moz-file-promise', ...
InputEvent.inputType - Web APIs
html <p id="log">input type: </p> <div contenteditable="true" style="margin: 20px;padding: 20px;border:2px dashed red;"> <p>some sample text.
... try inserting line breaks, or deleting text in different ways, or pasting different content in.</p> <hr> <ul> <li>a sample</li> <li>bulleted</li> <li>list.</li> </ul> <p>another paragraph.</p> </div> javascript const log = document.getelementbyid('log'); const editable = document.queryselector('div[contenteditable]'); editable.addeventlistener('input', loginputtype); function loginputtype(event) { log.textcontent = `input type: ${event.inputtype}`; } result try editing the text inside the <div> and see what happens.
Intersection Observer API - Web APIs
threshold example <template id="boxtemplate"> <div class="samplebox"> <div class="label topleft"></div> <div class="label topright"></div> <div class="label bottomleft"></div> <div class="label bottomright"></div> </div> </template> <main> <div class="contents"> <div class="wrapper"> </div> </div> </main> .contents { position: absolute; width: 700px; height: 1725px; } .wrapper { position: relative; top: 600px; } .sam...
... [0.5], [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], [0, 0.25, 0.5, 0.75, 1.0] ]; for (let i=0; i<=1.0; i+= 0.01) { thresholdsets[0].push(i); } // add each box, creating a new observer for each for (let i=0; i<4; i++) { let template = document.queryselector("#boxtemplate").content.clonenode(true); let boxid = "box" + (i+1); template.queryselector(".samplebox").id = boxid; wrapper.appendchild(document.importnode(template, true)); // set up the observer for this box observeroptions.threshold = thresholdsets[i]; observers[i] = new intersectionobserver(intersectioncallback, observeroptions); observers[i].observe(document.queryselector("#" + boxid)); } // scroll to the starting position document.scrollingelement.scrolltop ...
KeyboardEvent.code - Web APIs
helvetica, sans-serif; border: 1px solid black; } javascript window.addeventlistener("keydown", function(event) { let str = "keyboardevent: key='" + event.key + "' | code='" + event.code + "'"; let el = document.createelement("span"); el.innerhtml = str + "<br/>"; document.getelementbyid("output").appendchild(el); }, true); try it out to ensure that keystrokes go to the sample, click in the output box below before pressing keys.
...tion(moverate); break; case "keya": case "arrowleft": // handle "turn left" angle -= turnrate; break; case "keyd": case "arrowright": // handle "turn right" angle += turnrate; break; } refresh(); // consume the event so it doesn't get handled twice event.preventdefault(); }, true); try it out to ensure that keystrokes go to the sample code, click inside the black game play field below before pressing keys.
MediaDevices.ondevicechange - Web APIs
because the example provides a handler for the devicechange event, the list is refreshed any time a media device is attached to or removed from the device running the sample.
... let videoelement = document.getelementbyid("video"); let logelement = document.getelementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.getelementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ video: { width: 160, height: 120, framerate: 30 }, audio: { samplerate: 44100, samplesize: 16, volume: 0.25 } }).then(stream => { videoelement.srcobject = stream; updatedevicelist(); }) .catch(err => log(err.name + ": " + err.message)); }, false); we set up global variables that contain references to the <ul> elements that are used to list the audio and video devices: let audiolist = document.getelementbyid("audiolist"); ...
MediaStreamConstraints.audio - Web APIs
examples for browsers with feature policy enabled, the samples below need the microphone feature enabled.
...x; padding-bottom: 4px; color: white; background-color: darkgreen; } javascript content let audioelement = document.getelementbyid("audio"); let logelement = document.getelementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.getelementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ audio: { samplesize: 8, echocancellation: true } }).then(stream => audioelement.srcobject = stream) .catch(err => log(err.name + ": " + err.message)); }, false); here we see an event handler for a click event which calls getusermedia(), specifying a set of audio constraints requesting that echo cancellation be enabled and that, if possible, the sample rate be 8 bits per sample instead of the mor...
MediaStreamTrack.enabled - Web APIs
in the case of audio, a disabled track generates frames of silence (that is, frames in which every sample's value is 0).
... empty audio frames have every sample's value set to 0.
Using the MediaStream Recording API - Web APIs
a sample application: web dictaphone to demonstrate basic usage of the mediarecorder api, we have built a web-based dictaphone.
...we wanted to give the first two (the header and the controls) fixed heights: header { height: 70px; } .main-controls { padding-bottom: 0.7rem; height: 170px; } however, we wanted to make the third area (which contains the recorded samples you can play back) take up whatever space is left, regardless of the device height.
MediaTrackConstraints - Web APIs
samplerate a constrainlong specifying the sample rate or range of sample rates which are acceptable and/or required.
... samplesize a constrainlong specifying the sample size or range of sample sizes which are acceptable and/or required.
MediaTrackSupportedConstraints - Web APIs
samplerate a boolean value whose value is true if the samplerate constraint is supported in the current environment.
... samplesize a boolean value whose value is true if the samplesize constraint is supported in the current environment.
Capabilities, constraints, and settings - Web APIs
applying constraints the first and most common way to use constraints is to specify them when you call getusermedia(): navigator.mediadevices.getusermedia({ video: { width: { min: 640, ideal: 1920 }, height: { min: 400, ideal: 1080 }, aspectratio: { ideal: 1.7777777778 } }, audio: { samplesize: 16, channelcount: 2 } }).then(stream => { videoelement.srcobject = stream; }).catch(handleerror); in this example, constraints are applied at getusermedia() time, asking for an ideal set of options with fallbacks for the video.
... let videodefaultconstraintstring = '{\n "width": 320,\n "height": 240,\n "framerate": 30\n}'; let audiodefaultconstraintstring = '{\n "samplesize": 16,\n "channelcount": 2,\n "echocancellation": false\n}'; these defaults ask for a pretty common camera configuration, but don't insist on any property being of special importance.
Microdata DOM API - Web APIs
code example this sample shows how the getitems() method can be used to obtain a list of all the top-level microdata items of a particular type given in the document: var cats = document.getitems("http://example.com/feline"); once an element representing an item has been obtained, its properties can be extracted using the properties idl attribute.
... code example this sample gets the first item of type "http://example.net/user" and then pops up an alert using the "name" property from that item.
Using Navigation Timing - Web APIs
html <div class="output"> </div> css .output { border: 1px solid #bbb; font: 16px "open sans", "helvetica", "arial", sans-serif; } in tandem with appropriate html and css, the result is: the values listed are for the <iframe> in which the sample is presented above.
... html <div class="output"> </div> css .output { border: 1px solid #bbb; font: 16px "open sans", "helvetica", "arial", sans-serif; } with this code in place, the result looks like this: the values listed are for the <iframe> in which the sample is presented.
Node - Web APIs
WebAPINode
examples remove all children nested within a node function removeallchildren(element) { while (element.firstchild) { element.removechild(element.firstchild) } } sample usage /* ...
... sample usage the following example prints the textcontent properties of each <span> tag in a <div> element named "box": <div id="box"> <span>foo</span> <span>bar</span> <span>baz</span> </div> const box = document.getelementbyid("box") eachnode(box, function(node) { if (null != node.textcontent) { console.log(node.textcontent) } }) the above will result in the following strings printin...
OfflineAudioContext.length - Web APIs
the length property of the offlineaudiocontext interface returns an integer representing the size of the buffer in sample-frames.
... syntax var length = offlineaudiocontext.length; value an integer representing the size of the buffer in sample-frames.
RTCOutboundRtpStreamStats - Web APIs
retransmittedbytessent the total number of bytes that have been retransmitted for this source as of the time the statistics were sampled.
... retransmittedpacketssent the total number of packets that have needed to be retransmitted for this source as of the time the statistics were sampled.
RTCPeerConnection.onaddstream - Web APIs
it is included here in order to help you adapt existing code and understand existing samples, which may not be up-to-date yet.
... example this code, based on an older version of our signaling and video calling sample, responds to addstream events by setting the video source for a <video> element to the stream specified in the event, and then enabling a "hang up" button in the app's user interface.
RTCRtpContributingSource.rtpTimestamp - Web APIs
the read-only rtptimestamp property of the rtcrtpcontributingsource interface returns a domhighrestimestamp indicating the source-generated time at which the media contained int he packet was first sampled or obtained.
... syntax let rtptimestamp = rtcrtpcontributingsource.rtptimestamp value an integer value specifiying a source-generated timestamp indicating the time at which the media in this packet, scheduled for play out at the time indicated by timestamp, was initially sampled or generated.
ScriptProcessorNode: audioprocess event - Web APIs
cancelable no default action none interface audioprocessingevent event handler property scriptprocessornode.onaudioprocess examples scriptnode.addeventlistener('audioprocess', function(audioprocessingevent) { // the input buffer is a song we loaded earlier var inputbuffer = audioprocessingevent.inputbuffer; // the output buffer contains the samples that will be modified and played var outputbuffer = audioprocessingevent.outputbuffer; // loop through the output channels (in this case there is only one) for (var channel = 0; channel < outputbuffer.numberofchannels; channel++) { var inputdata = inputbuffer.getchanneldata(channel); var outputdata = outputbuffer.getchanneldata(channel); // loop through the 4096 samples f...
...or (var sample = 0; sample < inputbuffer.length; sample++) { // make output equal to the same as the input outputdata[sample] = inputdata[sample]; // add noise to each output sample outputdata[sample] += ((math.random() * 2) - 1) * 0.2; } } }) you could also set up the event handler using the scriptprocessornode.onaudioprocess property: scriptnode.onaudioprocess = function(audioprocessingevent) { ...
SecurityPolicyViolationEvent - Web APIs
securitypolicyviolationevent.sampleread only a domstring representing a sample of the resource that caused the violation, usually the first 40 characters.
... this will only be populated if the resource is an inline script, event handler, or style — external resources causing a violation will not generate a sample.
ServiceWorkerRegistration.showNotification() - Web APIs
examples navigator.serviceworker.register('sw.js'); function shownotification() { notification.requestpermission(function(result) { if (result === 'granted') { navigator.serviceworker.ready.then(function(registration) { registration.shownotification('vibration sample', { body: 'buzz!
... buzz!', icon: '../images/touch/chrome-touch-icon-192x192.png', vibrate: [200, 100, 200, 100, 200, 100, 200], tag: 'vibration-sample' }); }); } }); } to invoke the above function at an appropriate time, you could use the serviceworkerglobalscope.onnotificationclick event handler.
VideoPlaybackQuality.creationTime - Web APIs
the read-only creationtime property on the videoplaybackquality interface reports the number of milliseconds since the browsing context was created this quality sample was recorded.
... syntax value = videoplaybackquality.creationtime; value a domhighrestimestamp object which indicates the number of milliseconds that elapased between the time the browsing context was created and the time at which this sample of the video quality was obtained.
VisualViewport - Web APIs
a live sample is also available.
...a live sample is also available.
WaveShaperNode.curve - Web APIs
amount : 50, n_samples = 44100, curve = new float32array(n_samples), deg = math.pi / 180, i = 0, x; for ( ; i < n_samples; ++i ) { x = i * 2 / n_samples - 1; curve[i] = ( 3 + k ) * x * 20 * deg / ( math.pi + k * math.abs(x) ); } return curve; }; ...
... distortion.curve = makedistortioncurve(400); distortion.oversample = '4x'; specifications specification status comment web audio apithe definition of 'curve' in that specification.
WebGLRenderingContext.getActiveUniform() - Web APIs
the type attribute of the return value will be one of the following: gl.float gl.float_vec2 gl.float_vec3 gl.float_vec4 gl.int gl.int_vec2 gl.int_vec3 gl.int_vec4 gl.bool gl.bool_vec2 gl.bool_vec3 gl.bool_vec4 gl.float_mat2 gl.float_mat3 gl.float_mat4 gl.sampler_2d gl.sampler_cube when using a webgl 2 context, the following values are possible additionally: gl.unsigned_int gl.unsigned_int_vec2 gl.unsigned_int_vec3 gl.unsigned_int_vec4 gl.float_mat2x3 gl.float_mat2x4 gl.float_mat3x2 gl.float_mat3x4 gl.float_mat4x2 gl.float_mat4x3 gl.sampler_2d gl.sampler_3d gl.sampler_cube gl.sampler_2d_shadow gl.sampler_...
...2d_array gl.sampler_2d_array_shadow gl.sampler_cube_shadow gl.int_sampler_2d gl.int_sampler_3d gl.int_sampler_cube gl.int_sampler_2d_array gl.unsigned_int_sampler_2d gl.unsigned_int_sampler_3d gl.unsigned_int_sampler_cube gl.unsigned_int_sampler_2d_array when gl.linkprogram is called, webgl creates a list of active uniforms.
WebGLRenderingContext.getRenderbufferParameter() - Web APIs
when using a webgl 2 context, the following value is available additionally: gl.renderbuffer_samples: returns a glint indicating the number of samples of the image of the currently bound renderbuffer.
... adds a new pname value: gl.renderbuffer_samples ...
WebGLRenderingContext.getUniform() - Web APIs
ivec3 int32array (with 3 elements) bvec3 array of glboolean (with 3 elements) vec4 float32array (with 4 elements) ivec4 int32array (with 4 elements) bvec4 array of glboolean (with 4 elements) mat2 float32array (with 4 elements) mat3 float32array (with 9 elements) mat4 float32array (with 16 elements) sampler2d glint samplercube glint additionally available in webgl 2 uint gluint uvec2 uint32array (with 2 elements) uvec3 uint32array (with 3 elements) uvec4 uint32array (with 4 elements) mat2x3 float32array (with 6 elements) mat2x4 float32array (with 8 elements) mat3x2 float32array (with 6 elemen...
...ts) mat3x4 float32array (with 12 elements) mat4x2 float32array (with 8 elements) mat4x3 float32array (with 12 elements) any sampler type glint examples var loc = gl.getuniformlocation(program, 'u_foobar'); gl.getuniform(program, loc); specifications specification status comment webgl 1.0the definition of 'getuniform' in that specification.
Web Authentication API - Web APIs
// sample arguments for registration var createcredentialdefaultargs = { publickey: { // relying party (a.k.a.
... attestation: "direct", timeout: 60000, challenge: new uint8array([ // must be a cryptographically random number sent from a server 0x8c, 0x0a, 0x26, 0xff, 0x22, 0x91, 0xc1, 0xe9, 0xb9, 0x4e, 0x2e, 0x17, 0x1a, 0x98, 0x6a, 0x73, 0x71, 0x9d, 0x43, 0x48, 0xd5, 0xa7, 0x6a, 0x15, 0x7e, 0x38, 0x94, 0x52, 0x77, 0x97, 0x0f, 0xef ]).buffer } }; // sample arguments for login var getcredentialdefaultargs = { publickey: { timeout: 60000, // allowcredentials: [newcredential] // see below challenge: new uint8array([ // must be a cryptographically random number sent from a server 0x79, 0x50, 0x68, 0x71, 0xda, 0xee, 0xee, 0xb9, 0x94, 0xc3, 0xc2, 0x15, 0x67, 0x65, 0x26, 0x22, 0xe3, 0xf3, 0xab, 0x3b, 0x7...
WindowOrWorkerGlobalScope.setInterval() - Web APIs
example usage your html page: <!doctype html> <html> <head> <meta charset="utf-8" /> <title>minidaemin example - mdn</title> <script type="text/javascript" src="minidaemon.js"></script> <style type="text/css"> #sample_div { visibility: hidden; } </style> </head> <body> <p> <input type="button" onclick="fadeinout.start(false /* optional */);" value="fade in" /> <input type="button" onclick="fadeinout.start(true);" value="fade out"> <input type="button" onclick="fadeinout.pause();" value="pause" /> </p> <div id="sample_div">some text here</div> <script type="text/javascript"> ...
...'hidden' : 'visible'; } } var fadeinout = new minidaemon(document.getelementbyid('sample_div'), opacity, 300, 8); </script> </body> </html> view this example in action usage notes the setinterval() function is commonly used to set a delay for functions that are executed again and again, such as animations.
Using XMLHttpRequest - Web APIs
the download events are fired on the xmlhttprequest object itself, as shown in the above sample.
...x" name="vehicle[]" value="car" /> <label for="vehicle_car">i have a car</label> </p> <p> describe yourself:<br /> <textarea name="description" cols="50" rows="8"></textarea> </p> <p> <input type="submit" value="submit" /> </p> </fieldset> </form> </body> </html> to test this, create a page named register.php (which is the action attribute of these sample forms), and put the following minimalistic content: <?php /* register.php */ header("content-type: text/plain"); /* note: you should never use `print_r()` in production scripts, or otherwise output client-submitted data without sanitizing it first.
OpenType font features guide - CSS: Cascading Style Sheets
discovering availability of features in fonts this is sometimes the trickiest thing to work out if you don't have any documentation that came with the fonts (many type designers and foundries will provide sample pages and css just for this very reason).
... note: these glyphs were copied out of a font sample and are not intended as prose.
Auto-placement in CSS Grid Layout - CSS: Cascading Style Sheets
fr)); grid-gap: 10px; grid-auto-flow: dense; list-style: none; margin: 1em auto; padding: 0; max-width: 800px; } .wrapper li { border: 1px solid #ccc; } .wrapper li.landscape { grid-column-end: span 2; } .wrapper li img { display: block; object-fit: cover; width: 100%; height: 100%; } <ul class="wrapper"> <li><img src="https://udn.realityripple.com/samples/72/ab41das78e.png" alt="placeholder"></li> <li class="landscape"><img src="https://udn.realityripple.com/samples/62/643f590dbc.png" alt="placeholder"></li> <li class="landscape"><img src="https://udn.realityripple.com/samples/62/643f590dbc.png" alt="placeholder"></li> <li class="landscape"><img src="https://udn.realityripple.com/samples/62/643f590dbc.png" alt="placeholder"></li> <li>...
...<img src="https://udn.realityripple.com/samples/72/ab41das78e.png" alt="placeholder"></li> <li><img src="https://udn.realityripple.com/samples/72/ab41das78e.png" alt="placeholder"></li> <li class="landscape"><img src="https://udn.realityripple.com/samples/62/643f590dbc.png" alt="placeholder"></li> <li><img src="https://udn.realityripple.com/samples/72/ab41das78e.png" alt="placeholder"></li> <li><img src="https://udn.realityripple.com/samples/72/ab41das78e.png" alt="placeholder"></li> <li><img src="https://udn.realityripple.com/samples/72/ab41das78e.png" alt="placeholder"></li> </ul> auto-placement can also help you lay out interface items which do have logical order.
Using CSS transforms - CSS: Cascading Style Sheets
<img style="transform: rotate(90deg); transform-origin: bottom left;" src="https://udn.realityripple.com/samples/6d/6633f3efc0.png"> skewing and translating here is the mdn logo, skewed by 10 degrees and translated by 150 pixels on the x-axis.
... <img style="transform: skewx(10deg) translatex(150px); transform-origin: bottom left;" src="https://udn.realityripple.com/samples/6d/6633f3efc0.png"> 3d specific css properties performing css transformations in 3d space is a bit more complex.
font - CSS: Cascading Style Sheets
WebCSSfont
*/ p { font: bold italic large serif } /* use the same font as the status bar of the window */ p { font: status-bar } live sample html <p> change the radio buttons below to see the generated shorthand and it's effect.
...t"> <input type="text" class="curcss" id="input_line_height"> <br/> line-height <br/> optional </div> <div class="propinputcont"> <input type="text" class="curcss mandatory" id="input_font_family"> <br/> font-family <br/> mandatory </div> </div> </form> <div class="fontshorthand"> this is some sample text.
mask-border - CSS: Cascading Style Sheets
div { width: 200px; background-color: lavender; border: 18px solid salmon; padding: 10px; /* prefixed longhand properties currently supported in chromium -webkit-mask-box-image-source: url(https://udn.realityripple.com/samples/2d/fd08a3134c.png); -webkit-mask-box-image-slice: 30 fill; -webkit-mask-box-image-width: 20px; -webkit-mask-box-image-repeat: round; -webkit-mask-box-image-outset: 1px; */ /* prefixed shorthand property currently supported in chromium */ -webkit-mask-box-image: url("https://udn.realityripple.com/samples/2d/fd08a3134c.png") /* source */ 30 fill / /* slice */ 20...
...px / /* width */ 1px /* outset */ round; /* repeat */ /* updated standard shorthand property, not supported anywhere yet */ mask-border: url("https://udn.realityripple.com/samples/2d/fd08a3134c.png") /* source */ 30 fill / /* slice */ 20px / /* width */ 1px /* outset */ round; /* repeat */ } result specifications specification status comment css masking module level 1the definition of 'mask-border' in that specification.
object-fit - CSS: Cascading Style Sheets
formal definition initial valuefillapplies toreplaced elementsinheritednocomputed valueas specifiedanimation typediscrete formal syntax fill | contain | cover | none | scale-down examples setting object-fit for an image html <section> <h2>object-fit: fill</h2> <img class="fill" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <img class="fill narrow" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <h2>object-fit: contain</h2> <img class="contain" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <img class="contain narrow" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <h2>object-f...
...it: cover</h2> <img class="cover" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <img class="cover narrow" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <h2>object-fit: none</h2> <img class="none" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <img class="none narrow" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <h2>object-fit: scale-down</h2> <img class="scale-down" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> <img class="scale-down narrow" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="mdn logo"> </section> css h2 { font-family: courier new, monospace; font-size: 1em; margin: 1em 0 0.3em;...
text-combine-upright - CSS: Cascading Style Sheets
html <p lang="ja" class="exampletext">平成20年4月16日に</p> css .exampletext { writing-mode: vertical-lr; text-combine-upright: digits 2; font: 36px serif; } results screenshotlive sample all the all value requires markup around every piece of horizontal text, but it is currently supported by more browsers than the digits value.
... html <p lang="zh-hant">民國<span class="num">105</span >年<span class="num">4</span >月<span class="num">29</span>日</p> css html { writing-mode: vertical-rl; font: 24px serif } .num { text-combine-upright: all } results screenshotlive sample specifications specification status comment css writing modes level 4the definition of 'text-combine-upright' in that specification.
Applying color to HTML elements using CSS - HTML: Hypertext Markup Language
here are some sample colors in hsl notation: table { border: 1px solid black; font: 16px "open sans", helvetica, arial, sans-serif; border-spacing: 0; border-collapse: collapse; } th, td { border: 1px solid black; padding:4px 6px; text-align: left; } th { background-color: hsl(0, 0%, 75%); } <table> <thead> <tr> <th scope="col">color in hsl notation</th> <th scope="col">example</th> <...
...we use a color picker tool to select a sample of the color we choose.
<input type="reset"> - HTML: Hypertext Markup Language
WebHTMLElementinputreset
a simple reset button we'll begin by creating a simple reset button: <form> <div> <label for="example">type in some sample text</label> <input id="example" type="text"> </div> <div> <input type="reset" value="reset the form"> </div> </form> this renders like so: try entering some text into the text field, and then pressing the reset button.
... <form> <div> <label for="example">type in some sample text</label> <input id="example" type="text"> </div> <div> <input type="reset" value="reset the form" accesskey="r"> </div> </form> the problem with the above example is that there's no way for the user to know what the access key is!
<track>: The Embed Text Track element - HTML: Hypertext Markup Language
WebHTMLElementtrack
lem = document.getelementbyid("texttrack"); texttrackelem.addeventlistener("cuechange", (event) => { let cues = event.target.track.activecues; }); in addition, you can use the oncuechange event handler: let texttrackelem = document.getelementbyid("texttrack"); texttrackelem.oncuechange = (event) => { let cues = event.target.track.activecues; }); examples <video controls poster="/images/sample.gif"> <source src="sample.mp4" type="video/mp4"> <source src="sample.ogv" type="video/ogv"> <track kind="captions" src="samplecaptions.vtt" srclang="en"> <track kind="descriptions" src="sampledescriptions.vtt" srclang="en"> <track kind="chapters" src="samplechapters.vtt" srclang="en"> <track kind="subtitles" src="samplesubtitles_de.vtt" srclang="de"> <track kind="subtitl...
...es" src="samplesubtitles_en.vtt" srclang="en"> <track kind="subtitles" src="samplesubtitles_ja.vtt" srclang="ja"> <track kind="subtitles" src="samplesubtitles_oz.vtt" srclang="oz"> <track kind="metadata" src="keystage1.vtt" srclang="en" label="key stage 1"> <track kind="metadata" src="keystage2.vtt" srclang="en" label="key stage 2"> <track kind="metadata" src="keystage3.vtt" srclang="en" label="key stage 3"> <!-- fallback --> ...
Content Security Policy (CSP) - HTTP
WebHTTPCSP
script-sample the first 40 characters of the inline script, event handler, or style that caused the violation.
... sample violation report let's consider a page located at http://example.com/signup.html.
Content-Security-Policy-Report-Only - HTTP
script-sample the first 40 characters of the inline script, event handler, or style that caused the violation.
... sample violation report let's consider a page located at http://example.com/signup.html.
Authoring MathML - MathML
see this github repository to get woff fonts and sample css stylesheets to use on your web site and check its test page.
... <div class="latex"> \documentclass[12pt]{article} \begin{document} \title{latexml example} \maketitle \begin{abstract} this is a sample latexml document.
<feGaussianBlur> - SVG: Scalable Vector Graphics
xample simple example svg <svg width="230" height="120" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <filter id="blurme"> <fegaussianblur in="sourcegraphic" stddeviation="5" /> </filter> <circle cx="60" cy="60" r="50" fill="green" /> <circle cx="170" cy="60" r="50" fill="green" filter="url(#blurme)" /> </svg> result screenshotlive sample drop shadow example svg <svg width="120" height="120" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <filter id="dropshadow"> <fegaussianblur in="sourcealpha" stddeviation="3" /> <feoffset dx="2" dy="4" /> <femerge> <femergenode /> <femergenode in="sourcegraphic" /> </femerge> </filter> <circle cx="60" cy="60" r="50" fi...
...ll="green" filter="url(#dropshadow)" /> </svg> result screenshotlive sample specifications specification status comment filter effects module level 1the definition of '<fegaussianblur>' in that specification.
Web technology for developers
code snippets this is a quick list of useful code snippets (small code samples) available for developers of extensions for the various mozilla applications.
... many of these samples can also be used in xulrunner applications, as well as in actual mozilla code itself.
Using the WebAssembly JavaScript API - WebAssembly
note: you can find the sample code in our webassembly-examples github repo.
... go back to your memory.html sample file, and fetch, compile, and instantiate your wasm module as before — add the following to the bottom of your script: webassembly.instantiatestreaming(fetch('memory.wasm'), { js: { mem: memory } }) .then(results => { // add code here }); since this module exports its memory, given an instance of this module called instance we can use an exported function accumulate() to create and p...
jpmignore - Archive of obsolete content
/sample/ a .jpmignore file with the above contents would ignore all zip files and .ds_store files and sample directory from the xpi generated by jpm xpi.
Getting started (cfx) - Archive of obsolete content
navigate to it, type cfx init, and hit enter: mkdir my-addon cd my-addon cfx init you'll see some output like this: * lib directory created * data directory created * test directory created * doc directory created * readme.md written * package.json written * test/test-main.js written * lib/main.js written * doc/main.md written your sample add-on is now ready for testing: try "cfx test" and then "cfx run".
Bootstrapped extensions - Archive of obsolete content
some code samples are provided.
Bookmarks - Archive of obsolete content
var thisuri = bmsvc.getbookmarkuri(newbkmkid); assuming you've run all the code samples previous to this one, this will output "http://google.com".
Dialogs and Prompts - Archive of obsolete content
refer to the interface documentation for documentation and sample code.
Downloading Files - Archive of obsolete content
downloading images sample function for fetching an image file from a url.
Miscellaneous - Archive of obsolete content
simulating mouse and key events https://developer.mozilla.org/samples/domref/dispatchevent.html also, new in firefox 3 / gecko 1.9: var utils = window.queryinterface(components.interfaces.nsiinterfacerequestor) .getinterface(components.interfaces.nsidomwindowutils); utils.sendmouseevent("mousedown", 10, 10, 0, 1, 0); utils.sendmouseevent("mouseup", 10, 10, 0, 1, 0); getting the currently selected text from browser.xul overlay context: var s...
Scrollbar - Archive of obsolete content
example xul window: <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="samplewindow" width="320" height="240" xmlns="http://www.mozilla.org/keymaster/gat...re.is.only.xul"> <hbox flex="1"> <browser type="content" src="http://mozilla.org" flex="1"/> <scrollbar orient="vertical"/> </hbox> </window> ...
URI parsing - Archive of obsolete content
so, here's some sample code to determine the base domain without any suffixes: var etldservice = components.classes["@mozilla.org/network/effective-tld-service;1"].
XPath - Archive of obsolete content
notes and sample code for xpath and ajax (the following was moved from document.evaluate) obj.evaluate(xpathexpression,contextnode,namespaceresolver,resulttype,result); //obj and contextnode should be the same object, if context is a ajax xml object (example: returnedxml) this should be used as : returnedxml.evaluate(xpathexpression,returnedxml,namespaceresolver,returntype,result); //contextnode should be used in the one in which it was created //add by mooring 2008-11-15 16:00 china var xhr = new ajax('post','demo.xml',parsexml,'xml'); //ajax is a class written by javascript which return responsexml object to parsexml function function parsexml(obj)//obj is the returnxml object now { if(!obj.documentelement) { alert("your browser does't support this script!"); return; ...
Communication between HTML and your extension - Archive of obsolete content
communication between an html page and and extension after building a sample extension by reading carefully and following the complete instructions for building an extension i was able to get an extension that could display something on the status bar.
Extension Versioning, Update and Compatibility - Archive of obsolete content
other tags aren't included in the result but do have their contents displayed, so the following snippet: <span><q>text</q></span> would be rendered exactly the same as: <q>text</q> sample file <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html lang="en-us" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <h2>my extension</h2> <ul> <li>this update fixes some stability related issues.</li> </ul> </html> what end-user sees the content of updateinfourl will be displayed to user in the add-ons page, in a list of all ...
Interaction between privileged and non-privileged pages - Archive of obsolete content
in the following code sample 2 methods are combined: setting an extra attribute in the original event target element, and creating a new event message with a new event target element.
Jetpack Processes - Archive of obsolete content
sample code for example code, check out the unit tests.
Listening to events in Firefox extensions - Archive of obsolete content
if you call javascript functions as part of the pageshow event, you can ensure these functions are called when the page is loaded in browsers other than firefox 1.5 by calling the pageshow event as part of the load event, as shown in the sample later in this article.
Chapter 6: Firefox extensions and XUL applications - Archive of obsolete content
listing 4: test_calc.js (adding sample test case) '2 1 -': function() { var calc = new rpncalc.rpncalc(); calc.init(); calc.push(2); calc.push(1); calc.minus(); assert.equals(calc.pop(), 1); }, listing 5: calc.js (implementing subtraction operation) minus: function() { this._letfunc(this._minus); }, _minus: function(a, b) { return a - b; }, listing 6: calc.js (correcting mistake in implementation of subtraction) ...
Chapter 2: Technologies used in developing extensions - Archive of obsolete content
listing 2: css code sample body { color: black; background-color: white; } p { margin-bottom: 1em; text-indent: 1em; } javascript: the world's most misunderstood language javascript is a scripting language first developed in the 1990s, at which time it was created as a way to add dynamic features to web pages.
Adding Toolbars and Toolbar Buttons - Archive of obsolete content
the toolbar code snippets page has a code sample you can use to do this.
Appendix A: Add-on Performance - Archive of obsolete content
look at the source samples in the article and notice how they mostly consist of nested if statements.
Getting Started with Firefox Extensions - Archive of obsolete content
the hello world extension our sample extensions and this tutorial in general are meant for modern versions of firefox, but most of it works on older versions too.
Handling Preferences - Archive of obsolete content
download this sample hello world using preferences.
Intercepting Page Loads - Archive of obsolete content
here's a code sample that keeps track of your progress listeners for all tabs: init : function() { gbrowser.browsers.foreach(function (browser) { this._toggleprogresslistener(browser.webprogress, true); }, this); gbrowser.tabcontainer.addeventlistener("tabopen", this, false); gbrowser.tabcontainer.addeventlistener("tabclose", this, false); }, uninit : function() { gbrowser.browsers.foreach(function (...
Introduction - Archive of obsolete content
in most cases we'll provide code samples that you can easily copy and adapt to your needs, as well as some working example extensions.
Overlay extensions - Archive of obsolete content
code snippets sample code for many of the things you'll want to do.
An Interview With Douglas Bowman of Wired News - Archive of obsolete content
i've been manually writing sample code for my own design prototypes for 4 or 5 years now.
XML data - Archive of obsolete content
you create a sample xml document, and a stylesheet that you can use to display it in your browser.
MMgc - Archive of obsolete content
sample stack trace: xmlclass.cpp:391 toplevel.cpp:164 toplevel.cpp:507 interpreter.cpp:1098 interpreter.cpp:20 methodenv.cpp:47 allocation traces, deletion traces etc.
MCD, Mission Control Desktop, AKA AutoConfig - Archive of obsolete content
my tests were on windows vista, and i noticed at least one difference, it is that paths changed; now the profile is in (for my procacci user sample): c:\users\procacci\appdata\roaming\thunderbird\profiles\v6we4uku.default start in debug mode in comand line interface: debug with displayerror() here's the result, i used the displayerror() method ( not the best way :-( see bug 206294 ) to show environment and ldap variables in order to check that it worked fine.
Source code directories overview - Archive of obsolete content
it shows how to embed the mozilla browser in a mac application as well as some sample file-handling code from apple.
Bonsai - Archive of obsolete content
checkins to any branch of xfe by ramiro between 26-feb-1998 and 12-may-1998 differences between revisions 3.1 and 3.3 of the file mozilla/cmd/xfe/forms.c that's a small sample, but it should be enough to get you started.
Editor Embedding Guide - Archive of obsolete content
cmd_samp toggles program output sample style on selection.
Monitoring downloads - Archive of obsolete content
download the full sample.
Mozilla Application Framework in Detail - Archive of obsolete content
sample component implementations you can extend and learn from.
Nanojit - Archive of obsolete content
-i ../nanojit -o jittest ../jittest.cpp libjs_static.a note: remove the -ddebug if you have not compiled spidermonkey with --enable-debug, and use whatever you called the sample source file in place of jittest.cpp.
Priority Content - Archive of obsolete content
note: use example at sample:original document information to credit original authors.
PyDOM - Archive of obsolete content
related topics pyxpcom: create and use xpcom components with python python-spidermonkey pydom samples: sample applications that use pydom pythonext: a firefox/xulrunner extension that can be used to install pydom ...
Abc Assembler Tests - Archive of obsolete content
sample abcasm test /* ***** begin license block ***** * version: mpl 1.1/gpl 2.0/lgpl 2.1 * * the contents of this file are subject to the mozilla public license version * 1.1 (the "license"); you may not use this file except in compliance with * the license.
Actionscript Acceptance Tests - Archive of obsolete content
below is a sample file that covers the 4 main us timezones: # place all timezones that this file applies to.
Tamarin build documentation - Archive of obsolete content
- run the android sdk/avd manager at /android-public/android-sdk-mac_86/tools/android and add android sdk platform-tools (to get adb), sdk platform android 2.3.3, and api 10 (samples and docs are optional).
Treehydra Manual - Archive of obsolete content
there is a sample application that checks for double-locking in a simple mutex api in test/esp_lock.js.
Anonymous Content - Archive of obsolete content
a sample xbl binding for the file widget might look as follows: <binding id="fileupload"> <content> <html:input type="text"/> <html:input type="button"/> </content> </binding> because this content is not visible to its parent element, it is said to be anonymous content.
Example Sticky Notes - Archive of obsolete content
fax - respond today.</p></div> <div class="sticker"><p>don't forget the eggs!</p></div> <div class="sticker"><p>the new project - who's on charge?</p></div> <div class="sticker"><p>learn more about xbl.</p></div> <p style="clear: left"><a href="http://validator.w3.org/check?uri=referer"><img src="https://udn.realityripple.com/samples/e2/dd625ef1cd.png" width="88" height="31" alt="valid html 4.01" style="border: 1px none"></a></p> </body> </html> notes.xml <?xml version="1.0"?> <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- in above only xbl namespace ...
Creating XPI Installer Modules - Archive of obsolete content
chrome/ us/ us.jar chatzilla/ chatzilla.jar chrome.rdf chromelist.txt classic/ classic.jar comm/ comm.jar content-packs/ content-packs.jar embed-sample/ embed-sample.jar en-us/ en-us.jar en-mac/ en-mac.jar en-unix/ en-unix.jar en-win/ en-win.jar help/ help.jar inspector/ inspector.jar installed-chrome.txt messenger/ messenger.jar ...
Examples - Archive of obsolete content
the following samples demonstrate some of the principal installation functions in the xpinstall api: file.macalias file.windowsshortcut [install.]adddirectory [install.]addfile installtrigger.installchrome installtrigger.startsoftwareupdate windows install example ...
exists - Archive of obsolete content
example f = getfolder( "program", "sample.txt" ); if ( file.exists(f) ) // do something with the file ...
isFile - Archive of obsolete content
example f = getfolder( "program", "sample.txt" ); if ( file.isfile(f) ) // the object represents a file ...
XPInstall API reference - Archive of obsolete content
deletevalue enumkeys enumvaluenames getvalue getvaluenumber getvaluestring iskeywritable keyexists setrootkey setvalue setvaluenumber setvaluestring valueexists winregvalue constructor other information return codes see complete list examples trigger scripts and install scripts code samples file.macalias file.windowsshortcut install.adddirectory install.addfile installtrigger.installchrome installtrigger.startsoftwareupdate windows install ...
Index - Archive of obsolete content
ArchiveMozillaXULIndex
(for seamonkey 1.x, see the page custom toolbar button:seamonkey.) 958 code samples add-ons, extensions this page contains sample code that you can use with the custom toolbar button tutorial.
Introduction to XUL - Archive of obsolete content
an example window below is a complete sample xul document that describes a window with a menu bar and an html content area.
ContextMenus - Archive of obsolete content
for example: <vbox context="_child"> <label value="hello"/> <menupopup> <menuitem label="cut"/> <menuitem label="copy"/> <menuitem label="paste"/> </menupopup> </vbox> in this sample, the context menu is found as the child of the vbox, because the context attribute is set to '_child'.
MenuItems - Archive of obsolete content
for instance, in the sample below, the delete command is disabled using the disabled attribute.
Providing Command-Line Options - Archive of obsolete content
using the example to use this sample code, save the commandline.js file into the components directory and add the following lines to your chrome.manifest file: component {2991c315-b871-42cd-b33f-bfee4fcbf682} components/commandline.js contract @mozilla.org/commandlinehandler/general-startup;1?type=myapp {2991c315-b871-42cd-b33f-bfee4fcbf682} category command-line-handler m-myapp @mozilla.org/commandlinehandler/general-startup;1?typ...
RDF Query Syntax - Archive of obsolete content
<vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a"> <template> <query> <content uri="?start"/> <triple subject="?start" predicate="http://www.xulplanet.com/rdf/relateditem" object="?relateditem"/> </query> <rule> ...
Recursive Generation - Archive of obsolete content
here is the content that was generated after one iteration: <vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a"> <template> <query> <content uri="?start"/> <triple subject="?start" predicate="http://www.xulplanet.com/rdf/relateditem" object="?relateditem"/> </query> <action> <hbox uri="?relateditem"> <button label="?start"/> <button label="?relateditem"/> </hbox> </action> ...
Result Generation - Archive of obsolete content
here is an example: <vbox datasources="http://www.xulplanet.com/ds/sample.rdf" ref="http://www.xulplanet.com/rdf/a" flex="1"> this is an indicator that we want to construct a xul template using the reference point with the uri 'http://www.xulplanet.com/rdf/a'.
Sorting Results - Archive of obsolete content
here is a sample of how to specify this in the rdf/xml datasource: <rdf:rdf xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:r="http://www.xulplanet.com/rdf/" xmlns:nc="http://home.netscape.com/nc-rdf#"> <rdf:description rdf:about="http://www.xulplanet.com/ndeakin/images/t/palace.jpg"> <r:date nc:parsetype="date">1125966767295<r...
Complete - Archive of obsolete content
it is just an extended code sample.
Toolbars - Archive of obsolete content
custom toolbar button another example of how to create a toolbar button, complete with a sample extension you can download and try.
Manifest Files - Archive of obsolete content
the packagename in the example above is 'tests', which means that the first field in the chrome url is 'tests' as in chrome://tests/content/sample.xul.
More Menu Features - Archive of obsolete content
the example below creates a simple submenu inside the file menu example 1 : source view <toolbox flex="1"> <menubar id="sample-menubar"> <menu id="file-menu" label="file"> <menupopup id="file-popup"> <menu id="new-menu" label="new"> <menupopup id="new-popup"> <menuitem label="window"/> <menuitem label="message"/> </menupopup> </menu> <menuitem label="open"/> <menuitem label="save"/> <menuseparator/> <menuitem label="exit...
Popup Menus - Archive of obsolete content
the sample below shows how we might do this: example 1 : source view <popupset> <menupopup id="clipmenu"> <menuitem label="cut"/> <menuitem label="copy"/> <menuitem label="paste"/> </menupopup> </popupset> <box context="clipmenu"> <label value="context click for menu"/> </box> here, the menupopup has been associated with a box.
Simple Menu Bars - Archive of obsolete content
example of a simple menu bar example 1 : source view <toolbox flex="1"> <menubar id="sample-menubar"> <menu id="file-menu" label="file"> <menupopup id="file-popup"> <menuitem label="new"/> <menuitem label="open"/> <menuitem label="save"/> <menuseparator/> <menuitem label="exit"/> </menupopup> </menu> <menu id="edit-menu" label="edit"> <menupopup id="edit-popup"> <menuitem label="undo"/> <menuitem label...
Trees and Templates - Archive of obsolete content
the following example shows a sample column: <treecol id="date" label="date" flex="1" persist="width ordinal hidden sortactive sortdirection" sort="rdf:http://home.netscape.com/web-rdf#lastmodifieddate"/> more details about the persist attribute will be described in the later section.
XUL Questions and Answers - Archive of obsolete content
using the following code sample, // get browsers object var browsers=document.getelementbyid('content').browsers; var numbrowsers=browsers.length; for (var i=0; numbrowsers>i; i++) { var thisuri=browsers[i].currenturi.spec; // do something with it.
XUL Template Primer - Bindings - Archive of obsolete content
for example, the sample in this document wouldn't work if the two <binding> elements were reversed, because of the dependency on the ?addr variable.
keyset - Archive of obsolete content
attributes disabled examples <keyset> <key id="sample-key" modifiers="shift" key="r"/> </keyset> attributes inherited from xul element align, allowevents, allownegativeassertions, class, coalesceduplicatearcs, collapsed, container, containment, context, contextmenu, datasources, dir, empty, equalsize, flags, flex, height, hidden, id, insertafter, insertbefore, left, maxheight, maxwidth, menu, minheight, minwidth, mousethrough, observes, ordinal, orient, pack, persist, popup, position, preference-editable, querytype, ref, removeelement, sortdir...
menu - Archive of obsolete content
ArchiveMozillaXULmenu
, command, crop, disabled, image, label, menuactive, open, sizetopopup, tabindex, value properties accessibletype, accesskey, command, control, crop, disabled, image, itemcount, label, labelelement, menupopup, open, parentcontainer, selected, tabindex, value methods appenditem, getindexofitem, getitematindex, insertitemat, removeitemat style classes menu-iconic example <menubar id="sample-menubar"> <menu id="file-menu" label="file"> <menupopup id="file-popup"> <menuitem label="new"/> <menuitem label="open"/> <menuitem label="save"/> <menuseparator/> <menuitem label="exit"/> </menupopup> </menu> <menu id="edit-menu" label="edit"> <menupopup id="edit-popup"> <menuitem label="undo"/> <menuitem label="redo"/> </menupopup>...
menubar - Archive of obsolete content
attributes grippyhidden, statusbar properties accessibletype, statusbar examples <menubar id="sample-menubar"> <menu id="action-menu" label="action"> <menupopup id="action-popup"> <menuitem label="new"/> <menuitem label="save" disabled="true"/> <menuitem label="close"/> <menuseparator/> <menuitem label="quit"/> </menupopup> </menu> <menu id="edit-menu" label="edit"> <menupopup id="edit-popup"> <menuitem label="undo"/> <menuitem label="r...
toolbaritem - Archive of obsolete content
examples <toolbaritem> <menulist label="bus"> <menupopup> <menuitem label="car"/> <menuitem label="taxi"/> <menuitem label="bus" selected="true"/> <menuitem label="train"/> </menupopup> </menulist> </toolbaritem> <toolbaritem id="sample-toolbutton-unified"> <toolbarbutton id="myext-button1" class="toolbarbutton-1" label="label1" /> <toolbarbutton id="myext-button2" class="toolbarbutton-1" label="labe2l" /> </toolbaritem> attributes inherited from xul element align, allowevents, allownegativeassertions, class, coalesceduplicatearcs, collapsed, container, containment, context, contextmenu, datasources, ...
XULRunner 1.8.0.1 Release Notes - Archive of obsolete content
sample applications are available from the mozilla developer center.
XULRunner 1.8.0.4 Release Notes - Archive of obsolete content
sample applications are available from the mozilla developer center.
XULRunner 1.9.1 Release Notes - Archive of obsolete content
sample applications are available from the mozilla developer center.
XULRunner 1.9.2 Release Notes - Archive of obsolete content
sample applications are available from the mozilla developer center.
XULRunner 1.9 Release Notes - Archive of obsolete content
sample applications are available from the mozilla developer center.
XULRunner 2.0 Release Notes - Archive of obsolete content
sample applications are available from the mozilla developer center.
Building XULRunner with Python - Archive of obsolete content
sample a sample xulrunner application with these python features is available.
Creating XULRunner Apps with the Mozilla Build System - Archive of obsolete content
here's a sample .mozconfig for building xulrunner and mccoy: # options for client.mk.
Creating a Windows Inno Setup installer for XULRunner applications - Archive of obsolete content
my app's .iss file sample as follows: ; script generated by the inno setup script wizard.
XUL Application Packaging - Archive of obsolete content
a sample application.ini file can be found in the mozilla source tree.
Gecko Compatibility Handbook - Archive of obsolete content
the toolbox aggregates several invaluable w3c tools for diagnosing web page problems as well as validators, code samples, and more.
Mozilla release FAQ - Archive of obsolete content
the first 3 tarballs had a simple sample logo, whereas the current source includes an icon from the community that won a contest.
2006-11-10 - Archive of obsolete content
guenter has provided some sample code using the 'mailto:' method.
Extentsions FAQ - Archive of obsolete content
siwebnavigation) .queryinterface(ci.nsidocshelltreeitem) .roottreeitem .queryinterface(ci.nsiinterfacerequestor) .getinterface(ci.nsidomwindow) .queryinterface(ci.nsidomchromewindow); var sidebar = toplevelwindow.document.getelementbyid("sidebar"); alert(sidebar.contentdocument); is there anyone successfully using dojo in a firefox extension and where to fine sample codes?
2006-12-01 - Archive of obsolete content
three replacement groups (with sample makeup) are proposed.
2006-09-30 - Archive of obsolete content
developers should use this sample instead: http://developer.mozilla.org/en/docs/xpcom_glue discussions dynamic load overlay a short discussion about the possibilities of loading and unloading xul overlay runtime reading binary data from file discusses about the code to read binary data from file how to build xpcom component on mac os x discusses about the make file code used to build xpcom components on mac os x successfully meetings none during this week.
NP_GetMIMEDescription - Archive of obsolete content
one mime type // example inside http://mxr.mozilla.org/mozilla-central/source/modules/plugin/sdk/samples/basic/unix/plugin.cpp #define mime_type_description "application/basic-plugin:bsp:basic example plug-in for mozilla" const char* np_getmimedescription(void) { return(mime_types_description); } two mime types const char* np_getmimedescription(void) { return "application/basic-example-plugin:xmp1:example 1;application/basic-example2-plugin:xmp2, xm2p:example 2"; } gnome integration if you ...
Adobe Flash - Archive of obsolete content
a complete code listing which expands on the above approach can be found in the flashversion.js file used in the samples.
XEmbed Extension for Mozilla Plugins - Archive of obsolete content
xembed sample plugin for a complete working sample of a plugin using in-process xembed, see the diamondx xembed example plugin.
Plugins - Archive of obsolete content
plugins: samples and test cases npapi plugin samples and test cases.
Developing cross-browser and cross-platform pages - Archive of obsolete content
// bad sample if (navigator.appversion.charat(0) == "8") { if (navigator.appname == "netscape") { isns8 = true; alert("netscape 8"); }; } else if (navigator.appversion.indexof("msie") != -1) { isie = true; alert("internet explorer"); }; while this kind of checking in the above code can work in a crude sense, sharp readers may wonder what happens when internet explorer 8 is released or when an ...
Using the W3C DOM - Archive of obsolete content
for example, the following short sample dynamically sets the left margin of a <div> element with an id of "inset" to half an inch: // in the html: <div id="inset">sample text</div> document.getelementbyid("inset").style.marginleft = ".5in"; note: internet explorer 5 through 7 have a flawed implementation of getelementbyid(), which returns the first element with a matching name or id (id versus name when using getelementbyid, msdn: g...
Using workers in extensions - Archive of obsolete content
if you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series: creating a status bar extension creating a dynamic status bar extension adding preferences to an extension localizing an extension updating an extension to support multiple mozilla applications download the sample you may download the complete example: download the example.
-ms-scroll-chaining - Archive of obsolete content
for more information, see html scrolling, panning and zooming sample or internet explorer 10 scrolling, panning, and zooming with touch.
-ms-scrollbar-3dlight-color - Archive of obsolete content
code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/scrollbarcolor.htm <!doctype html> <html> <head> <title>scrollbar-3dlight-color</title> <style> .blue3dlight { -ms-scrollbar-3dlight-color: blue; scrollbar-3dlight-color: blue; /* use the standard when available.
-ms-scrollbar-darkshadow-color - Archive of obsolete content
code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/scrollbarcolor.htm <!doctype html> <html> <head> <title>scrollbar-darkshadow-color</title> <style> .blueshadow { scrollbar-darkshadow-color: blue; } </style> </head> <body> <textarea class="blueshadow">the gutter elements in the scroll bar for this element will be blue.</textarea> </body> </html> specifications n...
::-ms-check - Archive of obsolete content
screenshotlive sample specifications not part of any specification.
RDF in Mozilla FAQ - Archive of obsolete content
</window> assuming that we've aquired a datasource somehow (e.g., like this), the following sample code illustrates how to add that datasource to the template, and then force the template to rebuild itself based on the newly added datasource's contents.
Using the Right Markup to Invoke Plugins - Archive of obsolete content
here is a sample: <applet code="nervoustext.class" width="534" height="50"> <param name="text" value="java(tm) 2 sdk, standard edition v1.4" /> </applet> the applet element has been deprecated in the html 4.01 specification, but an advantage to using it is that in mozilla-based browsers such as netscape 7, if you are missing java, an automatic obtainment mechanism is in place.
Crisp pixel art look with image-rendering - Game development
edges; image-rendering: pixelated; image-rendering: crisp-edges; } and some javascript to set up the canvas and load the image: // get canvas context var ctx = document.getelementbyid('game').getcontext('2d'); // load image var image = new image(); image.onload = function () { // draw the image into the canvas ctx.drawimage(image, 0, 0); } image.src = 'https://udn.realityripple.com/samples/11/a2954fe197.png'; this code used together produces the following result: note: you can check out the original code on github (and a live example.) ...
2D breakout game using pure JavaScript - Game development
every step has editable, live samples available to play with so you can see what the intermediate stages should look like.
2D breakout game using Phaser - Game development
every step has editable, live samples available to play with, so you can see what the intermediate stages should look like.
Index - MDN Web Docs Glossary: Definitions of Web-related terms
when used in conjunction with xpointer (firefox supports a subset of it, and is used in the code sample below), xinclude can also target just specific portions of a document for inclusion.
Styling tables - Learn web development
to start with, make a local copy of the sample markup, download both images (noise and leopardskin), and put the three resulting files in a working directory somewhere on your local computer.
Legacy layout methods - Learn web development
start out by making a local copy of our sample simple-grid.html file, which contains the following markup in its body.
Normal Flow - Learn web development
overflowing inline elements will <span>wrap onto a new line if possible (like this one containing text)</span>, or just go on to a new line if not, much like this image will do: <img src="https://udn.realityripple.com/samples/9e/6ff6af6fd4.jpg"></p> body { width: 500px; margin: 0 auto; } p { background: rgba(255,84,104,0.3); border: 2px solid rgb(255,84,104); padding: 10px; margin: 10px; } span { background: white; border: 1px solid black; } summary now that you understand normal flow, and how the browser lays things out by default, move on to understand how to change this default display to c...
Practical positioning examples - Learn web development
each panel contains some sample content.
Styling links - Learn web development
; font-family: sans-serif; } p { line-height: 1.4; } a { outline: none; text-decoration: none; padding: 2px 1px 0; } a:link { color: #265301; } a:visited { color: #437a16; } a:focus { border-bottom: 1px solid; background: #bae498; } a:hover { border-bottom: 1px solid; background: #cdfeaa; } a:active { background: #265301; color: #cdfeaa; } we'll also provide some sample html to apply the css to: <p>there are several browsers available, such as <a href="#">mozilla firefox</a>, <a href="#">google chrome</a>, and <a href="#">microsoft edge</a>.</p> putting the two together gives us this result: so what did we do here?
Sending forms through JavaScript - Learn web development
using this object is detailed in using formdata objects, but here are two examples: using a standalone formdata object <button>click me!</button> you should be familiar with that html sample.
HTML basics - Learn web development
paragraphs as explained above, <p> elements are for containing paragraphs of text; you'll use these frequently when marking up regular text content: <p>this is a single paragraph</p> add your sample text (you should have it from what should your website look like?) into one or a few paragraphs, placed directly below your <img> element.
JavaScript basics - Learn web development
these include: browser application programming interfaces (apis) built into web browsers, providing functionality such as dynamically creating html and setting css styles; collecting and manipulating a video stream from a user's webcam, or generating 3d graphics and audio samples.
Publishing your website - Learn web development
this article explains how to get your simple sample code online with little effort.
Getting started with the Web - Learn web development
publishing your sample code describes how to get your simple sample code online with minimum effort.
Creating hyperlinks - Learn web development
here are a few other sample mailto urls: mailto: mailto:nowhere@mozilla.org mailto:nowhere@mozilla.org,nobody@mozilla.org mailto:nowhere@mozilla.org?cc=nobody@mozilla.org mailto:nowhere@mozilla.org?cc=nobody@mozilla.org&subject=this%20is%20the%20subject test your skills!
Adding vector graphics to the Web - Learn web development
in the input section below you'll see that we've already provided you with some samples to get you started.
Graceful asynchronous programming with Promises - Learn web development
first of all, download our simple html template and the sample image file that we'll fetch.
Drawing graphics - Learn web development
in this case you'll also need to save a copy of our sample image — firefox.png — in the same directory.
Fetching data from the server - Learn web development
we have created a sample site called the can store — it's a fictional supermarket that only sells canned goods.
Storing the information you need — Variables - Learn web development
if you are using a desktop browser, the best place to type your sample code is your browser's javascript console (see what are browser developer tools for more information on how to access this tool).
Test your skills: JSON - Learn web development
json data about some mother cats and their kittens is available in sample.json.
Properly configuring server MIME types - Learn web development
if you're using the apache web server, simply copy this sample .htaccess file to the directory that contains the files that you want to send with the correct mime types.
Introduction to client-side frameworks - Learn web development
if you want to see code samples from this section in action, you can check out a working version of the app on codepen, which also allows users to add and delete new tasks.
Accessibility in React - Learn web development
note: if you need to check your code against our version, you can find a finished version of the sample react app code in our todo-react repository.
Beginning our React todo list - Learn web development
note: if you need to check your code against our version, you can find a finished version of the sample react app code in our todo-react repository.
Getting started with Svelte - Learn web development
then we will learn how to setup our development environment, create a sample app, understand the structure of the project, and see how to run it locally and build it for production.
Creating our first Vue component - Learn web development
note: if you need to check your code against our version, you can find a finished version of the sample vue app code in our todo-vue repository.
Adding a new todo form: Vue events, methods, and models - Learn web development
previous overview: client-side javascript frameworks next we now have sample data in place, and a loop that takes each bit of data and renders it inside a todoitem in our app.
Focus management with Vue refs - Learn web development
note: if you need to check your code against our version, you can find a finished version of the sample vue app code in our todo-vue repository.
Styling Vue components with CSS - Learn web development
summary our work is done on the styling of our sample app.
Introduction to automated testing - Learn web development
next, you'll need some sample html, css and javascript content to test your system on — make copies of our sample index.html, main.js, and style.css files in a subfolder with the name src inside your project folder.
Handling common HTML and CSS problems - Learn web development
now download mootools and selectivizr, and save them in the same directory as your sample html.
Handling common JavaScript problems - Learn web development
the service worker api is also very complex to use, so code libraries have started appearing to make common service worker uses-cases much easier to implement (see the service worker cookbook for several useful code samples).
Setting up your own test automation environment - Learn web development
note: saucelabs-sample-test-frameworks contains several useful examples showing how to set up different combinations of test/assertion tools.
Package management basics - Learn web development
our next move is to build up a sample toolchain, putting all that we've learnt so far into practice.
Gecko info for Windows accessibility vendors
if you seriously need to understand msaa, you'll need to read the docs on msdn and play with the sample apps and code that come with msaa sdk 1.3.
Lightweight themes
view a sample theme header here.
A bird's-eye view of the Mozilla framework
the code samples in the article are based on mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9a1) gecko/20051104 seamonkey/1.1a from a new source tree checked out 11/04/05.
Creating a Firefox sidebar
a sample extension to add a web panel is available as a starter.obsolete since gecko 57 if you'd like to have a deeper integration with the browser to offer more complex features, a traditional overlay extension can be an option.
Debugging
debugging a hang on os x collecting "samples" to attach to a bug.
Gecko Logging
example usage code sample #include "mozilla/logging.h" using mozilla::loglevel; static mozilla::lazylogmodule slogger("example_logger"); static void dostuff() { moz_log(slogger, loglevel::info, ("doing stuff.")); int i = 0; int start = time::nowms(); moz_log(slogger, loglevel::debug, ("starting loop.")); while (i++ < 10) { moz_log(slogger, loglevel::verbose, ("i = %d", i)); } // only calculate the ...
Commenting IDL for better documentation
example this is an example of what the sample interface document idl would look like: /** * @brief a make-believe interface that eats and enjoys cookies.
Contributing to the Mozilla code base
r?jsample` mozilla in most of the projects uses phabricator for code review.
Developer guide
code snippets useful code samples for a wide variety of things you might need to figure out how to do.
Storage access policy: Block cookies from trackers
in the sample image below, trackertest.org is classified as a tracking resource, while the request to example.com is not.
Using the Browser API
MozillaGeckoChromeAPIBrowser APIUsing
this is implemented in our sample app with the following functions: browser.addeventlistener('mozbrowserloadstart',function() { stopreload.textcontent = 'x'; }); browser.addeventlistener('mozbrowserloadend',function(e) { canmovebwd(); canmovefwd(); stopreload.textcontent = 'r'; console.log(e.detail.backgroundcolor); controls.style.background = e.detail.backgroundcolor; }); when the mozbrowserloadstart event fires, ...
MozBeforePaint
the timestamp property of this event will be set to the time when the animation frame is sampled; this is relevant when trying to synchronize mozrequestanimationframe animations with smil animations or css transitions.
Embedding Tips
it is left as an exercise to make this sample synchronous, i.e.
HTML parser threading
unlike nshtml5treeopexecutor::runflushloop(), nshtml5treeopexecutor::flushdocumentwrite() does not sample the clock to return early.
How to Report a Hung Firefox
aces.nsixulruntime).processtype != components.interfaces.nsixulruntime.process_type_default) {components.utils.import("resource://gre/modules/ctypes.jsm");var zero = new ctypes.intptr_t(8);var badptr = ctypes.cast(zero, ctypes.pointertype(ctypes.int32_t));var crash = badptr.contents;}', true); } other techniques on os x if you use a nightly build (>= firefox 16), you can use activity monitor's "sample process" feature to generate a sample.
Implementing QueryInterface
some alternatives the ns_impl_query_interface[012] macros the sample above implements two xpcom interfaces in addition to nsisupports.
Localizing with Mozilla Translator
from cvs to mercurial in mt so, you have a firefox product in mt with a platform neutral and, inside it, several directories (''components'' in mt terminology) more or less like the second sample above, checked out from cvs.
Basics
there are links to more samples, screenshots and instructions on how to download fonts for various platforms.
Extras
i> </mrow> <mrow> <mi title="natural log">ln</mi> <mo>&applyfunction;</mo> <mi>a</mi> </mrow> </mfrac> </mrow> </math> </p> css content math.cue *[title] { color: blue; } mixing with other markups html content <math display="block"> <mrow> <mi>a</mi> <mo>=</mo> <mo>[</mo> <mtable> <mtr> <mtd><mn>1</mn></mtd> <mtd> <mtext> <img width="16" height="16" src="https://udn.realityripple.com/samples/3f/9341cbddc0.png" alt="mozilla-16" /> </mtext> </mtd> </mtr> <mtr> <mtd> <mtext><input value="type" size="4"/></mtext> </mtd> <mtd><mn>4</mn></mtd> </mtr> </mtable> <mo>]</mo> </mrow> </math> <math display="block"> <msqrt> <mpadded width="30px" height="15px" depth="15px" voffset="-15px"> <mtext> <svg width="30px" height="30px"> <defs> <radialgradient id="radgrad1" cx="50%" cy="50%" r="50%" ...
MathML3Testsuite
note that in general, comparing with the "sample rendering" is not enough to conclude on the success/failure of the test.
Mozilla MathML Project
mathml in mozilla developer network mathml accessibility in mozilla sample mathml documents screenshots mathml start page - with translations in different languages ( arabic, chinese, hebrew, thai) mathml basics - document tailored to display correctly with just the symbol font that is pre-installed by default on most os configurations.
Mozilla projects on GitHub
mdn code samples for the mdn web site.
Intel Power Gadget
unfortunately, the gecko profiler takes 1000 samples per second on desktop and is cpu intensive and so is likely to skew the rapl estimates significantly, so the api integration was removed.
Reporting a Performance Problem
the profiler uses a fixed size buffer to store sample data.
Performance
memory profiler the memory profiler samples allocation events and provides different views to analyze the allocation characteristic.
Productization guide
for example, putting one sample news feed on the bookmarks toolbar in new profiles in firefox helps in learning about the live bookmarks.
I/O Functions
for sample code that illustrates basic i/o operations, see introduction to nspr.
I/O Types
for sample code that illustrates basic i/o operations, see introduction to nspr.
Interval Timing
in almost all cases the epoch is defined as the value of the interval timer at the time it was sampled.
Logging
g at execution time: nspr_log_modules nspr_log_file logging functions and macros the functions and macros for logging are: pr_newlogmodule pr_setlogfile pr_setlogbuffering pr_logprint pr_logflush pr_log_test pr_log pr_assert pr_assert pr_static_assert (new in nspr 4.6.6xxx this hasn't been released yet; the number is a logical guess) pr_not_reached use example the following sample code fragment demonstrates use of the logging and debugging aids.
Threads
for an overview of the nspr threading model and sample code that illustrates its use, see introduction to nspr.
NSPR API Reference
introduction to nspr nspr naming conventions nspr threads thread scheduling setting thread priorities preempting threads interrupting threads nspr thread synchronization locks and monitors condition variables nspr sample code nspr types calling convention types algebraic types 8-, 16-, and 32-bit integer types signed integers unsigned integers 64-bit integer types floating-point integer type native os integer types miscellaneous types size type pointer difference types boolean types status type for return values threads threading types and constants threading functions creating, joining, and identifying threads controlling thread priorities control...
Function_Name
syntax #include <headers.h> returntype function_name( paramtype paramname, paramtype paramname, ); parameters paramname sample: in pointer to a certcertdbhandle representing the certificate database to look in paramname sample: in pointer to an secitem whose type must be sidercertbuffer and whose data contains a der-encoded certificate description long description of this function, what it does, and why you would use it.
NSS FAQ
MozillaProjectsNSSFAQ
nss includes detailed documentation of the ssl api and sample code that demonstrates basic ssl functionality (setting up an encrypted session, server authentication, and client authentication) to help jump start the integration process.
NSS_3.12.1_release_notes.html
bug 311432: ecc's ecl_use_fp code (for linux x86) fails pairwise consistency test bug 330622: certutil's usage messages incorrectly document certain options bug 330628: coreconf/linux.mk should _not_ default to x86 but result in an error if host is not recognized bug 359302: remove the sslsample code from nss source tree bug 372241: need more versatile form of cert_nametoascii bug 390296: nss ignores subject cn even when san contains no dnsname bug 401928: support generalized pkcs#5 v2 pbes bug 403543: pkix: need a way to enable/disable aia cert fetching bug 408847: pkix_ocspchecker_check does not support specified responder (and given signercert) bug 414003: crash [[@ cert_d...
NSS_3.12_release_notes.html
type bug 339906: sec_pkcs12_install_bags passes uninitialized variables to functions bug 396484: certutil doesn't truncate existing temporary files when writing them bug 251594: certificate from pkcs#12 file with colon in friendlyname not selectable for signing/encryption bug 321584: nss pkcs12 decoder fails to import bags without nicknames bug 332633: remove duplicate header files in nss/cmd/sslsample bug 335019: pk12util takes friendly name from key, not cert bug 339173: mem leak whenever secmod_handle_string_arg called in loop bug 353904: klocwork null ptr deref in secasn1d.c bug 366390: correct misleading function names in fipstest bug 370536: memory leaks in pointer tracker code in debug builds only bug 372242: cert_comparerdn uses incorrect algorithm bug 379753: s/mime should support aes ...
Overview of NSS
nss comes with an extensive and growing set of documentation, including introductory material, api references, man pages for command-line tools, and sample code.
PKCS #11 Module Specs
sample file: library= name="netscape internal crypto module" parameters="configdir=/u/relyea/.netscape certprefix= secmod=secmod.db" nss="flags=internal,pkcs11module trustorder=1 cipherorder=-1 ciphers= slotparams={0x1=[slotflags='rsa,dsa,dh,rc4,rc2,des,md2,md5,sha1,ssl,tls,publiccerts,random'] 0x2=[slotflags='rsa' askpw=only]}" library=dkck32.dll name="datakey signasure 3600" nss="trustorder=50 ciph...
NSS PKCS11 Functions
see also for examples of password callback functions, see the samples in the samples directory.
Building and installing NSS
build instructions installation guide sample manual installation ...
NSS tools : modutil
sample script for example, the pkcs #11 installer script could be in the file pk11install.
pkfnc.html
see also for examples of password callback functions, see the samples in the samples directory.
sslfnc.html
see also for examples of certificate authentication callback functions, see the sample code referenced from chapter 2, "getting started with ssl." ssl_authcertificate default callback function used to authenticate certificates received from the remote end of an ssl connection if the application has not previously called ssl_authcertificatehook to specify its own certificate authentication callback function.
sslintro.html
chapter 2, "getting started with ssl" illustrates their use in sample client and server applications.
NSS tools : modutil
MozillaProjectsNSStoolsmodutil
sample script for example, the pkcs #11 installer script could be in the file pk11install.
Network Security Services
sample code demonstrates how nss can be used for cryptographic operations, certificate handling, ssl, etc.
Pork
old pork page pork details that haven't been moved to mdc renaming with pork sample pork application todos pork 1.0 release tracking bug pork releases download pork here community view pork forums...
FOSS
designed to supplement existing embeddings, gpsee ships with a sample trivial embedding, a scripting host, and an augmented version of mozilla's js shell.
Hacking Tips
reproduced here: // sample usage from gdb: // // (gdb) p $word = js::debug::getmarkwordaddress(obj) // $1 = (uintptr_t *) 0x7fa56d5fe360 // (gdb) p/x $mask = js::debug::getmarkmask(obj, js::gc::gray) // $2 = 0x200000000 // (gdb) watch *$word // hardware watchpoint 7: *$word // (gdb) cond 7 *$word & $mask // (gdb) cont // // note that this is *not* a watchpoint on a single bit.
Index
for sample code that creates and initializes a jscontext, see jsapi user guide.
JSRuntime
sample code to set up and tear down a jsruntime and a jscontext is at jsapi user guide.
JS_NewContext
for sample code that creates and initializes a jscontext, see jsapi user guide.
JS_SetGlobalObject
see the sample code at jsapi user guide.
JS_malloc
js_realloc code sample realloc is famously tricky to use correctly.
Profiling SpiderMonkey
here's a sample mozconfig: mk_add_options moz_objdir=@topsrcdir@/ff-opt-libxul mk_add_options moz_make_flags=-j3 ac_add_options --enable-optimize ac_add_options --enable-libxul ac_add_options --enable-shark ac_add_options --enable-debugger-info-modules ac_add_options --enable-application=browser 2.) you'll want to run shark on both the browser and [xpcshell], since the host environments differ.
XForms Accessibility
you can try the following link to test xforms accessibility: visual xforms elements in xhtml document at bugzilla.mozilla.org visual xforms elements in xul document at bugzilla.mozilla.org you can see xforms sample tests at mozilla xforms project there are set of tests at beaufour.dk w3c's xforms test at w3.org keyboard navigation issues navigation sequence though xforms spec declares navindex attribute to define the navigation sequence (see 1.0 specs or 1.1 specs) but rich schwerdtfeger (distinguished engineer, swg accessibility architect/strategist chair, ibm accessibility architecture review board)...
Manipulating bookmarks using Places
var thisuri = bmsvc.getbookmarkuri(newbkmkid); assuming you've run all the code samples previous to this one, this will output "http://google.com".
XML Extras
with older builds, passing strings to send() works only in chrome, see post.html sample.
XPCOM glue
MozillaTechXPCOMGlue
sample compiler/linker flags code compiled using xpcom headers should always #include "xpcom-config.h" from the sdk, to ensure that xpcom #defines are correct.
How to build an XPCOM component in JavaScript
a sample makefile.in # this source code form is subject to the terms of the mozilla public # license, v.
Packaging WebLock
the sample installation script shown below uses the mozilla xpinstall technology to manipulate an installer and talk to mozilla'schrome registry as high-level javascript objects.
JavaXPCOM
sample code there are several java test applications checked in to the tree that give examples on how to embed gecko or init xpcom from within java.
PyXPCOM
other resources pythonext - extension that provides pyxpcom samples - demo applications using pyxpcom community python-xpcom bindings mailing list (activestate) #pyxpcom on irc.mozilla.org source code the pyxpcom code is available here: http://hg.mozilla.org/pyxpcom/ to build pyxpcom, see building pyxpcom.
mozIStorageAggregateFunction
sample code both of the following code samples assume that the variable dbconn is an opened mozistorageconnection.
mozIStorageFunction
sample code both of the following code samples assume that the variable dbconn is an opened mozistorageconnection.
nsICommandLine
see also sample js component that implements a command-line flag.
nsIConsoleService
note: see the code samples below for how to call getmessagearray.
nsIDOMMozNetworkStatsData
date date the date of the sample.
nsIEnumerator
sample usage var iter = --------(); try { iter.first(); do { var data = iter.currentitem(); if( data instanceof ci.nsi------ ) { ...
nsITraceableChannel
see nsitraceablechannel, intercept http traffic for a more detailed description with code samples.
Frequently Asked Questions
e.g., using blocks as in this sample // the most efficient scheme is to scope your |nscomptr| to live exactly as long // as you need to hold the reference nsresult somelongfunction( nsibar* abar ) { nsresult rv; // ...
Getting Started Guide
using do_queryinterface, the sample above would look like this how to queryinterface into an nscomptr.
Reference Manual
here is a sample demonstrating the various positions these `annotations' can appear in, using dont_addref // controlling assignment into an |nscomptr|...
XPCOM tasks
things we need to evangelize we need to keep up-to-date documentation, samples, and have brown-bags to keep people informed.
Creating a gloda message query
see gloda examples for more code samples.
Index
see gloda examples for more code samples.
Building a Thunderbird extension 5: XUL
example xul overlay document create a new file called myhelloworld.xul within the content folder you created earlier with the following content: <?xml version="1.0"?> <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/javascript" src="chrome://myfirstext/content/overlay.js"/><!-- a reference to your javascript file --> <statusbar id="status-bar"> <statusbarpanel id="my-panel" label="date"/> </statusbar> </overlay> the <statusbar> widget named status-bar specifies the merge point within the application windo...
Creating a Custom Column
our replyto_col_overlay.xul should now contain something similar to this: <?xml version="1.0"?> <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <tree id="threadtree"> <treecols id="threadcols"> <splitter class="tree-splitter" /> <treecol id="colreplyto" persist="hidden ordinal width" currentview="unthreaded" flex="2" label="reply-to" tooltiptext="click to sort by the reply-to header" /> </treecols> </tree> <!-- in...
Add Option to Context Menu
for thunderbird 2 <?xml version="1.0"?> <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <menupopup id="messagepanecontext"> <menuitem id="my_option" label="my option concise and cool label" oncommand="alert('hi')"/> </menupopup> </overlay> for thunderbird 3 <?xml version="1.0"?> <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <popup id="mailcontext"> <menuitem id="my_option" label="my option concise a...
Use SQLite
{ var dbconnection = adbservice.opendatabase(adbfile); this._dbcreatetables(dbconnection); return dbconnection; }, _dbcreatetables: function(adbconnection) { for(var name in this.dbschema.tables) adbconnection.createtable(name, this.dbschema.tables[name]); }, }; window.addeventlistener("load", function(e) { tbirdsqlite.onload(e); }, false); this is another practical sample on how to handle opendatabase and sql queries on the client side, using in-memory (blob) storage of 2mb: var db = opendatabase('mydb', '1.0', 'test db', 2 * 1024 * 1024); var msg; db.transaction(function (tx) { tx.executesql('create table if not exists logs (id unique, log)'); tx.executesql('insert into logs (id, log) values (1, "foobar")'); tx.executesql('insert into logs (id, log) values...
Theme Packaging
sample install.rdf file <?xml version="1.0"?> <rdf xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <description about="urn:mozilla:install-manifest"> <em:id>{18b64b56-d42f-428d-a88c-baa413bc413f}</em:id> <em:version>1.0</em:version> <em:type>4</em:type> <!-- target application this extension can install into, with mi...
Using the Multiple Accounts API
some sample code: (where accountmanager is the account manager.
WebIDL bindings
see this sample patch that migrates window.performance.* to webidl bindings.
Eyedropper - Firefox Developer Tools
changing a color value in the rules view color values appearing in the inspector's rules view have color samples next to them: clicking the sample shows a color picker popup.
Aggregate view - Firefox Developer Tools
you'll then see a list of all the functions that allocated objects, ordered by the size of the allocations they made: the structure of this view is very much like the structure of the call tree, only it shows allocations rather than processor samples.
Migrating from Firebug - Firefox Developer Tools
like in firebug it lists the total execution time of each function call under total time as well as the number of calls under samples, the time spent within the function under self time and the related percentages in reference to the total execution time.
Animation inspector example: CSS transitions - Firefox Developer Tools
html content <div class="channel"> <img src="https://udn.realityripple.com/samples/e6/a96484b5c3.png" class="icon"/> <span class="note">firefox developer edition</span> </div> css content .channel { padding: 2em; margin: 0.5em; box-shadow: 1px 1px 5px #808080; margin: 1.5em; } .channel > * { vertical-align: middle; line-height: normal; } .icon { width: 50px; height: 50px; filter: grayscale(100%); transition: transform 750ms ease-in, filter 750ms ease-in-out; } .note { margin-left: 1em; font: 1.5em "open sans",arial,sans-serif; overflow: hidden; white-space: nowrap; display: inline-block; opacity: 0; width: 0; transition: opacity 500ms 150ms, width 500ms 150ms; } .icon#selecte...
Animation inspector example: Web Animations API - Firefox Developer Tools
html content <div class="channel"> <img src="https://udn.realityripple.com/samples/e6/a96484b5c3.png" id="icon"/> <span id="note">firefox developer edition</span> </div> css content .channel { padding: 2em; margin: 0.5em; box-shadow: 1px 1px 5px #808080; margin: 1.5em; } .channel > * { vertical-align: middle; line-height: normal; } #icon { width: 50px; height: 50px; filter: grayscale(100%); } #note { margin-left: 1em; font: 1.5em "open sans",arial,sans-serif; overflow: hidden; white-space: nowrap; display: inline-block; opacity: 0; width: 0; } javascript content var iconkeyframeset = [ { transform: 'scale(1)', filter: 'grayscale(100%)'}, { filter: 'grayscale(100%)'...
UI Tour - Firefox Developer Tools
fonts view the fonts view shows all the fonts in the page along with editable samples.
AbsoluteOrientationSensor - Web APIs
syntax var absoluteorientationsensor = new absoluteorientationsensor([options]) parameters options optional options are as follows: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onreading will be called.
Accelerometer.Accelerometer() - Web APIs
syntax var accelerometer = new accelerometer([options]) parameters options optional options are as follows: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onerror will be called.
AmbientLightSensor.AmbientLightSensor() - Web APIs
syntax var ambientlightsensor = new ambientlightsensor(options) parameters options optional currently only one option is supported: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onreading will be called.
AudioBufferSourceNode.detune - Web APIs
example const audioctx = new audiocontext(); const channelcount = 2; const framecount = audioctx.samplerate * 2.0; // 2 seconds const myarraybuffer = audioctx.createbuffer(channelcount, framecount, audioctx.samplerate); for (let channel = 0; channel < channelcount; channel++) { const nowbuffering = myarraybuffer.getchanneldata(channel); for (let i = 0; i < framecount; i++) { nowbuffering[i] = math.random() * 2 - 1; } } const source = audioctx.createbuffersource(); source.buffer = myarr...
AudioBufferSourceNode.start() - Web APIs
the computation of the offset into the sound is performed using the sound buffer's natural sample rate, rather than the current playback rate, so even if the sound is playing at twice its normal speed, the midway point through a 10-second audio buffer is still 5.
AudioContext.outputLatency - Web APIs
this is the time, in seconds, between the browser passing an audio buffer out of an audio graph over to the host system's audio subsystem to play, and the time at which the first sample in the buffer is actually processed by the audio output device.
AudioParamDescriptor - Web APIs
parameters['customgain'][i] : parameters['customgain'][0]) // note: a parameter contains an array of 128 values (one value for each of 128 samples), // however it may contain a single value which is to be used for all 128 samples // if no automation is scheduled for the moment.
AudioScheduledSourceNode - Web APIs
silence is represented, as always, by a stream of samples with the value zero (0).
AudioTrackList.length - Web APIs
var videoelem = document.queryselector("video"); var numaudiotracks = 0; if (videoelem.audiotracks) { numaudiotracks = videoelem.audiotracks.length; } note that this sample checks to be sure htmlmediaelement.audiotracks is defined, to avoid failing on browsers without support for audiotrack.
AudioWorkletNode.parameters - Web APIs
parameters['customgain'][i] : parameters['customgain'][0]) // note: a parameter contains an array of 128 values (one value for each of 128 samples), // however it may contain a single value which is to be used for all 128 samples // if no automation is scheduled for the moment.
AudioWorkletProcessor.parameterDescriptors (static getter) - Web APIs
parameters['customgain'][i] : parameters['customgain'][0]) // note: a parameter contains an array of 128 values (one value for each of 128 samples), // however it may contain a single value which is to be used for all 128 samples // if no automation is scheduled for the moment.
AudioWorkletProcessor - Web APIs
this method gets called for each block of 128 sample-frames and takes input and output arrays and calculated values of custom audioparams (if they are defined) as parameters.
BaseAudioContext.createBufferSource() - Web APIs
var audioctx = new (window.audiocontext || window.webkitaudiocontext)(); var button = document.queryselector('button'); var pre = document.queryselector('pre'); var myscript = document.queryselector('script'); pre.innerhtml = myscript.innerhtml; // stereo var channels = 2; // create an empty two second stereo buffer at the // sample rate of the audiocontext var framecount = audioctx.samplerate * 2.0; var myarraybuffer = audioctx.createbuffer(2, framecount, audioctx.samplerate); button.onclick = function() { // fill the buffer with white noise; //just random values between -1.0 and 1.0 for (var channel = 0; channel < channels; channel++) { // this gives us the actual arraybuffer that contains the data var nowbuf...
BaseAudioContext.createConstantSource() - Web APIs
the createconstantsource() property of the baseaudiocontext interface creates a constantsourcenode object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value.
BaseAudioContext.createDelay() - Web APIs
example we have created a simple example that allows you to play three different samples on a constant loop — see create-delay (you can also view the source code).
BaseAudioContext.decodeAudioData() - Web APIs
the decoded audiobuffer is resampled to the audiocontext's sampling rate, then passed to a callback or promise.
BasicCardRequest.supportedNetworks - Web APIs
legal values are defined in the w3c's document card network identifiers approved for use with payment request api, and are currently: amex cartebancaire diners discover jcb mastercard mir unionpay visa example the following example shows a sample definition of the first parameter of the paymentrequest() constructor, the data property of which contains supportednetworks and supportedtypes properties.
BasicCardRequest.supportedTypes - Web APIs
legal values are defined in basiccardtype enum, and are currently: credit debit prepaid example the following example shows a sample definition of the first parameter of the paymentrequest() constructor, the data property of which contains supportednetworks and supportedtypes properties.
BasicCardResponse.billingAddress - Web APIs
example let's look at a sample payment request: var request = new paymentrequest(supportedinstruments, details, options); // call show() to trigger the browser's payment flow.
BasicCardResponse.cardNumber - Web APIs
example let's look at a sample payment request: var request = new paymentrequest(supportedinstruments, details, options); // call show() to trigger the browser's payment flow.
BasicCardResponse.cardSecurityCode - Web APIs
example let's look at a sample payment request: var request = new paymentrequest(supportedinstruments, details, options); // call show() to trigger the browser's payment flow.
BasicCardResponse.cardholderName - Web APIs
example let's look at a sample payment request: var request = new paymentrequest(supportedinstruments, details, options); // call show() to trigger the browser's payment flow.
BasicCardResponse.expiryMonth - Web APIs
example let's look at a sample payment request: var request = new paymentrequest(supportedinstruments, details, options); // call show() to trigger the browser's payment flow.
BasicCardResponse.expiryYear - Web APIs
example let's look at a sample payment request: var request = new paymentrequest(supportedinstruments, details, options); // call show() to trigger the browser's payment flow.
BiquadFilterNode.frequency - Web APIs
frequency's default value is 350 with a nominal range of 10 to the nyquist frequency — that is, half of the sample rate.
Body.bodyUsed - Web APIs
WebAPIBodybodyUsed
html content <img class="my-image" src="https://udn.realityripple.com/samples/46/29059a2b39.png"> js content var myimage = document.queryselector('.my-image'); fetch('https://upload.wikimedia.org/wikipedia/commons/7/77/delete_key1.jpg').then(function(response) { console.log(response.bodyused); var res = response.blob(); console.log(response.bodyused); return res; }).then(function(response) { var objecturl = url.createobjecturl(response); myimage...
Body - Web APIs
WebAPIBody
html content <img class="my-image" src="https://udn.realityripple.com/samples/46/29059a2b39.png"> js content const myimage = document.queryselector('.my-image'); fetch('https://upload.wikimedia.org/wikipedia/commons/7/77/delete_key1.jpg') .then(res => res.blob()) .then(res => { const objecturl = url.createobjecturl(res); myimage.src = objecturl; }); specifications specification status comment fetchthe definition of 'body' in that speci...
CSSNumericValue.sub() - Web APIs
examples let mathsum = css.px("23").sum(css.percent("4")).sum(css.cm("3")).sum(css.in("9")); // prints "calc(23px - 4% - 3cm - 9in)" console.log(mathsum.tostring()); and/or include a list of links to useful code samples that live elsewhere: specifications specification status comment css typed om level 1the definition of 'sub' in that specification.
CSSNumericValue.sum() - Web APIs
examples let mathsum = css.px("23").sum(css.percent("4")).sum(css.cm("3")).sum(css.in("9")); // prints "calc(23px - 4% - 3cm - 9in)" console.log(mathsum.tostring()); and/or include a list of links to useful code samples that live elsewhere: specifications specification status comment css typed om level 1the definition of 'sub' in that specification.
CSSPositionValue - Web APIs
#image { width: 300px; height: 300px; border: 1px solid black; background-color: #dededf; object-fit: none; } <p>check the developer tools to see the log in the console and to inspect the style attribute on the image.</p> <img id="image" src="https://udn.realityripple.com/samples/db/4f9fbd7dfb.svg" alt="mdn logo"/> ...
Cache - Web APIs
WebAPICache
examples this code snippet is from the service worker selective caching sample.
CanvasRenderingContext2D.arc() - Web APIs
let startangle = 0; // starting point on circle let endangle = math.pi + (math.pi * j) / 2; // end point on circle let anticlockwise = i % 2 == 1; // draw anticlockwise ctx.arc(x, y, radius, startangle, endangle, anticlockwise); if (i > 1) { ctx.fill(); } else { ctx.stroke(); } } } result screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.arc' in that specification.
CanvasRenderingContext2D.createPattern() - Web APIs
the original image looks like this: html <canvas id="canvas" width="300" height="300"></canvas> javascript var canvas = document.getelementbyid('canvas'); var ctx = canvas.getcontext('2d'); var img = new image(); img.src = 'https://udn.realityripple.com/samples/04/aaeaf9aac4.png'; img.onload = function() { var pattern = ctx.createpattern(img, 'repeat'); ctx.fillstyle = pattern; ctx.fillrect(0, 0, 300, 300); }; creating a pattern from a canvas in this example we create a pattern from the contents of an offscreen canvas.
CanvasRenderingContext2D.fillStyle - Web APIs
" width="150" height="150"></canvas> const canvas = document.getelementbyid('canvas'); const ctx = canvas.getcontext('2d'); for (let i = 0; i < 6; i++) { for (let j = 0; j < 6; j++) { ctx.fillstyle = `rgb( ${math.floor(255 - 42.5 * i)}, ${math.floor(255 - 42.5 * j)}, 0)`; ctx.fillrect(j * 25, i * 25, 25, 25); } } the result looks like this: screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.fillstyle' in that specification.
CanvasRenderingContext2D.filter - Web APIs
html <canvas id="canvas"></canvas> <div style="display:none;"> <img id="source" src="https://udn.realityripple.com/samples/90/a34a525ace.jpg"> </div> javascript const canvas = document.getelementbyid('canvas'); const ctx = canvas.getcontext('2d'); const image = document.getelementbyid('source'); image.addeventlistener('load', e => { ctx.filter = 'contrast(1.4) sepia(1) drop-shadow(9px 9px 2px #e81)'; ctx.drawimage(image, 10, 10, 180, 120); }); result specifications specification status com...
CanvasRenderingContext2D.globalAlpha - Web APIs
ctx.fillstyle = '#6c0'; ctx.fillrect(75, 0, 75, 75); ctx.fillstyle = '#09f'; ctx.fillrect(0, 75, 75, 75); ctx.fillstyle = '#f30'; ctx.fillrect(75, 75, 75, 75); ctx.fillstyle = '#fff'; // set transparency value ctx.globalalpha = 0.2; // draw transparent circles for (let i = 0; i < 7; i++) { ctx.beginpath(); ctx.arc(75, 75, 10 + 10 * i, 0, math.pi * 2, true); ctx.fill(); } screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.globalalpha' in that specification.
CanvasRenderingContext2D.lineCap - Web APIs
guides ctx.strokestyle = '#09f'; ctx.beginpath(); ctx.moveto(10, 10); ctx.lineto(140, 10); ctx.moveto(10, 140); ctx.lineto(140, 140); ctx.stroke(); // draw lines ctx.strokestyle = 'black'; for (let i = 0; i < linecap.length; i++) { ctx.linewidth = 15; ctx.linecap = linecap[i]; ctx.beginpath(); ctx.moveto(25 + i * 50, 10); ctx.lineto(25 + i * 50, 140); ctx.stroke(); } screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.linecap' in that specification.
CanvasRenderingContext2D.lineJoin - Web APIs
document.getelementbyid('canvas').getcontext('2d'); var linejoin = ['round', 'bevel', 'miter']; ctx.linewidth = 10; for (let i = 0; i < linejoin.length; i++) { ctx.linejoin = linejoin[i]; ctx.beginpath(); ctx.moveto(-5, 5 + i * 40); ctx.lineto(35, 45 + i * 40); ctx.lineto(75, 5 + i * 40); ctx.lineto(115, 45 + i * 40); ctx.lineto(155, 5 + i * 40); ctx.stroke(); } screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.linejoin' in that specification.
CanvasRenderingContext2D.miterLimit - Web APIs
ar code = textarea.value; function drawcanvas() { ctx.clearrect(0, 0, canvas.width, canvas.height); eval(textarea.value); } reset.addeventlistener("click", function() { textarea.value = code; drawcanvas(); }); edit.addeventlistener("click", function() { textarea.focus(); }) textarea.addeventlistener("input", drawcanvas); window.addeventlistener("load", drawcanvas); screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.miterlimit' in that specification.
CanvasRenderingContext2D.strokeStyle - Web APIs
ctx = document.getelementbyid('canvas').getcontext('2d'); for (let i = 0; i < 6; i++) { for (let j = 0; j < 6; j++) { ctx.strokestyle = `rgb( 0, ${math.floor(255 - 42.5 * i)}, ${math.floor(255 - 42.5 * j)})`; ctx.beginpath(); ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, math.pi * 2, true); ctx.stroke(); } } the result looks like this: screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.strokestyle' in that specification.
Basic usage of canvas - Web APIs
xt) { var ctx = canvas.getcontext('2d'); ctx.fillstyle = 'rgb(200, 0, 0)'; ctx.fillrect(10, 10, 50, 50); ctx.fillstyle = 'rgba(0, 0, 200, 0.5)'; ctx.fillrect(30, 30, 50, 50); } } </script> </head> <body onload="draw();"> <canvas id="canvas" width="150" height="150"></canvas> </body> </html> this example looks like this: screenshotlive sample « previousnext » ...
Compositing example - Web APIs
this sample program demonstrates a number of compositing operations.
Compositing and clipping - Web APIs
screenshotlive sample « previousnext » ...
ConstantSourceNode() - Web APIs
the constantsourcenode() constructor creates a new constantsourcenode object instance, representing an audio source which constantly outputs samples whose values are always the same.
ConvolverNode() - Web APIs
exceptions exception explanation notsupportederror the referenced audiobuffer does not have the correct number of channels, or it has a different sample rate to the associated audiocontext.
ConvolverNode.buffer - Web APIs
this audiobuffer must have the same sample-rate as the audiocontext or an exception will be thrown.
CrashReportBody - Web APIs
some sample json might look like this: { "type": "crash", "age": 42, "url": "https://example.com/", "user_agent": "mozilla/5.0 (x11; linux x86_64; rv:60.0) gecko/20100101 firefox/60.0", "body": { "reason": "oom" } } note: crash reports are always delivered to the endpoint group named default; there is currently no way to override this.
DOMMatrixReadOnly.flipX() - Web APIs
const flipped = document.getelementbyid('flipped'); const matrix = new dommatrixreadonly(); const flippedmatrix = matrix.flipx(); flipped.setattribute('transform', flippedmatrix.tostring()); screenshotlive sample specifications specification status comment geometry interfaces module level 1the definition of 'dommatrixreadonly.flipx()' in that specification.
DOMMatrixReadOnly.scale() - Web APIs
ing matrix is 3d const browserexpectssixparamscale = !scaledmatrixwithorigin.is2d; if (browserexpectssixparamscale) { scaledmatrixwithorigin = matrix.scale(0.5, 0.5, 1, 25, 25, 0); } document.queryselector('#transformed').setattribute('transform', scaledmatrix.tostring()); document.queryselector('#transformedorigin').setattribute('transform', scaledmatrixwithorigin.tostring()); screenshotlive sample specifications specification status comment geometry interfaces module level 1the definition of 'dommatrixreadonly.scale()' in that specification.
DOMMatrixReadOnly.translate() - Web APIs
const matrix = new dommatrixreadonly().translate(25, 25); document.queryselector('#transformed').setattribute('transform', matrix.tostring()); screenshotlive sample specifications specification status comment geometry interfaces module level 1the definition of 'dommatrixreadonly.translate()' in that specification.
DOMPoint.fromPoint() - Web APIs
examples creating a mutable point from a read-only point if you have a dompointreadonly object, you can easily create a mutable copy of that point: var mutablepoint = dompoint.frompoint(readonlypoint); creating a 2d point this sample creates a 2d point, specifying an inline object that includes the values to use for x and y.
DOMPointReadOnly.fromPoint() - Web APIs
examples creating a 2d point this sample creates a 2d point, specifying an inline object that includes the values to use for x and y.
DelayNode.delayTime - Web APIs
example we have created a simple example that allows you to play three different samples on a constant loop — see create-delay (you can also view the source code).
DelayNode - Web APIs
WebAPIDelayNode
example we have created a simple example that allows you to play three different samples on a constant loop — see create-delay (you can also view the source code).
Document: touchcancel event - Web APIs
bubbles yes cancelable no interface touchevent event handler property ontouchcancel examples code samples for those events are available on the dedicated page: touch events.
Document: touchend event - Web APIs
bubbles yes cancelable yes interface touchevent event handler property ontouchend examples code samples for those events are available on the dedicated page: touch events.
Document: touchmove event - Web APIs
bubbles yes cancelable yes interface touchevent event handler property ontouchmove examples code samples for those events are available on the dedicated page: touch events.
Document: touchstart event - Web APIs
bubbles yes cancelable yes interface touchevent event handler property ontouchstart examples code samples for those events are available on the dedicated page: touch events.
Examples of web and XML development using the DOM - Web APIs
s[i].height + ", width=" + arrimages[i].width + ", style.height=" + arrimages[i].style.height + ", style.width=" + arrimages[i].style.width + "<\/li>"; } strhtml += "<\/ul>"; objoutput.innerhtml = strhtml; } </script> </head> <body onload="init();"> <p>image 1: no height, width, or style <img id="image1" src="https://udn.realityripple.com/samples/d2/8ba7141ed1.gif"> </p> <p>image 2: height="50", width="500", but no style <img id="image2" src="https://udn.realityripple.com/samples/d2/8ba7141ed1.gif" height="50" width="500"> </p> <p>image 3: no height, width, but style="height: 50px; width: 500px;" <img id="image3" src="https://udn.realityripple.com/samples/d2/8ba7141ed1.gif" style="height: 50px; width: 50...
Element.attributes - Web APIs
utes if (paragraph.hasattributes()) { var attrs = paragraph.attributes; var output = ""; for(var i = attrs.length - 1; i >= 0; i--) { output += attrs[i].name + "->" + attrs[i].value; } result.value = output; } else { result.value = "no attributes to show"; } } </script> </head> <body> <p id="paragraph" style="color: green;">sample paragraph</p> <form action=""> <p> <input type="button" value="show first attribute name and value" onclick="listattributes();"> <input id="result" type="text" value=""> </p> </form> </body> </html> specifications specification status comment domthe definition of 'element.attributes' in that specification.
Element: keypress event - Web APIs
<div> <label for="sample">focus the input and type something:</label> <input type="text" name="text" id="sample"> </div> <p id="log"></p> const log = document.getelementbyid('log'); const input = document.queryselector('input'); input.addeventlistener('keypress', logkey); function logkey(e) { log.textcontent += ` ${e.code}`; } onkeypress equivalent input.onkeypress = logkey; specifications specifica...
Element: touchcancel event - Web APIs
bubbles yes cancelable no interface touchevent event handler property ontouchcancel examples code samples for those events are available on the dedicated page: touch events.
Element: touchend event - Web APIs
bubbles yes cancelable yes interface touchevent event handler property ontouchend examples code samples for those events are available on the dedicated page: touch events.
Element: touchmove event - Web APIs
bubbles yes cancelable yes interface touchevent event handler property ontouchmove examples code samples for those events are available on the dedicated page: touch events.
Element: touchstart event - Web APIs
bubbles yes cancelable yes interface touchevent event handler property ontouchstart examples code samples for those events are available on the dedicated page: touch events.
ExtendableEvent - Web APIs
examples this code snippet is from the service worker prefetch sample (see prefetch example live.) the code calls extendableevent.waituntil() in serviceworkerglobalscope.oninstall, delaying treating the serviceworkerregistration.installing worker as installed until the passed promise resolves successfully.
FetchEvent.request - Web APIs
example this code snippet is from the service worker fetch sample (run the fetch sample live).
FileException - Web APIs
var fileentry = fs.root.getfile('log.txt', {create: true, exclusive:true}0; } catch (e) { onerrror(e); } the sample code was borrowed from html5rocks attribute attribute type description code unsigned short the most appropriate error code for the condition.
GainNode - Web APIs
WebAPIGainNode
the gain is a unitless value, changing with time, that is multiplied to each corresponding sample of all input channels.
GlobalEventHandlers.onmousedown - Web APIs
html <div class="container"> <div class="view" hidden></div> <img src="https://udn.realityripple.com/samples/90/a34a525ace.jpg"> </div> css .container { width: 320px; height: 213px; background: black; } .view { position: absolute; width: 100px; height: 100px; background: white; border-radius: 50%; } img { mix-blend-mode: darken; } javascript function showview(event) { view.removeattribute('hidden'); view.style.left = event.clientx - 50 + 'px'; view.style.top = event.client...
Gyroscope.Gyroscope() - Web APIs
syntax var gyroscope = new gyroscope([options]) parameters options optional options are as follows: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onreading will be called.
HTMLImageElement.alt - Web APIs
<div class="container"> <img src="https://udn.realityripple.com/samples/87/eace6b7d6a.svg" alt="new page!" class="pageinfo-badge"> <p class="contents"> lorem ipsum dolor sit amet, consectetur adipiscing elit.
HTMLImageElement.src - Web APIs
examples specifying a single image html <img src="https://udn.realityripple.com/samples/d6/7ab36d79bb.jpg" width="160" alt="slices of grapefruit, looking yummy."> result using src with an image set when using a set of images with the srcset property, the src serves as either a fallback for older browsers, or as the 1x size of the image.
HTMLImageElement.x - Web APIs
<table id="userinfo"> <colgroup> <col span="2" class="group1"> <col> </colgroup> <tr> <th>userid</th> <th>name</th> <th>avatar</th> </tr> <tr> <td>12345678</td> <td>johnny rocket</td> <td><img src="https://udn.realityripple.com/samples/d6/7ab36d79bb.jpg"</td> </th> </table> <pre id="log"> </pre> javascript the javascript code that fetches the image from the table and looks up its x and y values is below.
HTMLImageElement.y - Web APIs
<table id="userinfo"> <colgroup> <col span="2" class="group1"> <col> </colgroup> <tr> <th>userid</th> <th>name</th> <th>avatar</th> </tr> <tr> <td>12345678</td> <td>johnny rocket</td> <td><img src="https://udn.realityripple.com/samples/d6/7ab36d79bb.jpg"</td> </th> </table> <pre id="log"> </pre> javascript the javascript code that fetches the image from the table and looks up its x and y values is below.
HTMLInputElement.select() - Web APIs
in browsers where it is not supported, it is possible to replace it with a call to htmlinputelement.setselectionrange() with parameters 0 and the input's value length: <input onclick="this.select();" value="sample text" /> <!-- equivalent to --> <input onclick="this.setselectionrange(0, this.value.length);" value="sample text" /> specifications specification status comment html living standardthe definition of 'select' in that specification.
HTMLElement.blur() - Web APIs
syntax element.blur(); examples remove focus from a text input html <input type="text" id="mytext" value="sample text"> <br><br> <button type="button" onclick="focusinput()">click me to gain focus</button> <button type="button" onclick="blurinput()">click me to lose focus</button> javascript function focusinput() { document.getelementbyid('mytext').focus(); } function blurinput() { document.getelementbyid('mytext').blur(); } result specification specification status comment html living standardthe definition of 'blur' in that specification.
HTMLScriptElement - Web APIs
function loaderror(oerror) { throw new urierror("the script " + oerror.target.src + " didn't load correctly."); } function affixscripttohead(url, onloadfunction) { var newscript = document.createelement("script"); newscript.onerror = loaderror; if (onloadfunction) { newscript.onload = onloadfunction; } document.head.appendchild(newscript); newscript.src = url; } sample usage: affixscripttohead("myscript1.js"); affixscripttohead("myscript2.js", function () { alert("the script \"myscript2.js\" has been correctly loaded."); }); specifications specification status comment html living standardthe definition of 'htmlscriptelement' in that specification.
HTML Drag and Drop API - Web APIs
identify what is draggable making an element draggable requires adding the draggable attribute and the ondragstart global event handler, as shown in the following code sample: <script> function dragstart_handler(ev) { // add the target element's id to the data transfer object ev.datatransfer.setdata("text/plain", ev.target.id); } window.addeventlistener('domcontentloaded', () => { // get the element by id const element = document.getelementbyid("p1"); // add the ondragstart event listener element.addeventlistener("dragstart", dragstart_...
Working with the History API - Web APIs
see window.onpopstate for sample usage.
IDBDatabase.deleteObjectStore() - Web APIs
example var dbname = "sampledb"; var dbversion = 2; var request = indexeddb.open(dbname, dbversion); request.onupgradeneeded = function(e) { var db = request.result; if (e.oldversion < 1) { db.createobjectstore("store1"); } if (e.oldversion < 2) { db.deleteobjectstore("store1"); db.createobjectstore("store2"); } // etc.
IDBObjectStore.delete() - Web APIs
example in the following code snippet, we open a read/write transaction on our database and delete one specific record out of our object store using delete() — a sample record with the key "walk dog".
IDBObjectStore.get() - Web APIs
example in the following code snippet, we open a read/write transaction on our database and get one specific record from object store using get() — a sample record with the key "walk dog".
IDBVersionChangeEvent.oldVersion - Web APIs
example var dbname = "sampledb"; var dbversion = 2; var request = indexeddb.open(dbname, dbversion); request.onupgradeneeded = function(e) { var db = request.result; if (e.oldversion < 1) { db.createobjectstore("store1"); } if (e.oldversion < 2) { db.deleteobjectstore("store1"); db.createobjectstore("store2"); } // etc.
IIRFilterNode.getFrequencyResponse() - Web APIs
examples in the following example we are using an iir filter on a media stream (for a complete full demo, see our stream-source-buffer demo live, or read its source.) as part of this demo, we get the frequency responses for this iir filter, for five sample frequencies.
ImageCapture.getPhotoCapabilities() - Web APIs
example the following example, extracted from chrome's image capture / photo resolution sample, uses the results from getphotocapabilities() to modify the size of an input range.
ImageCapture.getPhotoSettings() - Web APIs
example the following example, extracted from chrome's image capture / photo resolution sample, uses the results from getphotosettings() to modify the size of an input range.
ImageCapture - Web APIs
example the following code is taken from chrome's grab frame - take photo sample.
InstallEvent - Web APIs
examples this code snippet is from the service worker prefetch sample (see prefetch running live.) the code calls extendableevent.waituntil() in serviceworkerglobalscope.oninstall and delays treating the serviceworkerregistration.installing worker as installed until the passed promise resolves successfully.
LinearAccelerationSensor.LinearAccelerationSensor() - Web APIs
syntax var linearaccelerationsensor = new linearaccelerationsensor([options]) parameters options optional options are as follows: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onreading will be called.
Magnetometer.Magnetometer() - Web APIs
syntax var magnetometer = new magnetometer([options]) parameters options optional options are as follows: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onreading will be called.
MediaCapabilities.decodingInfo() - Web APIs
example //create media configuration to be tested const mediaconfig = { type : 'file', // or 'media-source' audio : { contenttype : "audio/ogg", // valid content type channels : 2, // audio channels used by the track bitrate : 132700, // number of bits used to encode 1s of audio samplerate : 5200 // number of audio samples making up that 1s.
MediaCapabilitiesInfo - Web APIs
example // mediaconfiguration to be tested const mediaconfig = { type : 'file', audio : { contenttype : "audio/ogg", channels : 2, bitrate : 132700, samplerate : 5200 }, }; // check support and performance navigator.mediacapabilities.decodinginfo(mediaconfig).then(result => { // result contains the media capabilities information console.log('this configuration is ' + (result.supported ?
MediaRecorder() - Web APIs
if bits per second values are not specified for video and/or audio, the default adopted for video is 2.5mbps, while the audio default is adaptive, depending upon the sample rate and the number of channels.
MediaRecorder - Web APIs
rc = audiourl; console.log("recorder stopped"); deletebutton.onclick = function(e) { evttgt = e.target; evttgt.parentnode.parentnode.removechild(evttgt.parentnode); } } mediarecorder.ondataavailable = function(e) { chunks.push(e.data); } }) .catch(function(err) { console.log('the following error occurred: ' + err); }) } this code sample is inspired by the web dictaphone demo.
MediaSettingsRange - Web APIs
example the following example, extracted from chrome's image capture / photo resolution sample, uses the results from getphotocapabilities().imagewidth to modify the size of an input range.
MediaStream.getVideoTracks() - Web APIs
example the following example, extracted from chrome's image capture / photo resolution sample, uses getvideotracks() to retrieve a track for passing to the imagecapture() constructor.
MediaStreamTrack.muted - Web APIs
when a track is disabled by setting enabled to false, it generates only empty frames (audio frames in which every sample is 0, or video frames in which every pixel is black).
Using the Media Capabilities API - Web APIs
const videoconfiguration = { type: "file", video: { contenttype: "video/webm;codecs=vp8", width: 800, height: 600, bitrate: 10000, framerate: 15 } }; had we been querying the decodability of an audio file, we would create an audio configuration including the number of channels and sample rate, leaving out the properties that apply only to video—namely, the dimensions and the frame rate: const audioconfiguration = { type: "file", audio: { contenttype: "audio/ogg", channels: 2, bitrate: 132700, samplerate: 5200 } }; had we been testing encoding capabilities, we would have created a mediaencodingconfiguration, which requires the type of media bei...
Media Capabilities API - Web APIs
if ('mediacapabilities' in navigator) { const audiofileconfiguration = { type : 'file', audio : { contenttype: "audio/mp3", channels: 2, bitrate: 132700, samplerate: 5200 } }; navigator.mediacapabilities.decodinginfo(audiofileconfiguration).then(result => { console.log('this configuration is ' + (result.supported ?
Navigator.getBattery() - Web APIs
this implements the battery status api; see that documentation for additional details, a guide to using the api, and sample code.
Navigator.mediaCapabilities - Web APIs
examples navigator.mediacapabilities.decodinginfo({ type : 'file', audio : { contenttype : "audio/mp3", channels : 2, bitrate : 132700, samplerate : 5200 } }).then(function(result) { console.log('this configuration is ' + (result.supported ?
Navigator.share() - Web APIs
WebAPINavigatorshare
then include an array of files in the call to navigator.share(): notice: that the sample handles feature detection by testing for navigator.canshare() rather than for navigator.share().
Node.removeChild() - Web APIs
WebAPINoderemoveChild
d.removechild(d_nested); to remove a specified element without having to specify its parent node: let node = document.getelementbyid("nested"); if (node.parentnode) { node.parentnode.removechild(node); } to remove all children from an element: let element = document.getelementbyid("top"); while (element.firstchild) { element.removechild(element.firstchild); } causing a typeerror <!--sample html code--> <div id="top"> </div> <script type="text/javascript"> let top = document.getelementbyid("top"); let nested = document.getelementbyid("nested"); // throws uncaught typeerror let garbage = top.removechild(nested); </script> causing a notfounderror <!--sample html code--> <div id="top"> <div id="nested"></div> </div> <script type="text/javascript"> let top = document.g...
Notification.requestPermission() - Web APIs
} we no longer show a live sample on this page, as chrome and firefox no longer allow notification permissions to be requested from cross-origin <iframe>s, with other browsers to follow.
Notification - Web APIs
} we no longer show a live sample on this page, as chrome and firefox no longer allow notification permissions to be requested from cross-origin <iframe>s, with other browsers to follow.
OES_fbo_render_mipmap - Web APIs
examples see the sample code in the khronos specification.
OES_standard_derivatives - Web APIs
ype dfdx(gentype) gentype dfdy(gentype) gentype fwidth(gentype) examples enabling the extensions: gl.getextension('oes_standard_derivatives'); gl.getextension('ext_shader_texture_lod'); shader code that avoids artifacts when wrapping texture coordinates: <script type="x-shader/x-fragment"> #extension gl_ext_shader_texture_lod : enable #extension gl_oes_standard_derivatives : enable uniform sampler2d mytexture; varying vec2 texcoord; void main(){ gl_fragcolor = texture2dgradext(mytexture, mod(texcoord, vec2(0.1, 0.5)), dfdx(texcoord), dfdy(texcoord)); } </script> specifications specification status comment oes_standard_derivativesthe definition of 'oes_standard_derivatives' in that specification.
OVR_multiview2 - Web APIs
currently, there is no way to use multiview to render to a multisampled backbuffer, so you should create contexts with antialias: false.
OfflineAudioContext - Web APIs
offlineaudiocontext.length read only an integer representing the size of the buffer in sample-frames.
PhotoCapabilities - Web APIs
example the following example, extracted from chrome's image capture / photo resolution sample, uses the results from getphotocapabilities() to modify the size of an input range.
PushEvent.PushEvent() - Web APIs
example var datainit = { data : 'some sample text' } var mypushevent = new pushevent('push', datainit); mypushevent.data.text(); // should return 'some sample text' browser compatibility the compatibility table on this page is generated from structured data.
PushManager.getSubscription() - Web APIs
example this code snippet is taken from a push messaging and notification sample.
RTCDataChannel.label - Web APIs
example this sample creates a data channel on an rtcpeerconnection, then, some time later, sets the content of a ui element to display the channel's name.
RTCDataChannel.onclose - Web APIs
example in this sample from a hypothetical instant messaging client, a data channel is created, then handlers for the open and close events are set up to enable and disable user interface objects based on the state of the channel.
RTCDataChannel.stream - Web APIs
example var datachannel = pc.createdatachannel("samplechannel"); console.log("data channel stream id: " + datachannel.stream); ...
RTCDataChannelEvent - Web APIs
pc.ondatachannel = function(event) { inbounddatachannel = event.channel; inbounddatachannel.onmessage = handleincomingmessage; inbounddatachannel.onopen = handlechannelopen; inbounddatachannel.onclose = handlechannelclose; } see a simple rtcdatachannel sample for another, more complete, example of how to use data channels.
RTCIceCandidateInit.candidate - Web APIs
that usage would change the above sample to look like this: function goticecandidatemessage(msg) { var icecandidate = new rtcicecandidate(msg.candidate); pc.addicecandidate(icecandidate).catch({ /* handle error */ }); } specifications specification status comment webrtc 1.0: real-time communication between browsersthe definition of 'rtcicecandidateinit.candidate' in that specification.
RTCPeerConnection.addTrack() - Web APIs
example this example is drawn from the code presented in the article signaling and video calling and its corresponding sample code.
RTCPeerConnection.createDataChannel() - Web APIs
ing an agreed-upon id (0 here): // both sides var pc = new rtcpeerconnection(options); var channel = pc.createdatachannel("chat", {negotiated: true, id: 0}); channel.onopen = function(event) { channel.send('hi!'); } channel.onmessage = function(event) { console.log(event.data); } for a more thorough example showing how the connection and channel are established, see a simple rtcdatachannel sample.
RTCStats.timestamp - Web APIs
the timestamp property of the rtcstats dictionary is a domhighrestimestamp object specifying the time at which the data in the object was sampled.
RTCStats - Web APIs
WebAPIRTCStats
timestamp a domhighrestimestamp object indicating the time at which the sample was taken for this statistics object.
RTCStatsReport - Web APIs
timestamp a domhighrestimestamp object indicating the time at which the sample was taken for this statistics object.
Range.selectNodeContents() - Web APIs
example range = document.createrange(); referencenode = document.getelementsbytagname("div")[0]; range.selectnodecontents(referencenode); live sample this example lets the user select and deselect a paragraph with buttons.
RelativeOrientationSensor.RelativeOrientationSensor() - Web APIs
syntax var relativeorientationsensor = new relativeorientationsensor([options]) parameters options optional options are as follows: frequency: the desired number of times per second a sample should be taken, meaning the number of times per second that sensor.onreading will be called.
SVGAElement.target - Web APIs
sample values can be found here example the code is taken from the "svgaelement example code" ...
Using the Screen Capture API - Web APIs
this could be refined further by specifying additional information for each of audio and video: const gdmoptions = { video: { cursor: "always" }, audio: { echocancellation: true, noisesuppression: true, samplerate: 44100 } } in this example the cursor will always be visible in the capture, and the audio track should ideally have noise suppression and echo cancellation features enabled, as well as an ideal audio sample rate of 44.1khz.
SecurityPolicyViolationEvent.SecurityPolicyViolationEvent() - Web APIs
sample: the sample of the securitypolicyviolationevent.
ServiceWorker.onstatechange - Web APIs
} ) examples this code snippet is from the service worker registration-events sample (live demo).
ServiceWorker.state - Web APIs
syntax someurl = serviceworker.state value a serviceworkerstate definition (see the spec.) examples this code snippet is from the service worker registration-events sample (live demo).
ServiceWorker - Web APIs
examples this code snippet is from the service worker registration-events sample (live demo).
ServiceWorkerGlobalScope.onfetch - Web APIs
}; example this code snippet is from the service worker prefetch sample (see prefetch example live.) the serviceworkerglobalscope.onfetch event handler listens for the fetch event.
ServiceWorkerGlobalScope - Web APIs
examples this code snippet is from the service worker prefetch sample (see prefetch example live.) the serviceworkerglobalscope.onfetch event handler listens for the fetch event.
Using Service Workers - Web APIs
let’s start this section by looking at a code sample — this is the first block you’ll find in our service worker: self.addeventlistener('install', (event) => { event.waituntil( caches.open('v1').then((cache) => { return cache.addall([ './sw-test/', './sw-test/index.html', './sw-test/style.css', './sw-test/app.js', './sw-test/image-list.js', './sw-test/star-wars-logo.jpg', './s...
Text.wholeText - Web APIs
WebAPITextwholeText
syntax str = textnode.wholetext; notes and example suppose you have the following simple paragraph within your webpage (with some whitespace added to aid formatting throughout the code samples here), whose dom node is stored in the variable para: <p>thru-hiking is great!
TextEncoder.prototype.encode() - Web APIs
examples <p class="source">this is a sample paragraph.</p> <p class="result">encoded result: </p> const sourcepara = document.queryselector('.source'); const resultpara = document.queryselector('.result'); const string = sourcepara.textcontent; const textencoder = new textencoder(); let encoded = textencoder.encode(string); resultpara.textcontent += encoded; specifications specification status comment encodingthe definition of...
TextEncoder.prototype.encodeInto() - Web APIs
u8array.subarray(position|0) : u8array); if (stats.written < u8array.length) u8array[stats.written] = 0; // append null if room return stats; } examples <p class="source">this is a sample paragraph.</p> <p class="result"></p> const sourcepara = document.queryselector('.source'); const resultpara = document.queryselector('.result'); const string = sourcepara.textcontent; const textencoder = new textencoder(); const utf8 = new uint8array(string.length); let encodedresults = textencoder.encodeinto(string, utf8); resultpara.textcontent += 'bytes read: ' + encodedresults.read + ...
TextTrackList.length - Web APIs
var mediaelem = document.queryselector("video, audio"); var numtexttracks = 0; if (mediaelem.texttracks) { numtexttracks = mediaelem.texttracks.length; } note that this sample checks to be sure htmlmediaelement.texttracks is defined, to avoid failing on browsers without support for texttrack.
VideoTrackList.length - Web APIs
var videoelem = document.queryselector("video"); var numvideotracks = 0; if (videoelem.videotracks) { numvideotracks = videoelem.videotracks.length; } note that this sample checks to be sure htmlmediaelement.videotracks is defined, to avoid failing on browsers without support for videotrack.
Visual Viewport API - Web APIs
example the code below is based on the sample the specification, though it adds a few things that make it function better.
WaveShaperNode.WaveShaperNode() - Web APIs
oversample: specifies what type of oversampling (if any) should be used when applying the shaping curve.
WebGL2RenderingContext.getQueryParameter() - Web APIs
examples var query = gl.createquery(); gl.beginquery(gl.any_samples_passed, query); var result = gl.getqueryparameter(query, gl.query_result); specifications specification status comment webgl 2.0the definition of 'getqueryparameter' in that specification.
WebGLRenderingContext.checkFramebufferStatus() - Web APIs
when using a webgl 2 context, the following values can be returned additionally: gl.framebuffer_incomplete_multisample: the values of gl.renderbuffer_samples are different among attached renderbuffers, or are non-zero if the attached images are a mix of renderbuffers and textures.
WebGLRenderingContext.enableVertexAttribArray() - Web APIs
fer); avertexposition = gl.getattriblocation(shaderprogram, "avertexposition"); gl.enablevertexattribarray(avertexposition); gl.vertexattribpointer(avertexposition, vertexnumcomponents, gl.float, false, 0, 0); gl.drawarrays(gl.triangles, 0, vertexcount); this code snippet is taken from the function animatescene() in "a basic 2d webgl animation example." see that article for the full sample and to see the resulting animation in action.
WebGLRenderingContext.getUniformLocation() - Web APIs
ormlocation(shaderprogram, "uglobalcolor"); urotationvector = gl.getuniformlocation(shaderprogram, "urotationvector") gl.uniform2fv(uscalingfactor, currentscale); gl.uniform2fv(urotationvector, currentrotation); gl.uniform4fv(uglobalcolor, [0.1, 0.7, 0.2, 1.0]); this code snippet is taken from the function animatescene() in "a basic 2d webgl animation example." see that article for the full sample and to see the resulting animation in action.
WebGLRenderingContext - Web APIs
webglrenderingcontext.samplecoverage() specifies multi-sample coverage parameters for anti-aliasing effects.
WebGL by example - Web APIs
next » webgl by example is a series of live samples with short explanations that showcase webgl concepts and capabilities.
Animating objects with WebGL - Web APIs
our sample loads a copy from a cdn in our html's <head>.
Animating textures in WebGL - Web APIs
our sample loads a copy from a cdn in our html's <head>.
Creating 3D objects using WebGL - Web APIs
our sample loads a copy from a cdn in our html's <head>.
Getting started with WebGL - Web APIs
the html fragment below declares a canvas that our sample will draw into.
Using shaders to apply color in WebGL - Web APIs
our sample loads a copy from a cdn in our html's <head>.
WebGL model view projection - Web APIs
the following code sample defines a method on the cubedemo object that will create the model matrix.
Establishing a connection: The WebRTC perfect negotiation pattern - Web APIs
this article introduces webrtc perfect negotiation, describing how it works and why it's the recommended way to negotiate a webrtc connection between peers, and provides sample code to demonstrate the technique.
Signaling and video calling - Web APIs
function handleicegatheringstatechangeevent(event) { // our sample just logs information to console here, // but you can do whatever you need.
Taking still photos with WebRTC - Web APIs
try this sample then read on to learn how it works.
WebRTC API - Web APIs
a simple rtcdatachannel sample the rtcdatachannel interface is a feature which lets you open a channel between two peers over which you may send and receive arbitrary data.
Writing WebSocket client applications - Web APIs
note: the example snippets in this article are taken from our websocket chat client/server sample.
Writing a WebSocket server in C# - Web APIs
this sample code can detect a get from the client.
Inputs and input sources - Web APIs
example this sample code shows a set of squeeze event handlers that implement these events to manage picking up and holding objects from the scene.
Rendering and the WebXR frame animation callback - Web APIs
sample renderer callback let's take a look at some real code that follows this basic pattern.
Starting up and shutting down a WebXR session - Web APIs
for more common causes of reference space resets and more details and sample code, see the documentation for the reset event.
Web Audio API best practices - Web APIs
both are legitimate ways of working, however, it's more common to use the former when you are working with full-length tracks, and the latter when working with shorter, more sample-like tracks.
Using IIR filters - Web APIs
the play button html looks like this: <button class="button-play" role="switch" data-playing="false" aria-pressed="false">play</button> and the click event listener starts like so: playbutton.addeventlistener('click', function() { if (this.dataset.playing === 'false') { srcnode = playsourcenode(audioctx, sample); ...
Window.getComputedStyle() - Web APIs
defaultview in many code samples, getcomputedstyle is used from the document.defaultview object.
XMLDocument.load() - Web APIs
WebAPIXMLDocumentload
examples var xmldoc = document.implementation.createdocument("", "test", null); function documentloaded (e) { alert(new xmlserializer().serializetostring(e.target)); // gives querydata.xml contents as string } xmldoc.addeventlistener("load", documentloaded, false); xmldoc.load('querydata.xml'); see also the load sample in the xml tests directory.
XRBoundedReferenceSpace.boundsGeometry - Web APIs
although some samples render a mesh or other shape to display the bounds to the user, in a real-world application, you shouldn't do this.
Web APIs
WebAPI
webgl_compressed_texture_pvrtc webgl_compressed_texture_s3tc webgl_compressed_texture_s3tc_srgb webgl_debug_renderer_info webgl_debug_shaders webgl_depth_texture webgl_draw_buffers webgl_lose_context wakelock wakelocksentinel waveshapernode webgl2renderingcontext webglactiveinfo webglbuffer webglcontextevent webglframebuffer webglprogram webglquery webglrenderbuffer webglrenderingcontext webglsampler webglshader webglshaderprecisionformat webglsync webgltexture webgltransformfeedback webgluniformlocation webglvertexarrayobject webkitcssmatrix websocket wheelevent window windowclient windoweventhandlers windoworworkerglobalscope worker workerglobalscope workerlocation workernavigator worklet writablestream writablestreamdefaultcontroller writablestreamdefaultwriter x xdomainreq...
ARIA: gridcell role - Accessibility
this sample code demonstrates a table-style grouping of information where the third and fourth columns have been removed.
ARIA: tab role - Accessibility
<div class="tabs"> <div role="tablist" aria-label="sample tabs"> <button role="tab" aria-selected="true" aria-controls="panel-1" id="tab-1" tabindex="0"> first tab </button> <button role="tab" aria-selected="false" aria-controls="panel-2" id="tab-2" tabindex="-1"> second tab </button> <button role="tab" aria-selected="false" aria-controls="panel-3" id="tab-3" tabindex="-1"> third tab </bu...
ARIA: button role - Accessibility
html <button type="button" onclick="handlebtnclick()" onkeydown="handlebtnkeydown()"> mute audio </button> <span role="button" tabindex="0" aria-pressed="false" onclick="handlebtnclick(event)" onkeydown="handlebtnkeydown(event)"> mute audio </span> <audio id="audio" src="https://udn.realityripple.com/samples/41/191d072707.mp3"> your browser does not support the <code>audio</code> element.
ARIA: textbox role - Accessibility
the hint should be a sample value or a brief description of the expected format.this information should not be used as a substitute for a label: a label is focusable, permanent, indicates what kind of information is expected, and increases the hit area for setting focus on the control, whereas placeholder text is only temporary hint about the expected value, which if implemented incorrectly can decrease accessibility.
-moz-force-broken-image-icon - CSS: Cascading Style Sheets
formal definition initial value0applies toimagesinheritednocomputed valueas specifiedanimation typediscrete formal syntax <integer> examples html <img src='/broken/image/link.png' alt='broken image link'> css img { -moz-force-broken-image-icon: 1; height: 100px; width: 100px; } result screenshotlive sample note: unless the image has a specified height and width the broken image icon will not be displayed but the alt attribute will also be hidden if -moz-force-broken-image-icon is set to 1.
-webkit-text-stroke-color - CSS: Cascading Style Sheets
)where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> examples varying the stroke color html <p>text with stroke</p> <input type="color" value="#ff0000"> css p { margin: 0; font-size: 4em; -webkit-text-stroke-width: 3px; -webkit-text-stroke-color: #ff0000; /* can be changed in the live sample */ } javascript var colorpicker = document.queryselector("input"); colorpicker.addeventlistener("change", function(evt) { document.queryselector("p").style.webkittextstrokecolor = evt.target.value; }); results specifications specification status comment compatibility standardthe definition of '-webkit-text-stroke-color' in that specification.
::-moz-list-number - CSS: Cascading Style Sheets
syntax li::-moz-list-number examples html <ol> <li>first item</li> <li>second item</li> <li>third item</li> </ol> css li::-moz-list-number { font-style: italic; font-weight: bold; } result screenshotlive sample specifications not part of any standard.
::-webkit-file-upload-button - CSS: Cascading Style Sheets
screenshotlive sample specifications not part of any standard.
::placeholder - CSS: Cascading Style Sheets
<label for="user-email">your email address</label> <span id="user-email-hint" class="input-hint">example: jane@sample.com</span> <input id="user-email" aria-describedby="user-email-hint" name="email" type="email"> placeholders in form fields are harmful — nielsen norman group windows high contrast mode placeholder text will appear with the same styling as user-entered text content when rendered in windows high contrast mode.
:state() - CSS: Cascading Style Sheets
WebCSS:state
my code block and/or include a list of links to useful code samples that live elsewhere: x y z specifications specification status comment unknownthe definition of 'the :state() selector' in that specification.
@font-face - CSS: Cascading Style Sheets
ttings: <font-variation-settings>; ] | [ font-stretch: <font-stretch>; ] | [ font-weight: <font-weight>; ] | [ font-style: <font-style>; ] }where <family-name> = <string> | <custom-ident>+ examples specifying a downloadable font this example simply specifies a downloadable font to use, applying it to the entire body of the document: view the live example <html> <head> <title>web font sample</title> <style type="text/css" media="screen, print"> @font-face { font-family: "bitstream vera serif bold"; src: url("https://mdn.mozillademos.org/files/2468/verasebd.ttf"); } body { font-family: "bitstream vera serif bold", serif } </style> </head> <body> this is bitstream vera serif bold.
Basic concepts of flexbox - CSS: Cascading Style Sheets
the live sample below contains items that have been given a width, the total width of the items being too wide for the flex container.
Mastering Wrapping of Flex Items - CSS: Cascading Style Sheets
the following live sample uses css grid layout to create a layout that has as many columns of at least 160 pixels as will fit, distributing the extra space between all columns.
Variable fonts guide - CSS: Cascading Style Sheets
h1 { font-family: some-non-variable-font-family; } @supports (font-variation-settings: 'wdth' 115) { h1 { font-family: some-variable-font-family; } } sample pages the following example pages show two different ways to structure your css.
CSS Grid Layout and Progressive Enhancement - CSS: Cascading Style Sheets
grid; grid-template-columns: 1fr 2fr; grid-template-areas: "img content"; margin-bottom: 1em; } .media::after { content: ""; display: block; clear: both; } .media .image { float: left; width: 150px; margin-right: 20px; } .media .text { padding: 10px; align-self: end; } <div class="media"> <div class="image"><img src="https://udn.realityripple.com/samples/89/f993f273dd.png" alt="placeholder"></div> <div class="text">this is a media object example.
Using CSS transitions - CSS: Cascading Style Sheets
hover over the box to see these properties animated.</p> <div class="box">sample</div> </body> css content .box { border-style: solid; border-width: 1px; display: block; width: 100px; height: 100px; background-color: #0000ff; transition: width 2s, height 2s, background-color 2s, transform 2s; } .box:hover { background-color: #ffcccc; width: 200px; height: 200px; transform: rotate(180deg); } when property value lists are of d...
Specificity - CSS: Cascading Style Sheets
<p id="foo">i am a sample text.</p> ...
Cubic Bezier Generator - CSS: Cascading Style Sheets
mentbyid('y2'); x2.value = reversex(x); x2.value = math.round(x2.value * 10000) / 10000; y2.value = reversey(y); y2.value = math.round(y2.value * 10000) / 10000; if (x2.value < 0) { x2.value = 0; } if (x2.value > 1) { x2.value = 1; } } updatecanvas(); } } initcanvas(); updatecanvas(); this is a sample tool; it lets you edit bezier curves.
Tools - CSS: Cascading Style Sheets
WebCSSTools
cubic bezier generatorthis is a sample tool; it lets you edit bezier curves.
align-content - CSS: Cascading Style Sheets
baseline<content-distribution> = space-between | space-around | space-evenly | stretch<overflow-position> = unsafe | safe<content-position> = center | start | end | flex-start | flex-end examples css #container { height:200px; width: 240px; align-content: center; /* can be changed in the live sample */ background-color: #8c8c8c; } .flex { display: flex; flex-wrap: wrap; } .grid { display: grid; grid-template-columns: repeat(auto-fill, 50px); } div > div { box-sizing: border-box; border: 2px solid #8c8c8c; width: 50px; display: flex; align-items: center; justify-content: center; } #item1 { background-color: #8cffa0; min-height: 30px; } #item2 { background-colo...
align-items - CSS: Cascading Style Sheets
baseline<overflow-position> = unsafe | safe<self-position> = center | start | end | self-start | self-end | flex-start | flex-end examples css #container { height:200px; width: 240px; align-items: center; /* can be changed in the live sample */ background-color: #8c8c8c; } .flex { display: flex; flex-wrap: wrap; } .grid { display: grid; grid-template-columns: repeat(auto-fill, 50px); } div > div { box-sizing: border-box; border: 2px solid #8c8c8c; width: 50px; display: flex; align-items: center; justify-content: center; } #item1 { background-color: #8cffa0; min-height: 30px; } #item2 { background-colo...
border-image-repeat - CSS: Cascading Style Sheets
st-letter.inheritednocomputed valueas specifiedanimation typediscrete formal syntax [ stretch | repeat | round | space ]{1,2} examples repeating border images css #bordered { width: 12rem; margin-bottom: 1rem; padding: 1rem; border: 40px solid; border-image: url("https://mdn.mozillademos.org/files/4127/border.png") 27; border-image-repeat: stretch; /* can be changed in the live sample */ } html <div id="bordered">you can try out various border repetition rules on me!</div> <select id="repetition"> <option value="stretch">stretch</option> <option value="repeat">repeat</option> <option value="round">round</option> <option value="space">space</option> <option value="stretch repeat">stretch repeat</option> <option value="space round">space round</option> </select>...
border-image - CSS: Cascading Style Sheets
#bitmap { width: 200px; background-color: #ffa; border: 36px solid orange; margin: 30px; padding: 10px; border-image: url("https://udn.realityripple.com/samples/2c/fa0192d18e.png") /* source */ 27 / /* slice */ 36px 28px 18px 8px / /* width */ 18px 14px 9px 4px /* outset */ round; /* repeat */ } result gradient html <div id="gradient">this element is surrounded by a gradient-based border image!</div> css #gradient { width: 200px; border: 30px solid; border-image: repea...
border-radius - CSS: Cascading Style Sheets
d' */ border-radius: 10px 40px 40px 10px; border: groove 1em red; border-radius: 2em; background: gold; border: ridge gold; border-radius: 13em/3em; border: none; border-radius: 40px 10px; border: none; border-radius: 50%; border: dotted; border-width: 10px 4px; border-radius: 10px 40px; border: dashed; border-width: 2px 4px; border-radius: 40px; live samples sample 1 : http://jsfiddle.net/tripad/qngkj/2/ sample 2 : http://jsfiddle.net/tripad/qngkj/3/ sample 3 : http://jsfiddle.net/tripad/qngkj/4/ sample 4 : http://jsfiddle.net/tripad/qngkj/5/ sample 5 : http://jsfiddle.net/tripad/qngkj/6/ specifications specification status comment css backgrounds and borders module level 3the definition of 'border-radius' in th...
break-inside - CSS: Cascading Style Sheets
fusce iaculis urna id neque dapibus, eu lacinia lectus dictum.</p> <figure> <img src="https://udn.realityripple.com/samples/fe/4508d88f78.png"> <figcaption>the firefox logo — fox wrapped around the world</figcaption> </figure> <p>praesent condimentum dui dui, sit amet rutrum diam tincidunt eu.
clip-path - CSS: Cascading Style Sheets
WebCSSclip-path
% at 25% 25%); } .defs { width: 0; height: 0; margin: 0; } pre { margin-bottom: 0; } svg { margin: 1em; font-family: sans-serif; width: 192px; height: 192px; } svg rect { stroke: pink; stroke-width: 16px; } svg text { fill: pink; text-anchor: middle; } svg text.em { font-style: italic; } complete example html <img id="clipped" src="https://udn.realityripple.com/samples/db/4f9fbd7dfb.svg" alt="mdn logo"> <svg height="0" width="0"> <defs> <clippath id="cross"> <rect y="110" x="137" width="90" height="90"/> <rect x="0" y="110" width="90" height="90"/> <rect x="137" y="0" width="90" height="90"/> <rect x="0" y="0" width="90" height="90"/> </clippath> </defs> </svg> <select id="clippath"> <option value="none">none</option>...
clip - CSS: Cascading Style Sheets
WebCSSclip
sition: relative; width: 536px; height: 350px; } #top-left, #middle, #bottom-right { position: absolute; top: 0; } #top-left { left: 360px; clip: rect(0 175px 113px 0); } #middle { left: 280px; clip: rect(119px 255px 229px 80px); } #bottom-right { left: 200px; clip: rect(235px 335px 345px 160px); } html <p class="dotted-border"> <img src="https://udn.realityripple.com/samples/8f/15174f3500.jpg" title="original graphic"> <img id="top-left" src="https://udn.realityripple.com/samples/8f/15174f3500.jpg" title="graphic clipped to upper left"> <img id="middle" src="https://udn.realityripple.com/samples/8f/15174f3500.jpg" title="graphic clipped towards middle"> <img id="bottom-right" src="https://udn.realityripple.com/samples/8f/15174f3500.jpg" title="graphic clipped ...
hue-rotate() - CSS: Cascading Style Sheets
syntax hue-rotate(angle) parameters angle the relative change in hue of the input sample, specified as an <angle>.
invert() - CSS: Cascading Style Sheets
the invert() css function inverts the color samples in the input image.
opacity() - CSS: Cascading Style Sheets
the opacity() css function applies transparency to the samples in the input image.
image-orientation - CSS: Cascading Style Sheets
flip ] examples orienting image from image data css #image { image-orientation: from-image; /* can be changed in the live sample */ } html <img id="image" src="https://udn.realityripple.com/samples/db/4f9fbd7dfb.svg" alt="orientation taken from the image"> <select id="imageorientation"> <option value="from-image">from-image</option> <option value="none">none</option> </select> javascript var imageorientation = document.getelementbyid("imageorientation"); imageorientation.addeventlistener("change", function (...
image-rendering - CSS: Cascading Style Sheets
<div> <img class="auto" alt="auto" src="https://udn.realityripple.com/samples/de/cedd397be3.jpg" /> <img class="pixelated" alt="pixelated" src="https://udn.realityripple.com/samples/de/cedd397be3.jpg" /> <img class="crisp-edges" alt="crisp-edges" src="https://udn.realityripple.com/samples/de/cedd397be3.jpg" /> </div> img { height: 200px; } css .auto { image-rendering: auto; } .pixelated { -ms-interpolation-mode: nearest-neighbor; image-rendering: pixe...
justify-content - CSS: Cascading Style Sheets
[ <content-position> | left | right ]where <content-distribution> = space-between | space-around | space-evenly | stretch<overflow-position> = unsafe | safe<content-position> = center | start | end | flex-start | flex-end examples setting flex item distribution css #container { display: flex; justify-content: space-between; /* can be changed in the live sample */ } #container > div { width: 100px; height: 100px; background: linear-gradient(-45deg, #788cff, #b4c8ff); } html <div id="container"> <div></div> <div></div> <div></div> </div> <select id="justifycontent"> <option value="start">start</option> <option value="end">end</option> <option value="flex-start">flex-start</option> <option value="flex-end">flex-end</option> <opt...
mask-clip - CSS: Cascading Style Sheets
WebCSSmask-clip
> | margin-boxwhere <box> = border-box | padding-box | content-box examples clipping a mask to the border box css #masked { width: 100px; height: 100px; background-color: #8cffa0; margin: 20px; border: 20px solid #8ca0ff; padding: 20px; mask-image: url(https://mdn.mozillademos.org/files/12668/mdn.svg); mask-size: 100% 100%; mask-clip: border-box; /* can be changed in the live sample */ } html <div id="masked"> </div> <select id="clipbox"> <option value="content-box">content-box</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box...
mask-composite - CSS: Cascading Style Sheets
ositing-operator> = add | subtract | intersect | exclude examples compositing mask layers with addition css #masked { width: 100px; height: 100px; background-color: #8cffa0; mask-image: url(https://mdn.mozillademos.org/files/12668/mdn.svg), url(https://mdn.mozillademos.org/files/12676/star.svg); mask-size: 100% 100%; mask-composite: add; /* can be changed in the live sample */ } html <div id="masked"> </div> <select id="compositemode"> <option value="add">add</option> <option value="subtract">subtract</option> <option value="intersect">intersect</option> <option value="exclude">exclude</option> </select> javascript var clipbox = document.getelementbyid("compositemode"); clipbox.addeventlistener("change", function (evt) { document.getelementbyid("mas...
mask-mode - CSS: Cascading Style Sheets
WebCSSmask-mode
ementsinheritednocomputed valueas specifiedanimation typediscrete formal syntax <masking-mode>#where <masking-mode> = alpha | luminance | match-source examples using alpha mask mode css #masked { width: 227px; height: 200px; background: blue linear-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12668/mdn.svg); mask-mode: alpha; /* can be changed in the live sample */ } html <div id="masked"> </div> <select id="maskmode"> <option value="alpha">alpha</option> <option value="luminance">luminance</option> <option value="match-source">match-source</option> </select> javascript var maskmode = document.getelementbyid("maskmode"); maskmode.addeventlistener("change", function (evt) { document.getelementbyid("masked").style.maskmode = evt.target.value...
mask-origin - CSS: Cascading Style Sheets
here <shape-box> = <box> | margin-boxwhere <box> = border-box | padding-box | content-box examples setting mask origin to border-box css #masked { width: 100px; height: 100px; margin: 10px; border: 10px solid blue; background-color: #8cffa0; padding: 10px; mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-origin: border-box; /* can be changed in the live sample */ } html <div id="masked"> </div> <select id="origin"> <option value="content-box">content-box</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box<...
mask-position - CSS: Cascading Style Sheets
ngth-percentage> = <length> | <percentage> examples setting mask position css #wrapper { border: 1px solid black; width: 250px; height: 250px; } #masked { width: 250px; height: 250px; background: blue linear-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-repeat: no-repeat; mask-position: top right; /* can be changed in the live sample */ margin-bottom: 10px; } html <div id="wrapper"> <div id="masked"> </div> </div> <select id="maskposition"> <option value="top">top</option> <option value="center">center</option> <option value="bottom">bottom</option> <option value="top right" selected>top right</option> <option value="center center">center center</option> <option value="bottom left">bottom left</option> ...
mask-repeat - CSS: Cascading Style Sheets
tion typediscrete formal syntax <repeat-style>#where <repeat-style> = repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2} examples setting repeat for a single mask css #masked { width: 250px; height: 250px; background: blue linear-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-repeat: repeat; /* can be changed in the live sample */ margin-bottom: 10px; } html content <div id="masked"> </div> <select id="repetition"> <option value="repeat-x">repeat-x</option> <option value="repeat-y">repeat-y</option> <option value="repeat" selected>repeat</option> <option value="space">space</option> <option value="round">round</option> <option value="no-repeat">no-repeat</option> </select> javascript content var rep...
mask-size - CSS: Cascading Style Sheets
WebCSSmask-size
h-percentage> = <length> | <percentage> examples setting mask size as a percentage css #masked { width: 200px; height: 200px; background: blue linear-gradient(red, blue); -webkit-mask-image: url(https://mdn.mozillademos.org/files/12668/mdn.svg); mask-image: url(https://mdn.mozillademos.org/files/12668/mdn.svg); -webkit-mask-size: 50%; mask-size: 50%; /* can be changed in the live sample */ margin-bottom: 10px; } html <div id="masked"> </div> <select id="masksize"> <option value="auto">auto</option> <option value="40% 80%">40% 80%</option> <option value="50%" selected>50%</option> <option value="200px 100px">200px 100px</option> <option value="cover">cover</option> <option value="contain">contain</option> </select> javascript var masksize = document.getelemen...
object-position - CSS: Cascading Style Sheets
<img id="object-position-1" src="https://udn.realityripple.com/samples/db/4f9fbd7dfb.svg" alt="mdn logo"/> <img id="object-position-2" src="https://udn.realityripple.com/samples/db/4f9fbd7dfb.svg" alt="mdn logo"/> css the css includes default styling for the <img> element itself, as well as separate styles for each of the two images.
offset-path - CSS: Cascading Style Sheets
| [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]<box> = border-box | padding-box | content-box examples animating an element with offset-path the offset-path properties in the css code sample defines a motion path that is identical to the <path> element in the svg.
place-content - CSS: Cascading Style Sheets
tingmode = evt.target.value; }); var direction = document.getelementbyid("direction"); direction.addeventlistener("change", function (evt) { document.getelementbyid("container").style.direction = evt.target.value; }); css #container { display: flex; height:240px; width: 240px; flex-wrap: wrap; background-color: #8c8c8c; writing-mode: horizontal-tb; /* can be changed in the live sample */ direction: ltr; /* can be changed in the live sample */ place-content: flex-end center; /* can be changed in the live sample */ } div > div { border: 2px solid #8c8c8c; width: 50px; background-color: #a0c8ff; } .small { font-size: 12px; height: 40px; } .large { font-size: 14px; height: 50px; } result specifications specification status comment ...
position - CSS: Cascading Style Sheets
WebCSSposition
overflowing inline elements <span>wrap onto a new line if possible — like this one containing text</span>, or just go on to a new line if not, much like this image will do: <img src="https://udn.realityripple.com/samples/9e/6ff6af6fd4.jpg"></p> css body { width: 500px; margin: 0 auto; } p { background: aqua; border: 3px solid blue; padding: 10px; margin: 10px; } span { background: red; border: 1px solid black; } .positioned { position: absolute; background: yellow; top: 30px; left: 30px; } result fixed positioning fixed positioning is similar to absolute positioning, with the ex...
transform-origin - CSS: Cascading Style Sheets
xcomputed valuefor <length> the absolute value, otherwise a percentageanimation typesimple list of length, percentage, or calc formal syntax [ <length-percentage> | left | center | right | top | bottom ] | [ [ <length-percentage> | left | center | right ] && [ <length-percentage> | top | center | bottom ] ] <length>?where <length-percentage> = <length> | <percentage> examples code sample transform: none; <div class="box1">&nbsp;</div> .box1 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform: none; -webkit-transform: none; } transform: rotate(30deg); <div class="box2">&nbsp;</div> .box2 { margin: 0.5em; width: 3em; height: 3em; border: soli...
Event reference
mozaudioavailable event mozilla specific the audio buffer is full and the corresponding raw samples are available.
Cross-browser audio basics - Developer guides
an audio player with feedback consider this snippet of html: <audio id="my-audio"> <source src="https://udn.realityripple.com/samples/6c/d385042de2.mp3" type="audio/mpeg"> <source src="https://udn.realityripple.com/samples/28/191a7bd2a5.ogg" type="audio/ogg"> <!-- place fallback here as <audio> supporting browsers will ignore it --> <a href="audiofile.mp3">audiofile.mp3</a> </audio> <div id="controls"> <span id="loading">loading</span> <button id="play" style="display:none">play</button> <button id="pause" style="...
Web Audio playbackRate explained - Developer guides
next we set playbackrate to 0.5, which represents half normal speed (the playbackrate is a multiplier applied to the original rate.) a complete example let's create a <video> element first, and set up video and playback rate controls in html: <video id="myvideo" controls> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type='video/mp4' /> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type='video/webm' /> </video> <form> <input id="pbr" type="range" value="1" min="0.5" max="4" step="0.1" > <p>playback rate <span id="currentpbr">1</span></p> </form> and apply some javascript to it: window.onload = function () { var v = document.getelementbyid("myvideo"); ...
Writing Web Audio API code that works in every browser - Developer guides
you can also check this article on porting which covers more cases and has many code samples.
Creating a cross-browser video player - Developer guides
var setfullscreendata = function(state) { videocontainer.setattribute('data-fullscreen', !!state); } this is used simply to set some basic css to improve the styling of the custom controls when they are in fullscreen (see the sample code for further details).
Challenge solutions - Developer guides
solution the following rule achieves this effect: ul { border: 10px solid lightblue; width: 100px; } layout default image position fixed image position challenge change your sample document, doc2.html, adding this tag to it near the end, just before </body>: <img id="fixed-pin" src="yellow-pin.png" alt="yellow map pin"> predict where the image will appear in your document.
Media events - Developer guides
mozaudioavailable sent when an audio buffer is provided to the audio layer for processing; the buffer contains raw audio samples that may or may not already have been played by the time you receive the event.
Rich-Text Editing in Mozilla - Developer guides
er; } img.intlink { border: 0; } #toolbar1 select { font-size:10px; } #textbox { width: 540px; height: 200px; border: 1px #000000 solid; padding: 12px; overflow: scroll; } #textbox #sourcetext { padding: 0; margin: 0; min-width: 498px; min-height: 200px; } #editmode label { cursor: pointer; } </style> </head> <body onload="initdoc();"> <form name="compform" method="post" action="sample.php" onsubmit="if(validatemode()){this.mydoc.value=odoc.innerhtml;return true;}return false;"> <input type="hidden" name="mydoc"> <div id="toolbar1"> <select onchange="formatdoc('formatblock',this[this.selectedindex].value);this.selectedindex=0;"> <option selected>- formatting -</option> <option value="h1">title 1 &lt;h1&gt;</option> <option value="h2">title 2 &lt;h2&gt;</option> <option value="h...
Making content editable - Developer guides
er; } img.intlink { border: 0; } #toolbar1 select { font-size:10px; } #textbox { width: 540px; height: 200px; border: 1px #000000 solid; padding: 12px; overflow: scroll; } #textbox #sourcetext { padding: 0; margin: 0; min-width: 498px; min-height: 200px; } #editmode label { cursor: pointer; } </style> </head> <body onload="initdoc();"> <form name="compform" method="post" action="sample.php" onsubmit="if(validatemode()){this.mydoc.value=odoc.innerhtml;return true;}return false;"> <input type="hidden" name="mydoc"> <div id="toolbar1"> <select onchange="formatdoc('formatblock',this[this.selectedindex].value);this.selectedindex=0;"> <option selected>- formatting -</option> <option value="h1">title 1 &lt;h1&gt;</option> <option value="h2">title 2 &lt;h2&gt;</option> <option value="h...
Parsing and serializing XML - Developer guides
"error while parsing" : odom.documentelement.nodename); parsing url-addressable resources into dom trees using xmlhttprequest here is sample code that reads and parses a url-addressable xml file into a dom tree: var xhr = new xmlhttprequest(); xhr.onload = function() { dump(xhr.responsexml.documentelement.nodename); } xhr.onerror = function() { dump("error while getting xml."); } xhr.open("get", "example.xml"); xhr.responsetype = "document"; xhr.send(); the value returned in the xhr object's responsexml field is a document cons...
<area> - HTML: Hypertext Markup Language
WebHTMLElementarea
the html specification defines it as valid, but the canonical html specification doesn’t, and it has no effect in any user agents.) examples <map name="primary"> <area shape="circle" coords="75,75,75" href="left.html" alt="click to go left"> <area shape="circle" coords="275,75,75" href="right.html" alt="click to go right"> </map> <img usemap="#primary" src="https://udn.realityripple.com/samples/6a/7e559101b3.png" alt="350 x 150 pic"> result specifications specification status comment referrer policythe definition of 'referrerpolicy attribute' in that specification.
<caption>: The Table Caption element - HTML: Hypertext Markup Language
WebHTMLElementcaption
<table> <caption>example caption</caption> <tr> <th>login</th> <th>email</th> </tr> <tr> <td>user1</td> <td>user1@sample.com</td> </tr> <tr> <td>user2</td> <td>user2@sample.com</td> </tr> </table> caption { caption-side: top; align: right; } table { border-collapse: collapse; border-spacing: 0px; } table, th, td { border: 1px solid black; } table {background: red;} do not alter caption.
<figure>: The Figure with Optional Caption element - HTML: Hypertext Markup Language
WebHTMLElementfigure
examples images <!-- just an image --> <figure> <img src="https://udn.realityripple.com/samples/6c/98485e5d8a.png" alt="the beautiful mdn logo."> </figure> <!-- image with a caption --> <figure> <img src="https://udn.realityripple.com/samples/6c/98485e5d8a.png" alt="the beautiful mdn logo."> <figcaption>mdn logo</figcaption> </figure> code snippets <figure> <figcaption>get browser details using <code>navigator</code>.</figcaption> <pre> function navigatorexample() { v...
<iframe>: The Inline Frame element - HTML: Hypertext Markup Language
WebHTMLElementiframe
html <iframe src="https://mdn-samples.mozilla.org/snippets/html/iframe-simple-contents.html" title="iframe example 1" width="400" height="300"> </iframe> result accessibility concerns people navigating with assistive technology such as a screen reader can use the title attribute on an <iframe> to label its content.
<kbd>: The Keyboard Input element - HTML: Hypertext Markup Language
WebHTMLElementkbd
<kbd> may be nested in various combinations with the <samp> (sample output) element to represent various forms of input or output based on visual cues.
<map> - HTML: Hypertext Markup Language
WebHTMLElementmap
examples <map name="primary"> <area shape="circle" coords="75,75,75" href="left.html"> <area shape="circle" coords="275,75,75" href="right.html"> </map> <img usemap="#primary" src="https://udn.realityripple.com/samples/6a/7e559101b3.png" alt="350 x 150 pic"> result expected live example output the live example above should appear similar to the following images (when using your keyboard tab key): for the left.html link: for the right.html link specifications specification status comment html living standardthe definition of '<map>' in that specification.
<var>: The Variable element - HTML: Hypertext Markup Language
WebHTMLElementvar
usage notes related elements other elements that are used in contexts in which <var> is commonly used include: <code>: the html code element <kbd>: the html keyboard input element <samp>: the html sample output element if you encounter code that is mistakenly using <var> for style purposes rather than semantic purposes, you should either use a <span> with appropriate css or, an appropriate semantic element among the following: <em> <i> <q> default style most browsers apply font-style to "italic" when rendering <var>.
HTML elements reference - HTML: Hypertext Markup Language
WebHTMLElement
<samp> the html sample element (<samp>) is used to enclose inline text which represents sample (or quoted) output from a computer program.
contextmenu - HTML: Hypertext Markup Language
</li> <menu type="context" id="changefont"> <menuitem label="increase font" onclick="incfont()"></menuitem> <menuitem label="decrease font" onclick="decfont()"></menuitem> </menu> <li contextmenu="changeimage" id="changeimage"> on the image below, you can fire the "change image" action in your context menu.<br /> <img src="https://udn.realityripple.com/samples/a2/b601bdfc0c.png" contextmenu="changeimage" id="promobutton" /> <menu type="context" id="changeimage"> <menuitem label="change image" onclick="changeimage()"></menuitem> </menu> </li> </ol> </body> javascript function shareviatwitter() { window.open("https://twitter.com/intent/tweet?text=" + "hurray!
itemscope - HTML: Hypertext Markup Language
<div itemscope itemtype="http://schema.org/recipe"> <h2 itemprop="name">grandma's holiday apple pie</h2> <img itemprop="image" src="https://udn.realityripple.com/samples/60/d063c361c1.jpg" width="50" height="50" /> <p> by <span itemprop="author" itemscope itemtype="http://schema.org/person"> <span itemprop="name">carol smith</span> </span> </p> <p> published: <time datetime="2009-11-05" itemprop="datepublished">november 5, 2009</time> </p> <span itemprop="description">this is my grandmother's apple pie recipe.
itemtype - HTML: Hypertext Markup Language
data itemscope itemtype schema.org product itemprop name executive anvil itemprop brand [thing] itemprop name acme example html <div itemscope itemtype="http://schema.org/product"> <span itemprop="brand">acme<br></span> <span itemprop="name">executive anvil<br></span> <img itemprop="image" src="https://udn.realityripple.com/samples/61/fa8ee62aba.png" width="50" height="50" alt="executive anvil logo" /><br> <span itemprop="description">sleeker than acme's classic anvil, the executive anvil is perfect for the business traveler looking for something to drop from a height.
HTML documentation index - HTML: Hypertext Markup Language
WebHTMLIndex
186 <samp>: the sample output element element, html, html text-level semantics, inline sample, reference, sample output, sample text, web the html sample element (<samp>) is used to enclose inline text which represents sample (or quoted) output from a computer program.
MIME types (IANA media types) - HTTP
these should never be used outside of sample code listings and documentation.
Cross-Origin Resource Sharing (CORS) - HTTP
WebHTTPCORS
here is a sample exchange between client and server: get /resources/credentialed-content/ http/1.1 host: bar.other user-agent: mozilla/5.0 (macintosh; intel mac os x 10.14; rv:71.0) gecko/20100101 firefox/71.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip,deflate connection: keep-alive referer: http://foo.example/examples/credential.
Configuring servers for Ogg media - HTTP
age, 27.508% ogg overhead presentation-time: 0.000 basetime: 0.000 theora: serialno 0170995062 1790 packets in 1068 pages, 1.7 packets/page, 1.049% ogg overhead video-framerate: 29.983 fps video-width: 640 video-height: 360 vorbis: serialno 0708996688 4531 packets in 167 pages, 27.1 packets/page, 1.408% ogg overhead audio-samplerate: 44100 hz audio-channels: 2 note that you can't simply serve up the reported content-duration line reported by oggz-info, because it's reported in hh:mm:ss format.
Using HTTP cookies - HTTP
WebHTTPCookies
get /sample_page.html http/2.0 host: www.example.org cookie: yummy_cookie=choco; tasty_cookie=strawberry note: here's how to use the set-cookie header in various server-side applications: php node.js python ruby on rails define the lifetime of a cookie the lifetime of a cookie can be defined in two ways: session cookies are deleted when the current session ends.
CSP: base-uri - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: default-src - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: form-action - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: img-src - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: navigate-to - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: script-src-attr - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: script-src-elem - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: script-src - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: style-src-attr - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
CSP: style-src-elem - HTTP
'report-sample' requires a sample of the violating code to be included in the violation report.
Firefox user agent string reference - HTTP
other gecko-based browsers these are some sample ua strings from other gecko-based browsers on various platforms.
Enumerability and ownership of properties - JavaScript
some sample code follows which demonstrates how to obtain the missing categories.
Expressions and operators - JavaScript
the following table describes the comparison operators in terms of this sample code: var var1 = 3; var var2 = 4; comparison operators operator description examples returning true equal (==) returns true if the operands are equal.
constructor - JavaScript
examples using the constructor method this code snippet is taken from the classes sample (live demo).
Arrow function expressions - JavaScript
this code sample using chrome 81 demonstrates that arrow functions allow the creation of global variables in such situations (both for a concise body and for a normal function body): > f1 = x => { y = x; console.log(`x: ${x}, y: ${y}`); return x + 1; } x => { y = x; console.log(`x: ${x}, y: ${y}`); return x + 1; } > y vm51587:1 uncaught referenceerror: y is not defined at <anonymous>:1:1 (anonymous) @ vm515...
Object.create() - JavaScript
using propertiesobject argument with object.create() var o; // create an object with null as prototype o = object.create(null); o = {}; // is equivalent to: o = object.create(object.prototype); // example where we create an object with a couple of // sample properties.
Proxy - JavaScript
.log(products['firefox']); // { name: 'firefox', type: 'browser' } console.log(products['chrome']); // undefined console.log(products.browser); // [{ name: 'firefox', type: 'browser' }, { name: 'seamonkey', type: 'browser' }] console.log(products.types); // ['browser', 'mailer'] console.log(products.number); // 3 a complete traps list example now in order to create a complete sample traps list, for didactic purposes, we will try to proxify a non-native object that is particularly suited to this type of operation: the doccookies global object created by the "little framework" published on the document.cookie page.
super - JavaScript
examples using super in classes this code snippet is taken from the classes sample (live demo).
<menclose> - MathML
possible values are: value sample rendering rendering in your browser description longdiv (default) a2 + b2 long division symbol actuarial a2 + b2 actuarial symbol radical a2 + b2 square root symbol.
<mfenced> - MathML
examples the last separator is repeated (,) sample rendering: rendering in your browser: a b c d e <math> <mfenced open="{" close="}" separators=";;,"> <mi>a</mi> <mi>b</mi> <mi>c</mi> <mi>d</mi> <mi>e</mi> </mfenced> </math> all excess is ignored (,) sample rendering: rendering in your browser: a b c d e <math> <mfenced open="[" close="]" separators="||||,"> <mi>a</mi> <mi>b</mi> <mi>c</mi> ...
<mfrac> - MathML
WebMathMLElementmfrac
examples sample rendering: your browser rendering: a b c d <math> <mfrac bevelled="true"> <mfrac> <mi> a </mi> <mi> b </mi> </mfrac> <mfrac> <mi> c </mi> <mi> d </mi> </mfrac> </mfrac> </math> specifications specification status comment mathml 3.0the definition of 'mfrac' in that specification.
<mmultiscripts> - MathML
examples using <mprescripts/> sample rendering: rendering in your browser: x d c b a <math> <mmultiscripts> <mi>x</mi> <!-- base expression --> <mi>d</mi> <!-- postsubscript --> <mi>c</mi> <!-- postsuperscript --> <mprescripts /> <mi>b</mi> <!-- presubscript --> <mi>a</mi> <!-- presuperscript --> </mmultiscripts> </math> using <none/> s...
<mover> - MathML
WebMathMLElementmover
examples sample rendering: rendering in your browser: x + y + z ⏞ <math> <mover accent="true"> <mrow> <mi> x </mi> <mo> + </mo> <mi> y </mi> <mo> + </mo> <mi> z </mi> </mrow> <mo> &#x23de; <!--top curly bracket--> </mo> </mover> </math> specifications specification status comment mathml 3.0the definition of 'mover' in that specific...
<mphantom> - MathML
examples sample rendering: rendering in your browser: x + y + z <math> <mrow> <mi> x </mi> <mo> + </mo> <mphantom> <mi> y </mi> <mo> + </mo> </mphantom> <mi> z </mi> </mrow> </math> specifications specification status comment mathml 3.0the definition of 'mphantom' in that specification.
<mroot> - MathML
WebMathMLElementmroot
examples sample rendering: rendering in your browser: x 3 <math> <mroot> <mi>x</mi> <mn>3</mn> </mroot> </math> specifications specification status comment mathml 3.0the definition of 'mroot' in that specification.
<msqrt> - MathML
WebMathMLElementmsqrt
examples sample rendering: rendering in your browser: x <math> <msqrt> <mi>x</mi> </msqrt> </math> specifications specification status comment mathml 3.0the definition of 'msqrt' in that specification.
<msub> - MathML
WebMathMLElementmsub
examples sample rendering: rendering in your browser: x 1 <math> <msub> <mi>x</mi> <mn>1</mn> </msub> </math> specifications specification status comment mathml 3.0the definition of 'msub' in that specification.
<msubsup> - MathML
examples sample rendering: rendering in your browser: ∫ 0 1 <math displaystyle="true"> <msubsup> <mo> &#x222b;<!--integral --> </mo> <mn> 0 </mn> <mn> 1 </mn> </msubsup> </math> specifications specification status comment mathml 3.0the definition of 'msubsup' in that specification.
<msup> - MathML
WebMathMLElementmsup
examples sample rendering: rendering in your browser: x 2 <math> <msup> <mi>x</mi> <mn>2</mn> </msup> </math> specifications specification status comment mathml 3.0the definition of 'msup' in that specification.
<munder> - MathML
WebMathMLElementmunder
examples sample rendering: rendering in your browser: x + y + z ⏟ <math> <munder accentunder="true"> <mrow> <mi> x </mi> <mo> + </mo> <mi> y </mi> <mo> + </mo> <mi> z </mi> </mrow> <mo> &#x23df; <!--bottom curly bracket--> </mo> </munder> </math> specifications specification status comment mathml 3.0the definition of 'munder' in th...
<munderover> - MathML
examples sample rendering: rendering in your browser: ∫ 0 ∞ <math displaystyle="true"> <munderover > <mo> &#x222b; <!--integral--> </mo> <mn> 0 </mn> <mi> &#x221e; <!--infinity--> </mi> </munderover> </math> specifications specification status comment mathml 3.0the definition of 'munderover' in that specification.
MathML
mathml examples mathml samples and examples to help you understand how it works.
Media container formats (file types) - Web media technologies
wave is good but uncompressed, so be aware of that before using it for large audio samples.
Media type and format guide: image, audio, and video content - Web media technologies
WebMediaFormats
it explains basic concepts about how audio is sampled, as well as concepts such as sample rate, audio frames, and audio compression.
Add to Home screen - Progressive web apps (PWAs)
the manifest for our sample app looks like this: { "background_color": "purple", "description": "shows random fox pictures.
Structural overview of progressive web apps - Progressive web apps (PWAs)
structure of a sample application the js13kpwa web site's structure is quite simple.
<animateTransform> - SVG: Scalable Vector Graphics
ww.w3.org/2000/svg"> <polygon points="60,30 90,90 30,90"> <animatetransform attributename="transform" attributetype="xml" type="rotate" from="0 60 70" to="360 60 70" dur="10s" repeatcount="indefinite"/> </polygon> </svg> live sample attributes global attributes conditional processing attributes » core attributes » animation event attributes » xlink attributes » animation attribute target attributes » animation timing attributes » animation value attributes » animation addition attributes » externalresourcesrequired specific attributes by from to type dom interface this element implements the...
<feColorMatrix> - SVG: Scalable Vector Graphics
sform="translate(0 280)" filter="url(#colormehuerotate)" /> <text x="70" y="330">huerotate</text> <!-- luminancetoalpha --> <filter id="colormelta"> <fecolormatrix in="sourcegraphic" type="luminancetoalpha" /> </filter> <use href="#circles" transform="translate(0 350)" filter="url(#colormelta)" /> <text x="70" y="400">luminancetoalpha</text> </svg> result screenshotlive sample specifications specification status comment filter effects module level 1the definition of '<fecolormatrix>' in that specification.
<filter> - SVG: Scalable Vector Graphics
WebSVGElementfilter
example svg <svg width="230" height="120" xmlns="http://www.w3.org/2000/svg"> <filter id="blurme"> <fegaussianblur stddeviation="5"/> </filter> <circle cx="60" cy="60" r="50" fill="green" /> <circle cx="170" cy="60" r="50" fill="green" filter="url(#blurme)" /> </svg> result screenshotlive sample specifications specification status comment filter effects module level 1the definition of '<filter>' in that specification.
SVG documentation index - SVG: Scalable Vector Graphics
WebSVGIndex
274 fills and strokes beginner, needlivesamples, svg, svg:tutorial there are several ways to color shapes (including specifying attributes on the object) using inline css, an embedded css section, or an external css file.
SVG animation with SMIL - SVG: Scalable Vector Graphics
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="100"> <title>svg smil animate with path</title> <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" /> <circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1"> <animatemotion path="m 0 0 h 300 z" dur="3s" repeatcount="indefinite" /> </circle> </svg> view live sample example 2: curved motion same example as before with a curved path and following the direction of the path.
Other content in SVG - SVG: Scalable Vector Graphics
that you can use clips, masks, filters, rotations and all other tools of svg on the content: <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"> <image x="90" y="-65" width="128" height="146" transform="rotate(45)" xlink:href="https://developer.mozilla.org/static/img/favicon144.png"/> </svg> screenshotlive sample embedding arbitrary xml since svg is an xml application, you can of course always embed arbitrary xml anywhere in an svg document.
Patterns - SVG: Scalable Vector Graphics
WebSVGTutorialPatterns
<pattern id="pattern" x="0" y="0" width=".25" height=".25"> <rect x="0" y="0" width="50" height="50" fill="skyblue"/> <rect x="0" y="0" width="25" height="25" fill="url(#gradient2)"/> <circle cx="25" cy="25" r="20" fill="url(#gradient1)" fill-opacity="0.5"/> </pattern> </defs> <rect fill="url(#pattern)" stroke="black" width="200" height="200"/> </svg> screenshotlive sample inside the <pattern> element, you can include any of the other basic shapes you've included before, and each of them can be styled using any of the styles you've learned before, including gradients and opacity.
Using templates and slots - Web Components
screenshotlive sample notice the following points about this rendered result: even though the instances of the <element-details> element in the document do not directly use the <details> element, they get rendered using <details> because the shadow root causes them to get populated with that.
XPath snippets - XPath
sample usage assume we have the following xml document (see also how to create a dom tree and parsing and serializing xml): example: an xml document to use with the custom evaluatexpath() utility function <?xml version="1.0"?> <people> <person first-name="eric" middle-initial="h" last-name="jung"> <address street="321 south st" city="denver" state="co" country="usa"/> <address street="123 ...
Index - XSLT: Extensible Stylesheet Language Transformations
WebXSLTIndex
15 for further reading needscontent, needshelp, transforming_xml_with_xslt, xml, xslt http://www.amazon.com/xslt-programme.../dp/0764543814 16 resources extensions, needscontent, needsexample, needslivesample, xml, xsl no summary!
WebAssembly Concepts - WebAssembly
you can get started with installing the necessary toolchain, compiling a sample rust program to a webassembly npm package, and using that in a sample web app, over at our compiling from rust to webassembly article.
Compiling from Rust to WebAssembly - WebAssembly
open this file, and change its contents to look like this: [package] name = "hello-wasm" version = "0.1.0" authors = ["your name <you@example.com>"] description = "a sample project with wasm-pack" license = "mit/apache-2.0" repository = "https://github.com/yourgithubusername/hello-wasm" [lib] crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2" fill in your own repository and use the same info that git uses for the authors field.