"use strict"; //returns the actual pixel ratio versus the CSS pixel ratio function get_pixel_ratio() { var pixel_ratio = null; pixel_ratio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth; //pixel_ratio = pixel_ratio * 100; return pixel_ratio; } function log_CSS_ratio() { ////console.log("CSS Pixel Ratio: " + global_css_pixel_ratio); } function apply_page_zoom(x) { document.documentElement.style.zoom = x; } function get_page_zoom() { var z = null; z = document.documentElement.style.zoom; return z; } function set_document_scale(s) { document.documentElement.style.transform = "scale(" + s + ")"; } function get_scale() { var s = null; s = document.body.style.scale; return s; } function set_scale(s) { var scale = null; document.body.style.scale = s; scale = s; return scale; } //gets the pixel ratio, sets the global pixel ratio variable, //gets the coordinates of the mouse (adjusted for any zoom discrepancy), //applies the actual page zoom function function reset_css_pixel_ratio() { var pixel_ratio = null; var set_ratio = null; //Get the css to pixel ratio of the document/page/window global_css_pixel_ratio = parseFloat(get_pixel_ratio()); pixel_ratio = parseFloat(get_pixel_ratio()); get_coords(); if (pixel_ratio === 1.25) { apply_page_zoom(0.8); //if the page is currently displaying as 100%, or having a CSS pixels to actual pixels be 1.25 } else { apply_page_zoom(pixel_ratio); //if the page is zoomed to any different size } } //If your web browser's default page zoom is 100% (ratio:1.25), //dont' apply pixel ratio offset for mouse coords. function reset_css_zoom_for_default() { var pixel_ratio = null; apply_page_zoom(1.25); } //Inverts the given pixel ratio (e.g. 1.25 zoom inverts to 0.8) function get_inverse_pixel_ratio(x) { var inverse_x = null; if (x !== 0) { inverse_x = parseFloat(1.0 / x); } else { inverse_x = 0; } return inverse_x; } //converts the pixel ratio to an inverse value, //and applies the page zoom function/method function invert_pixel_ratio_apply_zoom() { var inverse_pixel_ratio = null; var set_ratio = null; inverse_pixel_ratio = get_inverse_pixel_ratio(parseFloat(get_pixel_ratio())); apply_page_zoom(inverse_pixel_ratio); return inverse_pixel_ratio; } //takes the pixel ratio, and returns the difference by subtracting the //inverse page ratio (e.g.from 1.0 - 0.8 = 0.2) function subtract_pixel_ratio_from_1(x) { var difference = null; var pixel_ratio = null; pixel_ratio = get_inverse_pixel_ratio(parseFloat(x)); difference = 1.0 - pixel_ratio; return difference; } //converts a pixel ratio (e.g. 0.8) to percent (e.g 80%) function ratio_to_percent(x) { var p = null; p = x * 100; return p; } //converts a percent (e.g. 80%) to a pixel ratio (e.g. 1.25) function percent_to_ratio(x) { var pixel_ratio = null; var has_percent_char = null; has_percent_char = x.toString.indexOf("%"); //if the percent is passed in as a string (e.g. "75%") if (has_percent_char > -1) { x = parseFloat(x.toString.replace("%", "")); //remove the "%" character from the string and retgurn a numeric value } pixel_ratio = x / 100; return pixel_ratio; } //subtracts the pixel ratio from from 1.0 and, //converts it to a percentage(i.e. ((1.0 - pixel ratio) * 100)) function get_percent_difference(px_ratio) { var inverse_x = null; var inverse_x_to_percent = null; var percent_difference = null; inverse_x = invert_pixel_ratio(px_ratio); inverse_x_to_percent = inverse_x * 100; percent_difference = 100 - inverse_x_to_percent; return percent_difference; } //takes any given pixel ratio (as a value between 0 and 1), //inverts the pixel ratio (1/x) and, returns a percentage value //as a number between 0 and 100 percent function get_ratio_difference(px_ratio) { var inverse_x = null; var inverse_x_to_percent = null; var percent_difference = null; inverse_x = invert_pixel_ratio(px_ratio); percent_difference = inverse_x; return percent_difference; } //pixel ratio (example: 1.25) is subtracted by 1.0, //and the difference is converted to a percentage value function pixel_ratio_to_percent_difference() { var px_ratio = null; var difference = null; var percent = null; px_ratio = get_pixel_ratio(); difference = get_percent_difference(px_ratio); return difference; } //takes the pixel ratio as a percentage value (between 0-100), and //inverts it (1/x), and then multiplies the return value by 100 (e.g. 0.2 * 100 = 20%). //It then gets the percent difference by subtracting //it from 100 (x - 100). It then converts it back to //a ratio(example: 0.2), and returns that value function percent_difference_to_pixel_ratio() { var percent_offset = null; var ratio_offset = null; percent_offset = pixel_ratio_to_percent_difference(); ratio_offset = percent_to_ratio(percent_offset); return ratio_offset; } /* function set_default_page_scale() { var scale = null; scale = "scale(1)"; document.body.style.webkitTransform = scale; // Chrome, Opera, Safari document.body.style.msTransform = scale; // IE 9 document.body.style.transform = scale; // General } */