Skip to content

Commit

Permalink
Indexing update.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonela10 committed Jun 2, 2024
1 parent 982a08b commit 6ab3c4c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 61 deletions.
85 changes: 45 additions & 40 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
<html>
<head>
<!-- Google tag (gtag.js) -->
<!-- Start VWO Async SmartCode -->
<link rel="preconnect" href="https://dev.visualwebsiteoptimizer.com" />
<script type='text/javascript' id='vwoCode'>
window._vwo_code || (function() {
var account_id=901568,
version=2.1,
settings_tolerance=2000,
hide_element='body',
hide_element_style = 'opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important',
/* DO NOT EDIT BELOW THIS LINE */
f=false,w=window,d=document,v=d.querySelector('#vwoCode'),cK='_vwo_'+account_id+'_settings',cc={};try{var c=JSON.parse(localStorage.getItem('_vwo_'+account_id+'_config'));cc=c&&typeof c==='object'?c:{}}catch(e){}var stT=cc.stT==='session'?w.sessionStorage:w.localStorage;code={use_existing_jquery:function(){return typeof use_existing_jquery!=='undefined'?use_existing_jquery:undefined},library_tolerance:function(){return typeof library_tolerance!=='undefined'?library_tolerance:undefined},settings_tolerance:function(){return cc.sT||settings_tolerance},hide_element_style:function(){return'{'+(cc.hES||hide_element_style)+'}'},hide_element:function(){if(performance.getEntriesByName('first-contentful-paint')[0]){return''}return typeof cc.hE==='string'?cc.hE:hide_element},getVersion:function(){return version},finish:function(e){if(!f){f=true;var t=d.getElementById('_vis_opt_path_hides');if(t)t.parentNode.removeChild(t);if(e)(new Image).src='https://dev.visualwebsiteoptimizer.com/ee.gif?a='+account_id+e}},finished:function(){return f},addScript:function(e){var t=d.createElement('script');t.type='text/javascript';if(e.src){t.src=e.src}else{t.text=e.text}d.getElementsByTagName('head')[0].appendChild(t)},load:function(e,t){var i=this.getSettings(),n=d.createElement('script'),r=this;t=t||{};if(i){n.textContent=i;d.getElementsByTagName('head')[0].appendChild(n);if(!w.VWO||VWO.caE){stT.removeItem(cK);r.load(e)}}else{var o=new XMLHttpRequest;o.open('GET',e,true);o.withCredentials=!t.dSC;o.responseType=t.responseType||'text';o.onload=function(){if(t.onloadCb){return t.onloadCb(o,e)}if(o.status===200){_vwo_code.addScript({text:o.responseText})}else{_vwo_code.finish('&e=loading_failure:'+e)}};o.onerror=function(){if(t.onerrorCb){return t.onerrorCb(e)}_vwo_code.finish('&e=loading_failure:'+e)};o.send()}},getSettings:function(){try{var e=stT.getItem(cK);if(!e){return}e=JSON.parse(e);if(Date.now()>e.e){stT.removeItem(cK);return}return e.s}catch(e){return}},init:function(){if(d.URL.indexOf('__vwo_disable__')>-1)return;var e=this.settings_tolerance();w._vwo_settings_timer=setTimeout(function(){_vwo_code.finish();stT.removeItem(cK)},e);var t;if(this.hide_element()!=='body'){t=d.createElement('style');var i=this.hide_element(),n=i?i+this.hide_element_style():'',r=d.getElementsByTagName('head')[0];t.setAttribute('id','_vis_opt_path_hides');v&&t.setAttribute('nonce',v.nonce);t.setAttribute('type','text/css');if(t.styleSheet)t.styleSheet.cssText=n;else t.appendChild(d.createTextNode(n));r.appendChild(t)}else{t=d.getElementsByTagName('head')[0];var n=d.createElement('div');n.style.cssText='z-index: 2147483647 !important;position: fixed !important;left: 0 !important;top: 0 !important;width: 100% !important;height: 100% !important;background: white !important;';n.setAttribute('id','_vis_opt_path_hides');n.classList.add('_vis_hide_layer');t.parentNode.insertBefore(n,t.nextSibling)}var o='https://dev.visualwebsiteoptimizer.com/j.php?a='+account_id+'&u='+encodeURIComponent(d.URL)+'&vn='+version;if(w.location.search.indexOf('_vwo_xhr')!==-1){this.addScript({src:o})}else{this.load(o+'&x=true')}}};w._vwo_code=code;code.init();})();
</script>
<!-- End VWO Async SmartCode --><script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-JLS2BR3Q62');
</script>
<script src="romans.js"></script>
<link rel="stylesheet" href="romans.css">
</head>
<body onload="init()">
<main class="container">
<section class="content">
<h1>Roman To Integer</h1>
<div class="group">
<input type="checkbox" name="mode-selector" />
<label for="mode-selector">Change Mode</label>
</div>
<div class="group">
<input type="text" name="conversion-input" />
</div>
<span class="convert-button">Convert</span>
<p class="convert-output"></p>
</section>
</main>
</body>
</html>
<head>
<!-- Google tag (gtag.js) -->
<!-- Start VWO Async SmartCode -->
<link rel="preconnect" href="https://dev.visualwebsiteoptimizer.com" />
<script type='text/javascript' id='vwoCode'>
window._vwo_code || (function () {
var account_id = 901568,
version = 2.1,
settings_tolerance = 2000,
hide_element = 'body',
hide_element_style = 'opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important',
/* DO NOT EDIT BELOW THIS LINE */
f = false, w = window, d = document, v = d.querySelector('#vwoCode'), cK = '_vwo_' + account_id + '_settings', cc = {}; try { var c = JSON.parse(localStorage.getItem('_vwo_' + account_id + '_config')); cc = c && typeof c === 'object' ? c : {} } catch (e) { } var stT = cc.stT === 'session' ? w.sessionStorage : w.localStorage; code = { use_existing_jquery: function () { return typeof use_existing_jquery !== 'undefined' ? use_existing_jquery : undefined }, library_tolerance: function () { return typeof library_tolerance !== 'undefined' ? library_tolerance : undefined }, settings_tolerance: function () { return cc.sT || settings_tolerance }, hide_element_style: function () { return '{' + (cc.hES || hide_element_style) + '}' }, hide_element: function () { if (performance.getEntriesByName('first-contentful-paint')[0]) { return '' } return typeof cc.hE === 'string' ? cc.hE : hide_element }, getVersion: function () { return version }, finish: function (e) { if (!f) { f = true; var t = d.getElementById('_vis_opt_path_hides'); if (t) t.parentNode.removeChild(t); if (e) (new Image).src = 'https://dev.visualwebsiteoptimizer.com/ee.gif?a=' + account_id + e } }, finished: function () { return f }, addScript: function (e) { var t = d.createElement('script'); t.type = 'text/javascript'; if (e.src) { t.src = e.src } else { t.text = e.text } d.getElementsByTagName('head')[0].appendChild(t) }, load: function (e, t) { var i = this.getSettings(), n = d.createElement('script'), r = this; t = t || {}; if (i) { n.textContent = i; d.getElementsByTagName('head')[0].appendChild(n); if (!w.VWO || VWO.caE) { stT.removeItem(cK); r.load(e) } } else { var o = new XMLHttpRequest; o.open('GET', e, true); o.withCredentials = !t.dSC; o.responseType = t.responseType || 'text'; o.onload = function () { if (t.onloadCb) { return t.onloadCb(o, e) } if (o.status === 200) { _vwo_code.addScript({ text: o.responseText }) } else { _vwo_code.finish('&e=loading_failure:' + e) } }; o.onerror = function () { if (t.onerrorCb) { return t.onerrorCb(e) } _vwo_code.finish('&e=loading_failure:' + e) }; o.send() } }, getSettings: function () { try { var e = stT.getItem(cK); if (!e) { return } e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return } return e.s } catch (e) { return } }, init: function () { if (d.URL.indexOf('__vwo_disable__') > -1) return; var e = this.settings_tolerance(); w._vwo_settings_timer = setTimeout(function () { _vwo_code.finish(); stT.removeItem(cK) }, e); var t; if (this.hide_element() !== 'body') { t = d.createElement('style'); var i = this.hide_element(), n = i ? i + this.hide_element_style() : '', r = d.getElementsByTagName('head')[0]; t.setAttribute('id', '_vis_opt_path_hides'); v && t.setAttribute('nonce', v.nonce); t.setAttribute('type', 'text/css'); if (t.styleSheet) t.styleSheet.cssText = n; else t.appendChild(d.createTextNode(n)); r.appendChild(t) } else { t = d.getElementsByTagName('head')[0]; var n = d.createElement('div'); n.style.cssText = 'z-index: 2147483647 !important;position: fixed !important;left: 0 !important;top: 0 !important;width: 100% !important;height: 100% !important;background: white !important;'; n.setAttribute('id', '_vis_opt_path_hides'); n.classList.add('_vis_hide_layer'); t.parentNode.insertBefore(n, t.nextSibling) } var o = 'https://dev.visualwebsiteoptimizer.com/j.php?a=' + account_id + '&u=' + encodeURIComponent(d.URL) + '&vn=' + version; if (w.location.search.indexOf('_vwo_xhr') !== -1) { this.addScript({ src: o }) } else { this.load(o + '&x=true') } } }; w._vwo_code = code; code.init();
})();
</script>
<!-- End VWO Async SmartCode -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', 'G-JLS2BR3Q62');
</script>
<script src="romans.js"></script>
<link rel="stylesheet" href="romans.css">
</head>

