Skip to main content

Posts

Showing posts with the label js

MOBX STORE SETUP

yarn add axios   yarn add lodash   yarn add mobx   yarn add mobx-react-lite   yarn add mobx-state-tree   yarn add @react-native-async-storage/async-storage yarn add mst-gql yarn add graphql-request

Fencing ( Latitude Longitude )

 Check Lat/Long is Inside/Outside of fencing <?php function onLine($side,$point)  //check whether p is on the line or not {   if ($point['x'] <= max($side['x']['x'], $side['y']['x']) && $point['x'] <= min($side['x']['x'], $side['y']['x']) &&    ($point['y'] <= max($side['x']['y'], $side['y']['y']) && $point['y'] <= min($side['x']['y'], $side['y']['y'])))       return true; return false; } function direction($point1,$point2,$point3) {    $val=($point2['y']-$point1['y'])*($point3['x']-$point2['x'])-($point2['x']-$point1['x'])*($point3['y']-$point2['y']);    if ($val == 0)    return 0; //colinear    else if ($val <0)    return 2;          //anti-clockwise direction    return 1;          //clockwise direction } function...

JS to show time slots ( PROGRESS TIMER )

  function format(time) {        // Hours, minutes and seconds     var hrs = ~~(time / 3600);     var mins = ~~((time % 3600) / 60);     var secs = ~~time % 60;     // Output like "1:01" or "4:03:59" or "123:03:59"     var ret = "";     if (hrs > 0) {         ret += "" + hrs + ":" + (mins < 10 ? "0" : "");     }     ret += "" + mins + ":" + (secs < 10 ? "0" : "");     ret += "" + secs;     return ret; } console.log(format(34322)); REF :  Labstack

REACT NATIVE DYNAMIC STAR RATING

  renderRatings ( rating ){     let stars = [];     // Loop 5 times     for (var i = 1; i <= 5; i++) {       // Set the path to filled stars       let path = <Icon name="star" style={{fontSize: 10, color: '#eb9534',marginHorizontal:2}}/>;       // If ratings is lower, set the path to unfilled stars       if (i > rating ) {         path = <Icon name="star" style={{fontSize: 10, color: theme.LIGHT_GREY_COLOR, marginHorizontal:2}}/>;       }       // Push the Image tag in the stars array       stars.push(path);     }     return (       <View style={{flexDirection:"row",marginTop: 5,}}>            { stars }       </View>     )   }     render () {   ...

SEARCH TABLE DATA JAVA SCRIPT

———————————————————————— CDN https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.js ———————————————————————— HTML  <input type="text" id="search" placeholder="Search"> ———————————————————————— JS (any column)  $("#search").on("keyup", function() {                 var value = $(this).val();                                  $("table tr").each(function(index) {                     if (index !== 0) {                         $row = $(this);                         var text = $row.text();                                          ...

FILE SIZE JAVASCRIPT

GET FILE SIZE function bytesToSize(bytes) {  var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];  if (bytes == 0) return '0 Byte';  var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));  return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];  }

GET SUBSTRING OF STRING WITH POSITION

$filename = " abcd.mp 4"; if (($pos = strpos($filename, ".")) !== FALSE) {           $whatIWant = substr($filename, $pos); echo $whatIWant; // .mp4        } VICEVERSA  $arr = explode(".", $filename, 2);        $first = $arr[0]; *************************************** if (($pos = strpos($filename, ".")) !== FALSE) {             $extension = substr($filename, $pos);         }        if(($arr = explode(".", $filename, 2)) !== FALSE){            $name = $arr[0];      }

HTML to pdf

< html > < head > < title > CANVAS </ title > <!-- Latest compiled and minified CSS --> < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css" > <!-- jQuery library --> < script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" > < / script > <!-- Latest compiled JavaScript --> < script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js" > < / script > < script src = "//cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js" > < / script > </ head > < body > < div class = "container" > < div class = "row" > < div id = "myCanvas" style = " background : white" > < div class = "alert alert-success" > ...

Node Js

___________ Node Js ________ Express framework _________________ Working ________ ********************************************************************************* 1.Make Root directory- mkdir directory_name 2.Create express server- express directory_name 3.Change current directory to root directory- cd directory_name 4.Install and save express package- npm install express --save 5.Install node_modules (default packages)- npm install 6.Install and save mysql module- npm install mysql --save 7.Install and save express-myconnection module- npm install express-myconnection --save 8.Install and save express-session module- npm install express-session --save 9.Set Port address in /bin/www- server.listen(port, function(){ console.log("Running port"+port);}); 10.Install ejs & uninstall jade- npm install ejs --save npm uninstall jade 11.Remove view engine jade & Set to ejs- app.set('view engine', 'ejs'); 12.Remove all jade files from "v...

IONIC

======================== How To install ionic  ===================================== 1. node js 2. npm install -g ionic cordova ======================== Create APP =============================================== 1.  ionic start helloWorld blank > Try Ionic 4? (y/N) > Starter template: (Use arrow keys) ❯ tabs     | A starting project with a simple tabbed interface   blank    | A blank starter project   sidemenu | A starting project with a side menu with navigation in the content area   super    | A starting project complete with pre-built pages, providers and bes t practices for Ionic development.   tutorial | A tutorial based project that goes along with the Ionic documentati Install the free Ionic Pro SDK and connect your app? (Y/n) > Y ? What would you like to do?   Link an existing app on Ionic Pro ❯ Create a new app on Ionic Pro         <-| ? Which gi...

Angular

API FORMAT : host/project_dir/controller_name/method_name?param1=&param2=&param2=&param2= =============== Angular ==================  The ng-app directive tells AngularJS that this is the root element of the AngularJS application. All AngularJS applications must have a root element. You can only have one ng-app directive in your HTML document. If more than one ng-app directive appears, the first appearance will be used. An NgModule is a class marked by the @NgModule decorator. @NgModule takes a metadata object that describes how to compile a component's template and how to create an injector at runtime. JSON.parse() is for "parsing" something that was received as JSON. JSON.stringify() is to create a JSON string out of an object/array. They are the inverse of each other. JSON.stringify() serializes a JS object into a JSON string, whereas JSON.parse() will deserialize a JSON string into a JS object. URL : https://angular.io/cli =================...

JavaScript

--- var array = [0, 1, null, 2, "", 3, undefined, 3,,,,,, 4,, 4,, 5,, 6,,,,]; var filtered = array.filter(function (el) {   return el != null; }); console.log(filtered); __________________________ Click on interval setInterval(function () {document.getElementById("checkin_submit").click();}, 6000); ___________________________________________________ ###Password Hide and show feild----- <input id="register_password" class="form-control" type="password" name="password" placeholder="Password" required><i  class="glyphicon glyphicon-eye-open eyemark" onclick="Toggle()" value="Show" ></i>  Script---- $(".glyphicon-eye-open").on("click", function() { $(this).toggleClass("glyphicon-eye-close");   var type = $("#login_password").attr("type");    var type2 = $("#register_password").attr("typ...