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); }
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(); } }
/** * @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()"); }
void DlgJsRoboKey::on_btnInstaRun_clicked() { loadJS(ui->memoInstaScript->toPlainText(), "instarun"); ui->lblStatus->setText(m_lastRunVal.toString()); }
TITANIUM_FUNCTION(Analytics, _start) { const auto analytics = GetStaticObject(this_object.get_context()).GetPrivate<Analytics>(); return this_object.get_context().CreateBoolean(analytics->loadJS()); }
void ReadiumJSApi::loadJSOnReady(std::string jScript) { loadJS("$(document).ready(function () {" + jScript + "});"); }
void ReadiumJSApi::openPageRight() { loadJS("ReadiumSDK.reader.openPageRight();"); }
void ReadiumJSApi::bookmarkCurrentPage() { loadJS("window.LauncherUI.getBookmarkData(ReadiumSDK.reader.bookmarkCurrentPage());"); }