Library, Rain & ul/li menus

Wow. It is really wet today.

I love the rain, yet even I resorted to running into the library for cover today. Inside the PC lab area, the rain is giving its full force unto the windows. Have a look:

Note: it was louder in person.

It is actually being a rather nice distraction here as I have woes with redesigning the menu bar for my upcoming Star Trek-themed fan site. Although there was nothing wrong with the menu before, I am currently rebuilding it on an offline test page using lists instead of modified anchors. There are pros and cons to this approach of course, with the main pro being it will naturally suit a multi-level list in the rather likely event I implement one in the future.

Here’s an interesting read on the subject:
https://css-tricks.com/navigation-in-lists-to-be-or-not-to-be/

The current issue is not being able to get the <ul> to float right. Observe the links being rendered over the logo that is floating left:
Capture

Whether you are for or against these lists, please note that currently I am only exploring my options.

Saturday was great!

Llywn-on reservoir. It is the largest of the three reservoirs in the Taff Fawr valley, Brecon Beacons National Park.

I have now revisited all three of them this year with my parents. The last time I went to these places was about a decade ago, and whilst my life has changed considerably since then, these places are as nice as I remember them. Each are large volumes of flat and relatively calm water with a ‘rangingly’ different surrounding.

Some phone photos of Llwyn-on Reservoir:

This one had a lot of forrestation around it. Whereas the first one I went to this year, the Beacons Reservoir (photos below), was mostly walled with a few interesting structures around it, and the Loops & Links path. The second one I do not have photos of, but it was similar to Llwyn-on.

Beacons Reservoir:

So if you’re in town and want a nice place to a spend a few hours or so with ranging scenes, I recommend these three reservoirs and the area surrounding them!

Why “Mobile-First” website development is actually a good thing

Upon examining my last three websites project, I have noticed a trend in the way I develop websites.

I usually design my websites desktop first/mobile later. Which has been fine until now since these offline projects were just code practise for me, and they were database-style websites that would be ill-suited for mobiles. But now, as I prepare to launch two websites that will be on the internet for the public’s viewing, I am starting to see why the “mobile-first” philosophy is actually a good one, and why modern developers should consider adhering to it.

In the last of the three older projects (which was about Aircraft Carriers), I did start redesigning the website to be content-efficient on mobile displays using CSS media queries, but the transition was troubled. I found my myself ‘hacking’ things to make things appear correctly, rewriting entire CSS stylesheets, and adding DIV containers to manipulate groups of elements better.  On my first new websites, I have opted to start transitioning to a mobile-first development scheme (I’ll explain more about why I finally decided to adopt this approach below).

Things have worked out far better this time around. Probably the best thing about this is that the transition from mobile to desktop is an expansion, whereas the transition to desktop to mobile is a contraction. Making an element contract from an already well-calculated specification can be problematic, hence some cases of rewriting the entire CSS so that everything acts uniformly. Manipulating elements designed to be small into larger elements from my experience is far easier.

The new websites look far better than all my previous efforts. But the change was incremental. The first new website, a Star Trek fan site, was only designed at the beginning with mobile devices in mind. There is a high degree of code commonality with my aircraft carrier website, except for the way I handle content efficiency. You might notice from the screenshots of my website there are these red tile objects. These are what display hyperlinks and other data that require morphing when viewed on smaller screens. Using media queries; their width, height, padding, font-size (in em instead of pixels) and optional images’ size are modified. The rest of the website’s content, such as headings and paragraphs, only have their font-size modified. The header’s size stays the same, although the standard menu gets switched into a mobile “hamburger” menu. The website is designed to be displayed in three fixed size brackets; desktop (> 1024px), tablet (< 1024px && > 768px) and mobile (< 768px). This website is due for launch before the years’ end. I will likely make a future post explaining this project.

 

(Please note that for the mobile website, a viewport meta tag is present to ensure that a phone’s web browser displays correctly and eliminates the view of that large blue margins. That screenshot is from a desktop browser.)

