emfunctions.hpp

Specialized, useful function for Empirical.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2015-2017 Michigan State University MIT Software license; see doc/LICENSE.md

Defines

INCLUDE_EMP_WEB_EMFUNCTIONS_HPP_GUARD
AlertVar(VAR)

Functions

static void DelayCall(const std::function<void()> &in_fun, int delay)

Call a function after a specified amount of time (in milliseconds)

static void OnResize(const std::function<void()> &in_fun)

Provide a function to call whenever a window’s size changes (no arguments).

static void OnResize(const std::function<void(int, int)> &in_fun)

Provide a function to call whenever a window’s size changes (new size as arguments)

inline double GetTime()

Get the current time, as provided by the web browser.

inline int GetWindowInnerWidth()

Determine with width of the current window.

inline int GetWindowInnerHeight()

Determine with height of the current window.

static void SetBackgroundColor(const std::string color)

Set the background color of this web page.

static void SetColor(const std::string color)
static void SetCursor(const char *type)
static void OpenWindow(const std::string &url)
static std::string text2html(const std::string &text)
String MakeHTMLLink(String text, String link, String color = "")
String MakeHTMLTrigger(String text, std::function<void()> in_fun, String color = "")

Generate a string that will associate text with a clickable link to call a function.

Parameters:
  • text – The text you want in the link.

  • in_fun – The function to call when the text is clicked on.

Returns:

The generated string NOTE: This will wrap a new function each time you call, so minimize calls!

inline std::string GetElementAttribute(const std::string &id, const std::string &attribute)

Get the value of.

Parameters:
  • attribute – in the element with

  • id – as its id.

inline void CopyText(const std::string &text)
inline void DownloadFile(std::string filename, const std::string &content)