Skip to content

Instantly share code, notes, and snippets.

View imesut's full-sized avatar

Mesut Yılmaz imesut

View GitHub Profile
@imesut
imesut / 0_reuse_code.js
Created July 10, 2016 12:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@imesut
imesut / getTextInRect.js
Created November 25, 2018 17:59
Get text in selected area by pdf.js with text layer rendering
// This method works only when pdf is rendered with Text Layer
// It compares particular text/word element coordinates with
// the rectangle's coordinates. If text/word coordinates is in
// the rectangle, text has got. And successing texts are similar.
// Check out text layer rendering option at the article below.
// https://www.sitepoint.com/custom-pdf-rendering/
function getTextInRect(pageNumber, Xi, Yi, Xl, Yl) { // modify pageNumber if required
// Get the page if page render method works like (page-1, page-2, ...)
// If not, modify according to
@imesut
imesut / 1.1.landing_page.js
Last active September 12, 2019 21:38
WeWALK Gift Case Scripts
// Landing Page
// Send to Parıltı
window.onload = document.getElementById("parilti").addEventListener("click", function(){
document.cookie = "send_to_parilti = 1; path=/";
window.location.href = "https://wewalk.io/tr/product/wewalk-akilli-baston/"});
// This is a client side script to update distant sales agreement on a Woocommerce / Wordpress checkout page
shipmentDifferent = document.getElementById("ship-to-different-address-checkbox");
function update(to, from) {
val = "";
for (var i in from) {
val += document.getElementById(from[i]).value + " ";
}
document.getElementById(to).innerText = val;
// Landing Page
// Do not send to Parıltı : send to myself
window.onload = document.getElementById("myself").addEventListener("click", function(){
document.cookie = "send_to_parilti = 0; path=/";
window.location.href = "https://wewalk.io/tr/product/wewalk-akilli-baston/"});
// Product Page
function getCookie(name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
}
var cookieValue = getCookie("send_to_parilti");
if(cookieValue == 1) {
document.getElementsByName("add-to-cart")[0].innerText = "Parıltı'ya Gönder"; // Means "Send to Parıltı"
// Checkout page
<p>Gönderi tercihiniz şu şekilde: </p><select id="shipping_selector" style="width:400px; height:40px">
<option value="myself">Kendime ya da tanıdığım bir görme engelliye alıyorum.</option>
<option value="parilti">Parıltı Derneği'ne göndermek istiyorum.</option>
</select>
function getCookie(name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
}
function fillParilti() {
//Show Other Shipping Address Field
document.getElementsByClassName("shipping_address")[0].style.display = "block";
document.getElementById("ship-to-different-address-checkbox").checked = true;
// Fill info
// API - SQL Query
select sum(orders.product_qty)
from wp_postmeta as company, wp_wc_order_product_lookup as orders
where company.meta_key = "_shipping_company" and company.meta_value = "Parıltı" and company.post_id = orders.order_id;
// API Progress.php
<?php
$servername = "localhost";
$username = "";
$password = "";
$dbname = "wordpress";
$sql = 'select sum(orders.product_qty) as sum from wp_postmeta as company, wp_wc_order_product_lookup as orders where company.meta_key = "_shipping_company" and company.meta_value = "Parıltı" and company.post_id = orders.order_id';
$link = mysqli_connect("localhost", $username, $password, $dbname);
mysqli_set_charset($link, "utf8");