My second website is eventually going to serve as my personal portfolio showcase. That was written from the ground up to be a mobile size. The default CSS code is for mobile styling, and then media queries modify it to desktop styling when needed. There are also three size brackets, however the during the mobile bracket, the wrapper that usually keeps the elements in the center of the screen is not fixed and the elements can scale to fit from 768px to 480px (before, the mobile bracket offered a fixed wrapper size of 512px). The tile styling system I used previously is currently omitted from the design as I am working on a better way of flexible size data representation. The design is still being built, so no screenshots yet.

So, why this change all of a sudden? Well, the fact is that more internet users are using mobiles these days – I personally have been using my phone to browse my favourite Star Trek websites more than ever. And the fact is, you really should not give your readers a negative point about the website’s design. I have seem some reports and statements that have talked about the woes in the eyes of the consumers when they use their phone to browse a non-mobile optimised website. People are quick to form opinions based on first impressions. And if that first impression is that the website has a poorly-optimised mobile site, then it is possible that no amount of good content will remedy the situation (it is funny, yet concerning how many things you can apply that logic to as well…). But anyway, I aim to give the best impressions I can with my first proper public websites!

Compassion

It is something that seems to exist in little quantity throughout most of the world. But thankfully, it exists for me.

About an hour ago, I was lying in bed on the verge of falling asleep when I felt a sharp pain in my shoulder. Not knowing what caused it, I turned my nightlight on and realised it was a wasp that stung me.

This is the first time I have been stung (or bitten) by an apocrita (the suborder of insects that includes ants, bees and wasps). To that end, I was unsure if I was allergic to the wasp’s venom. My first reaction was to knock John’s door and ask him if there were any signs of an allergic reaction since this was on the back of my shoulder. I am glad to say that the impact seems to be minimal, and it is not hurting much now. I can also still breathe, so I assume I am not allergic.

When my attention turned back to the wasp, I realised he or she was injured.

My guess is that whilst I was still in the half-sleeping state, I must have tried to remove whatever was pricking me with my fingers. The wasp could not fly, and was trying to flee across my bed. John suggested that I either remove it or kill it.

Killing it was not an option for me. Even if I had an allergic reaction, that would not justify taking fatal action against a creature that was likely threatened by my presence. So even before I went to clean the penetration spot out to ensure no venom was left in that part of my skin, I got a piece of tissue and relocated the wasp out of my room to a place that is safer for little dude.

I truly do not know if he or she will survive, but I made sure that I gave it the best chances of survival. In the previous instances of me accidentally causing harm to insects and spiders, I have typically reacted with a lot of regret and self-loathing. This time I think I was a little more mature about it and just simply got on with trying to do what I can to make things right. Even if the wasp dies, I can rest knowing I tried.

And I am glad I reacted as such though – my thoughts were focused on trying to save the little fella above all else.

One of the most amazing things about this planet is its wildlife. And I am not just talking about the ‘desirable’ mammals like cats and dogs, but species like wasps, spiders, snakes, sharks, scorpions… They all deserve to live, even if you think that they are annoying or you are scared of them. We are currently in the middle of one of Earth’s largest extinction-level events (known as the Holocene extinction). I would be damned if I gave up on trying (where possible) to not be a contributing factor of it. As impossible that may seem in this day and age.

Fun planning, dank milestones. KAubersnek style.

So, the results from yesterday.

You will be pleased to know the solution works! I have yet to do extensive/thorough testing, although I am doing on-the-fly debugging in the meantime until I achieve this first operational milestone. And that is what I want to talk about. Milestones.

I do love my planning, and I have thought out a fair bit about what I want the program to be once it is done. So far, I have a well-defined operational milestone that I am dubbing “Full Operational Capability” (very professional sounding). This milestone is reached once the core functionality of the browser is complete. That means no advanced developer tools are being added at this stage, nor will the styling be finalised. Basically, the following criteria must be met:

  • Basic web functionality
    • Direct navigation
    • Past and forward history traversing
    • Native search query forwarding
  • Basic user settings
    • Home page setting
    • Search engine setting
    • Basic UI layout settings (hiding the bookmark bar, etc.)
  • Basic bookmarking system
    • Tab-based bookmark-managing functionality
    • UI bookmark bar
  • Basic ‘luxuries’ (you could consider these non-essentials)
    • Custom source code view
    • Custom context menu for default right-clicking within the GeckoWebBrowser
    • Custom download management capabilities
    • InPrivate browser

