• The forum software that supports hummy.tv will be upgraded to XenForo 2.3 on Wednesday the 20th of November 2024 starting at 7pm

    There will be some periods where the forum is unavailable, please bear with us. More details can be found in the upgrade thread.

Help required with coding

Trev

The Dumb One
I found THIS thread a couple of days ago and thought to myself "I'll have some of that". However, when I started 'going into' it, I realised that I didn't know enough about the protocol of green and red text etc. so decided to ask for help rather than brick my box, as they say.

So' I'll repost the code to save swapping about then 'give it some' with questions.
Diff:
--- /mod/webif/html/lib/topbar-orig.jim
+++ /mod/webif/html/lib/topbar.jim
@@ -27,11 +27,18 @@
if {[system model] eq "HDR" && [system usbdisks] > 0} {
     source /mod/webif/include/usbeject.jim
}
+set dmson [system param DMS_START_ON]
+set lstn [system is_listening 9000]
+set stat [expr $dmson?"Server is enabled":"Server is disabled"]
+set img [expr $dmson && $lstn?"181_1_00_Help2_Green.png":"181_1_00_Help1_Red.png"]
+set stat [expr $lstn?"$stat and is running.":"$stat and is NOT running."]
source /mod/webif/include/vfd.jim
-puts {
+puts "
<div id=idletime></div>
-</div>
-}
+<div id=serverstat>
+Server Status: &nbsp;<img class=va src=/images/$img title=\"$stat\">
+</div></div>
+"
source /mod/webif/include/toolbar.jim
puts {
<script type=text/javascript src=/js/topbar.js></script>

The top two lines seem to point at two files with preceding --- and +++
I have the file ".../mod/webif/html/lib/topbar.jim" but not the file ".../mod/webif/html/lib/topbar-orig.jim". Presumably the latter is a backup for 'brick' prevention?

Q1. What is the relevance of the --- and +++ in front of these two lines?
Q2. I assume that green lines starting with a '+' are to be added where indicated in the code and those in red starting with a '-' are to be deleted? But are the '+' left in (I guess not?)
Q3. What about the last line that is in red, but has no '-'
Q4. What is the third line, "@@ -27,11 +27,18 @@" all about?
 
Those are standard output from the diff command for comparing two text files, and can be used as input to automatically insert the patches. I went into all this a few months ago (let me find it)...
 
Here it is; syntax is described in post 3, and a means to apply the patches directly in post 2.

 
I have the file ".../mod/webif/html/lib/topbar.jim" but not the file ".../mod/webif/html/lib/topbar-orig.jim". Presumably the latter is a backup for 'brick' prevention?
That's just the previous version of the file that somebody saved in order to do the compare. The name is irrelevant.
Q1. What is the relevance of the --- and +++ in front of these two lines?
It identifies them as a header block for what follows.
Q2. I assume that green lines starting with a '+' are to be added where indicated in the code and those in red starting with a '-' are to be deleted? But are the '+' left in (I guess not?)
Yes and no, respectively.
Q3. What about the last line that is in red, but has no '-'
Those would seem to be display artifacts/errors. If it doesn't start with + or - then don't do anything to it.
Q4. What is the third line, "@@ -27,11 +27,18 @@" all about?
It gives context i.e. the location and line count of what to change in old and new.

You could always copy the contents of the patch into a temporary file and then use the patch command to apply them
e.g. patch -p 0 -i /tmp/patchfile --dry-run
and then when you're happy it's going to do the right thing patch -p 0 -i /tmp/patchfile

Edit: the --dry-run option doesn't seem to be implemented on the default busybox version on the Humax.
 
Last edited:
Thanks for that BH and prpr.
I think I'll make a backup of the two relevant files then do the mods manually. Don't like to wander too far into the unknown all at once without leaving a breadcrumb trail.
 
OK, I've done the changes, but the new Server Status text and image (which works OK) are a bit below the grey top bar, and in the main hidden by the "What's the box doing" overlay.
Double checked my mods and it seems correct.
Any ideas?
 
Just what you don't want, someone to take a guess, ah well here goes anyway, either the top 65 line or the red minus 3 lines above it

4123
 
OK, I've done the changes, but the new Server Status text and image (which works OK) are a bit below the grey top bar, and in the main hidden by the "What's the box doing" overlay.
Double checked my mods and it seems correct.
Any ideas?

I suspect you have made the changes to topbar.jim but not the following changes to mod/webif/html/css/style.css its those that position and style the elements.
 
Just what you don't want, someone to take a guess, ah well here goes anyway, either the top 65 line or the red minus 3 lines above it

View attachment 4123
In css empty lines are irrelevant, so whether one is there or not does not matter, however a missing closing } will make following rule fail, equally failing to set the selector correctly will cause its rules to be ignored, selectors start with # for id selectors and with . for a class. Selector rules are contained within {} brackets.
 
