Skip to content

Instantly share code, notes, and snippets.

View ppbntl19's full-sized avatar
🎯
Focusing

Pooran Prakash ppbntl19

🎯
Focusing
View GitHub Profile
//download map as png
downloadAsPng1() {
var me = this;
let width = me.template.querySelector("svg.d3").getBoundingClientRect().width;
let height = me.template.querySelector("svg.d3").getBoundingClientRect().height;
try {
const output = { name: "result1.png", width: width, height: height };
let svg =
'<svg style="width: 100%; height: 100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
me.template.querySelector("svg.d3").innerHTML +
@ppbntl19
ppbntl19 / image_cache.js
Last active January 12, 2023 09:57
This is a java script code that allow image caching offline for a graphic element
//This is a javascript code that allow image caching offline for a graphic element
//This example is using html 5 File Api to get image data.
//Please replace current component id with your graphic element id
localstorage_image_cache("722c-e69a-c6db");
//Save image in local storage
function localstorage_image_cache(graphic_image_component_id) {
//Return if browser is not firefox
if (typeof InstallTrigger == 'undefined') return;
// LocalStorage with image
var storage_files = JSON.parse(localStorage.getItem(graphic_image_component_id)) || {},
@ppbntl19
ppbntl19 / image_cache.js
Last active January 12, 2023 09:59
This example is using canvs toDataURL method for getting image data
//This example is using canvs toDataURL method for getting image data
//Save image for offline useage
localstorage_image_cache("f5b2-0b98-cf5f");
//Save image in local storage
function localstorage_image_cache(graphic_image_component_id) {
//Return if browser is not firefox
if (typeof InstallTrigger == 'undefined') return;
// localStorage with image
var storage_files = JSON.parse(localStorage.getItem(graphic_image_component_id)) || {},
//Get Image

Answer by Rob W http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser/9851769#9851769

Googling for browser reliable detection often results in checking the User agent string. This method is not reliable, because it's trivial to spoof this value.
I've written a method to detect browsers by [duck-typing][1].

Only use the browser detection method if it's truly necessary, such as showing browser-specific instructions to install an extension. Use feature detection when possible.

Demo: https://jsfiddle.net/311aLtkz/

@ppbntl19
ppbntl19 / Readme.md
Last active May 19, 2017 10:32
Image caching using local storage (Offline supports for images)

JS library based on the File API to cache images for offline recovery (target: cordova/phonegap & chrome) https://github.com/chrisben/imgcache.js

This library is using HTML5 file api system. Some of File Api method is not supported in safar and Mozilla firfox. Here in above two example we are using canvs and File reader to storae image data in local storage for offline access.

@ppbntl19
ppbntl19 / README.md
Last active July 5, 2018 21:53
Bootstrap-wysiwyg minimal usage ( supoort added without jQuery HotKeys and Font-Awesome.css )

Bootstrap-wysiwyg minimal usage ( supoort added without jQuery HotKeys and Font-Awesome.css )

bootstrap-wysiwyg

GitHub release GitHub license

A tiny Bootstrap and jQuery based WYSIWYG rich text editor based on the browser function execCommand.

@ppbntl19
ppbntl19 / MutationObserver.js
Last active March 23, 2017 05:21
Using Javascript MutationObserver
//More Details https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
//Will not work if more then one lookup is used on same page
//Please remove all comments for live
//Add Mututationobserver on selected component
$("#component-abca-2a71-4474").on("click",".search_for_salesforce_record,.lookup_salesforce_record ", function() {
new MutationObserver(function(mutations) {
// Do something here
if($('#component-abca-2a71-4474 .found_record_list li') && $('#component-abca-2a71-4474 .found_record_list li').length > 0) {
//Add css to change for lookup result
$('#component-abca-2a71-4474 .found_record_list li').append('<span class="glyphicon glyphicon-hand-up"></span><style>#select_icon{display:none}.found_record_list #select_icon{display:inline}</style>');
@ppbntl19
ppbntl19 / Digital_Signature_using _Web_Crypto.js
Last active March 1, 2017 08:11
Tested on Safari/Ios/Chrome/Firefox)
//Jsfiddle https://jsfiddle.net/h2u4fowj/58/
function str2ab(str) {
var buf = new ArrayBuffer(str.length);
var bufView = new Uint8Array(buf);
for (var i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
@ppbntl19
ppbntl19 / mongoose-connection-options.js
Last active November 11, 2016 06:53
mLab recommended mongoose connection options. More supported connections for the underlying Node Native driver can be found here: http://mongodb.github.io/node-mongodb-native/
// mongoose 4.3.x
var mongoose = require('mongoose');
/*
* Mongoose by default sets the auto_reconnect option to true.
* We recommend setting socket options at both the server and replica set level.
* We recommend a 30 second connection timeout because it allows for
* plenty of time in most operating environments.
*/
var options = {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var old = ('Iseeit Inc');