This milestone determines how far the project will go. If I am unable to create a usable web browser by not meeting this criterion, I will either cancel the project or postpone it until a time I have learnt what I need to know to complete this. Remember, I am always learning.

However, if this milestone is reached, I will then begin work on the next two milestones:

  1. Developer Tools Completion
    • This stage involves implementing some of the advanced developer features that the project is designed to accommodate. This includes the addition of a non-WYSIWYG webpage editor with helpful options designed to speed up the development of HTML and CSS code without the clutterful and fun-sapping ways of WYSIWYG designers such as Adobe Dreamweaver. This functionality is currently being explored in a project called “KAubershark”, which I am not prepared to reveal yet (it is still very rough and early)
  2. UI Design Unification
    • This stage involves finalising the overall design of all aspects of the software. This includes making the design unique and unified across all forms, dialogs and controls. After this is done, the project will be complete.

I have not gone into too much detail for these milestones in case of further refinements to the ideas. What I gave you is a basic brief of what the work entails, but I do have other ideas that I am still playing around in my head with. Work on ‘KAubershark’ is currently on hold until the first milestone is complete. It originally started as a standalone idea as a non-WYSIWYG development suite, and what code I have done for it is currently in a separate solution. That work is mostly rough and is for the purpose of exploring the plausibility of the idea, since it will naturally be a huge task and I want to make sure it is worth the effort. The final way I am going to implement KAubershark is not finalised either. My two options are to integrate the work into KAubersnek’s solution, or keep it as a separate standalone software and add a bridge for the two applications to access each other.

So that is it for this post! I hope you appreciate the insight, and please watch this space!

Problem-solving with KAubersnek

Straight into this.

KAubersnek is my project to create a personal (and only for me) web browser that will aid me in developing websites by providing me with custom developer-focused tools (and will serve as a piece within my future portfolio of work). However. Currently, I am far from realising that goal. But for now, I have been making considerable progress in maturing the basic web browser itself into a usable frame to work with.

2017-06-18_1508
KAubersnek as it looks currently (2017-06-18)

The UI is currently based heavily on the open-source Chromium (of which Google Chrome is a well-known release of) UI. But one of the goals for reaching what I am calling the “full operational capability milestone” is to have a custom tab design. However, designing the UI is currently taking a backseat role in favour of allowing the UI to be more flexible for when I add crucial features take enable the browser to be fully operational.

So that’s pretty much the overview, but today when I was working around a me-induced bug/oversight, I thought that I might be cool to write down this problem with a methodical solution so that I could convey what it is like to be a programmer (at least in my eyes) when solving a problem. Here goes nothing. Also, one more thing. This is written in a way that allows it to be understood (I hope) by almost anyone with at least some basic idea what programming is like. To that end, I will be attempting to explain some of the more complex concepts that people might have trouble getting their heads around. But I at least hope you know what a class, object or a control is. If not, you might want to look them up first.

The problem
When loading a website in the browser, you had to remain on the current tab until the page was loaded. Otherwise, switching tabs during the download resulted in some of the results of the download (namely the website’s title) being applied to the wrong tab. This was because the code originally forwarded the downloaded title from the user control the GeckoWebBrowser object is a member of, to the currently-active tab on the TabControl object which is housed on the main form. As aforementioned, this was a simple oversight as it was just a case of the data being sent to the wrong object in some specific cases.

What it looks like
2017-06-18_2125.png

Listed process ‘chart’

  1. A webpage download action is taken by the user within the browser; via URL navigation, web search or hyperlink navigation
  2. The user switches tab whilst the download is in progress
  3. The download completes within the other tab, and the DocumentComplete event is triggered on that instance of the browser
    • The DocumentComplete event gets triggered when the GeckoWebBrowser object declares that it has finished downloading the webpage and its content
  4. The DocumentComplete event code sets the text of the currently-selected tab as the DocumentTitle of the downloaded webpage, as reported by the GeckoWebBrowser
    • There is no check/flag to see if this is the correct tab that actually contains the user-created control with its GeckoWebBrowser