@ezra pound. Yes, guesses are not what you want under these circumstances.
@Matthew. Thanks for your input. I have in fact changed the code in style.ccs as per your stuff in your thread that I linked to in post #1 (I think)'
Here is the relevant part of my toolbar.jim.
Code:
if {[system model] eq "HDR" && [system usbdisks] > 0} {
    source /mod/webif/include/usbeject.jim
}
set dmson [system param DMS_START_ON]
set lstn [system is_listening 9000]
set stat [expr $dmson?"Server is enabled":"Server is disabled"]
set img [expr $dmson && $lstn?"181_1_00_Help2_Green.png":"181_1_00_Help1_Red.png"]
set stat [expr $lstn?"$stat and is running.":"$stat and is NOT running."]
source /mod/webif/include/vfd.jim
puts "
<div id=idletime></div>
<div id=serverstat>
Server Status: &nbsp;<img class=va src=/images/$img title=\"$stat\">
</div></div>
"

source /mod/webif/include/toolbar.jim
puts {
<script type=text/javascript src=/js/topbar.js></script>

<!-- end of topbar -->
}
And the relevant bit of style.ccs
Code:
#idletime, #serverstat
{
    position: absolute;
    left: 50px;
    top: 45px;
    font-style: italic;
    font-size: 12px;
}
#serverstat {
      left: 32px;
      top: 65px;
}
#serverstat img{
      width: 26px;
      height: 26px;
}
div.footer
{
    clear: both;
    padding-top: 2em;
}
What have I screwed up please?
 
The css file may be cached by your browser so you may want to restart it or force a page reload to see if that makes a difference.
Often pages don't display correctly immediately after a package update
 
Thanks Myms. f5 sorted it. Simples. How easy was that? Nothing screwed, just a forgetful old fool. (See my tile on my avatar).:frantic:
Thanks also to all who contributed to my major success story :)
 
Thanks Myms. f5 sorted it. Simples. How easy was that? Nothing screwed, just a forgetful old fool. (See my tile on my avatar).:frantic:
Thanks also to all who contributed to my major success story :)
You'll soon be writing your own packages !
 
The css file may be cached by your browser so you may want to restart it or force a page reload to see if that makes a difference.
Often pages don't display correctly immediately after a package update
:thumbsup_:

That`s what I was just about to suggest, some browsers are ridiculously aggressive with caching these days, especially WebKit based ones (chrome, safari etc) I get really annoyed when they even go caching error pages, have they redefined what 401/404/500 means!! :mad:
 
I use Chrome on my computers. I haven't tried on my tablet yet.
Writing packages? No problems. I'm a black belt now. :roflmao:

404? Yes they do seem to have redefined it into some mamby pamby snowflake statement that will not offend the idiots who type the wrong URL.
 
Time flies like an arrow.
Fruit flies like a banana.
Were you perhaps referencing this classic?
Mathematics Made Difficult - Carl E Linderholm - p149 said:
'Fruit flies like a banana' is a proposition in entomological gastronomy, whereas 'Fruit flies like a banana' is a proposition in horticultural aerobatics.
 
Last edited:
Were you perhaps referencing this classic?
Not directly (too profound for me!). I expect wherever I picked it up from was though.
I just liked the whole noun/verb thing. I don't know whether this is peculiar to English or not, seeing as I've virtually forgotten all of what foreign languages I did know.
 
Back
Top