1 // This file is part of NIT ( http://www.nitlanguage.org )
3 // Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 converterModule
= null; // Global application object.
19 // Indicate load success.
20 function moduleDidLoad() {
21 converterModule
= document
.getElementById('converter');
22 // Send a message to the Native Client module.
23 if (converterModule
!= null) {
24 console
.log('converterModule loaded.');
28 // The 'message' event handler. This handler is fired when the NaCl module
29 // posts a message to the browser by calling PPB_Messaging.PostMessage()
30 // (in C) or pp::Instance.PostMessage() (in C++). This implementation
31 // displays the result in the JS console, puts the result in the '#rez' input and make it visible.
32 function handleMessage(message_event
) {
33 if (message_event
.data
.hasOwnProperty('exit')){
34 console
.log('Nit code exited with value: ' + message_event
.data
.exit
+ '.');
37 console
.log(message_event
.data
.value
.valueOf());
38 $
('#rez').val(message_event
.data
.value
.valueOf().toFixed(2));
39 $
('#rez').css('visibility', 'visible');