{
  "script": "require('MistJSHttpRequestHelper, MistJSToast')\nfunction getWeather(city){var http=MistJSHttpRequestHelper.sharedInstance()\nvar url='http://api.openweathermap.org/data/2.5/weather?q='+city.toJS()+'&appid=e29037c971eb05e99323a39106735690&units=metric&lang=zh'\nhttp.get_handler(url,block('NSDictionary *, NSError *',function(response,error){var res=response.toJS()\nMistJSToast.alert_content('Result',[res.name,res.weather[0].description,res.main.temp].join(', '))}))}\nglobal.export(getWeather)",
  "layout": {
    "style": {
      "direction": "vertical",
      "align-items": "center"
    },
    "children": [
      {
        "type": "button",
        "style": {
          "title": "点击查询天气",
          "height": 60,
          "width": 120,
          "border-color": "#a5a5a5",
          "border-width": 1,
          "margin-top": 30
        },
        "on-tap": {
          "js-getWeather": "Hangzhou"
        }
      },
      {
        "style": {
          "height": "1px",
          "width": "45%",
          "background-color": "#a5a5a5",
          "margin-top": 30
        }
      },
      {
        "type": "text",
        "style": {
          "text": "Mist 中的 JS 借助 JavaScriptCore 完成模板中较复杂的控件点击逻辑、模板中发请求等，将这些原本要写在 native 代码里的逻辑动态化。开发调试过程：\n\n1、在 on-tap 中指定需要调用的 js 方法，需以\"js-\"开头，eg. \"js-getWeather\"\n2、在 Sublime 中，Command+Shift+M -> Jump To JS File，如果不存在，会自动新建模板同名 JS 文件\n3、编写 JS 代码，当你保存时，JS 代码会被自动格式化，同步至 .mist 文件的 script 标签中，并立即重新执行，上例中：function getWeather(city) {xxx}\n4、验证 JS 逻辑，如果出错，会在状态栏提示错误信息，点击可查看详细错误，在错误页空白处双击可关闭错误窗口",
          "font-size": 13,
          "padding": 30,
          "lines": 0,
          "line-spacing": 3,
          "font-style": "light"
        }
      }
    ]
  }
}