Search thousands of free JavaScript snippets that you can quickly copy and paste into your web pages. Get free JavaScript tutorials, references, code, menus, calendars, popup windows, games, and much more.
gamemaker parallax background
Information about object: obj_player
Sprite: spr_player
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code: ///player movement code flying_level=200; moving=false; if (keyboard_check(ord('W'))) { y-=5; moving=true; } if (keyboard_check(ord('S'))) { y+=5; moving=true; } if moving=false && y<flying_level// move back to center { y+=2; y=y+((flying_level-y)*0.01); } if moving=false && y>flying_level // move back to center { y-=2; y=y-((y-flying_level)*0.01); } global.difference=(flying_level-y)/10;//set as a global value as it will be used for parallax background image_angle=global.difference-10; //keep in screen if y<20 y=20; if y>380 y=380;
execute code: ///parallax global.difference global.difference background_y[1] = view_yview[0]+global.difference*0.5-100; background_y[2] = view_yview[0]+global.difference*1-75; background_y[3] = view_yview[0]+global.difference*2-75;
movable object that leave trail gamemaker
https://www.youtube.com/watch?v=x29Ok-VxHhw
Information about object: obj_tank
Information about object: obj_tank
Sprite: spr_tank
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: tyre=5;//set inital tyre timer
Step Event:
execute code: ///movement code if keyboard_check(ord('A')) { image_angle+=2; direction=image_angle } if keyboard_check(ord('D')) { image_angle-=2; direction=image_angle } if keyboard_check(ord('W')) { speed+=0.5; } if speed>20 speed=20; speed-=0.2;//add friction if speed<0 speed=0
execute code: ///tyre tyre-=speed; if tyre<0//if count, run the code { tyre=instance_create(x,y,obj_tyre);//create a tyre tyre.image_angle=direction;//set angle to direction of tank tyre=20;//restart timer }
obj_tyre
Information about object: obj_tankSprite: spr_tank Solid: false Visible: true Depth: 0 Persistent: false Parent:Children: Mask: No Physics ObjectCreate Event:
execute code: tyre=5;//set inital tyre timerStep Event:
execute code: ///movement code if keyboard_check(ord('A')) { image_angle+=2; direction=image_angle } if keyboard_check(ord('D')) { image_angle-=2; direction=image_angle } if keyboard_check(ord('W')) { speed+=0.5; } if speed>20 speed=20; speed-=0.2;//add friction if speed<0 speed=0execute code: ///tyre tyre-=speed; if tyre<0//if count, run the code { tyre=instance_create(x,y,obj_tyre);//create a tyre tyre.image_angle=direction;//set angle to direction of tank tyre=20;//restart timer }
onscreen keyboard gamemaker
Information about object: obj_button
Sprite: spr_button
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: image_speed=0; letter = "A";//set letter
Step Event:
execute code: if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x,mouse_y,id)//if clicked { global.message+=letter;//add letter to string } if position_meeting(mouse_x,mouse_y,id) { image_index=1; } else { image_index=0; }
Draw Event:
execute code: draw_self(); draw_set_font(fnt_button); draw_set_halign(fa_center); draw_text(x+16, y+4, letter);//draw letter over button
obj obj_enter
create event:
//creating all the buttons //top row var alphabet = "QWERTYUIOP"; for(var i = 0; i<10; i++){ var bt = instance_create(64+i*32+(8*i), 64, obj_button); bt.letter = string_char_at(alphabet, i+1); } //middle row var alphabet = "ASDFGHJKL"; for(var i = 0; i<9; i++){ var bt = instance_create(72+i*32+(8*i), 104, obj_button); bt.letter = string_char_at(alphabet, i+1); } //BOTTOM row var alphabet = "ZXCVBNM"; for(var i = 0; i<7; i++){ var bt = instance_create(88+i*32+(8*i), 144, obj_button); bt.letter = string_char_at(alphabet, i+1); } global.message="";
step event:
if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x,mouse_y,id)//if clicked
{
show_message(global.message);//show typed string
game_restart();
}
draw event: draw_set_halign(fa_left);
draw_text(50,300,"Word "+global.message);//show typed text so far
draw_self();
text based gamemaker
Information about object: obj_question
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: //set variables: data=0; q=1; //open file and read questions: file=file_text_open_read("questions.txt"); while (!file_text_eof(file))//loops until end of file { data++; question[data,1]=file_text_read_string(file);//read question file_text_readln(file); question[data,2]=file_text_read_string(file);//read answer 1 file_text_readln(file); question[data,3]=file_text_read_string(file);//read answer 2 file_text_readln(file); question[data,4]=file_text_read_string(file);//read answer 3 file_text_readln(file); question[data,5]=file_text_read_real(file);//read correct answer 1 file_text_readln(file); } file_text_close(file);
Step Event:
execute code: if (keyboard_check_pressed(vk_left)) {q-=1;}//change question number if (keyboard_check_pressed(vk_right)) {q+=1;}//change question number if q==0 q=data;//keep in range if q==(data+1) q=1;//keep in range
Draw Event:
execute code: //draw the data draw_text(50,100,question[q,1]); draw_text(50,200,question[q,2]); draw_text(50,300,question[q,3]); draw_text(50,400,question[q,4]); draw_text(50,500,question[q,5]);
world clock gamemaker
Information about object: obj_world_clock
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: ///set up variables //set time zone date_set_timezone(timezone_utc);//get local time london_hour=0; london_minute=0; london_second=0; newyork_hour=0; newyork_minute=0; newyork_second=0; sydney_hour=0; sydney_minute=0; sydney_second=0;
Step Event:
execute code: //calculations will differ depending where in the world you are london_hour=date_get_hour(date_current_datetime());//get local time london_minute=date_get_minute(date_current_datetime());//get local time london_second=date_get_second(date_current_datetime());//get local time newyork_hour=(london_hour+19+24) mod 24;//set newyork time newyork_minute=london_minute; newyork_second=london_second; sydney_hour=(london_hour+10) mod 24;//set sydney time sydney_minute=london_minute; sydney_second=london_second; london_hour_string=string(london_hour); if string_length(london_hour_string)==1 london_hour_string="0"+london_hour_string; london_minute_string=string(london_minute); if string_length(london_minute_string)==1 london_minute_string="0"+london_minute_string; london_second_string=string(london_second); if string_length(london_second_string)==1 london_second_string="0"+london_second_string; newyork_hour_string=string(newyork_hour); if string_length(newyork_hour_string)==1 newyork_hour_string="0"+newyork_hour_string; newyork_minute_string=string(newyork_minute); if string_length(newyork_minute_string)==1 newyork_minute_string="0"+newyork_minute_string; newyork_second_string=string(newyork_second); if string_length(newyork_second_string)==1 newyork_second_string="0"+newyork_second_string; sydney_hour_string=string(sydney_hour); if string_length(sydney_hour_string)==1 sydneyhour_string="0"+sydney_hour_string; sydney_minute_string=string(sydney_minute); if string_length(sydney_minute_string)==1 sydney_minute_string="0"+sydney_minute_string; sydney_second_string=string(sydney_second); if string_length(sydney_second_string)==1 sydney_second_string="0"+sydney_second_string;
Draw Event:
execute code: //draw times draw_text(50,50,"london "+london_hour_string+":"+london_minute_string+" - "+london_second_string); draw_text(50,150,"newyork "+newyork_hour_string+":"+newyork_minute_string+" - "+newyork_second_string); draw_text(50,250,"sydney "+sydney_hour_string+":"+sydney_minute_string+" - "+sydney_second_string);
gamemaker fire projectile
obj_source
global left release
projectile=instance_create(x,y,obj_projectile);//create projectile
projectile.direction=point_direction(x,y,mouse_x,mouse_y);//set direction to mouse
projectile.speed=4;//set the speed
gamemaker breakout remake
Information about object:
Sprite: spr_ball
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: motion_set(random(180),3);//start ball moving
Collision Event with object obj_wall_tlr:
execute code: move_bounce_all(true);//bounce off walls
Collision Event with object obj_wall_bottom:
execute code: show_message("Game Over");//die when hit bottom game_restart();
Collision Event with object obj_player_bat:
execute code: move_bounce_all(true);//bounce off the bat
Collision Event with object obj_stone_blue:
execute code: move_bounce_all(true);//bounce off brick
Information about object: obj_player_bat
Sprite: spr_player_bat Solid: false Visible: true Depth: 0 Persistent: false Parent:Children: Mask: No Physics ObjectStep Event:execute code: //simple movement code if (keyboard_check(vk_left)) {x-=5;} if (keyboard_check(vk_right)) {x+=5;}Information about object: obj_stone_blueSprite: spr_stone_blue Solid: true Visible: true Depth: 0 Persistent: false Parent:Children: Mask: No Physics ObjectCollision Event with object <undefined>:execute code: instance_destroy();Draw Event:execute code: draw_sprite(spr_stone_blue,0,x,y);
Gamemaker Backstab/teleport
obj_player
create event:
spawn_id = 0
step event:
inst = instance_place(x,y,obj_spawn_point)
if inst//create/update spawn point
{
spawn_id = inst
}
if (keyboard_check(ord('T')))//move to last spawn point
{
x=spawn_id.x;
y=spawn_id.y;
}
//movement code
if (keyboard_check(ord('A'))) {x-=5;}
if (keyboard_check(ord('D'))) {x+=5;}
if (keyboard_check(ord('W'))) {y-=5;}
if (keyboard_check(ord('S'))) {y+=5;}
obj_enemy
step event:
x++
create event:
spawn_id = 0
step event:
inst = instance_place(x,y,obj_spawn_point)
if inst//create/update spawn point
{
spawn_id = inst
}
if (keyboard_check(ord('T')))//move to last spawn point
{
x=spawn_id.x;
y=spawn_id.y;
}
//movement code
if (keyboard_check(ord('A'))) {x-=5;}
if (keyboard_check(ord('D'))) {x+=5;}
if (keyboard_check(ord('W'))) {y-=5;}
if (keyboard_check(ord('S'))) {y+=5;}
obj_enemy
step event:
x++
Draw Text with Shadow gamemaker
obj_example:
create event:
text="This is some random text to show a shadow of text.";//set text to draw
draw event:
draw_set_font(font_example);//set the font to use
draw_set_colour(c_black);//set the colour for shadow
draw_text(40-1,40-1,text);//draw text offset
draw_set_colour(c_red);//set draw colour
draw_text(40,40,text);//draw top main text
create event:
text="This is some random text to show a shadow of text.";//set text to draw
draw event:
draw_set_font(font_example);//set the font to use
draw_set_colour(c_black);//set the colour for shadow
draw_text(40-1,40-1,text);//draw text offset
draw_set_colour(c_red);//set draw colour
draw_text(40,40,text);//draw top main text
gamemaker dictionary check
obj_dict
create event:
dictionary=ds_list_create();//create a ds list to hold words
dic_file=file_text_open_read("dictionary.txt"); //open text file with words
while(!file_text_eof(dic_file))//repeat until end of book
{
word=file_text_read_string(dic_file);//get next word
ds_list_add(dictionary,word);//add to ds list
file_text_readln(dic_file);//read to next line
}
create event:
dictionary=ds_list_create();//create a ds list to hold words
dic_file=file_text_open_read("dictionary.txt"); //open text file with words
while(!file_text_eof(dic_file))//repeat until end of book
{
word=file_text_read_string(dic_file);//get next word
ds_list_add(dictionary,word);//add to ds list
file_text_readln(dic_file);//read to next line
}
step event:
word_to_find=get_string("word","");
position = ds_list_find_index(dictionary, word_to_find);
if position>0
{
show_message("Found");
}
else
{
show_message("Not Found");
}
gamemaker Spawn enemies in a random specified location
obj_player
create event:
spawn_x=x;//set initial spawn points
spawn_y=y;
step event:
//movement code
if (keyboard_check(ord('A'))) {x-=5;}
if (keyboard_check(ord('D'))) {x+=5;}
if (keyboard_check(ord('W'))) {y-=5;}
if (keyboard_check(ord('S'))) {y+=5;}
if (keyboard_check(ord('T')))//move to last spawn point
{
x=spawn_x;
y=spawn_y;
}
if place_meeting(x,y,obj_spawn_point)//create/update spawn point
{
spawn_x=other.x;
spawn_y=other.y;
}
GAMEMAKER Save Highscore to INI
OBJ_SCOREHIGHSCORE
CREATE EVENT
ini_open("scores.ini");//open file
global.highscore=ini_read_real("scores","high",0);//load scores high if present, otherwise set as 0
ini_close();//close ini
DRAW EVENT
draw_text(100,100,"Highest Score:="+string(global.highscore));//draw value of global.highscore
OBJ_BUTTON
score= get_integer("Enter A Score:", 0);//get an integer
if score>global.highscore//do this if bigger than current score
{
ini_open("scores.ini");//open ini
ini_write_real("scores","high",score);//write a value
ini_close();//close value
global.highscore=score;//update highscore
show_message("High Score Updated");//message
}
else//do this if not bigger than current score
{
show_message("Score Is Not Bigger Than Current Highscore");//message
}
CREATE EVENT
ini_open("scores.ini");//open file
global.highscore=ini_read_real("scores","high",0);//load scores high if present, otherwise set as 0
ini_close();//close ini
DRAW EVENT
draw_text(100,100,"Highest Score:="+string(global.highscore));//draw value of global.highscore
OBJ_BUTTON
score= get_integer("Enter A Score:", 0);//get an integer
if score>global.highscore//do this if bigger than current score
{
ini_open("scores.ini");//open ini
ini_write_real("scores","high",score);//write a value
ini_close();//close value
global.highscore=score;//update highscore
show_message("High Score Updated");//message
}
else//do this if not bigger than current score
{
show_message("Score Is Not Bigger Than Current Highscore");//message
}
Gamemaker Substitution Cipher
create event:
alpha_src = " 0123456789abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//Plain Text
alpha_dst = "tuwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789abcdefghijklmnopqrs";//Encoded Text
text1 = get_string("Source:", "");//Get string to convert
index = 1;//position in Plain text
str = ""; // result
for (var index = 1; index < string_length(text1)+1; index += 1)
{
char = string_char_at(text1, index);//get character at position in string
pos = string_pos(char, alpha_src);//find position of letter in Plain Text
if (pos > 0)
{
// if char occurs in source alphabet, add
// according one from destination alphabet
// to output
str += string_char_at(alpha_dst, pos);//At letter from position in Encoded
}
else
{
// otherwise just add itself
str += char;
}
}
result=str;//result is finished encoded
show_message(result);//show encoded message
alpha_src = " 0123456789abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//Plain Text
alpha_dst = "tuwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789abcdefghijklmnopqrs";//Encoded Text
text1 = get_string("Source:", "");//Get string to convert
index = 1;//position in Plain text
str = ""; // result
for (var index = 1; index < string_length(text1)+1; index += 1)
{
char = string_char_at(text1, index);//get character at position in string
pos = string_pos(char, alpha_src);//find position of letter in Plain Text
if (pos > 0)
{
// if char occurs in source alphabet, add
// according one from destination alphabet
// to output
str += string_char_at(alpha_dst, pos);//At letter from position in Encoded
}
else
{
// otherwise just add itself
str += char;
}
}
result=str;//result is finished encoded
show_message(result);//show encoded message
Gamemaker Random Dice Roller
create event:
//set up dice
dice1=0;
dice2=0;
dice3=0;
dice4=0;
dice5=0;
step event:
if position_meeting(mouse_x,mouse_y,id) && mouse_check_button_released(mb_left)//if button press released
{
dice1=irandom_range(1,6);//choose a random value for dice
dice2=irandom_range(1,6);
dice3=irandom_range(1,6);
dice4=irandom_range(1,6);
dice5=irandom_range(1,6);
}
draw event:
draw_self();
draw_sprite(spr_dice,dice1,50,50);//draw choosen sub image
draw_sprite(spr_dice,dice2,150,50);
draw_sprite(spr_dice,dice3,250,50);
draw_sprite(spr_dice,dice4,350,50);
draw_sprite(spr_dice,dice5,450,50);
//set up dice
dice1=0;
dice2=0;
dice3=0;
dice4=0;
dice5=0;
step event:
if position_meeting(mouse_x,mouse_y,id) && mouse_check_button_released(mb_left)//if button press released
{
dice1=irandom_range(1,6);//choose a random value for dice
dice2=irandom_range(1,6);
dice3=irandom_range(1,6);
dice4=irandom_range(1,6);
dice5=irandom_range(1,6);
}
draw event:
draw_self();
draw_sprite(spr_dice,dice1,50,50);//draw choosen sub image
draw_sprite(spr_dice,dice2,150,50);
draw_sprite(spr_dice,dice3,250,50);
draw_sprite(spr_dice,dice4,350,50);
draw_sprite(spr_dice,dice5,450,50);
GAmeMaker Vertical Credits Scrolling
Create Event:
text="(c) Lorem##
Video - Ipsum##
Sound - Dolor##
Stunts - Sit##
Editing - Amet##
";//credits - ## for line break
x=room_width/2;//find middle of room
y=room_height+50;//start 50 pixels off of the room
height=string_height(text);//height of text in pixels
Step Event:
y-=0.5;//move up screen
if y==(0-height) instance_destroy();//if off screen destroy
Draw Event:
draw_set_halign(fa_center);//set allignment
draw_text(x,y,text);
text="(c) Lorem##
Video - Ipsum##
Sound - Dolor##
Stunts - Sit##
Editing - Amet##
";//credits - ## for line break
x=room_width/2;//find middle of room
y=room_height+50;//start 50 pixels off of the room
height=string_height(text);//height of text in pixels
Step Event:
y-=0.5;//move up screen
if y==(0-height) instance_destroy();//if off screen destroy
Draw Event:
draw_set_halign(fa_center);//set allignment
draw_text(x,y,text);
GAME MAKER Create a Shadow
DRAW EVENT:
draw_sprite_ext(spr_duck, 0, x-2, y-2, 1, 1, -5, c_black, 1 );
draw_self();
draw_sprite_ext(spr_duck, 0, x-2, y-2, 1, 1, -5, c_black, 1 );
draw_self();
GAMEMAKER ROOM WRAPPING
OBJ_PLAYER
STEP EVENT:
///keyboard movement
if (keyboard_check(ord('A'))) {x-=5;}
if (keyboard_check(ord('D'))) {x+=5;}
if (keyboard_check(ord('W'))) {y-=5;}
if (keyboard_check(ord('S'))) {y+=5;}
if x>room_width+1 //if off edge of room right
{
x=1; //move to other side
}
if x<-1 //if off edge of room left
{
x=room_width-1; //move to other side
}
if y>room_height+1 //if off edge of room bottom
{
y=1; //move to other side
}
if y<-1 //if off edge of room top
{
y=room_height-1; //move to other side
}
[gamemaker] Pop-Up RPG Style Text Box
obj_message
create_event
global.message=ds_list_create();//create a ds list to hold messages
can_show=true;//set that a message can show
to_draw="";//set text to draw to ""
alarm 0 event
///alarm0 set alarm1
alarm[1]=room_speed*1;//create a short pause
to_draw="";//remove text to show
alarm 1 event:
///set as able to show
can_show=true;//allow message to show
step event:
///check if message waiting
check=ds_list_size(global.message);//get no of messages waiting
if check>0 && can_show//do this if more than one message and can show
{
to_draw=ds_list_find_value(global.message,0);//get message from top of ds list
ds_list_delete(global.message,0);//delete this message
can_show=false;//prevent showing
alarm[0]=room_speed*4;//create a pause
}
draw event:
///draw message
if to_draw!=""//do if there is a message waiting
{
//draw a background box
draw_set_colour(c_blue);
draw_rectangle(100,280,700,320,false);
//draw a message
draw_set_font(font_message);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_colour(c_red);
draw_text(400+1,300+1,to_draw);
draw_set_colour(c_white);
draw_text(400,300,to_draw);
}
obj_player
release event:
//choose an example message and sent to scriptmessage=choose("this is a message","this another message","this is yet another message");
scr_message(message);
scr_message
//add message to a ds list
ds_list_add(global.message,argument0);
[GAMEMAKER] Random Sentence Generator
create event:
sentence="";
draw event:
draw_text(50,50,sentence);
press s event:
name=choose("Edward","Lance","Lorilla");
what=choose("went swimming","ate chocolate");
where=choose("in the park","at the cinema","at the beach");
name2=choose("with Lorem","with Ipsum","With Dolor");
when=choose("on Monday","yesterday","last week");
space=" ";
sentence=name+space+what+space+where+space+name2+space+when;
sentence="";
draw event:
draw_text(50,50,sentence);
press s event:
name=choose("Edward","Lance","Lorilla");
what=choose("went swimming","ate chocolate");
where=choose("in the park","at the cinema","at the beach");
name2=choose("with Lorem","with Ipsum","With Dolor");
when=choose("on Monday","yesterday","last week");
space=" ";
sentence=name+space+what+space+where+space+name2+space+when;
GAMEMAKER Firework Display Using Effects
Step event:
//create firework effect at random position in room,with random size and colour
effect_create_above(ef_firework,random(room_width),random(room_height),irandom(2),choose(c_yellow,c_red,c_blue,c_green));
//create firework effect at random position in room,with random size and colour
effect_create_above(ef_firework,random(room_width),random(room_height),irandom(2),choose(c_yellow,c_red,c_blue,c_green));
[GAMEMAKER] Rotate and Move Object to Mouse Position
player event:
angle=point_direction(x,y,mouse_x,mouse_y);//calculate angle between self and mouse
direction=angle;//set direction to move in
image_angle=angle;//set angle of sprite
speed=2;//set moving speed
angle=point_direction(x,y,mouse_x,mouse_y);//calculate angle between self and mouse
direction=angle;//set direction to move in
image_angle=angle;//set angle of sprite
speed=2;//set moving speed
Reverse Sentence Order gamemaker
create event:
msg = "one two three for five"; //string to splitreversed="";//initialize string
splits[0]="";//initialize array
splitBy = " "; //string to split the first string by
slot = 0;//starting slot
str2 = ""; //var to hold the current split we're working on building
for (var i = 1; i < (string_length(msg)+1); i++)
{
currStr = string_copy(msg, i, 1);//get character 1 by 1
if (currStr == splitBy)//split if [space] found
{
splits[slot] = str2; //add this split to the array of all splits
slot++;
str2 = "";
}
else
{
str2 = str2 + currStr;
splits[slot] = str2;//add last word
}
}
//add back to a new string
for(var i = slot; i >-1 ; i -= 1)//start a number of slots and reduce i by one each loop
{
reversed+=splits[i]+" ";
}
draw event:
draw_text(50,40,reversed);vuejs web crawler
<script src="https://gist.github.com/edwardlorilla/db6ae50305865ba1059538323290db1c.js"></script>
VB NET dramacool download web crawler
Imports System.ComponentModel
Imports System.Net
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://www4.dramacool9.io/meteor-garden-2018-episode-27.html")
Dim response As System.Net.HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
Dim rssourceCode As String = sr.ReadToEnd
Dim r As New Regex("<h3 class=""title"" onclick=""window.location = '([^<]*)'"">([^<]*)</h3>")
Dim matches As MatchCollection = r.Matches(rssourceCode)
For Each itemcode As Match In matches
ListBox1.Items.Add(itemcode.Groups(1).ToString)
Next
End Sub
Private Sub ListBox1_DoubleClick(sender As Object, e As EventArgs) Handles ListBox1.DoubleClick
MessageBox.Show(ListBox1.SelectedItem.ToString)
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://www4.dramacool9.io" + ListBox1.SelectedItem.ToString)
Dim response As System.Net.HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
Dim rssourceCode As String = sr.ReadToEnd
Dim r As New Regex("<iframe allowfullscreen=""true"" webkitallowfullscreen=""true"" mozallowfullscreen=""true"" marginheight=""0"" marginwidth=""0"" scrolling=""no"" frameborder=""0"" style=""width: 100%"" src=""([^<]*)"" target=""_blank""></iframe>")
Dim matches As Match = r.Match(rssourceCode)
Dim downloadRequest As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https:" & matches.Groups(1).ToString())
Dim downloadresponse As System.Net.HttpWebResponse = downloadRequest.GetResponse
Dim dsr As System.IO.StreamReader = New System.IO.StreamReader(downloadresponse.GetResponseStream)
Dim downloadrssourceCode As String = dsr.ReadToEnd
Dim downloadRegex As New Regex("file: '([^<]*)',label: 'auto P','type' : 'mp4'")
Dim downloadMatches As Match = downloadRegex.Match(downloadrssourceCode)
Dim client As WebClient = New WebClient
AddHandler client.DownloadProgressChanged, AddressOf client_ProgressChanged
AddHandler client.DownloadFileCompleted, AddressOf client_DownloadCompleted
client.DownloadFileAsync(New Uri(downloadMatches.Groups(1).ToString()), "E:\meteor garden" & ListBox1.SelectedItem.ToString)
End Sub
Private Sub client_DownloadCompleted(sender As Object, e As AsyncCompletedEventArgs)
MessageBox.Show("Download Complete")
End Sub
Private Sub client_ProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs)
Dim bytesIn As Double = Double.Parse(e.BytesReceived.ToString())
Dim totalBytes As Double = Double.Parse(e.TotalBytesToReceive.ToString())
Dim percentage As Double = bytesIn / totalBytes * 100
Label1.Text = percentage
ProgressBar1.Value = Int32.Parse(Math.Truncate(percentage).ToString())
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
End Class
Monster Character Creation vuejs
Labels:
monster hunter world character creation monster hunter world character creation female monster hunter world character classes monster hunter world character creation guide,
monster hunter world male character creation monster hunter character creation monster hunter world character creation reddit monster hunter world character sliders
vuejs ascii <---to---> hex converter
https://gist.github.com/edwardlorilla/0bb499c5bad42c16773173260b7d910b
Dart ascii to hex
ascii_to_hex(form)
{
var symbols = " !\"#\$%&'()*+,-./0123456789:;<=>?@";
var loAZ = "abcdefghijklmnopqrstuvwxyz";
symbols += loAZ.toUpperCase();
symbols += "[\\]^_`";
symbols += loAZ;
symbols += "{|}~";
var valueStr = form;
var hexChars = "0123456789abcdef";
var text = "";
for( var i=0; i Divide, returning an integer result
if ( text != "" ) text += " ";
text += hexChars[index2];
text += hexChars[index1];
}
return text;
}
void main() {
print(ascii_to_hex('form'));
}
Dart Equality and Relational Operators
void main() {
var num1 = 5;
var num2 = 9;
var res = num1 > num2;
print('num1 greater than num2 :: ' + res.toString());
res = num1 < num2;
print('num1 lesser than num2 :: ' + res.toString());
res = num1 >= num2;
print('num1 greater than or equal to num2 :: ' + res.toString());
res = num1 <= num2;
print('num1 lesser than or equal to num2 :: ' + res.toString());
res = num1 != num2;
print('num1 not equal to num2 :: ' + res.toString());
res = num1 == num2;
print('num1 equal to num2 :: ' + res.toString());
}
dart: arithmetic operators
void main() {
var num1 = 101;
var num2 = 2;
var res = 0;
res = num1+num2;
print("Addition: ${res}");
res = num1-num2;
print("Subtraction: ${res}");
res = num1*num2;
print("Multiplication: ${res}");
res = num1/num2;
print("Division: ${res}");
res = num1~/num2;
print("Division returning Integer: ${res}");
res = num1%num2;
print("Remainder: ${res}");
num1++;
print("Increment: ${num1}");
num2--;
print("Decrement: ${num2}");
}
Dart: Function Area Converter
area(area, value) {
double acre = 0.0,
square_mile = 0.0,
square_foot = 0.0,
square_inch = 0.0,
square_km = 0.0,
square_meter = 0.0,
hectare = 0.0,
square_yard = 0.0;
if (area == 'acre') {
hectare = value * 0.404686;
square_foot = value * 43560;
square_inch = value * 6.273e6;
square_km = value * 0.00404686;
square_meter = value * 4046.86;
square_mile = value * 0.0015625;
square_yard = value * 4840;
} else if (area == 'square_mile') {
acre = value * 640;
square_foot = value * 2.788e7;
square_inch = value * 4.014e9;
square_km = value * 2.58999;
square_meter = value * 2.59e6;
hectare = value * 258.999;
square_yard = value * 3.098e6;
} else if (area == 'square_foot') {
acre = value * 2.2957e-5;
hectare = value * 9.2903e-6;
square_inch = value * 144;
square_km = value * 9.2903e-8;
square_meter = value * 0.092903;
square_mile = value * 3.587e-8;
square_yard = value * 0.111111;
} else if (area == 'square_inch') {
acre = value * 1.5942e-7;
square_foot = value * 0.00694444;
hectare = value * 6.4516e-8;
square_km = value * 6.4516e-10;
square_meter = value * 0.00064516;
square_mile = value * 2.491e-10;
square_yard = value * 0.000771605;
} else if (area == 'square_km') {
acre = value * 247.105;
square_foot = value * 1.076e7;
square_inch = value * 1.55e9;
hectare = value * 100;
square_meter = value * 1e6;
square_mile = value * 0.386102;
square_yard = value * 1.196e6;
} else if (area == 'square_meter') {
acre = value * 0.000247105;
square_foot = value * 10.7639;
square_inch = value * 1550;
square_km = value * 1e-6;
hectare = value * 1e-4;
square_mile = value * 3.861e-7;
square_yard = value * 1.19599;
} else if (area == 'hectare') {
acre = value * 2.47105;
square_foot = value * 107639;
square_inch = value * 1.55e7;
square_km = value * 0.01;
square_meter = value * 10000;
square_mile = value * 0.00386102;
square_yard = value * 11959.9;
} else if (area == 'square_yard') {
acre = value * 0.000206612;
square_foot = value * 9;
square_inch = value * 1296;
square_km = value * 8.3613e-7;
square_meter = value * 0.836127;
square_mile = value * 3.2283e-7;
hectare = value * 8.3613e-5;
}
return "acre:$acre \nsquare_foot:$square_foot\nsquare_inch:$square_inch\nsquare_km:$square_km\nsquare_meter:$square_meter\nhectare:$hectare\nsquare_yard:$square_yard";
}
void main() {
print(area('square_foot', 2));
}
double acre = 0.0,
square_mile = 0.0,
square_foot = 0.0,
square_inch = 0.0,
square_km = 0.0,
square_meter = 0.0,
hectare = 0.0,
square_yard = 0.0;
if (area == 'acre') {
hectare = value * 0.404686;
square_foot = value * 43560;
square_inch = value * 6.273e6;
square_km = value * 0.00404686;
square_meter = value * 4046.86;
square_mile = value * 0.0015625;
square_yard = value * 4840;
} else if (area == 'square_mile') {
acre = value * 640;
square_foot = value * 2.788e7;
square_inch = value * 4.014e9;
square_km = value * 2.58999;
square_meter = value * 2.59e6;
hectare = value * 258.999;
square_yard = value * 3.098e6;
} else if (area == 'square_foot') {
acre = value * 2.2957e-5;
hectare = value * 9.2903e-6;
square_inch = value * 144;
square_km = value * 9.2903e-8;
square_meter = value * 0.092903;
square_mile = value * 3.587e-8;
square_yard = value * 0.111111;
} else if (area == 'square_inch') {
acre = value * 1.5942e-7;
square_foot = value * 0.00694444;
hectare = value * 6.4516e-8;
square_km = value * 6.4516e-10;
square_meter = value * 0.00064516;
square_mile = value * 2.491e-10;
square_yard = value * 0.000771605;
} else if (area == 'square_km') {
acre = value * 247.105;
square_foot = value * 1.076e7;
square_inch = value * 1.55e9;
hectare = value * 100;
square_meter = value * 1e6;
square_mile = value * 0.386102;
square_yard = value * 1.196e6;
} else if (area == 'square_meter') {
acre = value * 0.000247105;
square_foot = value * 10.7639;
square_inch = value * 1550;
square_km = value * 1e-6;
hectare = value * 1e-4;
square_mile = value * 3.861e-7;
square_yard = value * 1.19599;
} else if (area == 'hectare') {
acre = value * 2.47105;
square_foot = value * 107639;
square_inch = value * 1.55e7;
square_km = value * 0.01;
square_meter = value * 10000;
square_mile = value * 0.00386102;
square_yard = value * 11959.9;
} else if (area == 'square_yard') {
acre = value * 0.000206612;
square_foot = value * 9;
square_inch = value * 1296;
square_km = value * 8.3613e-7;
square_meter = value * 0.836127;
square_mile = value * 3.2283e-7;
hectare = value * 8.3613e-5;
}
return "acre:$acre \nsquare_foot:$square_foot\nsquare_inch:$square_inch\nsquare_km:$square_km\nsquare_meter:$square_meter\nhectare:$hectare\nsquare_yard:$square_yard";
}
void main() {
print(area('square_foot', 2));
}
Area Converter Dart
void main() {
double acre = 0.0,
square_mile = 5.0,
square_foot = 0.0,
square_inch = 0.0,
square_km = 0.0,
square_meter = 0.0,
hectare = 0.0,
square_yard = 0.0;
acre = square_mile * 640;
square_foot = square_mile * 2.788e7;
square_inch = square_mile * 4.014e9;
square_km = square_mile * 2.58999;
square_meter = square_mile * 2.59e6;
hectare = square_mile * 258.999;
square_yard = square_mile * 3.098e6;
print("acre:$acre \nsquare_foot:$square_foot\nsquare_inch:$square_inch\nsquare_km:$square_km\nsquare_meter:$square_meter\nhectare:$hectare\nsquare_yard:$square_yard");
}
double acre = 0.0,
square_mile = 5.0,
square_foot = 0.0,
square_inch = 0.0,
square_km = 0.0,
square_meter = 0.0,
hectare = 0.0,
square_yard = 0.0;
acre = square_mile * 640;
square_foot = square_mile * 2.788e7;
square_inch = square_mile * 4.014e9;
square_km = square_mile * 2.58999;
square_meter = square_mile * 2.59e6;
hectare = square_mile * 258.999;
square_yard = square_mile * 3.098e6;
print("acre:$acre \nsquare_foot:$square_foot\nsquare_inch:$square_inch\nsquare_km:$square_km\nsquare_meter:$square_meter\nhectare:$hectare\nsquare_yard:$square_yard");
}
Mean, Median, Mode and Range Calculator
Labels:
and mode calculator?,
and mode review (article),
and Range,
and Range in JavaScript,
Calculate Mean,
calculate the median of an array with javascript,
Calculating the average/mean,
How to create a mean,
javascript - Finding the mode of an array,
JavaScript statistical functions for arrays: max,
Mean,
Median,
midrange,
min,
Mode,
Mode and Range Calculator,
range
vuejs adding and subtracting fractions calculator
https://gist.github.com/edwardlorilla/5ed2bcad88acbed5c0e5aad949ae9f14
Labels:
add subtract,
adding fractions and decimals calculator,
adding fractions calculator,
adding fractions with whole numbers,
adding mixed fractions calculator,
adding subtracting fractions calculator,
addition or subtraction of fractions with different denominators,
different,
fraction calculator simplify,
how to add fractions with unlike denominators,
like,
multiplying mixed fractions,
unlike denominators
Tool: ROT13 Caesar Cipher
Labels:
caesar cipher,
caesar cipher calculator,
caesar cipher decoder java,
caesar cipher in c,
caesar cipher java ascii,
caesar cipher java source code,
caesar cipher java tutorial,
caesar cipher wheel,
caesar's cipher,
Encoder,
javascript cipher example,
javascript cipher function,
javascript simple cipher,
rot cipher decoder,
ROT-13 Cipher - ROT13 - Decoder,
shift cipher,
Solver,
substitution cipher javascript,
Translator,
write a program to encrypt and decrypt using caesar cipher
Disemvowel Tool vuejs
Labels:
remove all instances of character from string,
remove character from string at index,
remove first and last character from string javascript,
remove first character from string,
remove first two characters from string,
remove last character from string javascript,
remove specific character from string,
trim specific character
vuejs remove extra spaces in string javascript
Labels:
How can I remove extra white space in a string in JavaScript,
How to remove extra white spaces using javascript or jquery ...,
javascript - Regex to replace multiple spaces with a single space,
javascript - Remove ALL white spaces from text,
javascript - remove special symbols and extra spaces and replace,
Javascript and regex: remove space after the last word in a string,
jquery - Javascript - How to remove all extra spacing between,
jquery - Remove Extra Spaces Before and After javascript string,
regex - remove extra spaces in string javascript,
Replace multiple whitespaces with single whitespace in JavaScrip
Online CSS Unminifier vuejs
Labels:
code formatting - Tool to Unminify / Decompress JavaScript,
convert compressed css,
css - Code unminify plugin for NetBeans IDE,
css expand,
denormalize css,
how to edit minified css,
html - Unminifying CSS in PhpStorm,
Newest 'unminify' Questions,
readable css,
sublime unminify,
sublimetext2 - sublime text 2 - way to unminify or beautify HTM,
un minify JS (javascript) code using visual studio?,
Unminify CSS styles,
unminify js and css,
unminify php
Tool: Remove Duplicate Lines
Labels:
javascript - Remove Duplicate Text in Textarea,
javascript - Remove duplicate values from JS array,
linux - How to delete duplicates in line of text?,
regex - Remove duplicate commas and extra commas at start/end,
Remove Duplicate Lines,
Remove duplicate objects from JSON file in JavaScript,
replace - Regex to find/remove duplicate line,
sorting - Fastest way to remove duplicate lines in very large,
unix - How to remove duplicate lines from a file
String Case Converter vuejs
Labels:
Case Converter Tool for Perfectly Formatted Text,
Convert Case - Convert upper case to lower case,
Convert Case Online,
convert small letter to capital in excel,
convert to capital letters online,
convert to small caps,
convert uppercase to lowercase in c,
convert uppercase to lowercase in excel,
Letter Case Converter,
lower case to uppe,
LowerCase,
Randomcase,
sentence case,
Title And Sentence Case Converter Tool,
title case converter,
Uppercase Lowercase Case Converter,
Uppercase or Lowercase Letters Text Tool,
uppercase to lowercase in word
Find and Replace Text regex vuejs
Labels:
How can I replace a regex substring match in Javascript?,
How to search replace with regex and keep case,
javascript - JS RegEx Find and Replace based on Group,
javascript - JS regex: replace all digits in string,
JavaScript REGEX Match all and replace,
Javascript RegEx: find GUID in an URL and replace it,
javascript string replace regex,
JavaScript/jQuery String Replace With Regex,
regex - javascript find and replace a dynamic pattern,
regex - Javascript Regexp Search and Replace,
regex - Javascript replace with reference to matched group,
regex example,
regex match,
regex replace all,
regex tester,
replace,
replace special characters,
string replace all
count the number of occurrences vuejs
Labels:
find all occurrences of a substring in a string javascript,
javascript character count,
javascript count how many times a character appears in a string,
javascript count occurrences of word in string,
javascript count string occurrences in array,
javascript like search,
javascript match,
write a javascript function to get the number of occurrences of each letter in specified string.
word frequency vuejs
Labels:
counting frequency of characters in a string using javascript,
fix a bug with standard,
frequency of characters in a string in javascript,
javascript - Best way to get word frequency counts for a website,
javascript - Counting the occurrences / frequency of array,
javascript - Word Frequency Count,
javascript - Word frequency counter,
Javascript counting the frequency letters of a string,
node.js - Word frequency count in javascript?,
word frequency analysis,
word frequency calculator,
word frequency chart,
word frequency counter microsoft word,
word frequency database,
Word frequency for array of key/values on javascript,
word frequency graph,
word frequency in javascript,
word frequency ranking,
word frequency search
Tool: Add / Remove Line Breaks vuejs
Labels:
html - Textarea - JavaScript | Remove line breaks and spaces from,
javascript - How to remove all line breaks from a string,
javascript - How to remove all line breaks from a string?,
javascript - How to remove line breaks and white space from,
javascript - RegEx: How to remove extra white spaces / line breaks,
javascript - Remove carriage return and space from a string,
javascript - Remove line breaks from start and end of string,
javascript - Replace all whitespace characters,
javascript remove line breaks from textarea,
javascript remove newline from end of string,
javascript remove whitespace from textarea,
javascript replace \n with newline,
javascript replace newline with comma,
line break javascript,
regex - How can I replace newlines/line breaks with spaces,
regex remove line breaks,
replace newline with space in javascript,
replace whitespace AND newline in javascript
Tool Add Prefix and/or Suffix into Each Line vuejs
Labels:
add a prefix or suffix to a word,
Add Prefix and/or Suffix into Each Line,
add prefix excel,
add prefix meaning,
add prefix to words,
Add Prefix/Suffix into Line,
add suffix online,
Bulk Add Prefix Suffix to Keywords Tool,
laravel-enso/vuedatatable,
prefix and suffix,
prefix for line,
prefix for the word line,
Prefixes and Suffixes
nodejs Handling HTTP PUT Requests express.js
Labels:
How to make an HTTP POST request in node.js,
How to make external HTTP requests with Node.js,
HTTP PUT Request with Node.js,
javascript - Do a PUT request via proxy using Node JS and request,
javascript - How do I use JSON in the body of an http PUT,
javascript - HTTP DELETE verb in Node.JS,
javascript - HTTP GET Request in Node.js Express,
javascript - Node.js server that accepts POST requests,
javascript - Put Request using pure NodeJs,
javascript - Using the PUT method with Express.js,
node.js - express PUT empty body,
node.js - Express.js get http method in controller,
node.js - How to control a PUT request with NodeJS Express,
node.js - How to make http put request with zip file in nodejs,
node.js - how to send a put request from html form in express,
node.js - Retrieve response of PUT request,
node.js - Why is my first Nodejs http PUT request working
nodejs os module
const os = require('os');
var totalMemory = os.totalmem();
var freeMemory = os.freemem(); console.log(`Total Memory: ${totalMemory}`);
console.log(`Free Memory: ${freeMemory}`);
nodejs path module
const path = require('path'); var pathObj = path.parse(__filename); console.log(pathObj);> node path-module.js
{ root: 'C:\\',
dir: 'C:\\Users\\Edward Lance Lorilla\\Documents\\node-practice',
base: 'path-module.js',
ext: '.js',
name: 'path-module' }
multipart element ui
<form name="documentForm" ref="form" @submit.prevent = "store$" method="post" enctype="multipart/form-data">
<el-upload :on-change="handleChange" :file-list="create$.file" action="" class="upload-demo" ref="upload" multiple :auto-upload="false"> <v-btn slot="trigger">Upload</v-btn> </el-upload>
<v-btn color="blue darken-1" flat form="documentForm" type="submit">Save</v-btn>
</form>
new Vue({methods:{store$(){ var vm = this var store$ = new FormData(vm.$refs.form); store$.append('category_id', vm.create$.category_id ) _.map(vm.create$.file, function(data){ store$.append('file[]', data.raw ) }) post('/api/documents', store$).then(function (response) { vm.$set(vm.$root.$data.documents, vm.$root.$data.documents.length, response.data ) vm.$root.successResponse('Create A Document') vm.$router.push('/documents') }).catch(function (_ref2) { vm.$root.errorResponse(_ref2) });}
})
creating and loading a module nodejs
//app.js
//logger.js
var logger = require('./logger.js');logger('edward');
//logger.js
var url = 'edward.io';function log(message) { console.log(message) } module.exports = log;
HTML5 Upload base64 Form App Script Google Sheet
forms.html
<!DOCTYPE html>
<html> <head> <base target="_blank"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Registration</title> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css"> <style> .disclaimer{width: 480px; color:#646464;margin:20px auto;padding:0 16px;text-align:center;font:400 12px Roboto,Helvetica,Arial,sans-serif}.disclaimer a{color:#009688}#credit{display:none} </style> </head> <body> <form class="main" id="form" novalidate="novalidate" style="max-width: 480px;margin: 40px auto;"> <div id="forminner"> <div class="row"> <div class="col s12"> <h5 class="center-align teal-text">Registration</h5> <p class="disclaimer">Fill up all fields.</p> </div> </div> <div class="row"> <div class="input-field col s12"> <input id="name" type="text" name="Name" class="validate" required="" aria-required="true"> <label for="name">Name</label> </div> </div> <div class="row"> <div class="input-field col s12"> <input id="pid" type="text" name="Pid" class="validate" required="" aria-required="true"> <label for="pid">Pid</label> </div> </div> <div class="row"> <div class="input-field col s12"> <input id="email" type="email" name="Email" class="validate" required="" aria-required="true"> <label for="email">Email Address</label> </div> </div> <div class="row"> <div class="input-field col s12"> <input id="tel" type="tel" name="Tel" class="validate" required="" aria-required="true"> <label for="tel">Telephone</label> </div> </div> <div class="row"> <div class="input-field col s12"> <select id="position" name="position"> <option value="" disabled selected>Position</option> <option value="Head">Head</option> <option value="Assistant">Assistant</option> <option value="Secretary">Secretary</option> <option value="Others">Others</option> </select> </div> </div> <div class="row"> <div class="file-field input-field col s12"> <div class="btn"> <span>File</span> <input id="files" type="file"> </div> <div class="file-path-wrapper"> <input class="file-path validate" type="text" placeholder="Select a file on your computer"> </div> </div> </div> <div class="row"> <div class="input-field col s6"> <button class="waves-effect waves-light btn submit-btn" type="submit" onclick="submitForm(); return false;">Submit</button> </div> </div> <div class="row"> <div class="input-field col s12" id = "progress"> </div> </div> </div> <div id="success" style="display:none"> <h5 class="left-align teal-text">File Uploaded</h5> <p>Your file has been successfully uploaded.</p> <p class="center-align"><a class="btn btn-large" onclick="restartForm()" >Restart</a></p> </div> </form> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script> <script> var file, reader = new FileReader(); reader.onloadend = function(e) { if (e.target.error != null) { showError("File " + file.name + " could not be read."); return; } else { google.script.run .withSuccessHandler(showSuccess) .uploadFileToGoogleDrive(e.target.result, file.name, $('input#name').val(), $('input#pid').val(), $('input#email').val(), $('input#tel').val()), $('input#position').val(); } }; function showSuccess(e) { if (e === "OK") { $('#forminner').hide(); $('#success').show(); } else { showError(e); } } function restartForm() { $('#form').trigger("reset"); $('#forminner').show(); $('#success').hide(); $('#progress').html(""); } function submitForm() { var files = $('#files')[0].files; if (files.length === 0) { showError("Please select a file to upload"); return; } file = files[0]; if (file.size > 1024 * 1024 * 5) { showError("The file size should be < 5 MB. "); return; } showMessage("Uploading file.."); reader.readAsDataURL(file); } function showError(e) { $('#progress').addClass('red-text').html(e); } function showMessage(e) { $('#progress').removeClass('red-text').html(e); } $(document).ready(function() { $('select').material_select(); }); </script> </body> </html> |
Code.gs
// 1. Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";
// 2. Run > setup
//
// 3. Publish > Deploy as web app
// - enter Project Version name and click 'Save New Version'
// - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)
//
// 4. Copy the 'Current web app URL' and post this in your form/script action
//
// 5. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)
var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('forms.html').setTitle("Registration With Document");
}
function uploadFileToGoogleDrive(data, file, name, pid, email, tel, position) {
try {
var dropbox = "Received Files";
//var folder, folders = DriveApp.getFoldersByName(dropbox);
var folder=DriveApp.getFolderById('0B86b-ALn-1MGSndHQ2NQMlExNVE');
/*
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder(dropbox);
}
*/
/* Credit: www.labnol.org/awesome */
var contentType = data.substring(5,data.indexOf(';')),
bytes = Utilities.base64Decode(data.substr(data.indexOf('base64,')+7)),
blob = Utilities.newBlob(bytes, contentType, file),
file = folder.createFolder([name, email].join(" ")).createFile(blob),
filelink=file.getUrl() ;
var lock = LockService.getPublicLock();
lock.waitLock(30000); // wait 30 seconds before conceding defeat.
// next set where we write the data - you could write to multiple/alternate destinations
var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key"));
var sheet = doc.getSheetByName(SHEET_NAME);
// we'll assume header is in row 1 but you can override with header_row in GET/POST data
var headRow = 1;
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
var nextRow = sheet.getLastRow()+1; // get next row
var row = [];
// loop through the header columns
for (i in headers){
if (headers[i] == "Timestamp"){ // special case if you include a 'Timestamp' column
row.push(new Date());
} else if (headers[i] == "name"){
row.push(name);
} else if (headers[i] == "pid"){
row.push(pid);
} else if (headers[i] == "email"){
row.push(email);
} else if (headers[i] == "tel"){
row.push(tel);
} else if (headers[i] == "position"){
row.push(position);
} else if (headers[i] == "filelink"){
row.push(filelink);
}
}
// more efficient to set values as [][] array than individually
sheet.getRange(nextRow, 1, 1, row.length).setValues([row]);
// return json success results
//return ContentService
// .createTextOutput(JSON.stringify({"result":"success", "row": nextRow}))
// .setMimeType(ContentService.MimeType.JSON);
return "OK";
} catch (f) {
return f.toString();
} finally { //release lock
lock.releaseLock();
}
}
function setup() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
SCRIPT_PROP.setProperty("key", doc.getId());
}
|
Subscribe to:
Posts (Atom)
I Quit AeroMedLab
Watch now (2 mins) | Today is my last day at AeroMedLab ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ...
-
code.gs // 1. Enter sheet name where data is to be written below var SHEET_NAME = "Sheet1" ; // 2. Run > setup // // 3....