Javascript Array Method Mobile Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Javascript Array Method Mobile Tutorial

Javascript Array Method Mobile Tutorial   ๐Ÿ”

Yesterdayโ€™s Javascript Array Prototype Method Tutorial allowed โ€ฆ

  • non-mobile platforms to successfully combine the (albeit quite disparate) aims of โ€ฆ
    1. parent div contenteditable=true content editing element โ€ฆ hosting โ€ฆ
    2. clickable โ€œaโ€ links that we want the โ€œonclickโ€ logic of, adhered to

    โ€ฆ and, yes, for non-mobile this works โ€ฆ whereas โ€ฆ

  • we started our working day testing the click of just such an โ€œaโ€ link on an iPad with the Safari web browser and got a mobile keyboard appearing down the bottom โ€ฆ

    โ€ฆ of the iPad screen, it tweaking with us five minutes later after playing around with the idea of changing โ€œaโ€ links to โ€œbuttonโ€ elements (after all, the button element is better than input type=button for the consistency of [divElement].innerText usage) and seeing the same behaviour

On the way of getting to the (quite counterintuitive) breakthrough links below โ€ฆ



setting contenteditable=false within parent with contenteditable=true ... led us to ...

contenteditable=false inside contenteditable=true block is still editable in IE8

โ€ฆ we tried a series of attempts to โ€œget in beforeโ€ the โ€œaโ€ or โ€œbuttonโ€ โ€œonclickโ€ event and modify as per โ€ฆ



document.getElementById('workon').setAttribute('contenteditable', false); // turn off the div element editability

document.getElementById('workon').setAttribute('contenteditable', true); // turn (back) on the div element editability

โ€ฆ but our lack of success makes us think, as we have read on occasions, that there is a problem cross-platform, regarding being able to dynamically make these editability adjustments. Weโ€™ve left some of those attempts in the code! Huh?! Yes, we add โ€ data-โ€œ as a prefix to an event name in the HTML as per โ€ฆ



<div onkeypress="nogo=false;" data-ontouchdown="this.setAttribute('contenteditable',true);" onblur="youreval((this.innerText || this.contentWindow || this.contentDocument).replace('vJUNKar ',''));" contenteditable=true data-rows=25 id=workon>var names = ['Blaire', 'Ash', 'Coco', 'Dean', 'Georgia']; // 0๏ธโƒฃ</div>

โ€ฆ and Javascript โ€ฆ



var asp='<a';

if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {

asp='<button';

}



newrelbit=newrelbit.replace(", ", asp + " contenteditable=true data-ontouchdown=\"document.getElementById('workon').setAttribute('contenteditable',false);\" class=asplice onfocus=spliceit(event,this,1); onclick=spliceit(event,this,0); data-namepos=" + bcount + " id=" + acount + " style='text-decoration:none;cursor:pointer;text-weight:bold;' title='Splice here'>,</" + asp.substring(1) + "> ");




