summaryrefslogtreecommitdiffstats
path: root/src/javascriptinterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/javascriptinterface.cpp')
-rw-r--r--src/javascriptinterface.cpp75
1 files changed, 31 insertions, 44 deletions
diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp
index b480635..b45a2f9 100644
--- a/src/javascriptinterface.cpp
+++ b/src/javascriptinterface.cpp
@@ -49,6 +49,7 @@ void JavascriptInterface::attachToDOM() {
* @see JavascriptInterface::attachToDOM()
*/
void JavascriptInterface::loadJQuery() {
+ // to test if this actually works...
QString js;
QString pathToJsDir(DEFAULT_QRC_HTML_DIR);
pathToJsDir.append("/js");
@@ -56,23 +57,23 @@ void JavascriptInterface::loadJQuery() {
QDir qrcJSDir(pathToJsDir);
QFileInfoList fiList = qrcJSDir.entryInfoList();
QFileInfo fi;
- foreach(fi, fiList)
- {
- if (fi.suffix() == "js") {
- //qDebug()<< fi.fileName();
- //qxtLog->debug() << fi.fileName();
- if (fi.fileName() != "test.js") {
- QFile file;
- file.setFileName(pathToJsDir + "/" + fi.fileName());
- file.open(QIODevice::ReadOnly);
- js = file.readAll();
- file.close();
+foreach(fi, fiList)
+{
+ if (fi.suffix() == "js") {
+ //qDebug()<< fi.fileName();
+ //qxtLog->debug() << fi.fileName();
+ if (fi.fileName() != "test.js") {
+ QFile file;
+ file.setFileName(pathToJsDir + "/" + fi.fileName());
+ file.open(QIODevice::ReadOnly);
+ js = file.readAll();
+ file.close();
- _parent->evaluateJavaScript(js);
- //qxtLog->debug() << "evaluated " + fi.fileName();
- }
- }
+ _parent->evaluateJavaScript(js);
+ //qxtLog->debug() << "evaluated " + fi.fileName();
}
+ }
+}
}
//-------------------------------------------------------------------------------------------------------
// Javascript functions for webpage
@@ -178,31 +179,33 @@ void JavascriptInterface::reboot() {
*
* @todo add some more informations
*/
-void JavascriptInterface::downloadInfo(const QString& filename, const double& filesize) {
- QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(filesize);
+void JavascriptInterface::downloadInfo(const QString& filename,
+ const double& filesize) {
+ QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(
+ filesize);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
/**
* This method updates the progress bar.
*
- * This method updates the progress bar of the HTML page when an download
- * happens.
+ * This method calls a Javascript function to update the progress bar of the download.
+ * Javascript must have a function called "updateProgress" to receive this information.
*
* @todo add some more informations
*/
-void JavascriptInterface::updateProgressBar(const int& percent, const double& speed,
- const QString& unit) {
+void JavascriptInterface::updateProgressBar(const int& percent,
+ const double& speed, const QString& unit) {
if (percent == 0)
return;
- QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg(speed).arg(unit);
+ QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg(
+ speed).arg(unit);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
/**
- * This method sends notifications.
- *
- * @todo add some more informations.
+ * This method sends out messages to Javascript. A corresponding function must be implemented
+ * on the webpage to receive these.
*/
void JavascriptInterface::notify(const QString& msg) {
qxtLog->debug() << "[jsi] Notifying: " << msg;
@@ -211,27 +214,16 @@ void JavascriptInterface::notify(const QString& msg) {
}
//-------------------------------------------------------------------------------------------------------
/**
- * @todo add some more informations
+ * Sets a callback function for when downloads are finished (will be called when the queue is empty).
*/
void JavascriptInterface::callbackOnFinished() {
QString code = QString("\%1").arg(_callbackOnDownloadsFinished);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
-//-------------------------------------------------------------------------------------------------------
/**
- * This method triggers the arriving of the IP address *FOR TESTING PURPOSES*
- *
- * Used for testing. This method triggers the arriving of the IP address.
- * Not needed in the final version since the here simulated event will be
- * fired automaticali by the udhcpc command.
- * This methods writes some data into a specific file. This file is watched by an
- * other process which will fire an event as soon as the file changes.
- *
- * @see fbgui::watchForTrigger()
- * @see fbgui::checkForTrigger(const QString& dirname)
- * @see bool fbgui::checkHost()
- * @see void fbgui::loadURL()
+ * This method triggers the URL load *FOR DEBUGGING/TESTING PURPOSES*
+
*/
void JavascriptInterface::trigger() {
QFile file(fileToTriggerURL);
@@ -241,8 +233,3 @@ void JavascriptInterface::trigger() {
}
file.close();
}
-//-------------------------------------------------------------------------------------------------------
-void JavascriptInterface::alert(const QString& message) {
- // expects a formatted message.
- _parent->evaluateJavaScript(QString("alert(").append(message));
-}