public bool onJsAlert(WebView view, String url, String message, JsResult result) { System.Console.WriteLine("Message!!! " + message); Log.Debug("LogTag", message); result.Confirm(); return(true); }
public static JsResult JsError(string status, string message) { var ret = new JsResult(); ret.Status = status; ret.Message = message; return ret; }
public ActionResult CreateNextSteps() { var jsResult = new JsResult(); GoogleClient client = new GoogleClient(CurrentUser, StorageContext); if (!client.AddNextStepsEvent(null)) jsResult.StatusCode = HttpStatusCode.NotFound; JsonResult result = new JsonResult(); result.Data = jsResult; return Json(result, JsonRequestBehavior.AllowGet); }
public static JsResult JsRedirect(string url) { var ret = new JsResult(); ret.Status = Status.Ok; ret.Action = Actions.Redirect; ret.Parameter = url; return ret; }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { var alertDialogBuilder = new AlertDialog.Builder(context) .SetMessage(message) .SetCancelable(false) .SetPositiveButton("Ok", (sender, args) => { result.Confirm(); }); alertDialogBuilder.Create().Show(); return(true); }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(activity) .SetTitle("提示") .SetMessage(message) .SetPositiveButton("确定", (s, e) => { result.Confirm(); }) .Create(); alertDialog.Show(); return(true); }
public override bool OnJsConfirm(WebView view, string url, string message, JsResult result) { _res = result; var builder = new AlertDialog.Builder(_mContext); builder.SetTitle("提示"); builder.SetMessage(message); builder.SetPositiveButton(Android.Resource.String.Ok, OkAction); builder.SetNegativeButton(Android.Resource.String.Cancel, CancelAction); builder.Create(); builder.Show(); return(true); }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { var alertDialogBuilder = new AlertDialog.Builder (context) .SetMessage (message) .SetCancelable (false) .SetPositiveButton ("Ok", (sender, args) => { result.Confirm (); }); alertDialogBuilder.Create().Show(); return true; }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { AlertDialog.Builder dialog = new AlertDialog.Builder(_activity); AlertDialog alert = dialog.Create(); alert.SetTitle(""); alert.SetMessage(message); alert.SetButton("OK", (c, ev) => { }); alert.Show(); result.Confirm(); return(true); }
/// <summary> /// Alertを表示する /// </summary> /// <param name="view"></param> /// <param name="url"></param> /// <param name="message"></param> /// <param name="result"></param> /// <returns></returns> public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { var dialog = new AlertDialog.Builder(view.Context); var dlg = dialog.SetTitle("!") .SetIcon(ContextCompat.GetDrawable(view.Context, Android.Resource.Drawable.IcDialogAlert)) .SetMessage(message) .SetPositiveButton(Android.Resource.String.Ok, (object sender, DialogClickEventArgs args) => { result.Confirm(); }).Create(); dlg.SetCanceledOnTouchOutside(false); dlg.Show(); return(true); }
public async Task <JsonResult> Delete(List <string> ids) { var result = new JsResult(); var errors = new List <string>(); if (Request.IsAjaxRequest()) { foreach (var id in ids) { try { /* * we actually should not delete record from database * we just need to update delete column * await _articleRepository.collection.DeleteOneAsync(Builders<Article>.Filter.Eq("_id", ObjectId.Parse(id))); * */ var existing = await _articleRepository.collection.Find(x => x.Id == id).FirstOrDefaultAsync(); var filter = Builders <Article> .Filter.Eq("_id", ObjectId.Parse(id)); var model = Builders <Article> .Update .Set("IsActive", false) .Set("IsDeleted", true) .Set("DateUpdated", DateTime.Now); await _articleRepository.collection.UpdateOneAsync(filter, model); } catch (Exception ex) { var msg = ex.Message; result.HasError = true; errors.Add("Id: " + id + " couldn't deleted."); } } } result.ErrorMessage = result.HasError ? "Some records could not deleted!" : "Deletion is ok."; result.ErrorList = errors; return(Json(result, JsonRequestBehavior.AllowGet)); }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { Logger.Log("JS", message); if (message.StartsWith("page count: ")) { int pageCount = int.Parse(message.Split(": ")[1]); ChapterLoaded?.Invoke(pageCount); } if (message == "swipe left") { SwipeLeft?.Invoke(); } if (message == "swipe right") { SwipeRight?.Invoke(); } if (message == "swipe down") { SwipeDown?.Invoke(); } if (message.StartsWith("word selected: ")) { string word = message.Split(": ")[1].Split('|')[0].Trim().ToLower(); string sentence = message.Split(": ")[1].Split('|')[1].Trim(); WordSelected?.Invoke(word, sentence); } result.Cancel(); return(true); }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { string userName = message.Split(new string[] { "~_*_~" }, StringSplitOptions.None)[0]; string password = message.Split(new string[] { "~_*_~" }, StringSplitOptions.None)[1]; Dictionary <string, string> data = new UserPasswordData().getUserPasswordDatas(); foreach (KeyValuePair <string, string> value in data) { if (value.Key == userName && value.Value == password) { Toast.MakeText(Application.Context, "Welcome!", ToastLength.Short).Show(); result.Confirm(); Intent myIntent; myIntent = new Intent(Application.Context, typeof(MainActivity)); myIntent.SetFlags(ActivityFlags.NewTask); Application.Context.StartActivity(myIntent); return(true); } } Toast.MakeText(Application.Context, "Login failed.", ToastLength.Short).Show(); result.Confirm(); return(true); }
public override bool OnJsConfirm(WebView view, string url, string message, JsResult result) { new AlertDialog.Builder(_context).SetTitle("提示").SetMessage(message).SetPositiveButton("确定", delegate { result.Confirm(); }).SetNegativeButton("取消", delegate { result.Cancel(); }).SetCancelable(false).Create().Show(); return true; }
public override bool OnJsAlert(Android.Webkit.WebView view, string url, string message, JsResult result) { if(message.StartsWith("something") { //This is where you would look for your magic string, anything starting with your magic string is what you would extract and/or act on //Do something.... result.Cancel(); //This cancels the JS alert (there are other talked about methods of doing this but this works for me) return true; //This tells the WebView "we got this" } return base.OnJsAlert(view, url, message, result); //Let the WebView handle this since we did not find out special string }
public ActionResult PostOnFacebook(string question) { var jsResult = new JsResult(); var user = this.StorageContext.GetUser(this.CurrentUser.ID, true); if (!FacebookHelper.PostQuestion(user, this.StorageContext, question)) jsResult.StatusCode = HttpStatusCode.NotFound; JsonResult result = new JsonResult(); result.Data = jsResult; return result; }
public override bool OnJsAlert(Android.Webkit.WebView view, string url, string message, JsResult result) { if (message != "PdfViewer_app_scheme:print") { return(base.OnJsAlert(view, url, message, result)); } using (var printManager = Forms.Context.GetSystemService(Android.Content.Context.PrintService) as PrintManager) { printManager?.Print(FileName, new FilePrintDocumentAdapter(FileName, Uri), null); } return(true); }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { // the built-in alert is pretty ugly, you could do something different here if you wanted to return base.OnJsAlert(view, url, message, result); }
public override bool OnJsAlert(WebView view, string url, string message, JsResult result) { return(base.OnJsAlert(view, url, message, result)); }
public override bool OnJsAlert(Android.Webkit.WebView view, string url, string message, JsResult result) { // the built-in alert is pretty ugly, you could do something different here if you wanted to return(base.OnJsAlert(view, url, message, result)); }
public override bool OnJsBeforeUnload(WebView view, string url, string message, JsResult result) { return(base.OnJsBeforeUnload(view, url, message, result)); }
/// <param name="view">The WebView that initiated the callback.</param> /// <param name="url">The url of the page requesting the dialog.</param> /// <param name="message">Message to be displayed in the window.</param> /// <param name="result">A JsResult used to send the user's response to /// javascript.</param> /// <summary> /// Fired when a javascript confirm should be shown /// </summary> /// <returns>To be added.</returns> public override bool OnJsConfirm(WebView view, string url, string message, JsResult result) { var alertDialogBuilder = new AlertDialog.Builder(this.m_context) .SetMessage(message) .SetCancelable(false) .SetPositiveButton(this.m_context.Resources.GetString(Resource.String.confirm), (sender, args) => { result.Confirm(); }) .SetNegativeButton(this.m_context.Resources.GetString(Resource.String.cancel), (sender, args) => { result.Cancel(); }); alertDialogBuilder.Create().Show(); return(true); }
public override bool OnJsAlert (WebView view, string url, string message, JsResult result) { return base.OnJsAlert (view, url, message, result); }
public static JsResult GenerateJs <T>(BuilderType _builderType, Type[] types) { JsResult _result = new JsResult(); string _toolsHtml = string.Empty; string _metaStr = "AllMetas = {"; string _controlsStr = "var EbObjects = {};"; string __jsonToJsObjectFunc = @" function Proc(jsonObj, rootContainerObj) { $.extend(rootContainerObj, jsonObj); rootContainerObj.Controls = new EbControlCollection({}); ProcRecur(jsonObj.Controls, rootContainerObj.Controls); setTimeout(function () { console.log(' attached rootContainerObj.Controls :' + JSON.stringify(rootContainerObj.Controls)); }, 500); }; function ProcRecur(src_controls, dest_controls) { $.each(src_controls.$values, function (i, control) { var newObj = ObjectFactory(control); dest_controls.Append (newObj); if (control.IsContainer){ newObj.Controls.$values=[]; ProcRecur(control.Controls, newObj.Controls); } }); };"; string _typeInfos = "function ObjectFactory(jsonObj) { "; foreach (var tool in types) { if (tool.GetTypeInfo().IsSubclassOf(typeof(T))) { if (tool.GetTypeInfo().IsDefined(typeof(EnableInBuilder)) && tool.GetTypeInfo().GetCustomAttribute <EnableInBuilder>().BuilderTypes.Contains(_builderType)) { if (!tool.GetTypeInfo().IsDefined(typeof(HideInToolBox))) { _toolsHtml += GetToolHtml(tool.Name.Substring(2)); } var toolObj = (T)Activator.CreateInstance(tool); _typeInfos += string.Format("if (jsonObj['$type'].includes('{0}')) return new EbObjects.{1}(jsonObj.EbSid, jsonObj); ", toolObj.GetType().FullName, toolObj.GetType().Name); GetJsObject(_builderType, toolObj, ref _metaStr, ref _controlsStr); } } } _metaStr += "}"; _controlsStr += ""; _result.Meta = _metaStr; _result.JsObjects = _controlsStr; _result.ToolBoxHtml = _toolsHtml; _result.TypeRegister = _typeInfos + " };"; _result.EbObjectTypes = "var EbObjectTypes = " + Get_EbObjTypesStr(); _result.JsonToJsObjectFuncs = __jsonToJsObjectFunc; return(_result); }