Notification texts go here Contact Us Buy Now!
Posts

Plus UI v2.6.5 JS APIs

Before using these APIs please note that these are only available in v2.6.5, they will be removed in v3.

Get user IP info:

utils.getIp(refresh?: boolean): Promise<IpResult>

Use the above method of utils object to get the user ip information. The interface IpResult is as shown:

interface Location {
  cca2: string;
  city: string;
  iata: string;
  lat: number;
  lon: number;
  region: string;
}

interface IpResult {
  colo: string;
  country?: string;
  fl: string;
  gateway: "off" | "on";
  http: string;
  ip: string;
  loc: string;
  location?: Location;
  rbi: "off" | "on";
  sliver: string;
  sni: string;
  timestamp: number;
  tls: string;
  userAgent: string;
  visitScheme: string;
  warp: "off" | "on";
}
Example:
utils.getIp().then((result) => {
  console.log("The IP is", result.ip);
});

Multithreading using Web Worker

You can use utils.Worker constructor to create a new worker thread.

Example:
const worker = new utils.Worker((self, register) => {
  register((ctx) => {
    return {
      hello: ()=> `[from:worker]: Hello! ${ctx.message}`
    }
  });
}, {
  context: { message: "My message" },
  name: "my-worker"
});

worker.call("hello").then(result => {
  console.log(result);
});

Formatting Blogger image url

utils.formatImage(bloggerImageUrl: string, options?: Options): string

You can create a new image url from existing blogger image url by modifying some of its parameters. Available options are:

interface Options {
  width?: number;
  height?: number;
  size?: number;
  ratio?: number;
  forceScaling?: boolean;
  flipHorizontally?: boolean;
  flipVertically?: boolean;
  rotate?: number;
  symbol?: number;
  download?: boolean;
  format?: "png" | "jpg" | "webp";
  cache?: number;
}
Example:
const bloggerImageUrl = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmxL-hkIX19cdlV93xhQnaZSwqU6Jmeq7JK9P7c_FbGFfemeaMVZnC3Ow4WZbc8kMlhxGjLSR2AhN9gsxfhtkPovJJ7zUDBILREULXuvNt2aFMcUAtKbN38kPngpTfHMLwmGuGZb7zK8vaX24LRXDdXus632s2zJp7mNqqzeIar5h8E_6grv8j0T_Y4g/w600-h300/Plus_UI_Typography.webp";

const modifiedImageUrl = utils.formatImage(bloggerImageUrl, {
  format: "webp"
});

console.log(modifiedImageUrl);

There are more but they are not documented yet!

About the Author

~ Hello World!

Post a Comment

🌟 Attention, Valued Community Members! 🌟

We're delighted to have you engage in our vibrant discussions. To ensure a respectful and inclusive environment for everyone, we kindly request your cooperation with the following guidelines:

1. Respect Privacy: Please refrain from sharing sensitive or private information in your comments.

2. Spread Positivity: We uphold a zero-tolerance policy towards hate speech or abusive language. Let's keep our conversations respectful and friendly.

3. Language of Choice: Feel free to express yourself in either English or Hindi. These two languages will help us maintain clear and coherent discussions.

4. Respect Diversity: To foster an inclusive atmosphere, we kindly request that you avoid discussing religious matters in your comments.

Remember, your contributions are valued, and we appreciate your commitment to making our community a welcoming place for everyone. Let's continue to learn and grow together through constructive and respectful discussions.

Thank you for being a part of our vibrant community! 🌟
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.