Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1 id="tittle">SOROBAN CALCULATOR</h1>
	<div class="container-flex">
		<div id="abacus" class="container-flex">
			<div id="framework">			
				<div id="upper-row"> 		
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col9-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col8-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col7-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col6-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col5-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col4-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col3-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col2-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col1-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10"><div class="vertical-line"></div>
						<img id="col0-5" class="ball5" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>								
				</div>
				<div id="lower-row">						
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col9-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col9-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col9-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col9-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col8-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col8-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col8-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col8-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col7-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col7-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col7-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col7-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col6-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col6-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col6-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col6-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col5-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col5-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col5-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col5-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col4-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col4-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col4-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col4-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower" ><div class="vertical-line"></div>
						<img id="col3-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col3-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col3-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col3-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col2-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col2-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col2-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col2-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col1-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col1-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col1-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col1-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
					<div class="col-10 lower"><div class="vertical-line"></div>
						<img id="col0-4" class="ball4" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col0-3" class="ball3" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col0-2" class="ball2" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
						<img id="col0-1" class="ball1" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/cat-pin.png" alt="cat face icon">
					</div>
				</div>			
			</div>				
			<div id="operators">
				<img id="clean" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/clean.png" alt="clean wood texture icon" class="operator-button">
				<img id="add" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/plus.jpg" alt="plus wood texture icon" class="operator-button sing ">
				<img id="extract" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/minus.jpg" alt="minus wood texture icon" class="operator-button sing">
				<img id="multiply" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/times.png" alt="multiplication wood texture icon" class="operator-button sing">
				<img id="divide" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/division.png" alt="division wood texture icon" class="operator-button sing">
				<img id="result" src="https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/equal.png" alt="equal wood texture icon" class="operator-button sing">
			</div>
		</div>
		<div id="display">	
			<p id="number">0</p>	
		</div>
		<footer>
			<span id="copyleft">&copy;</span> 2016. Made by <a href="https://twitter.com/juankboards" target="_blank">JuanKboards</a>
		</footer>
	</div>
              
            
!

CSS

              
                @font-face {
	font-family: PWChalk;
	src: local(chalk.ttf);
}

* {
	font-family: PWChalk;	
}

body {	
	background-image: url("https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/background.JPG");	
	z-index: -1;
}

#tittle {
  font-family: PWChalk;
  color: #dda500;
  text-align: center;
  font-size: 2em;
  font-weight: bold;
  text-shadow: 3px 3px 0px rgba(0,0,0,0.1), 7px 7px 0px rgba(0,0,0,0.05);
}

.container-flex {	
	margin: 10px auto;
	width: 815px;
	height: 549px;
}

#abacus{
	width: 100%;
	height: 82%;
	margin-bottom: 10px;
}

/*----- Abacus layout ------*/

#framework {	
	background-image: url("https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/wood.JPG");
    background-size: 80px 60px;
	background-repeat: repeat;
	height: 100%;
	width: 92%;
	padding: 1px;
	border: 5px solid #2C1910;
	border-radius: 5px;
}

#upper-row {		
	margin: 25px auto 0;	
	height: 22%;
	width: 90%;
	background-image: url("https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/wood-background.jpg");
    background-size: 80px 60px;
	background-repeat: repeat;
	border: 5px solid #2C1910;
	border-radius: 5px;
}

#lower-row {	
	margin: 18px auto 0;	
	height: 60%;
	width: 90%;
	background-image: url("https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/wood-background.jpg");
    background-size: 80px 60px;
	background-repeat: repeat;
	border: 5px solid #2C1910;
	border-radius: 5px;
}

.col-10 {
	display: block;
	float: left;
	width: 10%;
	height: 100%;
	margin: 0;
}


/*------ abacus components ------*/

.vertical-line {
	width: 8%;
	height: 100%;
	background-color: #888;
	border: 1px solid #000;
	margin: 0 auto;
	z-index: -1;
}

#framework {
	float: left;
}

#framework img {
	position: relative;		
	width: 100%;
	cursor: pointer;
	disabl
}

.ball5 {
	bottom: 96px;
}

.ball4 {
	bottom: 192px;
}

.ball3 {
	bottom: 212px;
}

.ball2 {
	bottom: 232px;
}

.ball1 {
	bottom: 252px;
}

/*------- operators and display layout -------*/


#operators {	
	float: left;	
	width: 8%;
	height: 90%;
	margin-top: 45px;
	padding-left: 5px;	
}

.operator-button {	
	display: block;		
	cursor: pointer;
	width: 100%;
}

#divide{
	-moz-transform: rotate(45deg);
	-o-transform: rotate(45deg);
	-webkit-transform: rotate(45deg);
	transform: rotate(45deg) ;
}

#display {		
	background-image: url("https://raw.githubusercontent.com/Juankboards/abacus-calculator/master/img/blackboard.jpg");
    background-size: 80px 40px;	
    border: 2px solid #2C1910;
	border-radius: 5px;	
	width: 100%;
	height: 50px;			
}

#display p {	
	color: #CCC;	
	font-size: 2.6em;	
	text-align: center;	
}

footer {
	font-family: "pacifico", cursive;
  	color: #ffa500;
	text-align: center;
	margin-top: 15px;	
}

footer a {
	font-family: "pacifico", cursive;
  	color: #00aa00;
	text-decoration: none;	
	font-style: italic;
}

#copyleft {
	display: inline-block;
	text-align: right;
	margin: 0px;
	-moz-transform: scaleX(-1);
	-o-transform: scaleX(-1);
	-webkit-transform: scaleX(-1);
	transform: scaleX(-1);
	filter: FlipH;
	-ms-filter: "FlipH";
}




              
            
!

