需要Javascript代码的说明

时间:2012-03-30 07:19:52

标签: javascript html5 webview

我想知道是否有人可以向我解释以下Javascript代码:

   j1 = {};
   j1.version = "0.0.1";
   j1.port = "0";
   j1.key = "DEFAULT_KEY"; //default random key  
   j1.requestID = 1000;
   j1.setPort = function (port) {
       this.port = port;
   };

   j1.setKey = function (key) {
       this.key = key;
   };

   j1.onDeviceReady = function () {};
   j1.onPushNotification = function (message) {};

   j1.platform = {};
   j1.platform.WINDOWS_PHONE = "WINDOWS_PHONE";
   j1.platform.IOS = "IOS";
   j1.platform.BLACKBERRY = "BLACKBERRY";
   j1.platform.ANDROID = "ANDROID";

   // Device  
   j1.device = {
       name: "",
       version: "",
       platform: "",
       uuid: "",
       initDevice: function (deviceName, deviceVersion, devicePlatform, deviceUUID) {
           this.name = deviceName;
           this.version = deviceVersion;
           this.platform = devicePlatform;
           this.uuid = deviceUUID;
       }
   };

这是一个混合移动Web应用程序。

感谢
斯纳

3 个答案:

答案 0 :(得分:0)

这里很难解释任何内容,因为代码只提供了一些结构。它并没有真正做任何有趣的事情。

答案 1 :(得分:0)

j1是对象文字。对象文字是以花括号括起来的以逗号分隔的属性键/值对列表。您可以详细了解herehere

答案 2 :(得分:-2)

j1是具有某些属性的对象。它使用json(javascript对象表示法http://www.json.org/