Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 10-21-2013, 12:06 PM   #16
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by Aeris View Post
Do you think guys that it would be easy, for example, with a similar approach, turn the wifi tray icon into a switch for the wifi off/on property? Inejcting some javascript as in this case... or javascript can't launch lipc commands?
It's possible to access LIPC from pillow app and it's possible to handle tap (as a standard click event) with JavaScript. So overall answer is yes.

This code executed in context of default_status_bar should work as a wireless switch.
Code:
var invertedState = (ConnectionState.connectionOnOff ? 0 : 1);
nativeBridge.setIntLipcProperty("com.lab126.cmd", "wirelessEnable", invertedState);
eureka is offline   Reply With Quote
Old 10-21-2013, 12:48 PM   #17
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Oh, wonderful, thanks!

I'm trying with:


Code:
document.getElementsByClassName("statusBarConnectionDiv").onclick=function(){
var invertedState = (ConnectionState.connectionOnOff ? 0 : 1);
nativeBridge.setIntLipcProperty("com.lab126.cmd", "wirelessEnable", invertedState);
};
But don't know where place the code exactly in the script for make it work (PS the forum puts a space that breaks "connection" word, don't know why)

Last edited by twobob; 10-21-2013 at 01:15 PM. Reason: converted to code tag
Aeris is offline   Reply With Quote
Old 10-21-2013, 05:52 PM   #18
discopig
Book Addict
discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.discopig ought to be getting tired of karma fortunes by now.
 
discopig's Avatar
 
Posts: 132
Karma: 1040318
Join Date: Apr 2013
Location: USA
Device: Kindle Paperwhite
This works great on my PW, thanks!
discopig is offline   Reply With Quote
Old 10-22-2013, 04:26 AM   #19
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by Aeris View Post
Oh, wonderful, thanks!

I'm trying with:


Code:
document.getElementsByClassName("statusBarConnectionDiv").onclick=function(){
var invertedState = (ConnectionState.connectionOnOff ? 0 : 1);
nativeBridge.setIntLipcProperty("com.lab126.cmd", "wirelessEnable", invertedState);
};
But don't know where place the code exactly in the script for make it work (PS the forum puts a space that breaks "connection" word, don't know why)
First of all, result of getElementsByClassName is a NodeList, not an element usable for attaching event listeners.

But then, after disabling wireless this div is hidden by default script (using display: none style), so it couldn't be clicked afterwards, until wireless is enabled again. So final solution should be more complex.

UPD: ah, it's possibly not a problem on PW where div isn't hidden, but inner icon is just changed to "airplane" (I'm speculating here, because I don't have a real PW).

Last edited by eureka; 10-22-2013 at 04:48 AM.
eureka is offline   Reply With Quote
Old 10-22-2013, 06:14 AM   #20
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Code:
            <div class="statusBarRightIconDock" id="statusBarRightIconDock">
                <div id="statusBarParentalControlsIconDiv" class="parentalControlsOn">
                </div>
                <div class="statusBarConnectionDiv">
                    <div id="connectionStatusIconDiv"></div>
                    <div id="connectionSignalStrengthIconDiv"></div>
                </div>
                <div id="batteryStatusIconDiv">
                    <div id="batteryFillContainer">
                        <div id="batteryFill"></div>
                    </div>
                </div>
                <div class="statusBarTimeDiv" id="timeDiv">
                    <span class="statusBarText" id="timeSpan"></span>
                </div>
            </div>
That's why I choosed "statusBarConnectionDiv", it is the outer div that contains both...

As reference I've used this:
http://www.w3schools.com/htmldom/dom_events.asp

where it says:
Code:
<button id="myBtn">Try it</button>

<script>
document.getElementById("myBtn").onclick=function(){displayDate()};
</script>
Here the full working online sample:
http://www.w3schools.com/htmldom/try...tmldom_events2

Last edited by Aeris; 10-22-2013 at 06:33 AM.
Aeris is offline   Reply With Quote
Old 10-22-2013, 06:39 AM   #21
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
@Aeris, we aren't contradicting each other.

Yes, exactly that outer div is hidden on disabling wireless (as seen in relevant script of KT 5.3.2.1). As I've said, it might be wrong assumption in case of PW firmware.

Yes, getElementById (in case of success) returns an HTMLElement value suitable for attaching event listener.
eureka is offline   Reply With Quote
Old 10-22-2013, 06:43 AM   #22
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Ahhhh ok now I got it! Same class name could return multiple nodes... I will try again now that I know these things

I'm also thinking if it would be appropriate to modify system files directly or not, to make persistent changes (embedding the javascript in the head at least). For now it seems to me too risky