<body onload="init()">
<main class="container">
<section class="content">
<h1>Roman To Integer</h1>
<div class="group">
<input type="checkbox" name="mode-selector" />
<label for="mode-selector">Change Mode</label>
</div>
<div class="group">
<input type="text" name="conversion-input" />
</div>
<span class="convert-button">Convert</span>
<p class="convert-output"></p>
</section>
</main>
</body>

</html>
32 changes: 16 additions & 16 deletions romans.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ const INVALID_ROMAN = 'Please enter a valid roman';
const INVALID_INTEGER = 'Please enter a valid integer';
const OUT_OF_RANGE = 'Out of range (1-3999)';

function init() {
function init() {

// Load elements once to avoid repetition on every invocation
var modeCheckbox = document.querySelector('input[type=\'checkbox\']');
var header = document.querySelector('h1');
var convertButton = document.querySelector('.convert-button');
var outputArea = document.querySelector('.convert-output');
var inputArea = document.querySelector('input[type=\'text\']');

modeCheckbox.addEventListener('change', function(e) {
modeCheckbox.addEventListener('change', function (e) {
header.innerHTML = getModeTitle(e.target.checked);
});

const getModeTitle = function(integerToRoman) {
const getModeTitle = function (integerToRoman) {
return integerToRoman ? 'Integer To Roman' : 'Roman To Integer';
};

Expand All @@ -26,7 +26,7 @@ function init() {
// 2 - Write the UI output (outputArea.innerHTML)
// 3 - Show error messages
// This is cleaner and also removes code duplications
convertButton.addEventListener('click', function() {
convertButton.addEventListener('click', function () {
// Google Analytics event tracking
gtag('event', 'click', {
'event_category': 'Button',
Expand All @@ -49,11 +49,11 @@ function init() {
// On top of that, they return a JSON object instead of updating the
// UI directly. The JSON object contains the result (ok/nok), the value
// and an error message if needed
const convertRomanToInteger = function(roman) {
const convertRomanToInteger = function (roman) {
var response = {
value: 0,
value: 0,
message: '',
result: false
result: false
};

// Regexp to check if a string is a valid roman number
Expand Down Expand Up @@ -108,11 +108,11 @@ const convertRomanToInteger = function(roman) {
// On top of that, they return a JSON object instead of updating the
// UI directly. The JSON object contains the result (ok/nok), the value
// and an error message if needed
const convertIntegerToRoman = function(num) {
const convertIntegerToRoman = function (num) {
var response = {
value: 0,
message: '',
result: false
message: '',
result: false
};

// Regexp to check the input is a valid integer
Expand All @@ -129,7 +129,7 @@ const convertIntegerToRoman = function(num) {
// Integer not in the supported range -> exit with the right message
if (Number(num) > 3999 || Number(num) < 1) {
response.message = OUT_OF_RANGE;
return response;
return response;
}

const mapping = {
Expand Down Expand Up @@ -163,7 +163,7 @@ const convertIntegerToRoman = function(num) {
return response;
};

const lessThan9 = function(num, obj) {
const lessThan9 = function (num, obj) {
if (num === 9) {
return obj[1] + obj[10];
} else if (num >= 5 && num < 9) {
Expand All @@ -175,7 +175,7 @@ const lessThan9 = function(num, obj) {
}
};

const greaterThan9 = function(num, obj) {
const greaterThan9 = function (num, obj) {
if (num >= 10 && num < 50) {
if (num === 10) {
return obj[10];
Expand Down Expand Up @@ -225,7 +225,7 @@ const greaterThan9 = function(num, obj) {
};

if (!String.prototype.repeat) {
String.prototype.repeat = function(count) {
String.prototype.repeat = function (count) {
'use strict';
if (this == null) {
throw new TypeError('can\'t convert ' + this + ' to object');
Expand All @@ -252,7 +252,7 @@ if (!String.prototype.repeat) {
throw new RangeError('repeat count must not overflow maximum string size');
}
var rpt = '';
for (;;) {
for (; ;) {
if ((count & 1) == 1) {
rpt += str;
}
Expand Down
13 changes: 8 additions & 5 deletions test.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<html>

<head>
<script src="https://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<script src="romans.js"></script>
<script src="tests.js"></script>
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/qunit/qunit-1.12.0.css">
<script src="https://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<script src="romans.js"></script>
<script src="tests.js"></script>
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/qunit/qunit-1.12.0.css">
</head>

<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

</html>

0 comments on commit 6ab3c4c

Please sign in to comment.