snipt

Ctrl+h for KB shortcuts

JavaScript

CS Cart - ZBA Z-3010 Scanner Aus Post Express Post tracking code input favlet

1
2
3
4
5
/* CS CART 2.x */
javascript:(function(){/*Scanner Postage Tracking7 Aug 2013Quick fix as the scanner adds 5 numerals at the start of the Australia Post Express Post tracking codes and does a carriage returnRMW Web Publishing*/if($('#content_add_shipment:visible').length>0){var scanned=$('#shipment_comments').val();if(scanned.length>0){scanned=scanned.trim();scanned=scanned.slice(4);/* example '997960402908127094' return 60402908127094 */if(scanned.length===14){$('#tracking_number').val(scanned).focus();$('#shipment_comments').val('');}else{alert('Something sus happened - the code is not correct. Please fix manually');return;}}else{alert('Please scan code into the "Comments" field');}/* Set Carrier to Australia Post */$('#carrier_key option[value="AUP"]').attr('selected','selected');/* Set Order Status to Posted */$('#order_status option[value="C"]').attr('selected','selected');/* Set Notification to True */$('#shipment_notify_user').attr('checked','checked');}else{alert('CS Cart "New Shipment" dialogue not active');}})()

/* CS CART 4.x */
javascript:!function(){!function(){if($('form[name=%22shipments_form%22]:visible').length%3E0){var%20e=$(%22%23shipmentcomments%22).val();if(e.length%3E0){if(e=e.trim(),e=e.slice(4),14!==e.length)return%20void%20alert(%22Somethings%20wrong%20-%20the%20code%20is%20not%20correct.%20Please%20fix%20manually%22);$(%22%23tracking_number%22).val(e).focus(),$(%22%23shipmentcomments%22).val(%22%22)}else%20alert('Please%20scan%20code%20into%20the%20%22Comments%22%20field');$('%23carrier_key%20option[value=%22aup%22]').prop(%22selected%22,!0),$('%23order_status%20option[value=%22C%22]').prop(%22selected%22,!0),$(%22%23shipment_notify_user%22).prop(%22checked%22,!0)}else%20alert('Unable%20to%20find%20CS%20Cart%20%22New%20Shipment%22%20modal')}()}();
https://snipt.net/embed/2693ff9953ca2d4d080614b35ea6a710/
/raw/2693ff9953ca2d4d080614b35ea6a710/
2693ff9953ca2d4d080614b35ea6a710
js
JavaScript
5
2019-06-16T02:16:30
True
False
False
/api/public/snipt/72417/
cs-cart-zba-z-3010-scanner-aus-post-express-post-tracking-code-input-favlet
<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="cm">/* CS CART 2.x */</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">javascript</span><span class="o">:</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="cm">/*Scanner Postage Tracking7 Aug 2013Quick fix as the scanner adds 5 numerals at the start of the Australia Post Express Post tracking codes and does a carriage returnRMW Web Publishing*/</span><span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#content_add_shipment:visible&#39;</span><span class="p">).</span><span class="nx">length</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">){</span><span class="kd">var</span> <span class="nx">scanned</span><span class="o">=</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#shipment_comments&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span><span class="k">if</span><span class="p">(</span><span class="nx">scanned</span><span class="p">.</span><span class="nx">length</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">){</span><span class="nx">scanned</span><span class="o">=</span><span class="nx">scanned</span><span class="p">.</span><span class="nx">trim</span><span class="p">();</span><span class="nx">scanned</span><span class="o">=</span><span class="nx">scanned</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">4</span><span class="p">);</span><span class="cm">/* example &#39;997960402908127094&#39; return 60402908127094 */</span><span class="k">if</span><span class="p">(</span><span class="nx">scanned</span><span class="p">.</span><span class="nx">length</span><span class="o">===</span><span class="mi">14</span><span class="p">){</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#tracking_number&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="nx">scanned</span><span class="p">).</span><span class="nx">focus</span><span class="p">();</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#shipment_comments&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">);}</span><span class="k">else</span><span class="p">{</span><span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Something sus happened - the code is not correct. Please fix manually&#39;</span><span class="p">);</span><span class="k">return</span><span class="p">;}}</span><span class="k">else</span><span class="p">{</span><span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Please scan code into the &quot;Comments&quot; field&#39;</span><span class="p">);}</span><span class="cm">/* Set Carrier to Australia Post */</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#carrier_key option[value=&quot;AUP&quot;]&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">,</span><span class="s1">&#39;selected&#39;</span><span class="p">);</span><span class="cm">/* Set Order Status to Posted */</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#order_status option[value=&quot;C&quot;]&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">,</span><span class="s1">&#39;selected&#39;</span><span class="p">);</span><span class="cm">/* Set Notification to True */</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#shipment_notify_user&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;checked&#39;</span><span class="p">,</span><span class="s1">&#39;checked&#39;</span><span class="p">);}</span><span class="k">else</span><span class="p">{</span><span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;CS Cart &quot;New Shipment&quot; dialogue not active&#39;</span><span class="p">);}})()</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="cm">/* CS CART 4.x */</span> </span><span id="L-5"><a name="L-5"></a><span class="nx">javascript</span><span class="o">:!</span><span class="kd">function</span><span class="p">(){</span><span class="o">!</span><span class="kd">function</span><span class="p">(){</span><span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;form[name=%22shipments_form%22]:visible&#39;</span><span class="p">).</span><span class="nx">length</span><span class="o">%</span><span class="mi">3</span><span class="nx">E0</span><span class="p">){</span><span class="kd">var</span><span class="o">%</span><span class="mi">20</span><span class="nx">e</span><span class="o">=</span><span class="nx">$</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">%</span><span class="mi">23</span><span class="nx">shipmentcomments</span><span class="o">%</span><span class="mi">22</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span><span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">length</span><span class="o">%</span><span class="mi">3</span><span class="nx">E0</span><span class="p">){</span><span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="o">=</span><span class="nx">e</span><span class="p">.</span><span class="nx">trim</span><span class="p">(),</span><span class="nx">e</span><span class="o">=</span><span class="nx">e</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span><span class="mi">14</span><span class="o">!==</span><span class="nx">e</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span><span class="k">return</span><span class="o">%</span><span class="mi">20</span><span class="k">void</span><span class="o">%</span><span class="mi">20</span><span class="nx">alert</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="nx">Somethings</span><span class="o">%</span><span class="mi">20</span><span class="nx">wrong</span><span class="o">%</span><span class="mi">20</span><span class="o">-%</span><span class="mi">20</span><span class="nx">the</span><span class="o">%</span><span class="mi">20</span><span class="nx">code</span><span class="o">%</span><span class="mi">20</span><span class="nx">is</span><span class="o">%</span><span class="mi">20</span><span class="nx">not</span><span class="o">%</span><span class="mi">20</span><span class="nx">correct</span><span class="p">.</span><span class="o">%</span><span class="mi">20</span><span class="nx">Please</span><span class="o">%</span><span class="mi">20</span><span class="nx">fix</span><span class="o">%</span><span class="mi">20</span><span class="nx">manually</span><span class="o">%</span><span class="mi">22</span><span class="p">);</span><span class="nx">$</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">%</span><span class="mi">23</span><span class="nx">tracking_number</span><span class="o">%</span><span class="mi">22</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">focus</span><span class="p">(),</span><span class="nx">$</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">%</span><span class="mi">23</span><span class="nx">shipmentcomments</span><span class="o">%</span><span class="mi">22</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">%</span><span class="mi">22</span><span class="p">)}</span><span class="k">else</span><span class="o">%</span><span class="mi">20</span><span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Please%20scan%20code%20into%20the%20%22Comments%22%20field&#39;</span><span class="p">);</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;%23carrier_key%20option[value=%22aup%22]&#39;</span><span class="p">).</span><span class="nx">prop</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="nx">selected</span><span class="o">%</span><span class="mi">22</span><span class="p">,</span><span class="o">!</span><span class="mi">0</span><span class="p">),</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;%23order_status%20option[value=%22C%22]&#39;</span><span class="p">).</span><span class="nx">prop</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="nx">selected</span><span class="o">%</span><span class="mi">22</span><span class="p">,</span><span class="o">!</span><span class="mi">0</span><span class="p">),</span><span class="nx">$</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="o">%</span><span class="mi">23</span><span class="nx">shipment_notify_user</span><span class="o">%</span><span class="mi">22</span><span class="p">).</span><span class="nx">prop</span><span class="p">(</span><span class="o">%</span><span class="mi">22</span><span class="nx">checked</span><span class="o">%</span><span class="mi">22</span><span class="p">,</span><span class="o">!</span><span class="mi">0</span><span class="p">)}</span><span class="k">else</span><span class="o">%</span><span class="mi">20</span><span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;Unable%20to%20find%20CS%20Cart%20%22New%20Shipment%22%20modal&#39;</span><span class="p">)}()}();</span> </span></pre></div> </td></tr></table>
auspost, barcode, bookmarklet, cscart, cscart4, ecommerce, favlet, scanned, shipping, shopping, store, tracking, z-3010