Analysis
The reason why this is not a simple cakewalk is because of how the structure of the program is. It is not one large object called ‘browser’. The ‘parental’ structure that I have to deal with looks like this:

  • The actual powerhouse under the hood (that is the browser) is the GeckoWebBrowser object.
  • The GeckoWebBrowser object is housed within a user-created control, which is a class that contains the GeckoWebBrowser object and all the controls needed to operate the browser at the basic level (buttons, address box, options menu, progress bar and status display label).
  • This user-created control is docked onto a TabPage object when the tab is first created. This TabPage is actually the object that contains the crucial property known as ‘Text’. This property is what gets updated each time a webpage is finished being downloaded.
  • The TabPages are then added to the TabControl’s TabPage collection. This collection is then represented as clickable tabs on the main form.

With that in mind, you can begin to picture what the issue is. Although the user-created control is docked onto a TabPage, that user-created control does not have a native ability to tell what its ‘parent’ object is. So, when the DocumentComplete event proceeded to update a TabPage’s ‘Text’ property, it does not care or recognise if the user switches TabPages by clicking one of the visual tabs. It just updates the selected tab. This problem is an oversight because I should have seen it coming, since I must put more code in to fix this either way. Now that I see what the issue is, I can now easily implement my three-part solution.

Solution

  1. I added an integer variable inside the user-created control called ‘intPosition’. This variable will store a value that indicates what position its parent TabPage should be at within the TabControl’s TabPage collection (known as index). So now the code that updates the TabPage’s ‘Text’ will know what TabPage to apply the change to. This position variable is initialised as soon as after the user-created control instance and its mounting TabPage is being created, and the value is based off the current number of TabPages within the index.
  2. I also added some code that updates the position variable in all opened instances of the user-created control when there is a change within the index. Changes to index are made when a tab is opened, closed or moved around. So this code is a must for such scenarios. For example; if I had three tabs open and I close the middle one, the third tab will have its position variable updated since it has now become the second tab in the index, and the browser would need to know that otherwise the program would literally DIE in runtime. Okay. Maybe not that extreme. But it would be bad.
  3. The code within the DocumentComplete event is updated so that it references the TabPage it needs to access via the index (cross-referenced with the position variable) instead of accessing whatever is the currently-selected index is.

Code

2017-06-18_2103
Code that creates the user-created control instance and TabPage
2017-06-18_1941
Code that updates each instance’s position control variable

Conclusion
I actually have not tested this yet. It is almost the end of today, so I will enjoy a sleep before I make sure the changes work. In theory, this should work no matter what however. But I will let you know tomorrow. My next post on the subject will go more in-depth about the goals and milestones of the project.

Anyway, I hope you enjoyed the read! 😊

Falklands War Commemorative Carrier Coin

So I just started collecting coins now it seems.

Today I received my second coin from World Challenge Coins, a neat company that sells a lot of British military coins (among other coins). The first one I ordered back in September 2016 was a commemorative Avro Vulcan bomber silver coin. This one is for the Falklands War carrier fleet, namely light carriers HMS Hermes (R12), Centaur-class, and HMS Invincible (R05), Invincible-class. I decided to order this coin as my personal tribute to both of these fine carriers that served the Royal Navy well under trying time of war and increasing budget cuts. I also fancied completing a 16-coin 35-year-anniversary collection dedicated to the Falklands War that came with it (a fancy cardboard ‘ammo box’ for holding them came with the coin).

The coin itself is silver. There was an option to upgrade to gold, but I did not have enough money to spare for it at the time. This coin cost £4.99 + £2.50 delivery. The coin has a fair bit of weight to it, even when it is out of the included protective casing. The photos I took of it in relatively-poor lighting do not do the coin’s quality justice, as it is a fine piece of pressed metal.

Coin_01
Both sides of the silver coin

I guess at this point I should do the usual disclaimers, like saying that I by no means support the deaths that occurred during the conflict. Because I don’t, and all I wanted is something to remember these amazing, misunderstood machines that I love so much by!