JS

              
                BALLS_INITIAL_POSITION = {
	".ball5": "96px",
	".ball4": "192px",
	".ball3": "212px",
	".ball2": "232px",
	".ball1": "252px"
};

BALLS_SECOND_POSITION = {
	".ball4": "263px",
	".ball3": "283px",
	".ball2": "303px",
	".ball1": "323px"
};



$(document).ready(function(){
	var idStr = "";
	var numId = "";
	var imgId = "";

	var baseBottomValue = "";
    var newBottomValue = "";
	var number = 0;

	var expressionArray = [];
	var expression = "";
		
	

	

	function move () {      	

    	if (numId==5){        		        
       		if ($(imgId).css("bottom") === "96px"){
       			$(imgId).css("bottom", "56px");
       			number += parseInt(numId)*Math.pow(10, idStr[3]);
       		} else {
       			$(imgId).css("bottom", "96px");
       			number -= parseInt(numId)*Math.pow(10, idStr[3]);
       		}
    	}
    	    	
        
    
    	if ($(imgId).css("bottom") !== newBottomValue){
            for (var i = numId; i < 5; i++){   

            	imgId = "#" + idStr.slice(0, idStr.length-1) + i;
            	baseBottomValue = BALLS_INITIAL_POSITION[".ball"+i];
            	newBottomValue = BALLS_SECOND_POSITION[".ball"+i];

            	if ($(imgId).css("bottom") !== newBottomValue){
            		$(imgId).css("bottom", newBottomValue);
            		number += Math.pow(10, idStr[3]); 		            		
            	}            	
            } 
        }else{
            for (var i = numId; i > 0; i--) {   

            	imgId = "#" + idStr.slice(0, idStr.length-1) + i;
            	baseBottomValue = BALLS_INITIAL_POSITION[".ball"+i];           	   

            	if ($(imgId).css("bottom") !== baseBottomValue){
            		$(imgId).css("bottom", baseBottomValue); 
            		number -= Math.pow(10, idStr[3]); 
            	}            	
        	}
        }    
    }

    function printNumber () {
		$("#number").text(expression+number); 
        console.log(expression+number);   
	}

	function clean(){
		for (var i = 0; i < 11; i++) {  
    			for (var j = 0; j <6; j++) { 
    				imgId = "#col" + i + "-" + j;
    				$(imgId).css("bottom", BALLS_INITIAL_POSITION[".ball"+j]);
    			}
    		}
    	number = 0;    	
	}

	function expressionJoin(){
		expression = expressionArray.join("");
	}

	function resultPosition(result){	
		if (parseInt(result)>0 && result.length < 10) {
			result = result.split("").reverse().join("");

			for (var i = 0; i < result.length; i++) {
				var counter = 0; 
				if (parseInt(result[i])>4){
					counter +=5;
					imgId = "#col" + i + "-5";				
					$(imgId).css("bottom","56px");
				}
				for (var j = 4; j > 0; j--) {							
					if (counter<parseInt(result[i])){
						imgId = "#col" + i + "-" + j;
						$(imgId).css("bottom", BALLS_SECOND_POSITION[".ball"+j]);
						counter += 1;
					}			
				}
			}
		};			
		$('#framework img').off("click");
		$('#framework img').css("cursor", "default");
		$('#operators .sing').css("cursor", "default");

	}

	function operation(){
		switch (idStr){
			case "clean":	
				$('#framework img').css("cursor", "pointer");
				$('#operators .sing').css("cursor", "pointer");
				$('#framework img').on({    	
			        'click': function (){
			        	idStr = this.id;
			        	numId = idStr.slice(-1);
			        	imgId = "#" + idStr;

			        	baseBottomValue = BALLS_INITIAL_POSITION[".ball"+numId];
				        newBottomValue = BALLS_SECOND_POSITION[".ball"+numId];
			        	
					    move();
					    printNumber();
					}	          
				});
				clean();      		
				expression = "";  
				expressionArray = []; 
				$("#number").text("0");          		  		
				break;  
			case "add":  
				expressionArray.push(number+"+");
				expressionJoin();        			
				clean();    
				$("#number").text(expression);   		        		
				break;
			case "extract":
				expressionArray.push(number+"-"); 
				 expressionJoin();        			
				clean();    
				$("#number").text(expression);  
				break;
			case "multiply":
				expressionArray.push(number+"*");
				expressionJoin();        			
				clean();    
				$("#number").text(expression);  
				break;
			case "divide":
				expressionArray.push(number+"/");
				expressionJoin();        			
				clean();    
				$("#number").text(expression);  
				break;
			case "result": 
				var result = 0;      		
				if (number==0){	
					result = eval(expression.slice(0,-1))				
					$("#number").text(result);			
				} else {
					result = eval(eval(expression + number))				
					$("#number").text(result);	
				}
				clean();				
				expression = "";  
				expressionArray = [];
				resultPosition(result.toString());				
				break; 	
		}        
	}
    
    $('#framework img').on({    	
        'click': function (){
        	idStr = this.id;
        	numId = idStr.slice(-1);
        	imgId = "#" + idStr;

        	baseBottomValue = BALLS_INITIAL_POSITION[".ball"+numId];
	        newBottomValue = BALLS_SECOND_POSITION[".ball"+numId];
        	
		    move();
		    printNumber();
		}	          
	});	


	
	

	$('#operators img').on({
        'click': function (){ 
        	idStr= this.id;        	
	        
	        operation();
	        	 
        	      
	        if (expression.length>23){
	        	$("#number").text("THAT IS A REALLY BIG EXPRESSION");	        	
        		clean();      		
				expression = "";  
				expressionArray = []; 		        	
	        }        
	    }        	
	});
	
})
              
            
!
999px

Console