Browse Source

Pass input to wasm function

pull/1/head
Ravi Shah 5 years ago
parent
commit
e417073b0d
  1. 6
      src/lib.rs
  2. 2
      www/app.js
  3. 1
      www/index.html
  4. 1
      www/package-lock.json

6
src/lib.rs

@ -153,11 +153,11 @@ pub fn translation(inter_codons: Vec<String>) -> Vec<String> {
} }
#[wasm_bindgen] #[wasm_bindgen]
pub fn main() {
pub fn main(mut strand: String) {
println!("Enter the DNA strand to be transcribed and translated: "); println!("Enter the DNA strand to be transcribed and translated: ");
let mut strand: String = "TACATGCCATACGAGACGAGCGCGCCTAAGCGGCGCAGACTCATGGTCATT".to_string();
strand = strand.to_uppercase();
//let mut strand: String = "TACATGCCATACGAGACGAGCGCGCCTAAGCGGCGCAGACTCATGGTCATT".to_string();
strand = strand.to_string().to_uppercase();
let messenger_rna = transcription(strand); let messenger_rna = transcription(strand);
println!("The transcribed strand is: {}", messenger_rna); println!("The transcribed strand is: {}", messenger_rna);

2
www/app.js

@ -5,4 +5,4 @@ const strand = urlParams.get('strand');
console.log(strand) console.log(strand)
wasm.main();
wasm.main(strand);

1
www/index.html

@ -6,7 +6,6 @@
</head> </head>
<body> <body>
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript> <noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript>
<script src="./bootstrap.js"></script>
<h1>Please enter the DNA strand in the space below:</h1> <h1>Please enter the DNA strand in the space below:</h1>
<form class="dna-input" action="app.html" method="get"> <form class="dna-input" action="app.html" method="get">
<input type="text" name="strand"> <input type="text" name="strand">

1
www/package-lock.json

@ -23,6 +23,7 @@
} }
}, },
"../pkg": { "../pkg": {
"name": "wasm-dna-transcription-translation",
"version": "0.1.0" "version": "0.1.0"
}, },
"node_modules/@types/events": { "node_modules/@types/events": {

Loading…
Cancel
Save