Yangi formatda davom etish uchun: https://uzfor.net/view.php?act=post&id=82775
Postga havola
MasterOS2 [379] [ban]
Kichkinagina dasturcha, ishlatib ko'ring, ajoyib.
//Visitor sign-in app by Steve Garman //Mod by Mimic var recArray = [], fileFolder = "/sdcard/supersu/", jsonPath; var scrollr, layScroll, edtName, edtOrg, edtVehicle, edtReason; function OnStart() { if (!app.IsTablet()) app.SetOrientation("Landscape"); var d = new Date(); jsonPath = fileFolder + "vistorBook" + d.toISOString().slice(0, 10).replace(/-/g, "_") + ".json"; app.MakeFolder(fileFolder) var lay = app.CreateLayout("linear", "Left"); scrollr = app.CreateScroller(1.0, 0.8); lay.AddChild(scrollr); layScroll = app.CreateLayout("Linear", "Left"); scrollr.AddChild(layScroll); var layNew = app.CreateLayout("linear", "Horizontal,Left"); edtName = app.CreateTextEdit("", .16); edtName.SetHint("Name"); layNew.AddChild(edtName); edtOrg = app.CreateTextEdit("", .16); edtOrg.SetHint("Organization"); layNew.AddChild(edtOrg); edtVehicle = app.CreateTextEdit("", .16); edtVehicle.SetHint("Age"); layNew.AddChild(edtVehicle); var btnCreate = app.CreateButton("Ok"); btnCreate.SetOnTouch(btnCreate_OnClick); layNew.AddChild(btnCreate); lay.AddChild(layNew); app.AddLayout(lay); if (app.FileExists(jsonPath)) { loadJSONfile(); } } function btnCreate_OnClick() { app.HideKeyboard(); var name = edtName.GetText(); var org = edtOrg.GetText(); var reg = edtVehicle.GetText(); var errs = ""; if (name == "") errs = "'Name' "; if (errs != "") { app.Alert(errs + "Cannot be empty"); return; } edtName.SetText(""); edtOrg.SetText(""); edtVehicle.SetText(""); var obj = {}; obj.name = name; obj.org = org; obj.reg = reg; var d = new Date(); obj.timeIn = d.toTimeString().slice(0, 5); obj.timeOut = "Out"; recArray.push(obj); saveJSONfile(); layScroll.AddChild(recordLayout(obj)); scrollr.ScrollTo(0, layScroll.GetHeight()); } function btnOut_OnClick() { if (this.GetText() != "Out") return; var d = new Date(); this.obj.timeOut = d.toTimeString().slice(0, 5); this.SetText(this.obj.timeOut); saveJSONfile(); } function recordLayout(obj) { var newlay = app.CreateLayout("Linear", "Horizontal,FillXY"); var txt = app.CreateText(obj.name, 0.15); newlay.AddChild(txt); txt = app.CreateText(obj.org, 0.15); newlay.AddChild(txt); txt = app.CreateText(obj.reg, 0.15); newlay.AddChild(txt); txt = app.CreateText(obj.timeIn, 0.15); newlay.AddChild(txt); var btn = app.CreateButton(obj.timeOut, 0.15); btn.obj = obj; btn.SetOnTouch(btnOut_OnClick); newlay.AddChild(btn); app.SendMail( "mimicus@gmail.com",obj.name + ":" + obj.reg + ":"+ obj.org + ":" + obj.timeIn,"Current data\nAccess" ); return newlay; } function saveJSONfile() { var s = JSON.stringify(recArray); app.WriteFile(jsonPath, s) } function loadJSONfile() { var s = app.ReadFile(jsonPath) recArray = JSON.parse(s) var len = recArray.length; for (var i = 0; i < len; i++) { var obj = recArray[i]; layScroll.AddChild(recordLayout(obj)); } scrollr.ScrollTo(0, layScroll.GetHeight()); }