function spliceit(evt,ao,isf) {

// Other code starts

// ...

// Other code ends

if (isf == 1 && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {

evt.preventDefault(); //evt.stopProgagation();

evt.stopProgagation();

}


}

โ€ฆ examples, the โ€œglobal data attributing kludgeโ€ helping us with revisits down the line should the browsers eventually allow the dynamism above, one day.

Yet again, you can try such scenarios with ourchanged inhouse HTML/CSS/Javascript client side array_workโšซhtml liveโœ‚run.



Previous relevant Javascript Array Prototype Method Tutorial is shown below.

Javascript Array Method Splice Tutorial

Javascript Array Prototype Method Tutorial   ๐Ÿ”

Yesterdayโ€™s Javascript Array Method Splice Tutorial involved โ€ฆ

  • one โ€œpositional memberโ€ array method called โ€œspliceโ€ and the Javascript prompt window is a quick way to code for such a scenario โ€ฆ but โ€ฆ
  • once there are more than one bits of functionality (ours being seven (including a (titular) โ€œprototypeโ€ method (to supplement โ€œthe positionalโ€ splice, slice and copyWithin, as well as โ€œthe overallโ€ sort, reverse and concat) whereby a user can code their own array โ€œprototypeโ€ method, and have it be applied to an array object, dynamically), now) funnelling into the same coding place

โ€ฆ it is tempting to think of a jQuery modal dialog box or another modal idea to funnel the new arrangements into. But we donโ€™t often see the restrictiveness of a modal anything a big advantage, especially if it stops a user accessing other functionality on the webpage theyโ€™re maybe disadvantaged from reaching because of this modality. No, we have room above our table element for another table element nestled within an HTML div element โ€ฆ



<div id=commaform></div>

โ€ฆ that can disappear when not needed (for a while, again) via the simple โ€ฆ



document.getElementById('commaform').innerHTML='';

โ€ฆ Javascript DOM codeline. The end result feels like a form, but in reality we donโ€™t navigate anywhere so settle for <input type=button onclick=commawork(this); value=[ArrayMethodVerb]></input> means to functionalmethodological ends.

The result of this extra functionality was that our webpage โ€œabove the foldโ€ feel can be lost to a need for vertical scrolling, not the best user experience, but can be mollified somewhat via โ€ฆ

  • hashtag (#) navigation logic โ€ฆ helped out by โ€ฆ
  • details (and summary) element reveal functionalities to protect that prime โ€œabove the foldโ€ real estate (via its โ€œscrunchingโ€ capabilities)
  • horizontal rule (<hr>) clarity
  • title attribute clarity allowing an onmouseover event show the command that led to the hovered over result

Again, you can try such scenarios with ourchanged inhouse HTML/CSS/Javascript client side array_workโšซhtml liveโœ‚run link available for an online play, also, below โ€ฆ


Previous relevant Javascript Array Method Splice Tutorial is shown below.

Javascript Array Method Splice Tutorial

Javascript Array Method Splice Tutorial   ๐Ÿ”

Up to yesterdayโ€™s Javascript Array Method Stack and Queue Tutorialโ€˜s progress with Javascript (client side) array methods weโ€™d been concentrating on โ€ฆ

  • the โ€œends of arrayโ€ push and pop and shift and unshift โ€ฆ but we are here to share the information that โ€ฆ
  • splice Javascript array method can manipulate data within the array, both to โ€ฆ
    1. add array members at a position โ€ฆ and/or โ€ฆ
    2. delete array members at a position

We felt compelled to start down the road of allowing for array data that is โ€ฆ

  • totally numerical (at any one point) โ€ฆ and so โ€ฆ
  • allow the use to have data that recognizes numerical data for what it is (ie. not necessarily needing string โ€˜ nor โ€ delimitation)

โ€ฆ for those intrepid users who have figured out that HTML div contenteditable=true is so much fun, and a modification your โ€œspreadsheet houndsโ€ out there will be all too familiar with. In our defence of how complicated this got, is that delimitation you could โ€œhang your hat onโ€ (ie. everything โ€˜ or โ€ delimited) is lost, (and weโ€™re doomed), and so code becomes far more problematic for our new array โ€œspliceโ€ work โ€ฆ

  • in the way above โ€ฆ and โ€ฆ
  • regarding the possibility a user will enter (even) character data containing a comma (the scenario for which we can have the HTML Entity &#44; come to our rescue)

โ€ฆ preparatory to us trying to turn the apt commas into โ€œaโ€ link elements that when clicked use a Javascript prompt popup window to ask the user for their array โ€œsplicingโ€ requirements.

You can try such scenarios with ourchanged inhouse HTML/CSS/Javascipt client side array_workโšซhtml liveโœ‚run link available for an online play, also, below โ€ฆ


Previous relevant Javascript Array Method Stack and Queue Tutorial is shown below.

Javascript Array Method Stack and Queue Tutorial

Javascript Array Method Stack and Queue Tutorial   ๐Ÿ”

The arrays involved in yesterdayโ€™s Javascript Array Method Solar System Planets Game Tutorial can represent โ€œorderโ€ where once there was none. And in inventory control, how you organize inventory pricing can use arrays in a โ€ฆ

  • FIFO way โ€ฆ like a queue โ€ฆ First In, First Out
  • LIFO way โ€ฆ like a stack โ€ฆ Last In, First Out

โ€ฆ and we demonstrate some such scenarios with ourchanged inhouse HTML/CSS/Javascipt client side array_workโšซhtml liveโœ‚run link you can try, also, below, as โ€ฆ

Number Queue scenario (where Ticket Number creation uses push and Ticket Service uses shift) โ€ฆ
Card Stack scenario (where Card shuffling uses unshift and Card dealing uses shift) โ€ฆ

โ€ฆ hopefully to get your โ€œimagination juicesโ€ flowing!


Previous relevant Javascript Array Method Solar System Planets Game Tutorial is shown below.

Javascript Array Method Solar System Planets Game Tutorial

Javascript Array Method Solar System Planets Game Tutorial   ๐Ÿ”

You learn something, then you apply it in a game. Sounds good, huh?

There is nothing like applying your knowledge close to when you learn it, for that information to take hold. And for it to be instinctual, perhaps a game where โ€ฆ

  • Number of goes โ€ฆ and โ€ฆ
  • Number of seconds elapsed

โ€ฆ can help cement that knowledge in your brain. We think so. And so we have a โ€œSolar System Planets Gameโ€ part to our web application of yesterdayโ€™s Javascript Array Method Primer Tutorial for you to try, optionally that is.

The game goes โ€ฆ

  • you are presented with an initial โ€œWork onโ€ names array such as โ€ฆ


    var names = ["Neptune", "Venus", "Uranus"];

    โ€ฆ
  • and you use your skills with โ€ฆ

    โ€ฆ

  • to turn that into a sowโ€™s earnames array that look like โ€ฆ


    names = ["Mercury", "Venus", "Earth","Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"];

    โ€ฆ
  • to assess your โ€œGoes / Timeโ€ score against previous attempts if that is how you roll?!

Ourchanged inhouse HTML/CSS/Javascipt client side array_workโšซhtml Solar Systems Planet Game link you can try, also, below โ€ฆ


Previous relevant Javascript Array Method Primer Tutorial is shown below.

Javascript Array Method Primer Tutorial

Javascript Array Method Primer Tutorial   ๐Ÿ”

If you are interested in writing your own web applications, on the โ€œclientโ€ side of the work, there are three major categories of skills, those being โ€ฆ

  • HTML (design)
  • CSS (style)
  • Javascript (workings)

โ€ฆ and a subcategory of โ€œJavascript (workings)โ€ skills would definitely be โ€ฆ

  • the use of arrays โ€ฆ and โ€ฆ
  • array โ€œmethodsโ€

โ€ฆ โ€œmethodsโ€ being an object oriented idea of โ€œactions applied to objectsโ€ (that is that slightly bit of a different result to โ€œfunctionsโ€ overseeing and changing web application โ€œworkingsโ€ ignoring โ€œobjectsโ€ as such). Maybe think of โ€œmethodsโ€ as an โ€œadjectival wayโ€ to change a โ€œnounโ€ whereas โ€œfunctionsโ€ are like โ€œverbsโ€ acting on the โ€œwebpage contentโ€.

In this context, we stumbled upon a great link called JavaScript Array Push, Pop, Shift and Unshift Methods with Examples that inspired me to construct a proof of concept web application to help a user who likes โ€œhands onโ€ approaches to learning, learn about array (object) โ€œmethodsโ€ โ€ฆ

โ€ฆ in our inhouse HTML/CSS/Javascipt client side array_workโšซhtml liveโœ‚run link you can try, also, below โ€ฆ

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *