Пример #1
0
bool DlgJsRoboKey::loadJSFile(const QString &file)
{
    QFile scriptFile(file);
    if (!scriptFile.open(QIODevice::ReadOnly))
    {
        return false;
    }
    // handle error
    QTextStream stream(&scriptFile);
    QString contents = stream.readAll();
    scriptFile.close();
    return loadJS(contents, file);
}
Пример #2
0
	TITANIUM_FUNCTION(Analytics, navEvent)
	{
		const auto js_context = this_object.get_context();
		const auto analytics = GetStaticObject(js_context).GetPrivate<Analytics>();

		// lazy loading
		const auto loaded = analytics->loadJS();
		if (loaded) {
			auto func = analytics->getTiObject().GetProperty("navEvent");
			return static_cast<JSObject>(func)(arguments, this_object);
		} else {
			TITANIUM_LOG_ERROR("Failed to execute Database.navEvent");
			return get_context().CreateNull();
		}
	}
Пример #3
0
/**
 * @brief DlgJsRoboKey::initialize
 *  Initialize all global objects and variables
 */
void DlgJsRoboKey::initialize()
{
    delete m_jsengine;
    m_jsengine = new QJSEngine(this);
    m_rk = m_jsengine->newQObject(m_pjsrobokey);
    m_jsengine->globalObject().setProperty("JsRoboKey", m_rk);
    m_jsengine->globalObject().setProperty("__APPFILEPATH__", QCoreApplication::applicationFilePath());
    m_jsengine->globalObject().setProperty("__APPDIRPATH__", QCoreApplication::applicationDirPath());
    m_jsengine->globalObject().setProperty("__HOMEPATH__", QDir::homePath());


    //QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
    //allow rk for short
    //make some functions global scope
    loadJS("jsrk = rk = JsRoboKey; "
           "alert = rk.alert; "
           "include = rk.include; "
           "require = rk.require", "JsRoboKey::initialize()");
}
Пример #4
0
void DlgJsRoboKey::on_btnInstaRun_clicked()
{
    loadJS(ui->memoInstaScript->toPlainText(), "instarun");
    ui->lblStatus->setText(m_lastRunVal.toString());
}
Пример #5
0
	TITANIUM_FUNCTION(Analytics, _start)
	{
		const auto analytics = GetStaticObject(this_object.get_context()).GetPrivate<Analytics>();
		return this_object.get_context().CreateBoolean(analytics->loadJS());
	}
Пример #6
0
void ReadiumJSApi::loadJSOnReady(std::string jScript)
{
    loadJS("$(document).ready(function () {" + jScript + "});");
}
Пример #7
0
void ReadiumJSApi::openPageRight()
{
    loadJS("ReadiumSDK.reader.openPageRight();");
}
Пример #8
0
void ReadiumJSApi::bookmarkCurrentPage() 
{
    loadJS("window.LauncherUI.getBookmarkData(ReadiumSDK.reader.bookmarkCurrentPage());");
}