Last edited by Aeris; 10-22-2013 at 06:53 AM.
Aeris is offline   Reply With Quote
Old 10-22-2013, 07:17 AM   #23
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by Aeris View Post
I'm also thinking if it would be appropriate to modify system files directly or not, to make persistent changes (embedding the javascript in the head at least)
As an easy way, it's OK. (If you don't mind probable problems with updating.)

However, it should possible to add new Upstart job definition (into /etc/init) for running that shell script right after (re)starting pillow. Something like /etc/init/pillow_local_mod.conf (not tested at all!!):
Code:
start on started pillow

task

script
  # put here any shell code
end script
or
Code:
start on mounted_userstore and started pillow

task

exec /bin/sh /mnt/us/extensions/pillow_mod.sh
The last example is probably not very security-wise (given that script on userstore is accessible by anyone).

UPD: as you've participated in thread about substituting of "shopping cart" icon, I'd like to inform you about search_bar (containing that icon) being a pillow sub-app. So icon and its tap action could be changed in runtime without modifying any files. Slightly relevant example.

Last edited by eureka; 10-22-2013 at 07:44 AM.
eureka is offline   Reply With Quote
Old 10-22-2013, 08:22 AM   #24
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
small reminder.

Breaking upstart WILL most likely brick your kindle.

"Word to the wise" and all that.
twobob is offline   Reply With Quote
Old 10-22-2013, 08:35 AM   #25
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by twobob View Post
small reminder.

Breaking upstart WILL most likely brick your kindle.

"Word to the wise" and all that.
Right. That said, this job and its depending behavior could be tested without reboot by restart pillow command. It will not break anything and if it works, reboot will not break anything too. It it doesn't work, just don't forget to delete its job configuration file before reboot.
eureka is offline   Reply With Quote
Old 10-22-2013, 09:56 AM   #26
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
On KT/PW differences in element's positioning. At least KT 5.3.2.1 (and, I assume, PW with equally recent firmware) provides Pillow.dpi global variable in javascripts/pillow.js script included in most (all?) Pillow HTML pages. Absence of this variable could point to device definitely being KT (but I'm not sure).

This variable, not suprisingly, contains DPI value. First part of this article explains connection between points ("pt" value in CSS), pixels and DPI.

With using of this information, concrete margin values could be computed dynamically. BTW, KT has 167 DPI, PW has 212 DPI.
eureka is offline   Reply With Quote
Old 10-22-2013, 10:08 AM   #27
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Eureka, adding a <script> import row in this file:

/usr/share/webkit-1.0/pillow/default_status_bar.html

in the head wouldn't be a safer approach?

If default_status_bar.html file goes fucked up someway, the kindle shouldn't brick anyway, right?
Aeris is offline   Reply With Quote
Old 10-22-2013, 10:37 AM   #28
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by Aeris View Post
Eureka, adding a <script> import row in this file:

/usr/share/webkit-1.0/pillow/default_status_bar.html

in the head wouldn't be a safer approach?

If default_status_bar.html file goes fucked up someway, the kindle shouldn't brick anyway, right?
You're asking either wrong question, or wrong person.

"Upstart job" way with automatic runtime modifications of Pillow app internals is appealing me much more than your alternative and I personally can deal with its known quirks. I have KT with easy accessible USB downloader mode, so any "bricking" concern is not a problem for me.

But even if I would have PW, possible "unsafeness" of adding new Upstart job wouldn't bother me at all.

And direct modifying of files on system partition is just not sexy solution. So its "safeness" is not an interesting discussion subject for me in this case.

UPD: that said, both methods are equally safe from my POV.

Last edited by eureka; 10-22-2013 at 10:46 AM.
eureka is offline   Reply With Quote
Old 10-22-2013, 11:26 AM   #29
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
OK, thanks for infos!
Aeris is offline   Reply With Quote
Old 10-22-2013, 08:22 PM   #30
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Currently I switched to this safe solution: I append the script launcher as last line of every program that restart pillow during the execution (like Koreader does, for example... maybe few others)
Aeris is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
support for IBM/360/370/S-390 code on the Kindles (KUAL) knc1 Kindle Developer's Corner 63 01-08-2014 06:02 PM
Bible app for e-ink Kindles (Kindle Active Content) draytonbenner Self-Promotions by Authors and Publishers 0 10-18-2012 10:23 AM
iPad Amazon’s Kindle iOS app now ready for the new iPad’s Retina*Display monkeyluis Apple Devices 9 03-18-2012 08:27 PM
A tray app for Calibre ? thomass Calibre 3 08-21-2011 05:19 PM
So is the Iliad really production ready and is the market ready for e-readers? pdam iRex 28 09-14-2006 05:24 PM


All times are GMT -4. The time now is 02:31 PM.


MobileRead.com is a privately owned, operated and funded community.