snipt

Ctrl+h for KB shortcuts

JavaScript

companion cube

1
2
3
4
5
$('#emergencyIntelligenceIncinerator').bind('textchange', function () {
  if ($(this).val().indexOf('companion cube') !== -1) {
    $('#continue').removeClass('disabled').attr('disabled', false);
  }
});
https://snipt.net/embed/00ebaea179ea1eebf9d6ff69f528e76d/
/raw/00ebaea179ea1eebf9d6ff69f528e76d/
00ebaea179ea1eebf9d6ff69f528e76d
js
JavaScript
5
2019-07-22T11:46:43
True
False
False
/api/public/snipt/15324/
companion-cube
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#emergencyIntelligenceIncinerator&#39;</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;textchange&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">().</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;companion cube&#39;</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#continue&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span> </span><span id="L-5"><a name="L-5"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
js

JavaScript

twitter text change

1
2
3
$('#twitter').bind('textchange', function (event, previousText) {
  $('#charactersLeft').html( 140 - parseInt($(this).val().length) );
});
https://snipt.net/embed/3dfec7d8c30699642d994102296ad5ef/
/raw/3dfec7d8c30699642d994102296ad5ef/
3dfec7d8c30699642d994102296ad5ef
js
JavaScript
3
2019-07-22T12:43:56
True
False
False
/api/public/snipt/15322/
twitter-text-change
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#twitter&#39;</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;textchange&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="nx">previousText</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#charactersLeft&#39;</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span> <span class="mi">140</span> <span class="o">-</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">().</span><span class="nx">length</span><span class="p">)</span> <span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
js

JavaScript

exhibitb

1
2
3
4
5
$('#exhibitb').bind('textchange', function (event, previousText) {
  $('#output').append('<p>Text changed from <strong>' + 
    previousText + '</strong> to <strong>' + $(this).val() + 
    '</strong> </p>');
});
https://snipt.net/embed/8ebd2cf661571b465f78a1f67e8652ee/
/raw/8ebd2cf661571b465f78a1f67e8652ee/
8ebd2cf661571b465f78a1f67e8652ee
js
JavaScript
5
2019-07-15T05:40:48
True
False
False
/api/public/snipt/15321/
exhibitb
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#exhibitb&#39;</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;textchange&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="nx">previousText</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#output&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;&lt;p&gt;Text changed from &lt;strong&gt;&#39;</span> <span class="o">+</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">previousText</span> <span class="o">+</span> <span class="s1">&#39;&lt;/strong&gt; to &lt;strong&gt;&#39;</span> <span class="o">+</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">()</span> <span class="o">+</span> </span><span id="L-4"><a name="L-4"></a> <span class="s1">&#39;&lt;/strong&gt; &lt;/p&gt;&#39;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
js

JavaScript

textchange link

<script src="/javascripts/plugins/jquery.textchange.js"></script>
https://snipt.net/embed/116857fa9daaf8f5e651f786a29b10fe/
/raw/116857fa9daaf8f5e651f786a29b10fe/
116857fa9daaf8f5e651f786a29b10fe
js
JavaScript
1
2019-07-22T11:49:11
True
False
False
/api/public/snipt/15320/
textchange-link
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">src</span><span class="o">=</span><span class="s2">&quot;/javascripts/plugins/jquery.textchange.js&quot;</span><span class="o">&gt;&lt;</span><span class="err">/script&gt;</span> </span></pre></div> </td></tr></table>
js

JavaScript

exhibita

1
2
3
4
5
6
7
$('#exhibita').bind('hastext', function () {
  $('#exhibitaButton').removeClass('disabled').attr('disabled', false);
});
	
$('#exhibita').bind('notext', function () {
  $('#exhibitaButton').addClass('disabled').attr('disabled', true);
});
https://snipt.net/embed/75193b1d73e2cb8885139cf1959c9c87/
/raw/75193b1d73e2cb8885139cf1959c9c87/
75193b1d73e2cb8885139cf1959c9c87
js
JavaScript
7
2019-07-22T12:06:36
True
False
False
/api/public/snipt/15319/
exhibita
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#exhibita&#39;</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;hastext&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#exhibitaButton&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">});</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#exhibita&#39;</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;notext&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> </span><span id="L-6"><a name="L-6"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#exhibitaButton&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span> </span><span id="L-7"><a name="L-7"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
js

JavaScript

include annotate

<script src="/javascripts/plugins/jquery.js"></script>
<script src="/javascripts/plugins/jquery.annotate.js"></script>
https://snipt.net/embed/a83915c95a6fe9c306ea021e53dfdc07/
/raw/a83915c95a6fe9c306ea021e53dfdc07/
a83915c95a6fe9c306ea021e53dfdc07
js
JavaScript
2
2019-07-19T10:22:23
True
False
False
/api/public/snipt/13895/
include-annotate
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">src</span><span class="o">=</span><span class="s2">&quot;/javascripts/plugins/jquery.js&quot;</span><span class="o">&gt;&lt;</span><span class="err">/script&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">src</span><span class="o">=</span><span class="s2">&quot;/javascripts/plugins/jquery.annotate.js&quot;</span><span class="o">&gt;&lt;</span><span class="err">/script&gt;</span> </span></pre></div> </td></tr></table>
js

JavaScript

serialize

$('#nutmeg span.note').seralizeAnnotations();
https://snipt.net/embed/235cdd01b87af1e1de37f4746a88d82c/
/raw/235cdd01b87af1e1de37f4746a88d82c/
235cdd01b87af1e1de37f4746a88d82c
js
JavaScript
1
2019-07-17T15:32:15
True
False
False
/api/public/snipt/13893/
serialize
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#nutmeg span.note&#39;</span><span class="p">).</span><span class="nx">seralizeAnnotations</span><span class="p">();</span> </span></pre></div> </td></tr></table>
js

JavaScript

positioning

1
2
3
$('#labeledNutmeg').annotatableImage(function(annotation){
  return $(document.createElement('span')).addClass('set-label');
}, {xPosition: 'left'});
https://snipt.net/embed/319cea54e5298516993cebd73afb1483/
/raw/319cea54e5298516993cebd73afb1483/
319cea54e5298516993cebd73afb1483
js
JavaScript
3
2019-07-20T16:17:23
True
False
False
/api/public/snipt/13891/
positioning
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#labeledNutmeg&#39;</span><span class="p">).</span><span class="nx">annotatableImage</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">annotation</span><span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;span&#39;</span><span class="p">)).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;set-label&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">},</span> <span class="p">{</span><span class="nx">xPosition</span><span class="o">:</span> <span class="s1">&#39;left&#39;</span><span class="p">});</span> </span></pre></div> </td></tr></table>
js