.LANG
How do I make an .lang?
A pure JavaScript re-implementation of LukyVJ's DOTLANG. What is a .lang? How do you make a .lang? This script and codes were developed by Kevin Gimbel on 11 August 2022, Thursday.
.LANG - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>.LANG</title> <link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,600' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="wrap">
<h1 class="headline"><span class="dot">.</span>LANG</h1>
<h4 class="sub-headline">Modern Math language.</h4>
<code>... + .... + ... = <span id="dotlang">... + (.... + ...) </span></code>
<code>..... - .... = <span id="dotlang">..... - ....</span></code>
<code>... * .... = <span id="dotlang">... * .... * ..</span></code>
<code>........ / .... = <span id="dotlang">........ / ....</span></code> <small>Based on <a href="https://github.com/bullgit/DOTLANG">DOTLANG</a> by <a href="https://twitter.com/LukyVj">LukyVj</a> and <span class="dot">Bull</span>git.</small>
</div> <script src="js/index.js"></script>
</body>
</html>
.LANG - Script Codes CSS Codes
body { font-family: 'Source Code Pro';
}
.headline { font-weight: 300; margin-bottom: -.75em; line-heigth: 0;
}
.dot { color: #1393d5;
}
.sub-headline { font-weight: 300; text-transform: uppercase; color: #555;
}
code { background: #ddd; border: 1px solid #bbb; padding: .25em; border-radius: 3px; display: block; margin: 1em 0;
}
.wrap { max-width: 20em; margin: 0 auto;
}
.LANG - Script Codes JS Codes
/* * Pure JavaScript implementation of DOTLANG (https://github.com/bullgit/DOTLANG) * * * many dot, such fucked-up-language, very difficult */
String.prototype.dotlang = function() { // // Regular Expressions to check what we've got here! // match will math all dots, e.g. " ... .. ." // // isPlus, isMinus, isMultiple and isDivided match // the math signs (+ - * /) and return true if any // of them is matched var match = this.match(/([.])+/g), isPlus = this.match(/\+/), isMinus = this.match(/\-/), isMultiple = this.match(/\*/), isDivided = this.match(/\//), openBracket = this.match(/\(/), closeBracket = this.match(/\)/); // // One function to calc them all! // // @param {type} - type of calculation (isPlus, isMinus, etc.) function calcDotlang(type) { // fancy getting a math sign, eh? var currType = type[0].toString().replace(/"/g, ''), result = 0; // // Finding out what type we have to deal with. // The first value of the type array (type[0]) // is always the math sign that was matched. // Then we just do the math! if(currType === '*') { result++; // increasing results to 1 so we can use it with match[i] * result for(var i = 0; i <= type.index; i++) { if(!match[i]) { continue; } result = match[i].length * result; } } if(currType === '+') { for(var i = 0; i <= type.index; i++) { if(!match[i]) { continue; } result += match[i].length; } } if(currType === '-') { result = match[0].length; // starting with the first match, so ... - .. is 3-2 for(var i = 1; i <= type.index; i++) { if(!match[i]) { continue; } result -= match[i].length; } } if(currType === '/') { result++; // again, making result 1 so it can be used to devide. for(var i = 1; i <= type.index; i++) { if(!match[i]) { continue; } result = match[i].length / result; } result = result - 1; } return result; } // // After all this functions setup stuff we // use the new function to get things dotty (that's not even a word, right?) // if(isPlus) { return calcDotlang(isPlus); } if(isMinus) { return calcDotlang(isMinus); } if(isMultiple) { return calcDotlang(isMultiple); } if(isDivided) { return calcDotlang(isDivided); }
}
// query all the dotlang-thingys
var dl = document.querySelectorAll('#dotlang');
// make all the dotlang math things become real math results \o/
for(var i = 0; i <= dl.length - 1; i++) { var ds = dl[i].innerText; dl[i].innerText = ds.dotlang();
}
Array.prototype.last = function() { return this[this.length - 1];
}
// Fancy getting the brackets right :D
var string = '... + ( ... + .. )', first = string.match(/(\.+)^\(/) fancy = string.match(/(\(+\s+.+\))/), //string.match(/(\(+\s+.+\))/), fancyDots = fancy.last().match(/(\.)+/);
console.log( 'the begining string: ' + string + '\n -> fancy as dots: ' + fancyDots[0] + ' + ' + fancyDots[1] + '\n -> fancy as number: ' + fancyDots[0].length + ' + ' + fancyDots[1].length + '\n -> result = ' + (fancyDots[0].length + fancyDots[1].length) + '\n -> and there\'s a dot missing.'
)
Developer | Kevin Gimbel |
Username | kevingimbel |
Uploaded | August 11, 2022 |
Rating | 3.5 |
Size | 3,709 Kb |
Views | 30,360 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Felixble Product Flags | 5,907 Kb |
CSS3 only Turret from Portal | 3,910 Kb |
CSS3 only Vault-Tec Logo | 3,855 Kb |
CSS Pre-Block Overflow example | 2,482 Kb |
ViewSwitcher | 4,203 Kb |
LazyLoad.js Example | 2,537 Kb |
Pure JavaScript Slider | 3,122 Kb |
An Object-Oriented ToDo-List | 5,275 Kb |
Chat UI - WIP | 7,858 Kb |
A Pen by Kevin Gimbel | 2,671 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Blog | Rottingroom | 1,430 Kb |
CSS Grid Overlay | Cliffpyles | 3,090 Kb |
Slide out Menu | Rbiggs | 4,936 Kb |
A Pen by Manoz | Manoz | 2,424 Kb |
Header | Er40 | 1,542 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
CSS 3D Radio buttons | Andreasnylin | 1,650 Kb |
Lunar eclipse | Ademilter | 2,056 Kb |
Fixed Scrolling Nav Bar | Philsinatra | 0 Kb |
React Recipe Box | Krokodill | 5,347 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!