<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Semih Durmus on Medium]]></title>
        <description><![CDATA[Stories by Semih Durmus on Medium]]></description>
        <link>https://medium.com/@semihdurmus?source=rss-985d5b29995b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c3DolgqRS0HQrb2gfY7aow.jpeg</url>
            <title>Stories by Semih Durmus on Medium</title>
            <link>https://medium.com/@semihdurmus?source=rss-985d5b29995b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:24:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@semihdurmus/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploying a Django Project to Heroku]]></title>
            <link>https://semihdurmus.medium.com/deploying-a-django-project-to-heroku-b0487a9f9b3e?source=rss-985d5b29995b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0487a9f9b3e</guid>
            <category><![CDATA[django-on-heroku]]></category>
            <dc:creator><![CDATA[Semih Durmus]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 10:53:27 GMT</pubDate>
            <atom:updated>2021-02-01T15:57:22.062Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DGlhUZZGPMjDJ7KrH7H8g.png" /><figcaption>Django to Heroku</figcaption></figure><ol><li>Remember to read <a href="https://devcenter.heroku.com/articles/deploying-python">official documents</a> first.</li></ol><p>2. When deploying a django project to heroku; <strong>requirements.txt </strong>and <strong>.gitignore</strong> files should be inside <strong>src</strong> folder. <strong>.env</strong> should also be there, but since we can manually add <strong>SECRET_KEY</strong> to heroku there is no no need to move the file into <strong>src</strong>. Also a good practice to duplicate <strong>.gitignore</strong> file into <strong>src</strong> folder if you have already initialised your project to GitHub.</p><p>3. Install the following packages in your command line</p><p>For Mac</p><pre>$ python3 -m pip install gunicorn</pre><pre>$ python3 -m pip install django-heroku</pre><p>For Windows</p><pre>$ py -m pip install gunicorn</pre><pre>$ py -m pip install django-heroku</pre><p>4. Go to <strong>settings.py</strong> and do the following</p><pre>import django_heroku</pre><p>Add this to the bottom of the page</p><pre>django_heroku.settings(locals())</pre><p>5. Make sure the directory is <strong>src</strong> and write this to command line</p><pre>pip freeze &gt; requirements.txt</pre><p>6. Create a file named <strong>Procfile</strong> under <strong>src</strong> folder. Write this code block inside the file. Make sure to write project name folder correctly. (It is simply the folder where <strong>settings.py</strong> is located)</p><pre>release: python manage.py makemigrations --no-input</pre><pre>release: python manage.py migrate --no-input</pre><pre>web: gunicorn prj_folder_name.wsgi</pre><p>7. Open <a href="http://heroku.com/">heroku</a>. Sign up if you have not already. New &gt; Create new app. Write the name of the app and select a proper region. (Assume the name of the app as <em>heroku-project-name</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z7kYRAZUQvGDQ4mlCuLLGA.png" /></figure><p>8. Open the app. Go to Settings &gt; Config Vars &gt; Reveal Config Vars. Write SECRET_KEY as key, and write your secret key (which should already be written in .env file) to value fields and Add.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3UmNA0zvF4W-rs2jrY2ZA.png" /></figure><p>9. Go to Deploy. Here we will use <strong>Heroku Git</strong> because it is much easier for those who has initiated the project to GitHub before. Download and install <a href="https://devcenter.heroku.com/articles/heroku-cli">Heroku CLI</a> if you have not done before.</p><p>10. Go to your CLI and and follow the code snippets below. Again make sure that the directory is src.</p><pre>$ git init</pre><pre>$ heroku login</pre><pre>$ heroku git:remote -a heroku-project-name</pre><pre>$ git add .</pre><pre>$ git commit -am “your commit message”</pre><pre>$ git push heroku master</pre><p>11. Congratulations your project is deployed to heroku. Now you can reach your project from the url <a href="https://heroku_project_name.herokuapp.com/">https://heroku-project-name.herokuapp.com</a></p><p>12. One more thing: Your data in SQLite3 database and user information does not exist any more. You should create required data once again. It’s good to start with creating a super user and make some customisation at admin panel.</p><p>13. Go to your CLI.</p><pre>$ heroku run bash</pre><pre>$ python manage.py createsuperuser</pre><p>14. Login to <a href="https://heroku_project_name.herokuapp.com/admin">https://heroku-project-name.herokuapp.com/admin</a> and manipulate data in admin panel.</p><p>15. Good tip is to try your paths, authorisation &amp; permissions with POSTMAN.</p><p>&lt;/Have a nice day&gt;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0487a9f9b3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up React Native Vector Icons for IOS]]></title>
            <link>https://medium.com/clarusway/setting-up-react-native-vector-icons-for-ios-a5d57e78cdb2?source=rss-985d5b29995b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5d57e78cdb2</guid>
            <category><![CDATA[react-native-vector-icons]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Semih Durmus]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 01:27:14 GMT</pubDate>
            <atom:updated>2020-12-23T20:05:13.420Z</atom:updated>
            <content:encoded><![CDATA[<p>Icons tell more than plenty of words do. That’s why they are widely used in mobile applications where design really matters. React Native Vector Icons is a great package offering a large variety of handy icons for mobile apps. This article will explain how we set up and use vector icons in React Native apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q3a4jdwQfiMATYCf" /><figcaption>Photo by <a href="https://unsplash.com/@aquatium?utm_source=medium&amp;utm_medium=referral">Harpal Singh</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First of all always remember to see the <a href="https://github.com/oblador/react-native-vector-icons">official document</a> for React Native Icons. This article will guide you specifically for IOS, and in an simple way that everybody can follow easily.</p><p><strong>Step-1: Installing the package</strong></p><p>Add a new terminal in VS Code and type one of the following codes according to your choice between npm or yarn.</p><pre>$npm i react-native-vector-icons</pre><pre>or</pre><pre>$yarn add react-native-vector-icons</pre><p>After the installation, it is better to check the package.json file if the react-native-vector-icons package is installed successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rpiw0d8c3KDfvtzv39zQ9g.png" /><figcaption>See the dependencies section</figcaption></figure><p><strong>Step-2: Copying font files to Xcode</strong></p><p>Open Xcode by opening the file in the following path:</p><pre>project-name-folder/ios/project-name.xworkspace</pre><p>…or you can just start the Xcode and open your project folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*EWJux1GPcpklUb7iCDiRpw.png" /><figcaption>Open a project or file</figcaption></figure><p>Now, right click on the folder with the project name (<em>in the example below the project name is workspace</em>) and choose ‘New Group’. Then rename the file you’ve just created as ‘Fonts’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2G_3lcXMBXn4vzZPmHygbA.png" /></figure><p>Open your main project folder and go through node_modules/react-native-vector-icons/Fonts. You will see the listed fonts as in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*vLC1wSmn-S9966r1XeiwDA.png" /></figure><p>From the list of .ttf files drag and drop the vector icon fonts of your choice(s) to the Fonts folder you created at Xcode. It’s wise to decide on the icons to use before, and upload just the font families including those icons. You can find the list of icons in the <a href="https://oblador.github.io/react-native-vector-icons/">react native vector icons directory</a>.</p><p>Once you drag the selected font files, make sure that ‘Copy items if needed’ and ‘Create folder references’ alternatives are selected. Then click ‘Finish’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIOmjReQ1Nzqi_UDk9aQcw.png" /><figcaption>Adding font files to Xcode</figcaption></figure><p><strong>Step-3: Setting up the Xcode</strong></p><p>Find and click on the ‘Info.plist’ file under the project-name folder. Then click the ‘+’ button on the top row (Information Property List) and choose ‘Add row’ from the list. Rename the created row as ‘Fonts provided by application’. It should be an auto-completed text, but no worries if it is not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*IiQuHoJxG-y5XhPXfU7QaA.png" /><figcaption>Add a row -&gt; Fonts provided by application</figcaption></figure><p>Click on the + button next to the ‘Fonts provided by application’ row and create as many items as the number of fonts you wish to use in the app. Write the full name of the font file (i.e. MaterialCommunityIcons.ttf) to the value section of each item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*h5mcyRfagBbge_CDg4ta6A.png" /><figcaption>Writing the name of the font file to value section</figcaption></figure><p><strong>Step-4: Pod Installing</strong></p><p>Now it’s time to update the pod. From the bash terminal in VS Code, run the following codes:</p><pre>$cd ios<br>$pod update<br>$cd ..</pre><p>Go back to Xcode. From the menu bar above, select ‘Product’ &gt; ‘Clean Build Folder’ then Run the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*rM-HvHU0sQRtvWkacKHi8w.png" /><figcaption>Clean Build Folder and Run</figcaption></figure><p><strong>Step-4: Use the Icons</strong></p><p>Pick the name of the icon from the <a href="https://oblador.github.io/react-native-vector-icons/">icons directory</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*yOePC8nSxrKouuEq8J2Thw.png" /><figcaption>Name of the icon</figcaption></figure><p>Then use it as shown in the code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBbV6ut52kg2W0LHwQK2iA.png" /><figcaption>An example use of the vector-icons</figcaption></figure><p>You can see many more options for using vector icons in the <a href="https://github.com/oblador/react-native-vector-icons">document</a>.</p><p><strong>Step-6: Enjoy the icons</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*pUy7ME3dkaRb6sNBO2iflQ.png" /></figure><p>Thanks for reading. You might want to check<a href="https://clarusway.com/blog/"> Clarusway blog</a> pages for more informational articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5d57e78cdb2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clarusway/setting-up-react-native-vector-icons-for-ios-a5d57e78cdb2">Setting up React Native Vector Icons for IOS</a> was originally published in <a href="https://medium.com/clarusway">Clarusway</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making a ToDo List with HTML, CSS and Javascript]]></title>
            <link>https://medium.com/clarusway/making-a-todo-list-with-html-css-and-javascript-154839b770b6?source=rss-985d5b29995b------2</link>
            <guid isPermaLink="false">https://medium.com/p/154839b770b6</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[to-do-list]]></category>
            <dc:creator><![CDATA[Semih Durmus]]></dc:creator>
            <pubDate>Wed, 07 Oct 2020 10:14:44 GMT</pubDate>
            <atom:updated>2020-12-24T22:31:43.780Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I would like to dedicate this story to our honourable instructor </em><a href="https://medium.com/u/e73a6994f6f8"><em>Ezran Bayantemur</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bWgvqfR0mozr2E18" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>One of the popular projects in terms of understanding the object &amp; class structure in Javascript is <strong>ToDo List</strong>. It is not hard to make up this project, yet it requires attention in certain points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rne71dHouj3ynazj0SUCTQ.png" /><figcaption>This is the final stage we’d like to reach</figcaption></figure><p>How does it function?</p><ul><li>User can write todo items in an input, and can add the items to an array by clicking the “Add” button.</li><li>Every time user adds an item, all the items are displayed on the screen, the latest one on top.</li><li>User can change the status of the items from undone to done or vice versa, just by clicking on them. Done items show up with a tick sign at the beginning and struck through.</li><li>User can delete any item at any time by clicking on the trash bin on the right side of each row.</li></ul><p>We will go over HTML, CSS and JS parts. You can directly skip to JS part if you’d like to.</p><h3><strong>Part-1 HTML</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_pextwqCx8pBUmkLbxNIA.png" /></figure><p>To explain briefly; in the &lt;head&gt; section we add meta tags, the link tag for connecting the document to style.css file, the script (that helps us to pull an icon from <a href="http://fontawesome.com/">fontawsome.com</a>. In this specific example we’ll only pull the trash can icon), and the title respectively.</p><p>Then it comes to &lt;body&gt;, we have 2 sections: &lt;header&gt; and &lt;ul&gt;. In the &lt;header&gt; element we have a &lt;h1&gt; title, and below we have a text input element for the user to enter the ToDo items in, and a button that we will use for getting the input values. Below the &lt;header&gt; we have an empty &lt;ul&gt; element. This is where we will display the input items in &lt;li&gt; elements when we get inputs from the user.</p><p>Each &lt;li&gt; elements under &lt;ul&gt; will look like this:</p><pre>&lt;li data-id=”0&quot;&gt;Clean the garden&lt;/li&gt;</pre><p>And the element below is the one for displaying trash can, which will be placed as a child of each &lt;li&gt; element.</p><pre>&lt;i class=”far fa-trash-alt”&gt;&lt;/i&gt;</pre><p>Finally, at the end of the &lt;body&gt; part we link the Javascript file in a &lt;script&gt; tag.</p><h3>Part-2 CSS</h3><p>First I should remind you that all the content in CSS part is up to the person’s understanding of design. The choices here are my personal preferences, so feel free to change anything you see here.</p><p>We import the “Acme” font style from <a href="https://fonts.google.com/">Google Fonts</a>. We will use this font for the &lt;h1&gt; title.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4juS6ALyRkqpRG5vGq1yqw.png" /></figure><p>Then we do the resetting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jht4UXI4Y5Aiwi5-UM2Rg.png" /></figure><p>Styling the &lt;header&gt; and the &lt;h1&gt; title. We can arrange the linear gradient colours and pull the code from <a href="https://cssgradient.io/">https://cssgradient.io/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkWQGF4x0ZB-DSGxXGErvA.png" /></figure><p>The input element shares 75%, and the “Add” button shares 25% of the total width, (which is restricted by 40px paddings on each side on header section.) To make both elements at equal height; we use the same font style, size and padding values. Transition value at “Add” button is for setting the duration of style change from normal to hover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yTcyCikJuuHENvayKToPEg.png" /></figure><p>Up to here we styled the elements which are visible. Now we will set design for elements which do not exist in the beginning, but will appear as we get user inserts. These elements are simply the &lt;li&gt; elements containing the ToDo texts and more.</p><p>All the &lt;li&gt; elements should appear the same way, so there is no need to label them with class or id. That’s why we use the selector ul li. First we set the cursor to pointer to show the user that this is a clickable element.</p><p>Then we set position to relative. This is because we are going to add two items/icons as a child or as a before pseudo element, and we are going to position the icons in relation to the &lt;li&gt; elements’ position. One way to accomplish this is by giving position absolute to the child elements. But in order for them to take position in respect to the parent element, we have to give the parent element position relative.</p><p>Again transition value is for setting the duration of style change from normal to hover. Preferable we do not want the elements to be selectable by the user. Therefore we set user-select property to none, and add extra codes so that this takes effect in several other browsers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2PJvPZgTgrqZL5mNk-7Fw.png" /></figure><p>We said all the &lt;li&gt; elements would have the same style. The only difference is that we set the elements with an odd sequence number to a darker background to make the list easier to be read (ul li:nth-child(odd). We could attain a very similar result by setting the colours of even elements (ul li:nth-child(even).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*STdxvWQrJxcyI5t14Rrr7g.png" /></figure><p>Finally we set the style for &lt;li&gt; elements with .checked class. reason for setting this class will be explained in the JS part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXwfdoj7bFCPt0M7ijp_CA.png" /></figure><p>Now we are creating the tick icon on the left by using before pseudo element. What we do here is to make up a vertical rectangle having a height of 15px, and width of 7 px, and with no background colour. Then we set 2px of border to only 2 sides making it look like a mirrored letter “L”. When the icon is rotated 45 degrees clockwise with transform property, we get an icon exactly look like a tick. Finally we position the icon absolute to the parent &lt;li&gt; element, so that it shows up at the beginning of the line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_BilAQ2oD_sHvVSoo1TtA.png" /></figure><p>Finally we put the trash icon, which we pull from <a href="http://fontawesome.com/">fontawesome.com</a> to the right.</p><pre>&lt;i class=”far fa-trash-alt”&gt;&lt;/i&gt;</pre><p>As we remember the icon has built-in class names, so we can use the existing class names for styling. Like in the tick icon we give &lt;i&gt; element position absolute, and place them to the right side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-L4McO3QbVLvbozC9Si9lA.png" /></figure><p>Here is how the tick and trash icons look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhDI-pY2T3s6hQJZrePT_g.png" /></figure><p>Now we are done with the CSS part. It’s time to continue with JS.</p><h3>Part-3 Javascript</h3><p>The main structure we will be using in JS part is that we will create a class, and embed the methods in. It means a quite big deal of the program will run inside the class.</p><p>First we create variable consisting of an array of objects. We will store every input of the user as an object inside this array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8LDL9ak3l2CdFlZm2y4mg.png" /></figure><p>Then we create the class named Todo_Class. We used the &lt;ul&gt; element as the only parameter of the class, where all the action in JS side will take part in. Accordingly, we will set up methods for :</p><ul><li>Adding the user input to the todoListObjectArray,</li><li>Changing the done or undone status of &lt;li&gt; elements,</li><li>Deleting elements and</li><li>Displaying all on the screen</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*xM9TZB8UGorQ04dTPRC-VQ.png" /></figure><p>We will soon turn back to the class, but first we go to the main part of the script.</p><p>First we assign the &lt;ul&gt; element to a the “listSection” which we will use as the parameter in the instance we will create. Right after we create our instance “myTodoList” from the “Todo_Class” and assign “listSection” as the parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNjNbNsYs971gN5MOimeTA.png" /></figure><p>Then we initiate the script by adding a click event to Add Button. In this way we get input from the user and turn it into an object with add() method inside the myTodoList instance. Let’s move inside the add() method and see what’s happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATOaR7_sKxraUhP3lgRDEw.png" /></figure><p>First we get the value of the user input in string format and assign it to todoInput variable. But we should check if the user has clicked the add button without entering anything. A very simple approach is to use if statement. If the input is an empty string give an alert, else take the input.</p><p>To store the data we prefer to use an object consisting of three properties: id, todoText and isDone. We assign the length of the object array as id, which is a simple solution. As we push new objects in, the id increases by one every time. todoText is the same as the string type user input, and isDone is a boolean which is false by default. We will turn it into true when the user clicks on the element. After creating the first object we add it into the object array. The reason we used unshift() instead of push() is that we want the most recent entries show up on top. Now it’s time to display what we have got. And since we got the value of the input we can clear the input area so that the user does not need to do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1cByvw1yr7tRfDs_jFj1oQ.png" /></figure><p><strong>Display()</strong> is perhaps the hardest part, but still no big deal. We will go one by one.</p><p>This line below is for cleaning the content of the &lt;ul&gt; element at the beginning. Because the algorithm here is that the method creates the content every time from start to end. If we do not clear at the beginning, we display items repetitive each time user clicks add button.</p><pre>this.ulElement.innerHTML = “”;</pre><p>Now we create a forEach loop for every object_item in the object array, and inside we do several work. First we create two new variables for creating elements for displaying the incoming data. “i” element here is for the trash icon.</p><pre>const liElement = document.createElement(“li”);</pre><pre>const delBtn = document.createElement(“i”);</pre><p>We assign the todoText as inner text to &lt;li&gt;. Then we set a new attribute to &lt;li&gt; and assign the id property value as the value of it. The reason of this move will be clear very soon.</p><pre>liElement.innerText = object_item.todoText;</pre><pre>liElement.setAttribute(“data-id”, object_item.id);</pre><p>We do add the same attribute and value for the trash icon (delBtn). Then we add two class names to make it appear exactly as a trash can. <br>&lt;i class=”far fa-trash-alt”&gt;&lt;/i&gt;</p><pre>delBtn.setAttribute(“data-id”, object_item.id);</pre><pre>delBtn.classList.add(“far”, “fa-trash-alt”);</pre><p>We have created the &lt;i&gt; (delBtn) element with all the content. Now it’s time we place it under &lt;li&gt; (liElement).</p><pre>liElement.appendChild(delBtn);</pre><p>Now we add a click event listener to every delBtn element we create, so that it directs to a function for deleting the selected object in the array and display the remaining items on the screen. We will explain it soon after we are done with the display() method. The most important thing here that we assign the id value of an item to a variable we named deleteId, but how? e.target brings us n&lt;i data-id=”0” class=”far fa-trash-alt”&gt;&lt;/i&gt; (id value can surely vary depending on which item on the object array we are on). And by e.target.getAttribute(“data-id”), we attain the value of the data-id attribute which is 0 here for example. We use the id value as an attribute to the deleteElement function.</p><pre>delBtn.addEventListener(“click”, function(e) {</pre><pre>const deleteId = e.target.getAttribute(“data-id”);</pre><pre>myTodoList.deleteElement(deleteId);</pre><pre>})</pre><p>Here we add a click event to every liElement in the object array, and attain the id value the same as above, and directs it as a parameter to done_undone function. There we will change the isDone property.</p><pre>liElement.addEventListener(“click”, function(e) {</pre><pre>const selectedId = e.target.getAttribute(“data-id”);</pre><pre>myTodoList.done_undone(selectedId);</pre><pre>})</pre><p>For styling purposes we add checked class to the items whose isDone property is true.</p><pre>if (object_item.isDone) {</pre><pre>liElement.classList.add(“checked”);</pre><pre>}</pre><p>Last move in the display() method. We created liElement for each object in the object array (todoObjectList), we set in content and data-id attribute. But still it does not appear on the screen, because we have not assigned the place it should stay. Below we set it as a child element of the ulElement, so that it has a designated place now, and it’s time to show up.</p><pre>this.ulElement.appendChild(liElement);</pre><p>Notice that we do everything in a forEach loop, so that each object in the loop will be displayed on the screen and get click events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zc6aHLrN-m9fjbVQI2I09Q.png" /></figure><p>We are finished with the display() method. Now we can focus on the <strong>done_undone() method</strong>.</p><p>Remember that we’ve sent the id value of the object as a parameter to this method. We assign the index number of the object, which has the same value as the inserted parameter’s value, and assign it to the selectedTodoIndex variable.</p><p>How? findIndex() is a method for bringing the index value of a certain object element in an object list. todoObjectList.findIndex() is for finding the index number of the certain object in the todoObjectList. But we have to tell what we are looking for in the parentheses. ((item)=&gt; item.id == x) which means bring the item in the array, whose id property’s value is equal to our parameter x, which is the id value of the liElement we have attained by clicking on it.</p><pre>const selectedTodoIndex = </pre><pre>todoObjectList.findIndex((item)=&gt; item.id == x);</pre><p>Now we see a long line of codes written as a ternary operator,</p><pre>condition ? exprIfTrue : exprIfFalse</pre><p>The code basically says: check the isDone value on the selected index of todoObjectList. If it is true assign false to it, and if it’s false assign true. In practice: when user clicks on the element the status changes to “done” and we add class “checked” (see display method) so that it looks in a different styling. When the user re-clicks on the same element it changes to “undone”, and styling changes to initial.</p><p>At the end of the method we should display the changes with display() method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiCGBMUYqLks0dmT5R2xfQ.png" /></figure><p><strong>Delete method </strong>functions very similar to done_undone method. We attain the index value the same way. As far as we get the id value to delete, we use splice method.</p><pre>todoObjectList.splice(selectedDelIndex,1);</pre><p>which means delete 1 item in the todoObjectList, whose index is “selectedDelIndex”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3HGNF8Je7jrXNmqM1c6EA.png" /></figure><h4><strong>And we are done!!!</strong></h4><p>This project may seem hard at first, but after a few repetitions you can learn a lot on object &amp; class structure and many other methods in JS.</p><p>Thanks for reading.</p><p>You can find the full JS code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8K7HcuJPAK2k-zuTRwLWzQ.png" /></figure><p>NOTE: For all the code source see: <a href="https://github.com/SemihDurmus/SD_03_Todo_List.git">https://github.com/SemihDurmus/SD_03_Todo_List.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=154839b770b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clarusway/making-a-todo-list-with-html-css-and-javascript-154839b770b6">Making a ToDo List with HTML, CSS and Javascript</a> was originally published in <a href="https://medium.com/clarusway">Clarusway</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>